From b31fe5c55dcbaf01286948580c2b3f09c5427b78 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 8 Feb 2015 23:37:34 -0800 Subject: help text for the "adjust for viewer timezone" toggle switch since you apparently need an IQ of 230 or greater to be able to use it correctly. --- mod/events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index a34aa62ab..10affd4ec 100755 --- a/mod/events.php +++ b/mod/events.php @@ -587,7 +587,7 @@ function events_content(&$a) { '$n_checked' => $n_checked, '$f_text' => t('Event Finishes:'), '$f_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$fyear+5),DateTime::createFromFormat('Y-m-d H:i',"$fyear-$fmonth-$fday $fhour:$fminute"),'finish_text',true,true,'start_text'), - '$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked), + '$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked, t('Important for events that happen in a particular place. Not practical for global holidays.'),), '$a_text' => t('Adjust for viewer timezone'), '$d_text' => t('Description:'), '$d_orig' => $d_orig, -- cgit v1.2.3 From 0e74ebc6a9f6ef6f8348a68d9ecee98795edd56b Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Feb 2015 15:12:15 -0800 Subject: title missing sending to diaspora (which doesn't support titles but let's not go there). --- mod/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/import.php b/mod/import.php index c9a4edb67..088c5cb61 100644 --- a/mod/import.php +++ b/mod/import.php @@ -250,7 +250,7 @@ function import_post(&$a) { if($seize) { - // replace our existing xchan if we're seizing control + // replace any existing xchan we may have on this site if we're seizing control $r = q("delete from xchan where xchan_hash = '%s'", dbesc($channel['channel_hash']) -- cgit v1.2.3 From ed810a360f9a52e1e57ea95723d46b68eb586f69 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Feb 2015 15:57:22 -0800 Subject: event form - provide map ability for location field and add preview ability --- mod/events.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 10affd4ec..144b9dd5e 100755 --- a/mod/events.php +++ b/mod/events.php @@ -8,6 +8,8 @@ require_once('include/items.php'); function events_post(&$a) { + logger('post: ' . print_r($_REQUEST,true)); + if(! local_channel()) return; @@ -178,6 +180,12 @@ function events_post(&$a) { $datarray['created'] = $created; $datarray['edited'] = $edited; + if(intval($_REQUEST['preview'])) { + $html = format_event_html($datarray); + echo $html; + killme(); + } + $event = event_store_event($datarray); @@ -597,6 +605,7 @@ function events_content(&$a) { '$t_orig' => $t_orig, '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, + '$preview' => t('Preview'), '$permissions' => t('Permissions'), '$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults),false)), '$submit' => t('Submit') -- cgit v1.2.3 From fce51876c9d2d8803acddaa9c5b4980eb82ec357 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Feb 2015 18:58:43 -0800 Subject: bring some styling back to the colorbox and improve the event preview ability --- mod/events.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 144b9dd5e..f209dab1d 100755 --- a/mod/events.php +++ b/mod/events.php @@ -85,11 +85,19 @@ function events_post(&$a) { $onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish"; if(strcmp($finish,$start) < 0 && !$nofinish) { notice( t('Event can not end before it has started.') . EOL); + if(intval($_REQUEST['preview'])) { + echo( t('Unable to generate preview.')); + killme(); + } goaway($onerror_url); } if((! $summary) || (! $start)) { notice( t('Event title and start time are required.') . EOL); + if(intval($_REQUEST['preview'])) { + echo( t('Unable to generate preview.')); + killme(); + } goaway($onerror_url); } @@ -104,6 +112,10 @@ function events_post(&$a) { ); if(! $x) { notice( t('Event not found.') . EOL); + if(intval($_REQUEST['preview'])) { + echo( t('Unable to generate preview.')); + killme(); + } return; } if($x[0]['allow_cid'] === '<' . $channel['channel_hash'] . '>' -- cgit v1.2.3 From 81e7b47b76e6cc72995e910190e4164d28ec5664 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Feb 2015 00:11:37 -0800 Subject: more progress on event confirmations --- mod/like.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/like.php b/mod/like.php index b3afd910f..7c328367b 100755 --- a/mod/like.php +++ b/mod/like.php @@ -49,6 +49,18 @@ function like_content(&$a) { case 'unabstain': $activity = ACTIVITY_ABSTAIN; break; + case 'attendyes': + case 'unattendyes': + $activity = ACTIVITY_ATTEND; + break; + case 'attendno': + case 'unattendno': + $activity = ACTIVITY_ATTENDNO; + break; + case 'attendmaybe': + case 'unattendmaybe': + $activity = ACTIVITY_ATTENDMAYBE; + break; default: return; break; @@ -300,6 +312,8 @@ function like_content(&$a) { } else { $post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status')); + if($item['resource_type'] === 'event') + $post_type = t('event'); $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $item['plink'])); $objtype = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); @@ -354,8 +368,12 @@ function like_content(&$a) { $bodyverb = t('%1$s doesn\'t agree with %2$s\'s %3$s'); if($verb === 'abstain') $bodyverb = t('%1$s abstains from a decision on %2$s\'s %3$s'); - - + if($verb === 'attendyes') + $bodyverb = t('%1$s is attending %2$s\'s %3$s'); + if($verb === 'attendno') + $bodyverb = t('%1$s is not attending %2$s\'s %3$s'); + if($verb === 'attendmaybe') + $bodyverb = t('%1$s may attend %2$s\'s %3$s'); if(! isset($bodyverb)) killme(); -- cgit v1.2.3 From 268691ffb460e7d0a53dec858ee9658e20660755 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Feb 2015 01:05:49 -0800 Subject: correct the object type if it isn't stored/linked to an item yet --- mod/like.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/like.php b/mod/like.php index 7c328367b..725551d6d 100755 --- a/mod/like.php +++ b/mod/like.php @@ -312,7 +312,7 @@ function like_content(&$a) { } else { $post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status')); - if($item['resource_type'] === 'event') + if($item['obj_type'] === ACTIVITY_OBJ_EVENT) $post_type = t('event'); $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $item['plink'])); -- cgit v1.2.3 From 79da33dafdac1427ac07b4414a5da5f9f3a2b03d Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Feb 2015 17:49:46 -0800 Subject: improvements in duplicate like detection, especially w/r/t event participation --- mod/like.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/like.php b/mod/like.php index 725551d6d..79c746825 100755 --- a/mod/like.php +++ b/mod/like.php @@ -287,21 +287,42 @@ function like_content(&$a) { else killme(); - $r = q("SELECT id FROM item WHERE verb = '%s' AND item_restrict = 0 - AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') LIMIT 1", - dbesc($activity), + + $verbs = " '".dbesc($activity)."' "; + $multi_undo = 0; + + // event participation and consensus items are essentially radio toggles. If you make a subsequent choice, + // we need to eradicate your first choice. + + if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) { + $verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' "; + $multi_undo = 1; + } + if($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) { + $verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' "; + $multi_undo = 1; + } + + + $r = q("SELECT id FROM item WHERE verb in ( $verbs ) AND item_restrict = 0 + AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ", dbesc($observer['xchan_hash']), intval($item_id), - dbesc($item['mid']) + dbesc($item['mid']), + intval($owner_uid) ); if($r) { // already liked it. Drop that item. require_once('include/items.php'); - drop_item($r[0]['id'],false,DROPITEM_PHASE1); - return; + foreach($r as $rr) { + drop_item($rr['id'],false,DROPITEM_PHASE1); + } + if($interactive) + return; + if(! $multi_undo) + killme(); } - } $mid = item_message_id(); -- cgit v1.2.3 From 79223b6b3d38bfbfb3a6d9530f6ccc5b7bb096c8 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Feb 2015 19:10:18 -0800 Subject: item voting tools --- mod/editpost.php | 6 +++++- mod/item.php | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/editpost.php b/mod/editpost.php index 1d9855c95..bdd3be450 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -74,7 +74,8 @@ function editpost_content(&$a) { $channel = $a->get_channel(); //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); - + + $voting = feature_enabled(local_channel(),'consensus_tools'); $category = ''; $catsenabled = ((feature_enabled(local_channel(),'categories')) ? 'categories' : ''); @@ -118,6 +119,9 @@ function editpost_content(&$a) { '$audio' => t('Insert Vorbis [.ogg] audio'), '$setloc' => t('Set your location'), '$noloc' => t('Clear browser location'), + '$voting' => t('Toggle voting'), + '$feature_voting' => $voting, + '$consensus' => (($itm[0]['item_flags'] & ITEM_CONSENSUS) ? 1 : 0), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$ptyp' => $itm[0]['type'], diff --git a/mod/item.php b/mod/item.php index 6ae02b510..ef0491895 100644 --- a/mod/item.php +++ b/mod/item.php @@ -59,6 +59,8 @@ function item_post(&$a) { $api_source = ((x($_REQUEST,'api_source') && $_REQUEST['api_source']) ? true : false); + $consensus = intval($_REQUEST['consensus']); + // 'origin' (if non-zero) indicates that this network is where the message originated, // for the purpose of relaying comments to other conversation members. // If using the API from a device (leaf node) you must set origin to 1 (default) or leave unset. @@ -683,6 +685,9 @@ function item_post(&$a) { $item_flags = $item_flags | ITEM_THREAD_TOP; } + if($consensus) + $item_flags |= ITEM_CONSENSUS; + if ((! $plink) && ($item_flags & ITEM_THREAD_TOP)) { $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid; } -- cgit v1.2.3 From c62d605608ea3cfa0430e007fe6bc7df5fa0d25f Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 11 Feb 2015 16:11:21 -0800 Subject: well that was certainly fun. And the reason why likes and other acitivity deletions weren't propagating. Hopefully this is the last reason and there aren't more lurking further down the chain. --- mod/like.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/like.php b/mod/like.php index 79c746825..47251935a 100755 --- a/mod/like.php +++ b/mod/like.php @@ -316,7 +316,7 @@ function like_content(&$a) { // already liked it. Drop that item. require_once('include/items.php'); foreach($r as $rr) { - drop_item($rr['id'],false,DROPITEM_PHASE1); + drop_item($rr['id'],true,DROPITEM_PHASE1); } if($interactive) return; -- cgit v1.2.3 From da2349bb6a85d13f0aa29046bef3021cf0c884ba Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Feb 2015 17:45:25 -0800 Subject: provide relief to sites that are severely impacted by the slow ITEM_UNSEEN searches. This does not incorporate any other flag optimisations as that will require a major DB update and possibly involve significant downtime. This is just to bite off a little chunk now and provide some much needed relief. --- mod/channel.php | 14 +++++--------- mod/display.php | 5 +---- mod/home.php | 2 +- mod/item.php | 6 +++--- mod/manage.php | 4 +--- mod/mood.php | 3 +-- mod/network.php | 7 ++----- mod/photos.php | 6 ++---- mod/ping.php | 19 +++++-------------- 9 files changed, 21 insertions(+), 45 deletions(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 1a471718d..788bacf70 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -147,23 +147,21 @@ function channel_content(&$a, $update = 0, $load = false) { if(($update) && (! $load)) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND (item_flags & %d) > 0 $sql_extra limit 1", + AND (item_flags & %d) > 0 AND item_unseen = 1 $sql_extra limit 1", dbesc($mid), intval($a->profile['profile_uid']), - intval(ITEM_WALL), - intval(ITEM_UNSEEN) + intval(ITEM_WALL) ); } else { $r = q("SELECT distinct parent AS `item_id`, created from item left join abook on item.author_xchan = abook.abook_xchan WHERE uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND ( item_flags & %d ) > 0 + AND (item_flags & %d) > 0 AND item_unseen = 1 AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra ORDER BY created DESC", intval($a->profile['profile_uid']), intval(ITEM_WALL), - intval(ITEM_UNSEEN), intval(ABOOK_FLAG_BLOCKED) ); } @@ -317,10 +315,8 @@ function channel_content(&$a, $update = 0, $load = false) { } if($is_owner && $update_unseen) { - $r = q("UPDATE item SET item_flags = (item_flags & ~%d) - WHERE (item_flags & %d) > 0 AND (item_flags & %d) > 0 AND uid = %d $update_unseen", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 + AND (item_flags & %d) > 0 AND uid = %d $update_unseen", intval(ITEM_WALL), intval(local_channel()) ); diff --git a/mod/display.php b/mod/display.php index 467c476da..c2e5c2426 100644 --- a/mod/display.php +++ b/mod/display.php @@ -231,10 +231,7 @@ function display_content(&$a, $update = 0, $load = false) { } if($updateable) { - $x = q("UPDATE item SET item_flags = ( item_flags & ~%d ) - WHERE (item_flags & %d)>0 AND uid = %d and parent = %d ", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $x = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 AND uid = %d and parent = %d ", intval(local_channel()), intval($r[0]['parent']) ); diff --git a/mod/home.php b/mod/home.php index 854e2df26..db4ae9c42 100644 --- a/mod/home.php +++ b/mod/home.php @@ -170,7 +170,7 @@ function home_content(&$a, $update = 0, $load = false) { $page_mode = 'list'; - $simple_update = (($update) ? " and ( item.item_flags & " . intval(ITEM_UNSEEN) . " ) > 0 " : ''); + $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); if($update && $_SESSION['loadtime']) $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; diff --git a/mod/item.php b/mod/item.php index ef0491895..99d28400b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -643,8 +643,7 @@ function item_post(&$a) { } } - if(local_channel() != $profile_uid) - $item_flags |= ITEM_UNSEEN; + $item_unseen = ((local_channel() != $profile_uid) ? 1 : 0); if($post_type === 'wall' || $post_type === 'wall-comment') $item_flags = $item_flags | ITEM_WALL; @@ -694,7 +693,7 @@ function item_post(&$a) { $datarray['aid'] = $channel['channel_account_id']; $datarray['uid'] = $profile_uid; - + $datarray['owner_xchan'] = (($owner_hash) ? $owner_hash : $owner_xchan['xchan_hash']); $datarray['author_xchan'] = $observer['xchan_hash']; $datarray['created'] = $created; @@ -729,6 +728,7 @@ function item_post(&$a) { $datarray['term'] = $post_tags; $datarray['plink'] = $plink; $datarray['route'] = $route; + $datarray['item_unseen'] = $item_unseen; // preview mode - prepare the body for display and send it via json diff --git a/mod/manage.php b/mod/manage.php index 4a7b25068..cb46a1b76 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -57,9 +57,7 @@ function manage_content(&$a) { $c = q("SELECT id, item_restrict, item_flags FROM item - WHERE (item_restrict = %d) and ( item_flags & %d )>0 and uid = %d", - intval(ITEM_VISIBLE), - intval(ITEM_UNSEEN), + WHERE item_restrict = 0 and item_unseen = 1 and uid = %d", intval($channels[$x]['channel_id']) ); diff --git a/mod/mood.php b/mod/mood.php index 4fe1ceb59..7663b2632 100755 --- a/mod/mood.php +++ b/mod/mood.php @@ -61,11 +61,10 @@ function mood_init(&$a) { $mid = item_message_id(); $action = sprintf( t('%1$s is %2$s','mood'), '[zrl=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/zrl]' , $verbs[$verb]); - $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN; + $item_flags = ITEM_WALL|ITEM_ORIGIN; if(! $parent_mid) $item_flags |= ITEM_THREAD_TOP; - $arr = array(); $arr['aid'] = get_account_id(); diff --git a/mod/network.php b/mod/network.php index 9a4707b4d..236d4c5e0 100644 --- a/mod/network.php +++ b/mod/network.php @@ -346,7 +346,7 @@ function network_content(&$a, $update = 0, $load = false) { else $page_mode = 'client'; - $simple_update = (($update) ? " and ( item.item_flags & " . intval(ITEM_UNSEEN) . " ) > 0 " : ''); + $simple_update = (($update) ? " and item.unseen = 1 " : ''); // This fixes a very subtle bug so I'd better explain it. You wake up in the morning or return after a day // or three and look at your matrix page - after opening up your browser. The first page loads just as it @@ -465,10 +465,7 @@ function network_content(&$a, $update = 0, $load = false) { } if(($update_unseen) && (! $firehose)) - $r = q("UPDATE item SET item_flags = ( item_flags & ~%d) - WHERE (item_flags & %d) > 0 AND uid = %d $update_unseen ", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d $update_unseen ", intval(local_channel()) ); diff --git a/mod/photos.php b/mod/photos.php index dbe165f60..33854dd76 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -877,11 +877,9 @@ function photos_content(&$a) { } if((local_channel()) && (local_channel() == $link_item['uid'])) { - q("UPDATE `item` SET item_flags = (item_flags & ~%d) WHERE parent = %d and uid = %d and (item_flags & %d)>0", - intval(ITEM_UNSEEN), + q("UPDATE `item` SET item_unseen = 0 WHERE item_unseen = 1 AND parent = %d AND uid = %d ", intval($link_item['parent']), - intval(local_channel()), - intval(ITEM_UNSEEN) + intval(local_channel()) ); } } diff --git a/mod/ping.php b/mod/ping.php index 6a89ad5cf..f49789be5 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -151,16 +151,12 @@ function ping_init(&$a) { if(x($_REQUEST, 'markRead') && local_channel()) { switch($_REQUEST['markRead']) { case 'network': - $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d) > 0 and uid = %d", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("update item set item_unseen = 0 where item_unseen = 1 and uid = %d", intval(local_channel()) ); break; case 'home': - $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d) > 0 and (item_flags & %d) > 0 and uid = %d", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("update item set item_unseen = 0 where item_unseen = 1 and (item_flags & %d) > 0 and uid = %d", intval(ITEM_WALL), intval(local_channel()) ); @@ -190,8 +186,7 @@ function ping_init(&$a) { } if(x($_REQUEST, 'markItemRead') && local_channel()) { - $r = q("update item set item_flags = ( item_flags & ~%d ) where parent = %d and uid = %d", - intval(ITEM_UNSEEN), + $r = q("update item set item_unseen = 0 where parent = %d and uid = %d", intval($_REQUEST['markItemRead']), intval(local_channel()) ); @@ -278,10 +273,8 @@ function ping_init(&$a) { $result = array(); $r = q("SELECT * FROM item - WHERE item_restrict = %d and ( item_flags & %d ) > 0 and uid = %d + WHERE item_restrict = 0 and item_unseen = 1 and uid = %d and author_xchan != '%s' ORDER BY created DESC", - intval(ITEM_VISIBLE), - intval(ITEM_UNSEEN), intval(local_channel()), dbesc($ob_hash) ); @@ -386,10 +379,8 @@ function ping_init(&$a) { if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) { $r = q("SELECT id, item_restrict, item_flags FROM item - WHERE (item_restrict = %d) and ( item_flags & %d ) > 0 and uid = %d + WHERE item_restrict = 0 and item_unseen = 1 and uid = %d and author_xchan != '%s'", - intval(ITEM_VISIBLE), - intval(ITEM_UNSEEN), intval(local_channel()), dbesc($ob_hash) ); -- cgit v1.2.3 From 084ca3f4a16084068a0ab04af651770142324f3a Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Feb 2015 18:49:42 -0800 Subject: typo --- mod/item.php | 1 + mod/network.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 99d28400b..120b5c66f 100644 --- a/mod/item.php +++ b/mod/item.php @@ -529,6 +529,7 @@ function item_post(&$a) { $body = preg_replace_callback('/\[\$b64url(.*?)\[\/(url)\]/ism','red_unescape_codeblock',$body); $body = preg_replace_callback('/\[\$b64code(.*?)\[\/(code)\]/ism','red_unescape_codeblock',$body); + // fix any img tags that should be zmg $body = preg_replace_callback('/\[img(.*?)\](.*?)\[\/img\]/ism','red_zrlify_img_callback',$body); diff --git a/mod/network.php b/mod/network.php index 236d4c5e0..944c3c1d1 100644 --- a/mod/network.php +++ b/mod/network.php @@ -346,7 +346,7 @@ function network_content(&$a, $update = 0, $load = false) { else $page_mode = 'client'; - $simple_update = (($update) ? " and item.unseen = 1 " : ''); + $simple_update = (($update) ? " and item_unseen = 1 " : ''); // This fixes a very subtle bug so I'd better explain it. You wake up in the morning or return after a day // or three and look at your matrix page - after opening up your browser. The first page loads just as it -- cgit v1.2.3 From 4b513d3322e03ed59e796ca60d09ee1d26cc50fb Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Feb 2015 19:22:07 -0800 Subject: issue #896 --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 120b5c66f..eb823b4b0 100644 --- a/mod/item.php +++ b/mod/item.php @@ -740,7 +740,7 @@ function item_post(&$a) { $datarray['author'] = $observer; $datarray['attach'] = json_encode($datarray['attach']); $o = conversation($a,array($datarray),'search',false,'preview'); - logger('preview: ' . $o, LOGGER_DEBUG); +// logger('preview: ' . $o, LOGGER_DEBUG); echo json_encode(array('preview' => $o)); killme(); } -- cgit v1.2.3 From 7ad425bbda549c3937c2feeac593bdcd21167019 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 14 Feb 2015 21:57:47 -0800 Subject: failure to auto update comments if it's your own. --- mod/item.php | 2 +- mod/rate.php | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index eb823b4b0..dbee2df3b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -644,7 +644,7 @@ function item_post(&$a) { } } - $item_unseen = ((local_channel() != $profile_uid) ? 1 : 0); + $item_unseen = 1; if($post_type === 'wall' || $post_type === 'wall-comment') $item_flags = $item_flags | ITEM_WALL; diff --git a/mod/rate.php b/mod/rate.php index 694b88ddd..cc12dcac9 100644 --- a/mod/rate.php +++ b/mod/rate.php @@ -119,12 +119,15 @@ function rate_content(&$a) { dbesc($channel['channel_hash']), dbesc($a->data['target']) ); - if($r) + if($r) { $a->data['xlink'] = $r[0]; - - $rating_val = $r[0]['xlink_rating']; - $rating_text = $r[0]['xlink_rating_text']; - + $rating_val = $r[0]['xlink_rating']; + $rating_text = $r[0]['xlink_rating_text']; + } + else { + $rating_val = 0; + $rating_text = ''; + } // if unset default to enabled if($poco_rating === false) -- cgit v1.2.3 From 0249fbb7e6da9de47fb3c091db4e4e296330993a Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Feb 2015 16:04:59 -0800 Subject: lost ability to delete events --- mod/events.php | 31 +++++++++++++++++++++++++++++++ mod/post.php | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index f209dab1d..010f1f7c4 100755 --- a/mod/events.php +++ b/mod/events.php @@ -273,6 +273,10 @@ function events_content(&$a) { $mode = 'add'; $item_id = intval(argv(2)); } + if(argc() > 2 && argv(1) === 'drop') { + $mode = 'drop'; + $event_id = argv(2); + } if(argv(1) === 'new') { $mode = 'new'; $event_id = ''; @@ -412,6 +416,8 @@ function events_content(&$a) { $last_date = $d; // FIXME $edit = (($rr['item_flags'] & ITEM_WALL) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null); + $drop = array($a->get_baseurl().'/events/drop/'.$rr['event_hash'],t('Delete event'),'',''); + $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8')); if(! $title) { list($title, $_trash) = explode(" $rr['event_hash'], 'start'=> $start, 'end' => $end, + 'drop' => $drop, 'allDay' => false, 'title' => $title, @@ -479,6 +486,30 @@ function events_content(&$a) { } + if($mode === 'drop' && $event_id) { + $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", + dbesc($event_id), + intval(local_channel()) + ); + if($r) { + $r = q("delete from event where event_hash = '%s' and uid = %d limit 1", + dbesc($event_id), + intval(local_channel()) + ); + if($r) { + $r = q("update item set resource_type = '', resource_id = '' where resource_type = 'event' and resource_id = '%s' and uid = %d", + dbesc($event_id), + intval(local_channel()) + ); + info( t('Event removed') . EOL); + } + else { + notice( t('Failed to remove event' ) . EOL); + } + goaway(z_root() . '/events'); + } + } + if($mode === 'edit' && $event_id) { $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", dbesc($event_id), diff --git a/mod/post.php b/mod/post.php index c90997335..6e35632da 100644 --- a/mod/post.php +++ b/mod/post.php @@ -467,7 +467,7 @@ function post_post(&$a) { * tells us we need to unencapsulate the AES-256-CBC content using the site private key */ - if(array_key_exists('iv',$data)) { + if($data && array_key_exists('iv',$data)) { $encrypted_packet = true; $data = crypto_unencapsulate($data,get_config('system','prvkey')); logger('mod_zot: decrypt1: ' . $data, LOGGER_DATA); -- cgit v1.2.3 From 9067d4c15729debea75ffea6931dd97c0f683fb5 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Feb 2015 18:38:26 -0800 Subject: taganyone wasn't working --- mod/acl.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/acl.php b/mod/acl.php index 6ae803596..e919bb912 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -99,6 +99,7 @@ function acl_init(&$a){ intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED), intval(XCHAN_FLAGS_DELETED) ); + } else { // Visitors $r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags @@ -148,12 +149,14 @@ function acl_init(&$a){ } } if(intval(get_config('system','taganyone')) || intval(get_pconfig(local_channel(),'system','taganyone'))) { - if((! $r) && $type == 'c') { - $r = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags + if((count($r) < 100) && $type == 'c') { + $r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags FROM xchan WHERE not (xchan_flags & %d )>0 $sql_extra2 order by $order_extra2 xchan_name asc" , intval(XCHAN_FLAGS_DELETED) ); + if($r2) + $r = array_merge($r,$r2); } } } -- cgit v1.2.3 From 2e3daf77bbf38970cf22ec14e4a6e42b4d7bdb95 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Feb 2015 20:20:23 -0800 Subject: site firehose --- mod/home.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/home.php b/mod/home.php index db4ae9c42..6d5c7db25 100644 --- a/mod/home.php +++ b/mod/home.php @@ -164,9 +164,16 @@ function home_content(&$a, $update = 0, $load = false) { } require_once('include/identity.php'); - $sys = get_sys_channel(); - $uids = " and item.uid = " . intval($sys['channel_id']) . " "; - $a->data['firehose'] = intval($sys['channel_id']); + + if(get_config('system','site_firehose')) { + require_once('include/security.php'); + $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and (item_flags & " . intval(ITEM_WALL) . " ) > 0 "; + } + else { + $sys = get_sys_channel(); + $uids = " and item.uid = " . intval($sys['channel_id']) . " "; + $a->data['firehose'] = intval($sys['channel_id']); + } $page_mode = 'list'; @@ -199,6 +206,7 @@ function home_content(&$a, $update = 0, $load = false) { intval(ABOOK_FLAG_BLOCKED) ); + } // Then fetch all the children of the parents that are on this page -- cgit v1.2.3 From 8774089005501a6429eb9a99a73de504598a24c3 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Feb 2015 21:22:05 -0800 Subject: preparatory work for site ratings --- mod/ratings.php | 18 ++++++++++++------ mod/ratingsearch.php | 15 +++++++++++---- 2 files changed, 23 insertions(+), 10 deletions(-) (limited to 'mod') diff --git a/mod/ratings.php b/mod/ratings.php index fe7865778..684856f45 100644 --- a/mod/ratings.php +++ b/mod/ratings.php @@ -35,7 +35,7 @@ function ratings_init(&$a) { $results = false; - $x = z_fetch_url($url . '/ratingsearch/' . $hash); + $x = z_fetch_url($url . '/ratingsearch/' . urlencode($hash)); if($x['success']) @@ -48,8 +48,9 @@ function ratings_init(&$a) { return; } - $a->poi = $results['target']; - + if(array_key_exists('xchan_hash',$results['target'])) + $a->poi = $results['target']; + $friends = array(); $others = array(); @@ -62,9 +63,9 @@ function ratings_init(&$a) { } } - $a->data = array_merge($friends,$others); + $a->data = array('target' => $results['target'], 'results' => array_merge($friends,$others)); - if(! $a->data) { + if(! $a->data['results']) { notice( t('No ratings') . EOL); } @@ -90,11 +91,16 @@ function ratings_content(&$a) { if(! $poco_rating) return; + $site_target = ((array_key_exists('target',$a->data) && array_key_exists('site_url',$a->data['target'])) ? + $a->data['target']['site_url'] : ''); + $o = replace_macros(get_markup_template('prep.tpl'),array( '$header' => t('Ratings'), '$rating_lbl' => t('Rating: ' ), + '$website' => t('Website: '), + '$site' => $site_target, '$rating_text_lbl' => t('Description: '), - '$raters' => $a->data + '$raters' => $a->data['results'] )); return $o; diff --git a/mod/ratingsearch.php b/mod/ratingsearch.php index ec2db570b..b95b4367e 100644 --- a/mod/ratingsearch.php +++ b/mod/ratingsearch.php @@ -32,12 +32,19 @@ function ratingsearch_init(&$a) { dbesc($hash . '%') ); + if(! $p) { + $p = q("select * from site where site_url like '%s' ", + dbesc('%' . $hash) + ); + + if(! $p) { + $ret['message'] = 'channel not found'; + json_return_and_die($ret); + } + } + if($p) $ret['target'] = $p[0]; - else { - $ret['message'] = 'channel not found'; - json_return_and_die($ret); - } $ret['success'] = true; -- cgit v1.2.3 From 1c4b9199809581504ee66212f3bb434fd9773aff Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Feb 2015 23:45:22 -0800 Subject: force site_url to be lowercase when stored. Otherwise rating hubs on postgres could get real messy. --- mod/rate.php | 9 +++++++++ mod/ratings.php | 3 ++- mod/ratingsearch.php | 14 +++++++++----- 3 files changed, 20 insertions(+), 6 deletions(-) (limited to 'mod') diff --git a/mod/rate.php b/mod/rate.php index cc12dcac9..2555b36a2 100644 --- a/mod/rate.php +++ b/mod/rate.php @@ -21,6 +21,13 @@ function rate_init(&$a) { if($r) { $a->poi = $r[0]; } + else { + $r = q("select * from site where site_url like '%s' ", + dbesc('%' . $target) + ); + if($r) + $a->data['site'] = strtolower($r[0]); + } } @@ -145,6 +152,8 @@ function rate_content(&$a) { $o = replace_macros(get_markup_template('rating_form.tpl'),array( '$header' => t('Rating'), + '$website' => t('Website:'), + '$site' => (($a->data['site']) ? '' . $a->data['site']['site_url'] . '' : ''), 'target' => $a->data['target'], '$tgt_name' => (($a->poi && $a->poi['xchan_name']) ? $a->poi['xchan_name'] : sprintf( t('Remote Channel [%s] (not yet known on this site)'), substr($a->data['target'],0,16))), '$lbl_rating' => t('Rating (this information is public)'), diff --git a/mod/ratings.php b/mod/ratings.php index 684856f45..dc98eb238 100644 --- a/mod/ratings.php +++ b/mod/ratings.php @@ -92,7 +92,8 @@ function ratings_content(&$a) { return; $site_target = ((array_key_exists('target',$a->data) && array_key_exists('site_url',$a->data['target'])) ? - $a->data['target']['site_url'] : ''); + '' . $a->data['target']['site_url'] . '' : ''); + $o = replace_macros(get_markup_template('prep.tpl'),array( '$header' => t('Ratings'), diff --git a/mod/ratingsearch.php b/mod/ratingsearch.php index b95b4367e..9c4f2f827 100644 --- a/mod/ratingsearch.php +++ b/mod/ratingsearch.php @@ -32,13 +32,17 @@ function ratingsearch_init(&$a) { dbesc($hash . '%') ); - if(! $p) { + if($p) + $target = $p[0]['xchan_hash']; + else { $p = q("select * from site where site_url like '%s' ", dbesc('%' . $hash) ); - - if(! $p) { - $ret['message'] = 'channel not found'; + if($p) { + $target = strtolower($hash); + } + else { + $ret['message'] = 'Rating target not found'; json_return_and_die($ret); } } @@ -50,7 +54,7 @@ function ratingsearch_init(&$a) { $r = q("select * from xlink left join xchan on xlink_xchan = xchan_hash where xlink_link = '%s' and xlink_rating != 0 and xlink_static = 1 order by xchan_name asc", - dbesc($p[0]['xchan_hash']) + dbesc($target) ); if($r) { -- cgit v1.2.3 From eb3c5916d759742fa87ec00622b363d0de29b283 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Feb 2015 01:17:15 -0800 Subject: pubsites ratings (mod/pubsites really really needs to be templatised, this was quick and dirty) --- mod/pubsites.php | 7 +++++-- mod/rate.php | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/pubsites.php b/mod/pubsites.php index c31bbcf97..ddd7baf92 100644 --- a/mod/pubsites.php +++ b/mod/pubsites.php @@ -22,10 +22,13 @@ function pubsites_content(&$a) { if($ret['success']) { $j = json_decode($ret['body'],true); if($j) { - $o .= ''; + $rate_meta = ((local_channel()) ? '' : ''); + $o .= '
' . t('Site URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Location') . '
' . t('Rate this hub') . '' . t('View hub ratings') . '
' . $rate_meta . ''; if($j['sites']) { foreach($j['sites'] as $jj) { - $o .= ''; + $host = strtolower(substr($jj['url'],strpos($jj['url'],'://')+3)); + $rate_links = ((local_channel()) ? '' : ''); + $o .= '' . $rate_links . ''; } } diff --git a/mod/rate.php b/mod/rate.php index 2555b36a2..a3a36b4a9 100644 --- a/mod/rate.php +++ b/mod/rate.php @@ -25,8 +25,10 @@ function rate_init(&$a) { $r = q("select * from site where site_url like '%s' ", dbesc('%' . $target) ); - if($r) - $a->data['site'] = strtolower($r[0]); + if($r) { + $a->data['site'] = $r[0]; + $a->data['site']['site_url'] = strtolower($r[0]['site_url']); + } } } -- cgit v1.2.3 From a1c4bbfa5cc59c5f61370d1c0e0a8d5c202729e4 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Feb 2015 01:22:11 -0800 Subject: quick fix for photos page until calls to like_puller() are fixed --- mod/photos.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/photos.php b/mod/photos.php index 33854dd76..8ac6ed3d7 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -977,10 +977,10 @@ function photos_content(&$a) { if($r) { - foreach($r as $item) { - like_puller($a,$item,$alike,'like'); - like_puller($a,$item,$dlike,'dislike'); - } +// foreach($r as $item) { +// like_puller($a,$item,$alike,'like'); +// like_puller($a,$item,$dlike,'dislike'); +// } $like_count = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid']] : ''); $like_list = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid'] . '-l'] : ''); -- cgit v1.2.3 From b4f639239fb0d6d5ed58fb7139bb7f88f1b77150 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Feb 2015 11:09:12 -0800 Subject: mopping up the public site ratings --- mod/pubsites.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/pubsites.php b/mod/pubsites.php index ddd7baf92..ff3854492 100644 --- a/mod/pubsites.php +++ b/mod/pubsites.php @@ -22,13 +22,13 @@ function pubsites_content(&$a) { if($ret['success']) { $j = json_decode($ret['body'],true); if($j) { - $rate_meta = ((local_channel()) ? '' : ''); - $o .= '
' . t('Site URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Location') . '
' . '' . $jj['url'] . '' . '' . $jj['access'] . '' . $jj['register'] . '' . $jj['location'] . '
' . t('Rate') . ' ' . t('View ratings') . '
' . '' . $jj['url'] . '' . '' . $jj['access'] . '' . $jj['register'] . '' . $jj['location'] . '
' . t('Rate this hub') . '' . t('View hub ratings') . '
' . $rate_meta . ''; + $rate_meta = ((local_channel()) ? '' : ''); + $o .= '
' . t('Site URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Location') . '
' . t('Rate this hub') . '
' . $rate_meta . ''; if($j['sites']) { foreach($j['sites'] as $jj) { $host = strtolower(substr($jj['url'],strpos($jj['url'],'://')+3)); - $rate_links = ((local_channel()) ? '' : ''); - $o .= '' . $rate_links . ''; + $rate_links = ((local_channel()) ? '' : ''); + $o .= '' . $rate_links . ''; } } -- cgit v1.2.3 From 533f39debe494dc826570ff030fcda35041d9038 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Feb 2015 17:01:13 -0800 Subject: bring back like/dislike summaries on photos --- mod/photos.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/photos.php b/mod/photos.php index 8ac6ed3d7..297790f6e 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -974,13 +974,21 @@ function photos_content(&$a) { $like = ''; $dislike = ''; + $conv_responses = array( + 'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')), + 'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')), + 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title')) + ); + + + if($r) { -// foreach($r as $item) { -// like_puller($a,$item,$alike,'like'); -// like_puller($a,$item,$dlike,'dislike'); -// } + foreach($r as $item) { + builtin_activity_puller($item, $conv_responses); + } + $like_count = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid']] : ''); $like_list = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid'] . '-l'] : ''); @@ -1084,6 +1092,13 @@ function photos_content(&$a) { $dislike_e = $dislike; + $response_verbs = array('like'); + if(feature_enabled($owner_uid,'dislike')) + $response_verbs[] = 'dislike'; + + + $responses = get_responses($conv_responses,$response_verbs,'',$link_item); + $photo_tpl = get_markup_template('photo_view.tpl'); $o .= replace_macros($photo_tpl, array( '$id' => $link_item['id'], //$ph[0]['id'], @@ -1098,6 +1113,7 @@ function photos_content(&$a) { '$unknown' => t('Unknown'), '$tag_hdr' => t('In This Photo:'), '$tags' => $tags, + 'responses' => $responses, '$edit' => $edit, '$likebuttons' => $likebuttons, '$like' => $like_e, -- cgit v1.2.3 From e00be4de2353e1ca58570bf37fd247ff99fa549f Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Feb 2015 19:47:36 -0800 Subject: The Diaspora communications policies allow comments to public posts literally from anybody. Allow this policy model by default for commenters from that network. This policy decision can be set or disabled on the addon/features settings page. --- mod/settings.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 8c927a97c..2ccedcb7b 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -114,6 +114,12 @@ function settings_post(&$a) { check_form_security_token_redirectOnErr('/settings/featured', 'settings_featured'); call_hooks('feature_settings_post', $_POST); + + if($_POST['dspr-submit']) { + set_pconfig(local_channel(),'system','diaspora_public_comments',intval($_POST['dspr_pubcomment'])); + info( t('Diaspora Policy Settings updated.') . EOL); + } + build_sync_packet(); return; } @@ -648,18 +654,31 @@ function settings_content(&$a) { } if((argc() > 1) && (argv(1) === 'featured')) { $settings_addons = ""; + + $o = ''; + $diaspora_enabled = get_config('system','diaspora_enabled'); $r = q("SELECT * FROM `hook` WHERE `hook` = 'feature_settings' "); - if(! count($r)) + if((! $r) && (! $diaspora_enabled)) $settings_addons = t('No feature settings configured'); + if($diaspora_enabled) { + $pubcomments = get_pconfig(local_channel(),'system','diaspora_public_comments'); + if($pubcomments === false) + $pubcomments = 1; + } + call_hooks('feature_settings', $settings_addons); - - + $tpl = get_markup_template("settings_addons.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_featured"), '$title' => t('Feature Settings'), + '$diaspora_enabled' => $diaspora_enabled, + '$pubcomments' => $pubcomments, + '$dsprtitle' => t('Diaspora Policy Settings'), + '$dsprhelp' => t('Allow any Diaspora member to comment on your public posts.'), + '$dsprsubmit' => t('Submit Diaspora Policy Settings'), '$settings_addons' => $settings_addons )); return $o; -- cgit v1.2.3 From 3ea77f0c105fe088af82f13de164af722e77a217 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Feb 2015 15:14:14 -0800 Subject: INSTALL: 'store' is created during setup but not 'store/[data]/smarty3' and we explicitly check for the latter and report that it isn't there or isn't writable. Doh. --- mod/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/setup.php b/mod/setup.php index d192eaf21..adcbbef16 100755 --- a/mod/setup.php +++ b/mod/setup.php @@ -535,7 +535,7 @@ function check_store(&$checks) { $status = true; $help = ""; - @os_mkdir('store',STORAGE_DEFAULT_PERMISSIONS); + @os_mkdir(TEMPLATE_BUILD_PATH,STORAGE_DEFAULT_PERMISSIONS,true); if( !is_writable('store') ) { -- cgit v1.2.3 From 5aad4a19f83a7e7de4ec9a7c819b9b5f7b4f1b3c Mon Sep 17 00:00:00 2001 From: Paolo Tacconi Date: Fri, 20 Feb 2015 10:09:59 +0100 Subject: Added version tag to siteinfo/json --- mod/siteinfo.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/siteinfo.php b/mod/siteinfo.php index 1f3cd4479..b73dca5b1 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -50,6 +50,18 @@ function siteinfo_init(&$a) { $site_info = get_config('system','info'); $site_name = get_config('system','sitename'); + if(! get_config('system','hidden_version_siteinfo')) { + $version = sprintf( t('Version %s'), RED_VERSION ); + if(@is_dir('.git') && function_exists('shell_exec')) { + $commit = @shell_exec('git log -1 --format="%h"'); + $tag = @shell_exec('git describe --tags --abbrev=0'); + } + if(! isset($commit) || strlen($commit) > 16) + $commit = ''; + } + else { + $version = $commit = ''; + } //Statistics $channels_total_stat = intval(get_config('system','channels_total_stat')); @@ -59,7 +71,8 @@ function siteinfo_init(&$a) { $hide_in_statistics = intval(get_config('system','hide_in_statistics')); $data = Array( - 'version' => RED_VERSION, + 'version' => $version, + 'version_tag' => $tag, 'commit' => $commit, 'url' => z_root(), 'plugins' => $visible_plugins, -- cgit v1.2.3 From 2765500844d7c85a6921f26cc708af8d967c9125 Mon Sep 17 00:00:00 2001 From: Paolo Tacconi Date: Fri, 20 Feb 2015 10:29:33 +0100 Subject: Fixes to version tag in siteinfo/json --- mod/siteinfo.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/siteinfo.php b/mod/siteinfo.php index b73dca5b1..e6798ce50 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -51,10 +51,10 @@ function siteinfo_init(&$a) { $site_info = get_config('system','info'); $site_name = get_config('system','sitename'); if(! get_config('system','hidden_version_siteinfo')) { - $version = sprintf( t('Version %s'), RED_VERSION ); + $version = RED_VERSION; if(@is_dir('.git') && function_exists('shell_exec')) { - $commit = @shell_exec('git log -1 --format="%h"'); - $tag = @shell_exec('git describe --tags --abbrev=0'); + $commit = trim( @shell_exec('git log -1 --format="%h"')); + $tag = trim( @shell_exec('git describe --tags --abbrev=0')); } if(! isset($commit) || strlen($commit) > 16) $commit = ''; -- cgit v1.2.3 From 2c7e8bea88abd4e835645996849e16ecd62dfa35 Mon Sep 17 00:00:00 2001 From: zottel Date: Fri, 20 Feb 2015 14:07:56 +0100 Subject: show item title in channel/mid and display pages --- mod/channel.php | 5 ++++- mod/display.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 788bacf70..109c9a596 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -329,8 +329,11 @@ function channel_content(&$a, $update = 0, $load = false) { $o .= conversation($a,$items,'channel',$update,'traditional'); } - if((! $update) || ($_COOKIE['jsAvailable'] != 1)) + if((! $update) || ($_COOKIE['jsAvailable'] != 1)) { $o .= alt_pager($a,count($items)); + if ($mid && $items[0]['title']) + $a->page['title'] = $items[0]['title'] . " - " . $a->page['title']; + } if($mid) $o .= '
'; diff --git a/mod/display.php b/mod/display.php index c2e5c2426..d06f1e66f 100644 --- a/mod/display.php +++ b/mod/display.php @@ -228,6 +228,9 @@ function display_content(&$a, $update = 0, $load = false) { $o .= conversation($a, $items, 'display', $update, 'client'); } else { $o .= conversation($a, $items, 'display', $update, 'traditional'); + if ($items[0]['title']) + $a->page['title'] = $items[0]['title'] . " - " . $a->page['title']; + } if($updateable) { -- cgit v1.2.3 From 48080d4103f19c6f2382be8f7ea66ca9b2f29d20 Mon Sep 17 00:00:00 2001 From: zottel Date: Fri, 20 Feb 2015 14:11:28 +0100 Subject: correct indent --- mod/display.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/display.php b/mod/display.php index d06f1e66f..d4a1acc5d 100644 --- a/mod/display.php +++ b/mod/display.php @@ -228,8 +228,8 @@ function display_content(&$a, $update = 0, $load = false) { $o .= conversation($a, $items, 'display', $update, 'client'); } else { $o .= conversation($a, $items, 'display', $update, 'traditional'); - if ($items[0]['title']) - $a->page['title'] = $items[0]['title'] . " - " . $a->page['title']; + if ($items[0]['title']) + $a->page['title'] = $items[0]['title'] . " - " . $a->page['title']; } -- cgit v1.2.3 From 1383915f865a26fe06c959d155f118b5934b3de7 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Feb 2015 22:58:09 -0800 Subject: notes about private realm registrations and multiple primary directories. --- mod/regdir.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/regdir.php b/mod/regdir.php index eecc99ca5..f24ee3951 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -1,6 +1,18 @@ false); @@ -32,7 +44,7 @@ function regdir_init(&$a) { json_return_and_die($result); } - $f = zot_finger('sys@' . $m['host']); + $f = zot_finger('[system]@' . $m['host']); if($f['success']) { $j = json_decode($f['body'],true); if($j['success'] && $j['guid']) { -- cgit v1.2.3 From 08f054130f5a57e2928e129131e7609271ec7f40 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 24 Feb 2015 16:36:27 -0800 Subject: require access token to view, query, or join directories in private realms, if the realm is so configured. --- mod/directory.php | 8 ++++++-- mod/dirsearch.php | 10 +++++++++- mod/regdir.php | 28 ++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 5 deletions(-) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index 329e255cf..bc5aa41e2 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -92,6 +92,9 @@ function directory_content(&$a) { $url = $directory['url'] . '/dirsearch'; } + $token = get_config('system','realm_token'); + + logger('mod_directory: URL = ' . $url, LOGGER_DEBUG); $contacts = array(); @@ -106,8 +109,6 @@ function directory_content(&$a) { } } - - if($url) { // We might want to make the tagadelic count (&kw=) configurable or turn it off completely. @@ -116,6 +117,9 @@ function directory_content(&$a) { $kw = ((intval($numtags)) ? $numtags : 24); $query = $url . '?f=&kw=' . $kw . (($safe_mode != 1) ? '&safe=' . $safe_mode : ''); + if($token) + $query .= '&t=' . $token; + if($search) $query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search); if(strpos($search,'@')) diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 5a0a7cee8..12abfafb8 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -13,7 +13,6 @@ function dirsearch_content(&$a) { $ret = array('success' => false); - $dirmode = intval(get_config('system','directory_mode')); if($dirmode == DIRECTORY_MODE_NORMAL) { @@ -21,6 +20,15 @@ function dirsearch_content(&$a) { json_return_and_die($ret); } + $access_token = $_REQUEST['t']; + + $token = get_config('system','realm_token'); + if($token && $access_token != $token) { + $result['message'] = t('This directory server requires an access token'); + return; + } + + if(argc() > 1 && argv(1) === 'sites') { $ret = list_public_sites(); json_return_and_die($ret); diff --git a/mod/regdir.php b/mod/regdir.php index f24ee3951..f12659dad 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -18,7 +18,8 @@ function regdir_init(&$a) { $result = array('success' => false); $url = $_REQUEST['url']; - + $access_token = $_REQUEST['t']; + $valid = 0; // we probably don't need the realm as we will find out in the probe. // What we may want to die is throw an error if you're trying to register in a different realm @@ -28,6 +29,18 @@ function regdir_init(&$a) { if(! $realm) $realm = DIRECTORY_REALM; + if($realm === DIRECTORY_REALM) { + $valid = 1; + } + else { + $token = get_config('system','realm_token'); + if($token && $access_token != $token) { + $result['message'] = 'This realm requires an access token'; + return; + } + $valid = 1; + } + $dirmode = intval(get_config('system','directory_mode')); if($dirmode == DIRECTORY_MODE_NORMAL) { @@ -56,14 +69,25 @@ function regdir_init(&$a) { } } + q("update site set site_valid = %d where site_url = '%s' limit 1", + intval($valid), + strtolower($url) + ); + json_return_and_die($result); } else { + + // We can put this in the sql without the condition after 31 march 2015 assuming + // most directory servers will have updated by then + // This just makes sure it happens if I forget + + $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-03-31')) ? ' and site_valid = 1 ' : '' ); if($dirmode == DIRECTORY_MODE_STANDALONE) { $r = array(array('site_url' => z_root())); } else { - $r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s'", + $r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s' $sql_extra ", dbesc(get_directory_realm()) ); } -- cgit v1.2.3 From 2a2cc309ce2f9a991978d7dda841663825a95370 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 25 Feb 2015 01:39:45 -0800 Subject: solve some (hopefully most) missing delivery issues --- mod/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index e1808fd55..ba52033ec 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -546,7 +546,7 @@ function admin_page_dbsync(&$a) { $o .= sprintf( t('Executing %s failed. Check system logs.'), $func); } elseif($retval === UPDATE_SUCCESS) { - $o .= sprintf( t('Update %s was successfully applied.', $func)); + $o .= sprintf( t('Update %s was successfully applied.'), $func); set_config('database',$func, 'success'); } else -- cgit v1.2.3 From a00c072f02efb741629b4b3e5b0eac1b3d6a95d4 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 26 Feb 2015 20:00:47 -0800 Subject: high level queue inspector - needs a lot more, like the ability to dump certain destinations and indicating known dead sites, but this is a start --- mod/admin.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index ba52033ec..a54a4b0b8 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -99,7 +99,8 @@ function admin_content(&$a) { 'channels' => Array($a->get_baseurl(true)."/admin/channels/", t("Channels") , "channels"), 'plugins' => Array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"), 'themes' => Array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"), - 'hubloc' => Array($a->get_baseurl(true)."/admin/hubloc/", t("Server") , "server"), + 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), +// 'hubloc' => Array($a->get_baseurl(true)."/admin/hubloc/", t("Server") , "server"), 'profs' => array(z_root() . '/admin/profs', t('Profile Config'), 'profs'), 'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync") ); @@ -164,6 +165,9 @@ function admin_content(&$a) { case 'profs': $o = admin_page_profs($a); break; + case 'queue': + $o = admin_page_queue($a); + break; default: notice( t("Item not found.") ); } @@ -583,6 +587,26 @@ function admin_page_dbsync(&$a) { } +function admin_page_queue($a) { + $o = ''; + + $r = q("select count(outq_posturl) as total, outq_posturl from outq + where outq_delivered = 0 group by outq_posturl order by total desc"); + + $o .= '

' . t('Queue Statistics') . '

'; + + if($r) { + $o .= '
' . t('Site URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Location') . '' . t('View hub ratings') . '
' . t('Rate') . ' ' . t('View ratings') . '
' . '' . $jj['url'] . '' . '' . $jj['access'] . '' . $jj['register'] . '' . $jj['location'] . '
' . t('Rate') . '
' . '' . $jj['url'] . '' . '' . $jj['access'] . '' . $jj['register'] . '' . $jj['location'] . ' ' . t('View ratings') . '
'; + foreach($r as $rr) { + $o .= ''; + } + $o .= '
' . t('Total Entries') . '  ' . t('Destination URL') . '
' . $rr['total'] . '' . $rr['outq_posturl'] . '
'; + } + + return $o; + +} + /** * Users admin page * -- cgit v1.2.3 From 05dff886c8e1d9da1f34f57c82d073714188f9d6 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 26 Feb 2015 20:07:08 -0800 Subject: don't report already delivered queue items in admin queue summary --- mod/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index a54a4b0b8..98b2f4266 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -202,7 +202,7 @@ function admin_page_summary(&$a) { $r = q("SELECT COUNT(id) as `count` FROM `register`"); $pending = $r[0]['count']; - $r = q("select count(*) as total from outq"); + $r = q("select count(*) as total from outq where outq_delivered = 0"); $queue = (($r) ? $r[0]['total'] : 0); // We can do better, but this is a quick queue status -- cgit v1.2.3 From af067666278046ef9f28e2657c1cf54950bd2d25 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 1 Mar 2015 16:59:44 +0100 Subject: provide some more yes/no labels --- mod/settings.php | 60 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 2ccedcb7b..3205797bb 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -965,18 +965,20 @@ function settings_content(&$a) { $timezone = date_default_timezone_get(); + $yes_no = array(t('No'),t('Yes')); + $opt_tpl = get_markup_template("field_checkbox.tpl"); if(get_config('system','publish_all')) { $profile_in_dir = ''; } else { $profile_in_dir = replace_macros($opt_tpl,array( - '$field' => array('profile_in_directory', t('Publish your default profile in the network directory'), $profile['publish'], '', array(t('No'),t('Yes'))), + '$field' => array('profile_in_directory', t('Publish your default profile in the network directory'), $profile['publish'], '', $yes_no), )); } $suggestme = replace_macros($opt_tpl,array( - '$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', array(t('No'),t('Yes'))), + '$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', $yes_no), )); @@ -1045,15 +1047,15 @@ function settings_content(&$a) { '$email' => array('email', t('Email Address:'), $email, ''), '$timezone' => array('timezone_select' , t('Your Timezone:'), $timezone, '', get_timezones()), '$defloc' => array('defloc', t('Default Post Location:'), $defloc, t('Geographical location to display on your posts')), - '$allowloc' => array('allow_location', t('Use Browser Location:'), ((get_pconfig(local_channel(),'system','use_browser_location')) ? 1 : ''), ''), + '$allowloc' => array('allow_location', t('Use Browser Location:'), ((get_pconfig(local_channel(),'system','use_browser_location')) ? 1 : ''), '', $yes_no), - '$adult' => array('adult', t('Adult Content'), $adult_flag, t('This channel frequently or regularly publishes adult content. (Please tag any adult material and/or nudity with #NSFW)')), + '$adult' => array('adult', t('Adult Content'), $adult_flag, t('This channel frequently or regularly publishes adult content. (Please tag any adult material and/or nudity with #NSFW)'), $yes_no), '$h_prv' => t('Security and Privacy Settings'), '$permissions_set' => $permissions_set, '$perms_set_msg' => t('Your permissions are already configured. Click to view/adjust'), - '$hide_presence' => array('hide_presence', t('Hide my online presence'),$hide_presence, t('Prevents displaying in your profile that you are online')), + '$hide_presence' => array('hide_presence', t('Hide my online presence'),$hide_presence, t('Prevents displaying in your profile that you are online'), $yes_no), '$lbl_pmacro' => t('Simple Privacy Settings:'), '$pmacro3' => t('Very Public - extremely permissive (should be used with caution)'), @@ -1061,7 +1063,7 @@ function settings_content(&$a) { '$pmacro1' => t('Private - default private, never open or public'), '$pmacro0' => t('Blocked - default blocked to/from everybody'), '$permiss_arr' => $permiss, - '$blocktags' => array('blocktags',t('Allow others to tag your posts'), 1-$blocktags, t('Often used by the community to retro-actively flag inappropriate content'),array(t('No'),t('Yes'))), + '$blocktags' => array('blocktags',t('Allow others to tag your posts'), 1-$blocktags, t('Often used by the community to retro-actively flag inappropriate content'), $yes_no), '$lbl_p2macro' => t('Advanced Privacy Settings'), @@ -1083,34 +1085,34 @@ 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, ''), + '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, '', $yes_no), + '$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, '', $yes_no), + '$post_profilechange' => array('post_profilechange', t('making an interesting profile change'), $post_profilechange, '', $yes_no), '$lbl_not' => t('Send a notification email when:'), - '$notify1' => array('notify1', t('You receive a connection request'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''), - '$notify2' => array('notify2', t('Your connections are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, ''), - '$notify3' => array('notify3', t('Someone writes on your profile wall'), ($notify & NOTIFY_WALL), NOTIFY_WALL, ''), - '$notify4' => array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, ''), - '$notify5' => array('notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, ''), - '$notify6' => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''), - '$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, ''), + '$notify1' => array('notify1', t('You receive a connection request'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, '', $yes_no), + '$notify2' => array('notify2', t('Your connections are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, '', $yes_no), + '$notify3' => array('notify3', t('Someone writes on your profile wall'), ($notify & NOTIFY_WALL), NOTIFY_WALL, '', $yes_no), + '$notify4' => array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, '', $yes_no), + '$notify5' => array('notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, '', $yes_no), + '$notify6' => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, '', $yes_no), + '$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, '', $yes_no), + '$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), ($notify & NOTIFY_POKE), NOTIFY_POKE, '', $yes_no), '$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, ''), - '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, ''), + '$vnotify1' => array('vnotify1', t('Unseen matrix activity'), ($vnotify & VNOTIFY_NETWORK), VNOTIFY_NETWORK, '', $yes_no), + '$vnotify2' => array('vnotify2', t('Unseen channel activity'), ($vnotify & VNOTIFY_CHANNEL), VNOTIFY_CHANNEL, '', $yes_no), + '$vnotify3' => array('vnotify3', t('Unseen private messages'), ($vnotify & VNOTIFY_MAIL), VNOTIFY_MAIL, t('Recommended'), $yes_no), + '$vnotify4' => array('vnotify4', t('Upcoming events'), ($vnotify & VNOTIFY_EVENT), VNOTIFY_EVENT, '', $yes_no), + '$vnotify5' => array('vnotify5', t('Events today'), ($vnotify & VNOTIFY_EVENTTODAY), VNOTIFY_EVENTTODAY, '', $yes_no), + '$vnotify6' => array('vnotify6', t('Upcoming birthdays'), ($vnotify & VNOTIFY_BIRTHDAY), VNOTIFY_BIRTHDAY, t('Not available in all themes'), $yes_no), + '$vnotify7' => array('vnotify7', t('System (personal) notifications'), ($vnotify & VNOTIFY_SYSTEM), VNOTIFY_SYSTEM, '', $yes_no), + '$vnotify8' => array('vnotify8', t('System info messages'), ($vnotify & VNOTIFY_INFO), VNOTIFY_INFO, t('Recommended'), $yes_no), + '$vnotify9' => array('vnotify9', t('System critical alerts'), ($vnotify & VNOTIFY_ALERT), VNOTIFY_ALERT, t('Recommended'), $yes_no), + '$vnotify10' => array('vnotify10', t('New connections'), ($vnotify & VNOTIFY_INTRO), VNOTIFY_INTRO, t('Recommended'), $yes_no), + '$vnotify11' => array('vnotify11', t('System Registrations'), ($vnotify & VNOTIFY_REGISTER), VNOTIFY_REGISTER, '', $yes_no), + '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')), -- cgit v1.2.3 From ba7bdd79b720dcb58dfd88a38f43444eb4da06f4 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Mar 2015 15:55:27 -0800 Subject: queue management actions. Still needs further work such as indication of last successful connection or indication that the hub was marked offline, but these are potentially expensive queries. --- mod/admin.php | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 98b2f4266..f97c15786 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -590,19 +590,42 @@ function admin_page_dbsync(&$a) { function admin_page_queue($a) { $o = ''; - $r = q("select count(outq_posturl) as total, outq_posturl from outq + $r = q("select count(outq_posturl) as total, outq_posturl, max(hubloc_connected) as connected from outq where outq_delivered = 0 group by outq_posturl order by total desc"); - $o .= '

' . t('Queue Statistics') . '

'; + if($_REQUEST['drophub']) { + require_once('hubloc.php'); + hubloc_mark_as_down($_REQUEST['drophub']); + } - if($r) { - $o .= ''; - foreach($r as $rr) { - $o .= ''; - } - $o .= '
' . t('Total Entries') . '  ' . t('Destination URL') . '
' . $rr['total'] . '' . $rr['outq_posturl'] . '
'; + if($_REQUEST['emptyhub']) { + $r = q("delete from outq where outq_posturl = '%s' ", + dbesc($_REQUEST['emptyhub']) + ); } + + + $r = q("select count(outq_posturl) as total, outq_posturl from outq + where outq_delivered = 0 group by outq_posturl order by total desc"); + + for($x = 0; $x < count($r); $x ++) { + $r[$x]['eurl'] = urlencode($r[$x]['outq_posturl']); + $r[$x]['connected'] = datetime_convert('UTC',date_default_timezone_get(),$r[$x]['connected'],'Y-m-d'); + } + + + $o = replace_macros(get_markup_template('admin_queue.tpl'), array( + '$banner' => t('Queue Statistics'), + '$numentries' => t('Total Entries'), + '$desturl' => t('Destination URL'), + '$nukehub' => t('Mark hub permanently offline'), + '$empty' => t('Empty queue for this hub'), + '$lastconn' => t('Last known contact'), + '$hasentries' => ((count($r)) ? true : false), + '$entries' => $r + )); + return $o; } -- cgit v1.2.3 From d83460cd2ae5216208a17154d7a9858a5a633b33 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Mar 2015 18:58:50 -0800 Subject: The never ending saga of parent = 0 bugs on Dreamhost. --- mod/ping.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/ping.php b/mod/ping.php index f49789be5..001c5594d 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -287,7 +287,7 @@ function ping_init(&$a) { $result[] = format_notification($item); } } - logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA); +// logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA); echo json_encode(array('notify' => $result)); killme(); } -- cgit v1.2.3 From df90677f900a1a6ed496628545a8e109700e168b Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Mar 2015 17:43:13 -0800 Subject: add the tag hijacking preference to Diaspora settings --- mod/settings.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 3205797bb..71ca38d91 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -117,6 +117,7 @@ function settings_post(&$a) { if($_POST['dspr-submit']) { set_pconfig(local_channel(),'system','diaspora_public_comments',intval($_POST['dspr_pubcomment'])); + set_pconfig(local_channel(),'system','prevent_tag_hijacking',intval($_POST['dspr_hijack'])); info( t('Diaspora Policy Settings updated.') . EOL); } @@ -666,6 +667,9 @@ function settings_content(&$a) { $pubcomments = get_pconfig(local_channel(),'system','diaspora_public_comments'); if($pubcomments === false) $pubcomments = 1; + $hijacking = get_pconfig(local_channel(),'system','prevent_tag_hijacking'); + + } call_hooks('feature_settings', $settings_addons); @@ -673,11 +677,13 @@ function settings_content(&$a) { $tpl = get_markup_template("settings_addons.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_featured"), - '$title' => t('Feature Settings'), + '$title' => t('Feature/Addon Settings'), '$diaspora_enabled' => $diaspora_enabled, '$pubcomments' => $pubcomments, '$dsprtitle' => t('Diaspora Policy Settings'), '$dsprhelp' => t('Allow any Diaspora member to comment on your public posts.'), + '$dsprhijack' => t('Prevent hashtags from being redirected to other sites'), + '$hijacking' => $hijacking, '$dsprsubmit' => t('Submit Diaspora Policy Settings'), '$settings_addons' => $settings_addons )); -- cgit v1.2.3 From 4b08ccd873a02dcbcd8603f4b8681de47776e31f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 4 Mar 2015 10:11:48 +0100 Subject: clean up account settings --- mod/settings.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 71ca38d91..a40a1deca 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -708,9 +708,8 @@ function settings_content(&$a) { $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_account"), '$title' => t('Account Settings'), - '$h_pass' => t('Password Settings'), - '$password1'=> array('npassword', t('New Password:'), '', ''), - '$password2'=> array('confirm', t('Confirm:'), '', t('Leave password fields blank unless changing')), + '$password1'=> array('npassword', t('Enter New Password:'), '', ''), + '$password2'=> array('confirm', t('Confirm New Password:'), '', t('Leave password fields blank unless changing')), '$submit' => t('Submit'), '$email' => array('email', t('Email Address:'), $email, ''), '$removeme' => t('Remove Account'), -- cgit v1.2.3 From eceafd5777c2b2c15d5db93e0a11bbeb328142e2 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 4 Mar 2015 10:26:25 +0100 Subject: fix wording --- mod/settings.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index a40a1deca..6b1e5ab0a 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -713,8 +713,7 @@ function settings_content(&$a) { '$submit' => t('Submit'), '$email' => array('email', t('Email Address:'), $email, ''), '$removeme' => t('Remove Account'), - '$removeaccount' => t('Remove this account from this server including all its channels'), - '$permanent' => t('Warning: This action is permanent and cannot be reversed.'), + '$removeaccount' => t('Remove this account including all its channels'), '$account_settings' => $account_settings )); return $o; @@ -1129,8 +1128,8 @@ function settings_content(&$a) { '$lbl_misc' => t('Miscellaneous Settings'), '$menus' => $menu, '$menu_desc' => t('Personal menu to display in your channel pages'), - '$removeme' => t('Remove this channel'), - '$permanent' => t('Warning: This action is permanent and cannot be reversed.'), + '$removeme' => t('Remove Channel'), + '$removechannel' => t('Remove this channel.'), )); call_hooks('settings_form',$o); -- cgit v1.2.3 From 431a462d60af173592cf6a046dc2280a07484402 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 4 Mar 2015 11:01:16 +0100 Subject: cleanup removeme --- mod/removeme.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/removeme.php b/mod/removeme.php index 492738b77..52145d639 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -9,6 +9,7 @@ function removeme_post(&$a) { return; if((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password'])))) + notice( t('Password not correct.') . EOL); return; if((! x($_POST,'verify')) || (! strlen(trim($_POST['verify'])))) @@ -21,6 +22,7 @@ function removeme_post(&$a) { $account = $a->get_account(); if(! account_verify_password($account['account_email'],$_POST['qxz_password'])) + notice( t('Password not correct.') . EOL); return; if($account['account_password_changed'] != NULL_DATE) { @@ -55,12 +57,12 @@ function removeme_content(&$a) { '$basedir' => $a->get_baseurl(), '$hash' => $hash, '$title' => t('Remove This Channel'), - '$desc' => t('This will completely remove this channel from the network. Once this has been done it is not recoverable.'), + '$desc' => array(t('WARNING: '), t('This channel will be completely removed from the network. '), t('This action is permanent and can not be undone!')), '$passwd' => t('Please enter your password for verification:'), - '$global' => array('global', t('Remove this channel and all its clones from the network'), false, t('By default only the instance of the channel located on this hub will be removed from the network')), + '$global' => array('global', t('Remove this channel and all its clones from the network'), false, t('By default only the instance of the channel located on this hub will be removed from the network'), array(t('No'),t('Yes'))), '$submit' => t('Remove Channel') )); return $o; -} \ No newline at end of file +} -- cgit v1.2.3 From e5e96dfbffd48b3d6b527e539e300a5091e7a19c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 4 Mar 2015 11:11:36 +0100 Subject: cleanup removeaccount --- mod/removeaccount.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/removeaccount.php b/mod/removeaccount.php index 18aaa2517..4505bbea0 100644 --- a/mod/removeaccount.php +++ b/mod/removeaccount.php @@ -9,6 +9,7 @@ function removeaccount_post(&$a) { return; if((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password'])))) + notice( t('Password not correct.') . EOL); return; if((! x($_POST,'verify')) || (! strlen(trim($_POST['verify'])))) @@ -22,6 +23,7 @@ function removeaccount_post(&$a) { $account_id = get_account_id(); if(! account_verify_password($account['account_email'],$_POST['qxz_password'])) + notice( t('Password not correct.') . EOL); return; if($account['account_password_changed'] != NULL_DATE) { @@ -55,7 +57,7 @@ function removeaccount_content(&$a) { '$basedir' => $a->get_baseurl(), '$hash' => $hash, '$title' => t('Remove This Account'), - '$desc' => t('This will completely remove this account including all its channels from the network. Once this has been done it is not recoverable.'), + '$desc' => array(t('WARNING: '), t('This account and all its channels will be completely removed from the network. '), t('This action is permanent and can not be undone!')), '$passwd' => t('Please enter your password for verification:'), '$global' => array('global', t('Remove this account, all its channels and all its channel clones from the network'), false, t('By default only the instances of the channels located on this hub will be removed from the network')), '$submit' => t('Remove Account') @@ -63,4 +65,4 @@ function removeaccount_content(&$a) { return $o; -} \ No newline at end of file +} -- cgit v1.2.3 From fb0f823be7142b715285ed8a2d18b98c240a630b Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Mar 2015 02:32:59 -0800 Subject: provide a list of potential addons and what they do for members who can't see the descriptions on the admin/plugins page Not all of these are in red-addons repository, please add any that haven't been listed. We should probably provide a list of addon repositories at the end. --- mod/settings.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 6b1e5ab0a..7ee2dba9e 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -679,10 +679,11 @@ function settings_content(&$a) { '$form_security_token' => get_form_security_token("settings_featured"), '$title' => t('Feature/Addon Settings'), '$diaspora_enabled' => $diaspora_enabled, + '$dsprdesc' => t('Settings for the built-in Diaspora emulator'), '$pubcomments' => $pubcomments, '$dsprtitle' => t('Diaspora Policy Settings'), '$dsprhelp' => t('Allow any Diaspora member to comment on your public posts.'), - '$dsprhijack' => t('Prevent hashtags from being redirected to other sites'), + '$dsprhijack' => t('Prevent your hashtags from being redirected to other sites'), '$hijacking' => $hijacking, '$dsprsubmit' => t('Submit Diaspora Policy Settings'), '$settings_addons' => $settings_addons -- cgit v1.2.3 From 39c17adc0b1d735b614b88eb4f44af02db5ba7b9 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Mar 2015 11:20:52 -0800 Subject: remove broken sql query from early queue manager. --- mod/admin.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index f97c15786..35e43252c 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -590,9 +590,6 @@ function admin_page_dbsync(&$a) { function admin_page_queue($a) { $o = ''; - $r = q("select count(outq_posturl) as total, outq_posturl, max(hubloc_connected) as connected from outq - where outq_delivered = 0 group by outq_posturl order by total desc"); - if($_REQUEST['drophub']) { require_once('hubloc.php'); hubloc_mark_as_down($_REQUEST['drophub']); -- cgit v1.2.3 From 410f3335a9e97276b3262196f50798ff56624af5 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Mar 2015 15:14:10 -0800 Subject: parse_url: if url returns an image/audio/video file instead of a webpage, return the bbcode for the appropriate content type. This results in two web fetches of the url in question, but the first one is just a HEAD. This way we won't try and download and parse an entire video. TODO: img's are checked to see if they should be zid-ified, but audio/video currently are not. --- mod/parse_url.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'mod') diff --git a/mod/parse_url.php b/mod/parse_url.php index 23d608411..49d5cae76 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -250,6 +250,34 @@ function parse_url_content(&$a) { } } + $result = z_fetch_url($url,false,0,array('novalidate' => true, 'nobody' => true)); + if($result['success']) { + $hdrs=array(); + $h = explode("\n",$result['header']); + foreach ($h as $l) { + list($k,$v) = array_map("trim", explode(":", trim($l), 2)); + $hdrs[$k] = $v; + } + if (array_key_exists('Content-Type', $hdrs)) + $type = $hdrs['Content-Type']; + if($type) { + if(in_array($type,array('image/jpeg','image/gif','image/png'))) { + $s = $br . '[img]' . $url . '[/img]' . $br; + $s = preg_replace_callback('/\[img(.*?)\](.*?)\[\/img\]/ism','red_zrlify_img_callback',$s); + echo $s; + killme(); + } + if(stripos($type,'video/') !== false) { + echo $br . '[video]' . $url . '[/video]' . $br; + killme(); + } + if(stripos($type,'audio/') !== false) { + echo $br . '[audio]' . $url . '[/audio]' . $br; + killme(); + } + } + } + logger('parse_url: ' . $url); $template = $br . '#^[url=%s]%s[/url]%s' . $br; -- cgit v1.2.3 From 76eb0a7e5606d61153b199094482c4c55685a035 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Mar 2015 18:55:17 -0800 Subject: Deprecate the "wall uploads" photo album. Photo uploads (from any source) with no album specified will go now into an album based on YYYY-MM. --- mod/wall_upload.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/wall_upload.php b/mod/wall_upload.php index 7ed1859a8..81ca643df 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -32,8 +32,7 @@ function wall_upload_post(&$a) { $observer = $a->get_observer(); - $args = array( 'source' => 'editor', 'album' => t('Wall Photos'), - 'not_visible' => 1, 'contact_allow' => array($channel['channel_hash'])); + $args = array( 'source' => 'editor', 'not_visible' => 1, 'contact_allow' => array($channel['channel_hash'])); $ret = photo_upload($channel,$observer,$args); -- cgit v1.2.3 From beace0f57afa9ed6ea5c2896573d5083fe855fed Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 5 Mar 2015 10:20:49 +0100 Subject: more yes/no labels --- mod/settings.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 7ee2dba9e..59a4b1f42 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -572,7 +572,7 @@ function settings_content(&$a) { // return; // } - + $yes_no = array(t('No'),t('Yes')); if((argc() > 1) && (argv(1) === 'oauth')) { @@ -850,16 +850,16 @@ function settings_content(&$a) { '$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview'), '$mobile_theme' => array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, ''), - '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, ''), + '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), - '$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''), - '$title_tosource' => array('title_tosource', t("Link post titles to source"), $title_tosource, ''), + '$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, '', $yes_no), + '$title_tosource' => array('title_tosource', t("Link post titles to source"), $title_tosource, '', $yes_no), '$layout_editor' => t('System Page Layout Editor - (advanced)'), '$theme_config' => $theme_config, '$expert' => feature_enabled(local_channel(),'expert'), - '$channel_list_mode' => array('channel_list_mode', t('Use blog/list mode on channel page'), get_pconfig(local_channel(),'system','channel_list_mode'), t('(comments displayed separately)')), - '$network_list_mode' => array('network_list_mode', t('Use blog/list mode on matrix page'), get_pconfig(local_channel(),'system','network_list_mode'), t('(comments displayed separately)')), + '$channel_list_mode' => array('channel_list_mode', t('Use blog/list mode on channel page'), get_pconfig(local_channel(),'system','channel_list_mode'), t('(comments displayed separately)'), $yes_no), + '$network_list_mode' => array('network_list_mode', t('Use blog/list mode on matrix page'), get_pconfig(local_channel(),'system','network_list_mode'), t('(comments displayed separately)'), $yes_no), '$channel_divmore_height' => array('channel_divmore_height', t('Channel page max height of content (in pixels)'), ((get_pconfig(local_channel(),'system','channel_divmore_height')) ? get_pconfig(local_channel(),'system','channel_divmore_height') : 400), t('click to expand content exceeding this height')), '$network_divmore_height' => array('network_divmore_height', t('Matrix page max height of content (in pixels)'), ((get_pconfig(local_channel(),'system','network_divmore_height')) ? get_pconfig(local_channel(),'system','network_divmore_height') : 400) , t('click to expand content exceeding this height')), @@ -970,8 +970,6 @@ function settings_content(&$a) { $timezone = date_default_timezone_get(); - $yes_no = array(t('No'),t('Yes')); - $opt_tpl = get_markup_template("field_checkbox.tpl"); if(get_config('system','publish_all')) { $profile_in_dir = ''; -- cgit v1.2.3 From 3fa41231611872b79f33469ceec5a8af1a95294d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 5 Mar 2015 12:47:18 +0100 Subject: only allow theme selection forms if there are any themes to select --- 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 59a4b1f42..bb0bfacbd 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -848,8 +848,8 @@ function settings_content(&$a) { '$baseurl' => $a->get_baseurl(true), '$uid' => local_channel(), - '$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview'), - '$mobile_theme' => array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, ''), + '$theme' => (($themes) ? array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview') : false), + '$mobile_theme' => (($mobile_themes) ? array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, '') : false), '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), -- cgit v1.2.3 From ec5c989352c91e050d306d234f638bb3fc7f6f6d Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Mar 2015 15:53:25 -0800 Subject: make destructive queue management functions an expert option --- mod/admin.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 35e43252c..13cf371b0 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -590,6 +590,8 @@ function admin_page_dbsync(&$a) { function admin_page_queue($a) { $o = ''; + $expert = ((array_key_exists('expert',$_REQUEST)) ? intval($_REQUEST['expert']) : 0); + if($_REQUEST['drophub']) { require_once('hubloc.php'); hubloc_mark_as_down($_REQUEST['drophub']); @@ -620,7 +622,8 @@ function admin_page_queue($a) { '$empty' => t('Empty queue for this hub'), '$lastconn' => t('Last known contact'), '$hasentries' => ((count($r)) ? true : false), - '$entries' => $r + '$entries' => $r, + '$expert' => $expert )); return $o; -- cgit v1.2.3 From 22391a24378cae317cdf62dc4be4b31b68e8191f Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Mar 2015 18:24:49 -0800 Subject: straighten out some directory stuff, which required some Comanche structural changes --- mod/directory.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index bc5aa41e2..dfc60b190 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -14,6 +14,20 @@ function directory_init(&$a) { dbesc($_GET['ignore']) ); } + + $observer = get_observer_hash(); + $global_changed = false; + + if(array_key_exists('global',$_REQUEST)) { + $globaldir = intval($_REQUEST['global']); + $global_changed = true; + } + if($global_changed) { + $_SESSION['globaldir'] = $globaldir; + if($observer) + set_xconfig($observer,'directory','globaldir',$globaldir); + } + } function directory_content(&$a) { @@ -26,6 +40,11 @@ function directory_content(&$a) { $safe_mode = 1; $observer = get_observer_hash(); + + if($observer) + $globaldir = get_xconfig($observer,'directory','globaldir'); + else + $globaldir = ((array_key_exists('globaldir',$_SESSION)) ? intval($_SESSION['globaldir']) : false); if($observer) { $safe_mode = get_xconfig($observer,'directory','safe_mode'); @@ -120,6 +139,9 @@ function directory_content(&$a) { if($token) $query .= '&t=' . $token; + if(! $globaldir) + $query .= '&hub=' . get_app()->get_hostname(); + if($search) $query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search); if(strpos($search,'@')) -- cgit v1.2.3 From ea8ea5a351d36b3575c98ccb0dda58805186d154 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Mar 2015 18:30:15 -0800 Subject: reverse the logic of "don't show emoticons" setting which seems awkward --- mod/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index bb0bfacbd..3dea83bb6 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -853,7 +853,7 @@ function settings_content(&$a) { '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), - '$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, '', $yes_no), + '$nosmile' => array('nosmile', t("Show emoticons (smilies) as images"), 1-intval($nosmile), '', $yes_no), '$title_tosource' => array('title_tosource', t("Link post titles to source"), $title_tosource, '', $yes_no), '$layout_editor' => t('System Page Layout Editor - (advanced)'), '$theme_config' => $theme_config, -- cgit v1.2.3 From bd4d2f3b44face9d265c28c84e9ca9eb85d1ee7d Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Mar 2015 19:16:50 -0800 Subject: make alpahabetic searches start with A --- mod/dirsearch.php | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'mod') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 12abfafb8..01cbccbed 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -186,8 +186,10 @@ function dirsearch_content(&$a) { } - if($sort_order == 'normal') + if($sort_order == 'normal') { $order = " order by xchan_name asc "; + $safesql .= " and ascii(substr(xchan_name FROM 1 FOR 1)) > 64 "; + } elseif($sort_order == 'reverse') $order = " order by xchan_name desc "; elseif($sort_order == 'reversedate') @@ -238,15 +240,44 @@ function dirsearch_content(&$a) { json_return_and_die($spkt); } else { - $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql $order $qlimit ", + + // The query mangling is designed to make alphabetic searches start with 'A' and not precede real names + // with those containing a bunch of punctuation + + if($sort_order == 'normal') { + $sql = $safesql .= " and ascii(substr(xchan_name FROM 1 FOR 1)) > 64 "; + } + else { + $sql = $safesql; + } + + $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $sql $order $qlimit ", intval(XCHAN_FLAGS_HIDDEN), intval(XCHAN_FLAGS_ORPHAN), intval(XCHAN_FLAGS_DELETED) ); - } - $ret['page'] = $page + 1; - $ret['records'] = count($r); + $ret['page'] = $page + 1; + $ret['records'] = count($r); + + + if(! $r) { + + if($sort_order == 'normal') { + $sql = $safesql .= " and ascii(substr(xchan_name FROM 1 FOR 1)) <= 64 "; + + $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $sql $order $qlimit ", + intval(XCHAN_FLAGS_HIDDEN), + intval(XCHAN_FLAGS_ORPHAN), + intval(XCHAN_FLAGS_DELETED) + ); + + $ret['page'] = $page + 1; + $ret['records'] = count($r); + + } + } + } if($r) { -- cgit v1.2.3 From f6da235a7d0eae48f7b691a139825708b99dcd75 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Mar 2015 23:31:01 -0800 Subject: major cleanup of directory options --- mod/directory.php | 30 +++++++++++++++++------------- mod/dirsearch.php | 42 ++++++++++-------------------------------- 2 files changed, 27 insertions(+), 45 deletions(-) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index dfc60b190..17a1776fe 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -17,6 +17,7 @@ function directory_init(&$a) { $observer = get_observer_hash(); $global_changed = false; + $safe_changed = false; if(array_key_exists('global',$_REQUEST)) { $globaldir = intval($_REQUEST['global']); @@ -28,6 +29,16 @@ function directory_init(&$a) { set_xconfig($observer,'directory','globaldir',$globaldir); } + if(array_key_exists('safe',$_REQUEST)) { + $safemode = intval($_REQUEST['safe']); + $safe_changed = true; + } + if($safe_changed) { + $_SESSION['safemode'] = $safemode; + if($observer) + set_xconfig($observer,'directory','safe_mode',$safemode); + } + } function directory_content(&$a) { @@ -46,20 +57,18 @@ function directory_content(&$a) { else $globaldir = ((array_key_exists('globaldir',$_SESSION)) ? intval($_SESSION['globaldir']) : false); - if($observer) { + if($observer) $safe_mode = get_xconfig($observer,'directory','safe_mode'); - } + else + $safe_mode = ((array_key_exists('safemode',$_SESSION)) ? intval($_SESSION['safemode']) : false); if($safe_mode === false) $safe_mode = 1; - else - $safe_mode = intval($safe_mode); - - if(x($_REQUEST,'safe')) - $safe_mode = (intval($_REQUEST['safe'])); $pubforums = null; if(array_key_exists('pubforums',$_REQUEST)) $pubforums = intval($_REQUEST['pubforums']); + if(! $pubforums) + $pubforums = null; $o = ''; nav_set_selected('directory'); @@ -153,15 +162,10 @@ function directory_content(&$a) { if(! is_null($pubforums)) $query .= '&pubforums=' . intval($pubforums); - if(! is_null($pubforums)) - $query .= '&pubforums=' . intval($pubforums); - - $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : 'normal'); + $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : 'date'); if($sort_order) $query .= '&order=' . urlencode($sort_order); - - if($a->pager['page'] != 1) $query .= '&p=' . $a->pager['page']; diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 01cbccbed..e734423a6 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -119,7 +119,7 @@ function dirsearch_content(&$a) { $sql_extra .= dir_query_build($joiner,'xprof_keywords',$keywords); if($forums) - $sql_extra .= dir_flag_build($joiner,'xprof_flags',XCHAN_FLAGS_PUBFORUM, $forums); + $sql_extra .= dir_flag_build(' AND ','xchan_flags',XCHAN_FLAGS_PUBFORUM, $forums); // we only support an age range currently. You must set both agege @@ -188,6 +188,11 @@ function dirsearch_content(&$a) { if($sort_order == 'normal') { $order = " order by xchan_name asc "; + + // Start the alphabetic search at 'A' + // This will make a handful of channels whose names begin with + // punctuation un-searchable in this mode + $safesql .= " and ascii(substr(xchan_name FROM 1 FOR 1)) > 64 "; } elseif($sort_order == 'reverse') @@ -241,49 +246,22 @@ function dirsearch_content(&$a) { } else { - // The query mangling is designed to make alphabetic searches start with 'A' and not precede real names - // with those containing a bunch of punctuation - - if($sort_order == 'normal') { - $sql = $safesql .= " and ascii(substr(xchan_name FROM 1 FOR 1)) > 64 "; - } - else { - $sql = $safesql; - } - - $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $sql $order $qlimit ", + $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql $order $qlimit ", intval(XCHAN_FLAGS_HIDDEN), intval(XCHAN_FLAGS_ORPHAN), intval(XCHAN_FLAGS_DELETED) ); + $ret['page'] = $page + 1; $ret['records'] = count($r); - - - if(! $r) { - - if($sort_order == 'normal') { - $sql = $safesql .= " and ascii(substr(xchan_name FROM 1 FOR 1)) <= 64 "; - - $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $sql $order $qlimit ", - intval(XCHAN_FLAGS_HIDDEN), - intval(XCHAN_FLAGS_ORPHAN), - intval(XCHAN_FLAGS_DELETED) - ); - - $ret['page'] = $page + 1; - $ret['records'] = count($r); - - } - } } + if($r) { $entries = array(); - foreach($r as $rr) { $entry = array(); @@ -348,7 +326,7 @@ function dir_query_build($joiner,$field,$s) { } function dir_flag_build($joiner,$field,$bit,$s) { - return dbesc($joiner) . " ( " . dbesc('xchan_flags') . " & " . intval($bit) . " ) " . ((intval($s)) ? '>' : '=' ) . " 0 "; + return dbesc($joiner) . " ( " . dbesc($field) . " & " . intval($bit) . " ) " . ((intval($s)) ? '>' : '=' ) . " 0 "; } -- cgit v1.2.3 From 73891dc5824f7495ce1103f826b88f3b8750f70f Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 6 Mar 2015 03:04:04 -0800 Subject: reverse smilie storage also --- mod/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 3dea83bb6..595878543 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -185,7 +185,7 @@ function settings_post(&$a) { set_pconfig(local_channel(),'system','user_scalable',$user_scalable); set_pconfig(local_channel(),'system','update_interval', $browser_update); set_pconfig(local_channel(),'system','itemspage', $itemspage); - set_pconfig(local_channel(),'system','no_smilies',$nosmile); + set_pconfig(local_channel(),'system','no_smilies',1-intval($nosmile)); set_pconfig(local_channel(),'system','title_tosource',$title_tosource); set_pconfig(local_channel(),'system','channel_list_mode', $channel_list_mode); set_pconfig(local_channel(),'system','network_list_mode', $network_list_mode); -- cgit v1.2.3 From 53e908d7b7ea1b1ff9aa5ca6154dc4c9e7ca0d13 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 6 Mar 2015 20:45:26 -0800 Subject: when fixing "naked links" make sure not to double link double urls as seen in archive.org - which has the complete unescaped target url, scheme and all, as part of its own. --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index dbee2df3b..8b45f5db9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -523,7 +523,7 @@ function item_post(&$a) { $body = preg_replace_callback('/\[url(.*?)\[\/(url)\]/ism','red_escape_codeblock',$body); $body = preg_replace_callback('/\[zrl(.*?)\[\/(zrl)\]/ism','red_escape_codeblock',$body); - $body = preg_replace_callback("/([^\]\='".'"'."]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ism", 'red_zrl_callback', $body); + $body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ism", 'red_zrl_callback', $body); $body = preg_replace_callback('/\[\$b64zrl(.*?)\[\/(zrl)\]/ism','red_unescape_codeblock',$body); $body = preg_replace_callback('/\[\$b64url(.*?)\[\/(url)\]/ism','red_unescape_codeblock',$body); -- cgit v1.2.3 From 9cd7546be5ad7f24534653f310c15362c3f2baa6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 7 Mar 2015 15:56:28 +0100 Subject: hopefully fix #919 --- mod/removeaccount.php | 2 -- mod/removeme.php | 2 -- 2 files changed, 4 deletions(-) (limited to 'mod') diff --git a/mod/removeaccount.php b/mod/removeaccount.php index 4505bbea0..70979ec15 100644 --- a/mod/removeaccount.php +++ b/mod/removeaccount.php @@ -9,7 +9,6 @@ function removeaccount_post(&$a) { return; if((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password'])))) - notice( t('Password not correct.') . EOL); return; if((! x($_POST,'verify')) || (! strlen(trim($_POST['verify'])))) @@ -23,7 +22,6 @@ function removeaccount_post(&$a) { $account_id = get_account_id(); if(! account_verify_password($account['account_email'],$_POST['qxz_password'])) - notice( t('Password not correct.') . EOL); return; if($account['account_password_changed'] != NULL_DATE) { diff --git a/mod/removeme.php b/mod/removeme.php index 52145d639..ff955775a 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -9,7 +9,6 @@ function removeme_post(&$a) { return; if((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password'])))) - notice( t('Password not correct.') . EOL); return; if((! x($_POST,'verify')) || (! strlen(trim($_POST['verify'])))) @@ -22,7 +21,6 @@ function removeme_post(&$a) { $account = $a->get_account(); if(! account_verify_password($account['account_email'],$_POST['qxz_password'])) - notice( t('Password not correct.') . EOL); return; if($account['account_password_changed'] != NULL_DATE) { -- cgit v1.2.3 From aac4affe656176f0538513435a4fdd8a69f244fc Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 7 Mar 2015 15:21:23 -0800 Subject: directory: fix public forum listing --- mod/dirsearch.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index e734423a6..b4154c1eb 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -12,6 +12,8 @@ function dirsearch_content(&$a) { $ret = array('success' => false); +// logger('request: ' . print_r($_REQUEST,true)); + $dirmode = intval(get_config('system','directory_mode')); @@ -119,7 +121,7 @@ function dirsearch_content(&$a) { $sql_extra .= dir_query_build($joiner,'xprof_keywords',$keywords); if($forums) - $sql_extra .= dir_flag_build(' AND ','xchan_flags',XCHAN_FLAGS_PUBFORUM, $forums); + $safesql .= dir_flag_build(' AND ','xchan_flags',XCHAN_FLAGS_PUBFORUM, $forums); // we only support an age range currently. You must set both agege @@ -165,9 +167,9 @@ function dirsearch_content(&$a) { } - $safesql = (($safe > 0) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " )>0 " : ''); + $safesql .= (($safe > 0) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " )>0 " : ''); if($safe < 0) - $safesql = " and ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " )>0 "; + $safesql .= " and ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " )>0 "; if($limit) $qlimit = " LIMIT $limit "; -- cgit v1.2.3 From 23ea974615cc8ffb3756769fe872affcee3d5c3a Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sat, 7 Mar 2015 18:19:52 +0100 Subject: Add alert to admin page about old PHP version. Add an alert message to admin summary page when a PHP version < 5.4 was detected as this has reached EOL and will not be supported with the new SabreDAV library. Some styleguide optimisation. Add NULL_DATE example to doc/sql_conventions.bb. Display a "0" when no plugins active in summary page. Added some more numbers to summary admin page, expired accounts, channels. Hope I interpreted them right. I have no idea how to get blocked accounts. --- mod/admin.php | 578 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 282 insertions(+), 296 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 13cf371b0..f461474c4 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -1,12 +1,14 @@ 1){ - switch (argv(1)){ + if (argc() > 1) { + switch (argv(1)) { case 'site': admin_page_site_post($a); break; @@ -27,7 +29,6 @@ function admin_post(&$a){ case 'channels': admin_page_channels_post($a); break; - case 'plugins': if (argc() > 2 && is_file("addon/" . argv(2) . "/" . argv(2) . ".php")){ @@ -38,7 +39,6 @@ function admin_post(&$a){ } } goaway($a->get_baseurl(true) . '/admin/plugins/' . argv(2) ); - return; // NOTREACHED break; case 'themes': $theme = argv(2); @@ -51,10 +51,8 @@ function admin_post(&$a){ } info(t('Theme settings updated.')); if(is_ajax()) return; - - goaway($a->get_baseurl(true) . '/admin/themes/' . $theme ); - return; + goaway($a->get_baseurl(true) . '/admin/themes/' . $theme ); break; case 'logs': admin_page_logs_post($a); @@ -65,20 +63,17 @@ function admin_post(&$a){ case 'dbsync': admin_page_dbsync_post($a); break; - case 'profs': admin_page_profs_post($a); break; - } } goaway($a->get_baseurl(true) . '/admin' ); - return; // NOTREACHED } /** - * @param App $a + * @param App $$a * @return string */ function admin_content(&$a) { @@ -93,29 +88,29 @@ function admin_content(&$a) { */ // array( url, name, extra css classes ) - $aside = Array( - 'site' => Array($a->get_baseurl(true)."/admin/site/", t("Site") , "site"), - 'users' => Array($a->get_baseurl(true)."/admin/users/", t("Accounts") , "users"), - 'channels' => Array($a->get_baseurl(true)."/admin/channels/", t("Channels") , "channels"), - 'plugins' => Array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"), - 'themes' => Array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"), - 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), -// 'hubloc' => Array($a->get_baseurl(true)."/admin/hubloc/", t("Server") , "server"), - 'profs' => array(z_root() . '/admin/profs', t('Profile Config'), 'profs'), - 'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync") + $aside = array( + 'site' => array($a->get_baseurl(true)."/admin/site/", t("Site") , "site"), + 'users' => array($a->get_baseurl(true)."/admin/users/", t("Accounts") , "users"), + 'channels' => array($a->get_baseurl(true)."/admin/channels/", t("Channels") , "channels"), + 'plugins' => array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"), + 'themes' => array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"), + 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), +// 'hubloc' => array($a->get_baseurl(true)."/admin/hubloc/", t("Server") , "server"), + 'profs' => array(z_root() . '/admin/profs', t('Profile Config'), 'profs'), + 'dbsync' => array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync") ); - + /* get plugins admin page */ - - $r = q("SELECT * FROM `addon` WHERE `plugin_admin`=1"); - $aside['plugins_admin']=Array(); + + $r = q("SELECT * FROM addon WHERE plugin_admin = 1"); + $aside['plugins_admin'] = array(); foreach ($r as $h){ - $plugin =$h['name']; - $aside['plugins_admin'][] = Array($a->get_baseurl(true)."/admin/plugins/".$plugin, $plugin, "plugin"); + $plugin = $h['name']; + $aside['plugins_admin'][] = array($a->get_baseurl(true) . '/admin/plugins/' . $plugin, $plugin, 'plugin'); // temp plugins with admin $a->plugins_admin[] = $plugin; } - + $aside['logs'] = Array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs"); $t = get_markup_template("admin_aside.tpl"); @@ -129,12 +124,11 @@ function admin_content(&$a) { )); - /** * Page content */ $o = ''; - + // urls if (argc() > 1){ switch (argv(1)) { @@ -169,12 +163,12 @@ function admin_content(&$a) { $o = admin_page_queue($a); break; default: - notice( t("Item not found.") ); + notice( t('Item not found.') ); } } else { $o = admin_page_summary($a); } - + if(is_ajax()) { echo $o; killme(); @@ -182,45 +176,76 @@ function admin_content(&$a) { } else { return $o; } -} +} /** - * Admin Summary Page - * @param App $a - * @return string + * @brief Returns content for Admin Summary Page. + * + * @param App $$a + * @return string HTML from parsed admin_summary.tpl */ function admin_page_summary(&$a) { - // list total user accounts, expirations etc. + $accounts = array(); + $r = q("SELECT COUNT(*) AS total, COUNT(IF(account_expires > %s, 1, NULL)) AS expiring, COUNT(IF(account_expires < %s AND account_expires != '%s', 1, NULL)) AS expired, COUNT(IF((account_flags & %d)>0, 1, NULL)) AS blocked FROM account", + db_utcnow(), + db_utcnow(), + dbesc(NULL_DATE), + intval(ACCOUNT_BLOCKED) + ); + if ($r) { + $accounts['total'] = array('label' => t('# Accounts'), 'val' => $r[0]['total']); + //@todo $accounts['blocked'] = array('label' => t('# blocked accounts'), 'val' => $r[0]['blocked']); + $accounts['expired'] = array('label' => t('# expired accounts'), 'val' => $r[0]['expired']); + $accounts['expiring'] = array('label' => t('# expiring accounts'), 'val' => $r[0]['expiring']); + } - - $r = q("SELECT COUNT(account_id) as total FROM `account`"); - $users = $r[0]['total']; - - $r = q("SELECT COUNT(id) as `count` FROM `register`"); + // pending registrations + $r = q("SELECT COUNT(id) AS `count` FROM register"); $pending = $r[0]['count']; - $r = q("select count(*) as total from outq where outq_delivered = 0"); - $queue = (($r) ? $r[0]['total'] : 0); + // available channels, primary and clones + $channels = array(); + $r = q("SELECT COUNT(*) AS total, COUNT(IF(channel_primary = 1, 1, NULL)) AS main, COUNT(IF(channel_primary = 0, 1, NULL)) AS clones FROM channel WHERE NOT (channel_pageflags & %d)>0", + intval(PAGE_REMOVED) + ); + if ($r) { + $channels['total'] = array('label' => t('# Channels'), 'val' => $r[0]['total']); + $channels['main'] = array('label' => t('# primary'), 'val' => $r[0]['main']); + $channels['clones'] = array('label' => t('# clones'), 'val' => $r[0]['clones']); + } // We can do better, but this is a quick queue status - + $r = q("SELECT COUNT(outq_delivered) AS total FROM outq WHERE outq_delivered = 0"); + $queue = (($r) ? $r[0]['total'] : 0); $queues = array( 'label' => t('Message queues'), 'queue' => $queue ); + // If no plugins active return 0, otherwise list of plugin names + $plugins = (count($a->plugins) == 0) ? count($a->plugins) : $a->plugins; + + // Could be extended to provide also other alerts to the admin + $alertmsg = ''; + // annoy admin about upcoming unsupported PHP version + if (version_compare(PHP_VERSION, '5.4', '<')) { + $alertmsg = 'Your PHP version ' . PHP_VERSION . ' will not be supported with the next major release of RedMatrix. You are strongly urged to upgrade to a current version.' + . '
PHP 5.3 has reached its End of Life (EOL) in August 2014.' + . ' A list about current PHP versions can be found here.'; + } - $t = get_markup_template("admin_summary.tpl"); + $t = get_markup_template('admin_summary.tpl'); return replace_macros($t, array( '$title' => t('Administration'), '$page' => t('Summary'), + '$adminalertmsg' => $alertmsg, '$queues' => $queues, - '$users' => Array( t('Registered users'), $users), - '$accounts' => $accounts, - '$pending' => Array( t('Pending registrations'), $pending), - '$version' => Array( t('Version'), RED_VERSION), - '$build' => get_config('system','db_version'), - '$plugins' => Array( t('Active plugins'), $a->plugins ) + '$accounts' => array( t('Registered accounts'), $accounts), + '$pending' => array( t('Pending registrations'), $pending), + '$channels' => array( t('Registered channels'), $channels), + '$plugins' => array( t('Active plugins'), $plugins ), + '$version' => array( t('Version'), RED_VERSION), + '$build' => get_config('system', 'db_version') )); } @@ -230,11 +255,11 @@ function admin_page_summary(&$a) { * @param App $a */ function admin_page_site_post(&$a){ - if (!x($_POST,"page_site")){ + if (!x($_POST, 'page_site')){ return; } - check_form_security_token_redirectOnErr('/admin/site', 'admin_site'); + check_form_security_token_redirectOnErr('/admin/site', 'admin_site'); $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : ''); $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false); @@ -244,69 +269,66 @@ function admin_page_site_post(&$a){ $theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : ''); // $site_channel = ((x($_POST,'site_channel')) ? notags(trim($_POST['site_channel'])) : ''); $maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0); - - + $register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0); $access_policy = ((x($_POST,'access_policy')) ? intval(trim($_POST['access_policy'])) : 0); $abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0); - $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : ''); - + $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : ''); + $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : ''); - $not_allowed_email = ((x($_POST,'not_allowed_email')) ? notags(trim($_POST['not_allowed_email'])) : ''); + $not_allowed_email = ((x($_POST,'not_allowed_email')) ? notags(trim($_POST['not_allowed_email'])) : ''); $block_public = ((x($_POST,'block_public')) ? True : False); $force_publish = ((x($_POST,'publish_all')) ? True : False); $disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? True : False); $no_login_on_homepage = ((x($_POST,'no_login_on_homepage')) ? True : False); - $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); - $no_community_page = !((x($_POST,'no_community_page')) ? True : False); - - $verifyssl = ((x($_POST,'verifyssl')) ? True : False); - $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); - $poll_interval = ((x($_POST,'poll_interval'))? intval(trim($_POST['poll_interval'])) : 0); - $maxloadavg = ((x($_POST,'maxloadavg'))? intval(trim($_POST['maxloadavg'])) : 50); - $feed_contacts = ((x($_POST,'feed_contacts')) ? intval($_POST['feed_contacts']) : 0); - $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? intval($_POST['diaspora_enabled']) : 0); - $verify_email = ((x($_POST,'verify_email')) ? 1 : 0); - - set_config('system','feed_contacts',$feed_contacts); - set_config('system','diaspora_enabled',$diaspora_enabled); - set_config('system','delivery_interval',$delivery_interval); - set_config('system','poll_interval',$poll_interval); - set_config('system','maxloadavg',$maxloadavg); - set_config('system','sitename',$sitename); - set_config('system','no_login_on_homepage',$no_login_on_homepage); - set_config('system','verify_email',$verify_email); - - if ($banner=="") { - del_config('system','banner'); - } - else { - set_config('system','banner', $banner); + $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); + $no_community_page = !((x($_POST,'no_community_page')) ? True : False); + + $verifyssl = ((x($_POST,'verifyssl')) ? True : False); + $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); + $poll_interval = ((x($_POST,'poll_interval')) ? intval(trim($_POST['poll_interval'])) : 0); + $maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50); + $feed_contacts = ((x($_POST,'feed_contacts')) ? intval($_POST['feed_contacts']) : 0); + $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? intval($_POST['diaspora_enabled']) : 0); + $verify_email = ((x($_POST,'verify_email')) ? 1 : 0); + + set_config('system', 'feed_contacts', $feed_contacts); + set_config('system', 'diaspora_enabled', $diaspora_enabled); + set_config('system', 'delivery_interval', $delivery_interval); + set_config('system', 'poll_interval', $poll_interval); + set_config('system', 'maxloadavg', $maxloadavg); + set_config('system', 'sitename', $sitename); + set_config('system', 'no_login_on_homepage', $no_login_on_homepage); + set_config('system', 'verify_email', $verify_email); + + if ($banner == '') { + del_config('system', 'banner'); + } else { + set_config('system', 'banner', $banner); } - if ($admininfo==''){ - del_config('system','admininfo'); - } - else { + if ($admininfo == ''){ + del_config('system', 'admininfo'); + } else { require_once('include/text.php'); linkify_tags($a, $admininfo, local_channel()); - set_config('system','admininfo', $admininfo); + set_config('system', 'admininfo', $admininfo); } - set_config('system','language', $language); - set_config('system','theme', $theme); + set_config('system', 'language', $language); + set_config('system', 'theme', $theme); if ( $theme_mobile === '---' ) { - del_config('system','mobile_theme'); + del_config('system', 'mobile_theme'); } else { - set_config('system','mobile_theme', $theme_mobile); - } + set_config('system', 'mobile_theme', $theme_mobile); + } // set_config('system','site_channel', $site_channel); set_config('system','maximagesize', $maximagesize); - + set_config('system','register_policy', $register_policy); set_config('system','access_policy', $access_policy); set_config('system','account_abandon_days', $abandon_days); @@ -317,11 +339,10 @@ function admin_page_site_post(&$a){ set_config('system','block_public', $block_public); set_config('system','publish_all', $force_publish); set_config('system','disable_discover_tab', $disable_discover_tab); - if($global_directory=="") { - del_config('system','directory_submit_url'); - } - else { - set_config('system','directory_submit_url', $global_directory); + if ($global_directory == '') { + del_config('system', 'directory_submit_url'); + } else { + set_config('system', 'directory_submit_url', $global_directory); } set_config('system','no_community_page', $no_community_page); @@ -333,8 +354,6 @@ function admin_page_site_post(&$a){ info( t('Site settings updated.') . EOL); goaway($a->get_baseurl(true) . '/admin/site' ); - return; // NOTREACHED - } /** @@ -342,11 +361,11 @@ function admin_page_site_post(&$a){ * @return string */ function admin_page_site(&$a) { - + /* Installed langs */ $lang_choices = array(); $langs = glob('view/*/strings.php'); - + if(is_array($langs) && count($langs)) { if(! in_array('view/en/strings.php',$langs)) $langs[] = 'view/en/'; @@ -358,17 +377,17 @@ function admin_page_site(&$a) { } /* Installed themes */ - $theme_choices_mobile["---"] = t("Default"); - $theme_choices = array(); - $files = glob('view/theme/*'); - if($files) { - foreach($files as $file) { - $vars = ''; - $f = basename($file); - if (file_exists($file . '/library')) - continue; - if (file_exists($file . '/mobile')) - $vars = t('mobile'); + $theme_choices_mobile["---"] = t("Default"); + $theme_choices = array(); + $files = glob('view/theme/*'); + if($files) { + foreach($files as $file) { + $vars = ''; + $f = basename($file); + if (file_exists($file . '/library')) + continue; + if (file_exists($file . '/mobile')) + $vars = t('mobile'); if (file_exists($file . '/experimental')) $vars .= t('experimental'); if (file_exists($file . '/unsupported')) @@ -376,29 +395,30 @@ function admin_page_site(&$a) { if ($vars) { $theme_choices[$f] = $f . ' (' . $vars . ')'; $theme_choices_mobile[$f] = $f . ' (' . $vars . ')'; - } + } else { - $theme_choices[$f] = $f; - $theme_choices_mobile[$f] = $f; - } - } - } + $theme_choices[$f] = $f; + $theme_choices_mobile[$f] = $f; + } + } + } /* Banner */ - $banner = get_config('system','banner'); + $banner = get_config('system', 'banner'); if($banner == false) $banner = 'red'; + $banner = htmlspecialchars($banner); - + /* Admin Info */ - $admininfo = get_config('system','admininfo'); + $admininfo = get_config('system', 'admininfo'); /* Register policy */ $register_choices = Array( REGISTER_CLOSED => t("No"), REGISTER_APPROVE => t("Yes - with approval"), REGISTER_OPEN => t("Yes") - ); + ); /* Acess policy */ $access_choices = Array( @@ -407,7 +427,7 @@ function admin_page_site(&$a) { ACCESS_FREE => t("My site has free access only"), ACCESS_TIERED => t("My site offers free accounts with optional paid upgrades") ); - + // $ssl_choices = array( // SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"), // SSL_POLICY_FULL => t("Force all links to use SSL") @@ -422,9 +442,9 @@ function admin_page_site(&$a) { '$upload' => t('File upload'), '$corporate' => t('Policies'), '$advanced' => t('Advanced'), - + '$baseurl' => $a->get_baseurl(true), - // name, label, value, help string, extra data... + // name, label, value, help string, extra data... '$sitename' => array('sitename', t("Site name"), htmlspecialchars(get_config('system','sitename'), ENT_QUOTES, 'UTF-8'),''), '$banner' => array('banner', t("Banner/Logo"), $banner, ""), '$admininfo' => array('admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. BBCode can be used here")), @@ -447,15 +467,14 @@ function admin_page_site(&$a) { '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")), '$disable_discover_tab' => array('disable_discover_tab', t("Disable discovery tab"), get_config('system','disable_discover_tab'), t("Remove the tab in the network view with public content pulled from sources chosen for this site.")), '$no_login_on_homepage' => array('no_login_on_homepage', t("No login on Homepage"), get_config('system','no_login_on_homepage'), t("Check to hide the login form from your sites homepage when visitors arrive who are not logged in (e.g. when you put the content of the homepage in via the site channel).")), - + '$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.")), '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), - '$form_security_token' => get_form_security_token("admin_site"), - + '$form_security_token' => get_form_security_token("admin_site"), )); } @@ -471,10 +490,10 @@ function admin_page_hubloc_post(&$a){ intval($hublocid) ); $hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post'; - + //perform ping $m = zot_build_packet($a->get_channel(),'ping'); - $r = zot_zot($hublocurl,$m); + $r = zot_zot($hublocurl,$m); //handle results and set the hubloc flags in db to make results visible $r2 = $r['body']; $r3 = $r2['success']; @@ -484,53 +503,44 @@ function admin_page_hubloc_post(&$a){ } else { //set HUBLOC_OFFLINE to 1 logger(' success = false ', LOGGER_DEBUG); - } - + //unfotunatly zping wont work, I guess return format is not correct - //require_once('mod/zping.php'); - //$r = zping_content($hublocurl); - //logger('zping answer: ' . $r, LOGGER_DEBUG); - + //require_once('mod/zping.php'); + //$r = zping_content($hublocurl); + //logger('zping answer: ' . $r, LOGGER_DEBUG); //in case of repair store new pub key for tested hubloc (all channel with this hubloc) in db //after repair set hubloc flags to 0 - } - goaway($a->get_baseurl(true) . '/admin/hubloc' ); - return; } function admin_page_hubloc(&$a) { - $o = ''; $hubloc = q("SELECT hubloc_id, hubloc_addr, hubloc_host, hubloc_status FROM hubloc"); - if(! $hubloc){ notice( t('No server found') . EOL); goaway($a->get_baseurl(true) . '/admin/hubloc'); } - $t = get_markup_template("admin_hubloc.tpl"); - return replace_macros($t, array( + $t = get_markup_template('admin_hubloc.tpl'); + return replace_macros($t, array( '$hubloc' => $hubloc, '$th_hubloc' => array(t('ID'), t('for channel'), t('on server'), t('Status')), - '$title' => t('Administration'), - '$page' => t('Server'), - '$queues' => $queues, - //'$accounts' => $accounts, /*$accounts is empty here*/ - '$pending' => Array( t('Pending registrations'), $pending), - '$plugins' => Array( t('Active plugins'), $a->plugins ), - '$form_security_token' => get_form_security_token("admin_hubloc") - )); - return $o; + '$title' => t('Administration'), + '$page' => t('Server'), + '$queues' => $queues, + //'$accounts' => $accounts, /*$accounts is empty here*/ + '$pending' => array( t('Pending registrations'), $pending), + '$plugins' => array( t('Active plugins'), $a->plugins ), + '$form_security_token' => get_form_security_token('admin_hubloc') + )); } function admin_page_dbsync(&$a) { - $o = ''; if(argc() > 3 && intval(argv(3)) && argv(2) === 'mark') { @@ -558,6 +568,7 @@ function admin_page_dbsync(&$a) { } else $o .= sprintf( t('Update function %s could not be found.'), $func); + return $o; } @@ -581,10 +592,9 @@ function admin_page_dbsync(&$a) { '$mark' => t('Mark success (if update was manually applied)'), '$apply' => t('Attempt to execute this update step automatically'), '$failed' => $failed - )); + )); return $o; - } function admin_page_queue($a) { @@ -604,7 +614,6 @@ function admin_page_queue($a) { } - $r = q("select count(outq_posturl) as total, outq_posturl from outq where outq_delivered = 0 group by outq_posturl order by total desc"); @@ -627,7 +636,6 @@ function admin_page_queue($a) { )); return $o; - } /** @@ -639,7 +647,7 @@ function admin_page_users_post(&$a){ $pending = ( x($_POST, 'pending') ? $_POST['pending'] : Array() ); $users = ( x($_POST, 'user') ? $_POST['user'] : Array() ); - check_form_security_token_redirectOnErr('/admin/users', 'admin_users'); + check_form_security_token_redirectOnErr('/admin/users', 'admin_users'); if (x($_POST,'page_users_block')){ foreach($users as $uid){ @@ -657,7 +665,7 @@ function admin_page_users_post(&$a){ } notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) ); } - + if (x($_POST,'page_users_approve')){ foreach($pending as $hash){ user_allow($hash); @@ -669,7 +677,6 @@ function admin_page_users_post(&$a){ } } goaway($a->get_baseurl(true) . '/admin/users' ); - return; // NOTREACHED } /** @@ -679,18 +686,18 @@ function admin_page_users_post(&$a){ function admin_page_users(&$a){ if (argc() > 2) { $uid = argv(3); - $account = q("SELECT * FROM account WHERE account_id = %d", + $account = q("SELECT * FROM account WHERE account_id = %d", intval($uid) ); if (! $account) { notice( t('Account not found') . EOL); goaway($a->get_baseurl(true) . '/admin/users' ); - } + } switch(argv(2)){ case "delete":{ - check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't'); + check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't'); // delete user require_once("include/Contact.php"); account_remove($uid,true,false); @@ -698,7 +705,7 @@ function admin_page_users(&$a){ notice( sprintf(t("User '%s' deleted"), $account[0]['account_email']) . EOL); }; break; case "block":{ - check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't'); + check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't'); q("UPDATE account SET account_flags = ( account_flags & ~%d ) where account_id = %d", intval(ACCOUNT_BLOCKED), intval( $uid ) @@ -708,15 +715,13 @@ function admin_page_users(&$a){ }; break; } goaway($a->get_baseurl(true) . '/admin/users' ); - return ''; // NOTREACHED - } - + /* get pending */ $pending = q("SELECT account.*, register.hash from account left join register on account_id = register.uid where (account_flags & %d )>0 ", intval(ACCOUNT_PENDING) - ); - + ); + /* get users */ $total = q("SELECT count(*) as total FROM account"); @@ -724,7 +729,7 @@ function admin_page_users(&$a){ $a->set_pager_total($total[0]['total']); $a->set_pager_itemspage(100); } - + // WEe'll still need to link email addresses to admin/users/channels or some such, but this bit doesn't exist yet. // That's where we need to be doing last post/channel flags/etc, not here. @@ -736,20 +741,20 @@ function admin_page_users(&$a){ $order = " order by account_email asc "; if($_REQUEST['order'] === 'expires') $order = " order by account_expires desc "; - if($_REQUEST['order'] === 'created') + if($_REQUEST['order'] === 'created') $order = " order by account_created desc "; - - $users =q("SELECT `account_id` , `account_email`, `account_lastlog`, `account_created`, `account_expires`, " . "`account_service_class`, ( account_flags & %d )>0 as `blocked`, " . + + $users = q("SELECT `account_id` , `account_email`, `account_lastlog`, `account_created`, `account_expires`, " . "`account_service_class`, ( account_flags & %d )>0 as `blocked`, " . "(SELECT %s FROM channel as ch " . "WHERE ch.channel_account_id = ac.account_id and not (ch.channel_pageflags & %d )>0) as `channels` " . "FROM account as ac where true $serviceclass $order limit %d offset %d ", intval(ACCOUNT_BLOCKED), db_concat('ch.channel_address', ' '), - intval(PAGE_REMOVED), + intval(PAGE_REMOVED), intval($a->pager['itemspage']), intval($a->pager['start']) ); - + // function _setup_users($e){ // $accounts = Array( // t('Normal Account'), @@ -765,8 +770,8 @@ function admin_page_users(&$a){ // return $e; // } // $users = array_map("_setup_users", $users); - - + + $t = get_markup_template("admin_users.tpl"); $o = replace_macros($t, array( // strings // @@ -789,7 +794,7 @@ function admin_page_users(&$a){ '$confirm_delete_multi' => t('Selected users will be deleted!\n\nEverything these users had posted on this site will be permanently deleted!\n\nAre you sure?'), '$confirm_delete' => t('The user {0} will be deleted!\n\nEverything this user has posted on this site will be permanently deleted!\n\nAre you sure?'), - '$form_security_token' => get_form_security_token("admin_users"), + '$form_security_token' => get_form_security_token("admin_users"), // values // '$baseurl' => $a->get_baseurl(true), @@ -798,6 +803,7 @@ function admin_page_users(&$a){ '$users' => $users, )); $o .= paginate($a); + return $o; } @@ -817,7 +823,7 @@ function admin_page_channels_post(&$a){ q("UPDATE channel SET channel_pageflags = ( channel_pageflags & ~%d ) where channel_id = %d", intval(PAGE_CENSORED), intval( $uid ) - ); + ); proc_run('php','include/directory.php',$uid,'nopush'); } notice( sprintf( tt("%s channel censored/uncensored", "%s channels censored/uncensored", count($channels)), count($channels)) ); @@ -831,7 +837,6 @@ function admin_page_channels_post(&$a){ } goaway($a->get_baseurl(true) . '/admin/channels' ); - return; // NOTREACHED } /** @@ -841,18 +846,18 @@ function admin_page_channels_post(&$a){ function admin_page_channels(&$a){ if (argc() > 2) { $uid = argv(3); - $channel = q("SELECT * FROM channel WHERE channel_id = %d", + $channel = q("SELECT * FROM channel WHERE channel_id = %d", intval($uid) ); if (! $channel) { notice( t('Channel not found') . EOL); goaway($a->get_baseurl(true) . '/admin/channels' ); - } + } - switch(argv(2)){ + switch(argv(2)) { case "delete":{ - check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't'); + check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't'); // delete channel require_once("include/Contact.php"); channel_remove($uid,true); @@ -872,10 +877,8 @@ function admin_page_channels(&$a){ }; break; } goaway($a->get_baseurl(true) . '/admin/channels' ); - return ''; // NOTREACHED - } - + /* get channels */ $total = q("SELECT count(*) as total FROM channel where not (channel_pageflags & %d)>0", @@ -885,7 +888,7 @@ function admin_page_channels(&$a){ $a->set_pager_total($total[0]['total']); $a->set_pager_itemspage(100); } - + $order = " order by channel_name asc "; $channels = q("SELECT * from channel where not ( channel_pageflags & %d )>0 $order limit %d offset %d ", @@ -893,7 +896,7 @@ function admin_page_channels(&$a){ intval($a->pager['itemspage']), intval($a->pager['start']) ); - + if($channels) { for($x = 0; $x < count($channels); $x ++) { if($channels[$x]['channel_pageflags'] & PAGE_CENSORED) @@ -902,7 +905,7 @@ function admin_page_channels(&$a){ $channels[$x]['blocked'] = false; } } - + $t = get_markup_template("admin_channels.tpl"); $o = replace_macros($t, array( // strings // @@ -920,13 +923,14 @@ function admin_page_channels(&$a){ '$confirm_delete_multi' => t('Selected channels will be deleted!\n\nEverything that was posted in these channels on this site will be permanently deleted!\n\nAre you sure?'), '$confirm_delete' => t('The channel {0} will be deleted!\n\nEverything that was posted in this channel on this site will be permanently deleted!\n\nAre you sure?'), - '$form_security_token' => get_form_security_token("admin_channels"), + '$form_security_token' => get_form_security_token("admin_channels"), // values // '$baseurl' => $a->get_baseurl(true), '$channels' => $channels, )); $o .= paginate($a); + return $o; } @@ -938,7 +942,7 @@ function admin_page_channels(&$a){ * @return string */ function admin_page_plugins(&$a){ - + /** * Single plugin */ @@ -948,9 +952,9 @@ function admin_page_plugins(&$a){ notice( t("Item not found.") ); return ''; } - + if (x($_GET,"a") && $_GET['a']=="t"){ - check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't'); + check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't'); // Toggle plugin status $idx = array_search($plugin, $a->plugins); @@ -965,27 +969,27 @@ function admin_page_plugins(&$a){ } set_config("system","addon", implode(", ",$a->plugins)); goaway($a->get_baseurl(true) . '/admin/plugins' ); - return ''; // NOTREACHED } // display plugin details require_once('library/markdown.php'); if (in_array($plugin, $a->plugins)){ - $status="on"; $action= t("Disable"); + $status = 'on'; + $action = t('Disable'); } else { - $status="off"; $action= t("Enable"); + $status = 'off'; + $action = t('Enable'); } - - $readme=Null; + + $readme = null; if (is_file("addon/$plugin/README.md")){ $readme = file_get_contents("addon/$plugin/README.md"); $readme = Markdown($readme); } else if (is_file("addon/$plugin/README")){ $readme = "
". file_get_contents("addon/$plugin/README") ."
"; - } - - $admin_form=""; + } + $admin_form = ''; if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){ @require_once("addon/$plugin/$plugin.php"); if(function_exists($plugin.'_plugin_admin')) { @@ -994,58 +998,55 @@ function admin_page_plugins(&$a){ } } - - $t = get_markup_template("admin_plugins_details.tpl"); + $t = get_markup_template('admin_plugins_details.tpl'); return replace_macros($t, array( '$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => $a->get_baseurl(true), - + '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => get_plugin_info($plugin), '$str_author' => t('Author: '), - '$str_maintainer' => t('Maintainer: '), - + '$str_maintainer' => t('Maintainer: '), + '$admin_form' => $admin_form, '$function' => 'plugins', '$screenshot' => '', '$readme' => $readme, - '$form_security_token' => get_form_security_token("admin_themes"), + '$form_security_token' => get_form_security_token('admin_plugins'), )); - } - - - + } + + /** * List plugins */ - $plugins = array(); - $files = glob("addon/*/"); + $files = glob('addon/*/'); if($files) { - foreach($files as $file) { + foreach($files as $file) { if (is_dir($file)){ - list($tmp, $id)=array_map("trim", explode("/",$file)); + list($tmp, $id) = array_map('trim', explode('/', $file)); $info = get_plugin_info($id); $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $info); } } } - - $t = get_markup_template("admin_plugins.tpl"); + + $t = get_markup_template('admin_plugins.tpl'); return replace_macros($t, array( '$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(true), - '$function' => 'plugins', + '$function' => 'plugins', '$plugins' => $plugins, - '$form_security_token' => get_form_security_token("admin_themes"), + '$form_security_token' => get_form_security_token('admin_plugins'), )); } @@ -1074,7 +1075,7 @@ function toggle_theme(&$themes,$th,&$result) { * @param string $th * @return int */ -function theme_status($themes,$th) { +function theme_status($themes, $th) { for($x = 0; $x < count($themes); $x ++) { if($themes[$x]['name'] === $th) { if($themes[$x]['allowed']) { @@ -1107,7 +1108,7 @@ function rebuild_theme_table($themes) { return $o; } - + /** * Themes admin page * @@ -1115,9 +1116,9 @@ function rebuild_theme_table($themes) { * @return string */ function admin_page_themes(&$a){ - - $allowed_themes_str = get_config('system','allowed_themes'); - $allowed_themes_raw = explode(',',$allowed_themes_str); + + $allowed_themes_str = get_config('system', 'allowed_themes'); + $allowed_themes_raw = explode(',', $allowed_themes_str); $allowed_themes = array(); if(count($allowed_themes_raw)) foreach($allowed_themes_raw as $x) @@ -1125,16 +1126,16 @@ function admin_page_themes(&$a){ $allowed_themes[] = trim($x); $themes = array(); - $files = glob('view/theme/*'); - if($files) { - foreach($files as $file) { - $f = basename($file); - $is_experimental = intval(file_exists($file . '/.experimental')); + $files = glob('view/theme/*'); + if($files) { + foreach($files as $file) { + $f = basename($file); + $is_experimental = intval(file_exists($file . '/.experimental')); $is_supported = 1-(intval(file_exists($file . '/.unsupported'))); // Is not used yet $is_allowed = intval(in_array($f,$allowed_themes)); $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed); - } - } + } + } if(! count($themes)) { notice( t('No themes found.')); @@ -1151,22 +1152,21 @@ function admin_page_themes(&$a){ notice( t("Item not found.") ); return ''; } - + if (x($_GET,"a") && $_GET['a']=="t"){ - check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't'); + check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't'); // Toggle theme status - toggle_theme($themes,$theme,$result); + toggle_theme($themes, $theme, $result); $s = rebuild_theme_table($themes); if($result) - info( sprintf('Theme %s enabled.',$theme)); + info( sprintf('Theme %s enabled.', $theme)); else - info( sprintf('Theme %s disabled.',$theme)); + info( sprintf('Theme %s disabled.', $theme)); - set_config('system','allowed_themes',$s); + set_config('system', 'allowed_themes', $s); goaway($a->get_baseurl(true) . '/admin/themes' ); - return ''; // NOTREACHED } // display theme details @@ -1177,30 +1177,28 @@ function admin_page_themes(&$a){ } else { $status="off"; $action= t("Enable"); } - + $readme=Null; if (is_file("view/theme/$theme/README.md")){ $readme = file_get_contents("view/theme/$theme/README.md"); $readme = Markdown($readme); } else if (is_file("view/theme/$theme/README")){ $readme = "
". file_get_contents("view/theme/$theme/README") ."
"; - } - - $admin_form=""; + } + + $admin_form = ''; if (is_file("view/theme/$theme/php/config.php")){ require_once("view/theme/$theme/php/config.php"); if(function_exists("theme_admin")){ $admin_form = theme_admin($a); } - } - $screenshot = array( get_theme_screenshot($theme), t('Screenshot')); if(! stristr($screenshot[0],$theme)) - $screenshot = null; + $screenshot = null; - $t = get_markup_template("admin_plugins_details.tpl"); + $t = get_markup_template('admin_plugins_details.tpl'); return replace_macros($t, array( '$title' => t('Administration'), '$page' => t('Themes'), @@ -1219,24 +1217,23 @@ function admin_page_themes(&$a){ '$screenshot' => $screenshot, '$readme' => $readme, - '$form_security_token' => get_form_security_token("admin_themes"), + '$form_security_token' => get_form_security_token('admin_themes'), )); - } - - - + } + + /** * List themes */ - + $xthemes = array(); if($themes) { foreach($themes as $th) { $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name'])); } } - - $t = get_markup_template("admin_plugins.tpl"); + + $t = get_markup_template('admin_plugins.tpl'); return replace_macros($t, array( '$title' => t('Administration'), '$page' => t('Themes'), @@ -1246,7 +1243,7 @@ function admin_page_themes(&$a){ '$plugins' => $xthemes, '$experimental' => t('[Experimental]'), '$unsupported' => t('[Unsupported]'), - '$form_security_token' => get_form_security_token("admin_themes"), + '$form_security_token' => get_form_security_token('admin_themes'), )); } @@ -1256,25 +1253,21 @@ function admin_page_themes(&$a){ * * @param App $a */ - function admin_page_logs_post(&$a) { - if (x($_POST,"page_logs")) { - check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs'); + if (x($_POST, 'page_logs')) { + check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs'); - $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : ''); - $debugging = ((x($_POST,'debugging')) ? true : false); - $loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0); + $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : ''); + $debugging = ((x($_POST,'debugging')) ? true : false); + $loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0); set_config('system','logfile', $logfile); set_config('system','debugging', $debugging); set_config('system','loglevel', $loglevel); - - } - info( t("Log settings updated.") ); + info( t('Log settings updated.') ); goaway($a->get_baseurl(true) . '/admin/logs' ); - return; // NOTREACHED } /** @@ -1282,7 +1275,7 @@ function admin_page_logs_post(&$a) { * @return string */ function admin_page_logs(&$a){ - + $log_choices = Array( LOGGER_NORMAL => 'Normal', LOGGER_TRACE => 'Trace', @@ -1290,10 +1283,10 @@ function admin_page_logs(&$a){ LOGGER_DATA => 'Data', LOGGER_ALL => 'All' ); - - $t = get_markup_template("admin_logs.tpl"); - $f = get_config('system','logfile'); + $t = get_markup_template('admin_logs.tpl'); + + $f = get_config('system', 'logfile'); $data = ''; @@ -1322,7 +1315,7 @@ readable."); } fclose($fp); } - } + } return replace_macros($t, array( '$title' => t('Administration'), @@ -1332,13 +1325,13 @@ readable."); '$data' => $data, '$baseurl' => $a->get_baseurl(true), '$logname' => get_config('system','logfile'), - - // name, label, value, help string, extra data... - '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""), - '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Red top-level directory.")), - '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices), - '$form_security_token' => get_form_security_token("admin_logs"), + // name, label, value, help string, extra data... + '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""), + '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Red top-level directory.")), + '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices), + + '$form_security_token' => get_form_security_token('admin_logs'), )); } @@ -1367,7 +1360,6 @@ function admin_page_profs_post(&$a) { // add to chosen array basic or advanced goaway(z_root() . '/admin/profs'); - } function admin_page_profs(&$a) { @@ -1390,7 +1382,6 @@ function admin_page_profs(&$a) { '$field_help' => array('field_help',t('Help text'),$_REQUEST['field_help'],t('Additional info (optional)')), '$submit' => t('Save') )); - } if((argc() > 2) && intval(argv(2))) { @@ -1413,9 +1404,4 @@ function admin_page_profs(&$a) { )); } -} - - - - - +} \ No newline at end of file -- cgit v1.2.3 From c6d45858bb73c0f3765fcc7257ed1347d6de1577 Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sun, 8 Mar 2015 19:02:48 +0100 Subject: Fixing (un)blocking accounts in /admin/users. When I look at the instructions in sql_conventions about setting bit flags I don't understand how this could have worked before. Changed the behavior for (un)blocking so that it should work now. --- mod/admin.php | 95 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 34 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index f461474c4..714548f04 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -197,7 +197,7 @@ function admin_page_summary(&$a) { ); if ($r) { $accounts['total'] = array('label' => t('# Accounts'), 'val' => $r[0]['total']); - //@todo $accounts['blocked'] = array('label' => t('# blocked accounts'), 'val' => $r[0]['blocked']); + $accounts['blocked'] = array('label' => t('# blocked accounts'), 'val' => $r[0]['blocked']); $accounts['expired'] = array('label' => t('# expired accounts'), 'val' => $r[0]['expired']); $accounts['expiring'] = array('label' => t('# expiring accounts'), 'val' => $r[0]['expiring']); } @@ -639,48 +639,66 @@ function admin_page_queue($a) { } /** - * Users admin page + * @brief Handle POST actions on users admin page. + * + * This function is called when on the admin user/account page the form was + * submitted to handle multiple operations at once. If one of the icons next + * to an entry are pressed the function admin_page_users() will handle this. * * @param App $a */ -function admin_page_users_post(&$a){ - $pending = ( x($_POST, 'pending') ? $_POST['pending'] : Array() ); - $users = ( x($_POST, 'user') ? $_POST['user'] : Array() ); +function admin_page_users_post($a) { + $pending = ( x($_POST, 'pending') ? $_POST['pending'] : array() ); + $users = ( x($_POST, 'user') ? $_POST['user'] : array() ); + $blocked = ( x($_POST, 'blocked') ? $_POST['blocked'] : array() ); check_form_security_token_redirectOnErr('/admin/users', 'admin_users'); - if (x($_POST,'page_users_block')){ - foreach($users as $uid){ - q("UPDATE account SET account_flags = (account_flags & %d) where account_id = %d", + // change to switch structure? + // account block/unblock button was submitted + if (x($_POST, 'page_users_block')) { + for ($i = 0; $i < count($users); $i++) { + // if account is blocked remove blocked bit-flag, otherwise add blocked bit-flag + $op = ($blocked[$i]) ? '& ~' : '| '; + q("UPDATE account SET account_flags = (account_flags $op%d) WHERE account_id = %d", intval(ACCOUNT_BLOCKED), - intval( $uid ) + intval($users[$i]) ); } notice( sprintf( tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)) ); } - if (x($_POST,'page_users_delete')){ - require_once("include/Contact.php"); - foreach($users as $uid){ - account_remove($uid,true,false); + // account delete button was submitted + if (x($_POST, 'page_users_delete')) { + require_once('include/Contact.php'); + foreach ($users as $uid){ + account_remove($uid, true, false); } notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) ); } - - if (x($_POST,'page_users_approve')){ - foreach($pending as $hash){ + // registration approved button was submitted + if (x($_POST, 'page_users_approve')) { + foreach ($pending as $hash) { user_allow($hash); } } - if (x($_POST,'page_users_deny')){ - foreach($pending as $hash){ + // registration deny button was submitted + if (x($_POST, 'page_users_deny')) { + foreach ($pending as $hash) { user_deny($hash); } } + goaway($a->get_baseurl(true) . '/admin/users' ); } /** - * @param App $a + * @brief Generate users admin page and handle single item operations. + * + * This function generates the users/account admin page and handles the actions + * if an icon next to an entry was clicked. If several items were selected and + * the form was submitted it is handled by the function admin_page_users_post(). + * + * @param App &$a * @return string */ function admin_page_users(&$a){ @@ -695,25 +713,34 @@ function admin_page_users(&$a){ goaway($a->get_baseurl(true) . '/admin/users' ); } - switch(argv(2)){ - case "delete":{ - check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't'); + check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't'); + + switch (argv(2)){ + case 'delete': // delete user - require_once("include/Contact.php"); + require_once('include/Contact.php'); account_remove($uid,true,false); - + notice( sprintf(t("User '%s' deleted"), $account[0]['account_email']) . EOL); - }; break; - case "block":{ - check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't'); - q("UPDATE account SET account_flags = ( account_flags & ~%d ) where account_id = %d", + break; + case 'block': + q("UPDATE account SET account_flags = ( account_flags | %d ) WHERE account_id = %d", intval(ACCOUNT_BLOCKED), - intval( $uid ) + intval($uid) ); - notice( sprintf( (($account[0]['account_flags'] & ACCOUNT_BLOCKED) ? t("User '%s' unblocked"):t("User '%s' blocked")) , $account[0]['account_email']) . EOL); - }; break; + notice( sprintf( t("User '%s' blocked") , $account[0]['account_email']) . EOL); + break; + case 'unblock': + q("UPDATE account SET account_flags = ( account_flags & ~%d ) WHERE account_id = %d", + intval(ACCOUNT_BLOCKED), + intval($uid) + ); + + notice( sprintf( t("User '%s' unblocked"), $account[0]['account_email']) . EOL); + break; } + goaway($a->get_baseurl(true) . '/admin/users' ); } @@ -725,7 +752,7 @@ function admin_page_users(&$a){ /* get users */ $total = q("SELECT count(*) as total FROM account"); - if(count($total)) { + if (count($total)) { $a->set_pager_total($total[0]['total']); $a->set_pager_itemspage(100); } @@ -772,7 +799,7 @@ function admin_page_users(&$a){ // $users = array_map("_setup_users", $users); - $t = get_markup_template("admin_users.tpl"); + $t = get_markup_template('admin_users.tpl'); $o = replace_macros($t, array( // strings // '$title' => t('Administration'), @@ -813,7 +840,7 @@ function admin_page_users(&$a){ * * @param App $a */ -function admin_page_channels_post(&$a){ +function admin_page_channels_post(&$a) { $channels = ( x($_POST, 'channel') ? $_POST['channel'] : Array() ); check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels'); -- cgit v1.2.3 From aff75888326e8f3ff2b9fbb91d653c7857940e6b Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Mar 2015 00:44:58 -0700 Subject: fix comanche regions after comanche refactor a few days ago --- mod/page.php | 1 + 1 file changed, 1 insertion(+) (limited to 'mod') diff --git a/mod/page.php b/mod/page.php index e8f17ebda..05d88aa52 100644 --- a/mod/page.php +++ b/mod/page.php @@ -92,6 +92,7 @@ function page_init(&$a) { if($l) { require_once('include/comanche.php'); comanche_parser(get_app(),$l[0]['body']); + get_app()->pdl = $l[0]['body']; } } -- cgit v1.2.3 From e7d32442762dfda9a65468fb448fcd7e4ec5566a Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Mar 2015 15:16:52 -0700 Subject: Allow site to over-ride directory options. Bugger off. --- mod/directory.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index 17a1776fe..d186a778d 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -48,21 +48,10 @@ function directory_content(&$a) { return; } - $safe_mode = 1; - $observer = get_observer_hash(); - if($observer) - $globaldir = get_xconfig($observer,'directory','globaldir'); - else - $globaldir = ((array_key_exists('globaldir',$_SESSION)) ? intval($_SESSION['globaldir']) : false); - - if($observer) - $safe_mode = get_xconfig($observer,'directory','safe_mode'); - else - $safe_mode = ((array_key_exists('safemode',$_SESSION)) ? intval($_SESSION['safemode']) : false); - if($safe_mode === false) - $safe_mode = 1; + $globaldir = get_globaldir_setting($observer); + $safe_mode = get_safemode_setting($observer); $pubforums = null; if(array_key_exists('pubforums',$_REQUEST)) -- cgit v1.2.3 From 16bcca6aab0267fb36ad95ca0ee5d1bd14e0ec37 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Mar 2015 15:24:05 -0700 Subject: up the count of directory tags --- mod/directory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index d186a778d..274584862 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -131,7 +131,7 @@ function directory_content(&$a) { $numtags = get_config('system','directorytags'); - $kw = ((intval($numtags)) ? $numtags : 24); + $kw = ((intval($numtags)) ? $numtags : 50); $query = $url . '?f=&kw=' . $kw . (($safe_mode != 1) ? '&safe=' . $safe_mode : ''); if($token) -- cgit v1.2.3 From 26a414fe4b3ab4b1d995233f0402532ad41eaeb7 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Mar 2015 16:25:55 -0700 Subject: make network page default options work more or less universally instead of just from the navbar, and fix some saved-search weirdness related to the delete-term icon --- mod/network.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index 944c3c1d1..161b06804 100644 --- a/mod/network.php +++ b/mod/network.php @@ -13,6 +13,12 @@ function network_init(&$a) { return; } + if(count($_GET) < 2) { + $network_options = get_pconfig(local_channel(),'system','network_page_default'); + if($network_options) + goaway('network' . '?f=&' . $network_options); + } + $channel = $a->get_channel(); $a->profile_uid = local_channel(); head_set_icon($channel['xchan_photo_s']); @@ -369,10 +375,13 @@ function network_content(&$a, $update = 0, $load = false) { // "New Item View" - show all items unthreaded in reverse created date order $items = q("SELECT item.*, item.id AS item_id, received FROM item + left join abook on item.author_xchan = abook.abook_xchan WHERE true $uids AND item_restrict = 0 + and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $simple_update $sql_extra $sql_nets - ORDER BY item.received DESC $pager_sql " + ORDER BY item.received DESC $pager_sql ", + intval(ABOOK_FLAG_BLOCKED) ); require_once('include/items.php'); -- cgit v1.2.3 From a611eed172cdec63f8007e74583178d12a9335ec Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Mon, 9 Mar 2015 17:54:14 -0700 Subject: Whoops... should've actually checked the pg manual before merging #920 :-) replace if(cond,val,val) with case when cond then val else val end, works on both DBs --- mod/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 714548f04..8fb9866a7 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -189,7 +189,7 @@ function admin_page_summary(&$a) { // list total user accounts, expirations etc. $accounts = array(); - $r = q("SELECT COUNT(*) AS total, COUNT(IF(account_expires > %s, 1, NULL)) AS expiring, COUNT(IF(account_expires < %s AND account_expires != '%s', 1, NULL)) AS expired, COUNT(IF((account_flags & %d)>0, 1, NULL)) AS blocked FROM account", + $r = q("SELECT COUNT(*) AS total, COUNT(CASE WHEN account_expires > %s THEN 1 ELSE NULL END) AS expiring, COUNT(CASE WHEN account_expires < %s AND account_expires != '%s' THEN 1 ELSE NULL END) AS expired, COUNT(CASE WHEN (account_flags & %d)>0 THEN 1 ELSE NULL END) AS blocked FROM account", db_utcnow(), db_utcnow(), dbesc(NULL_DATE), @@ -208,7 +208,7 @@ function admin_page_summary(&$a) { // available channels, primary and clones $channels = array(); - $r = q("SELECT COUNT(*) AS total, COUNT(IF(channel_primary = 1, 1, NULL)) AS main, COUNT(IF(channel_primary = 0, 1, NULL)) AS clones FROM channel WHERE NOT (channel_pageflags & %d)>0", + $r = q("SELECT COUNT(*) AS total, COUNT(CASE WHEN channel_primary = 1 THEN 1 ELSE NULL END) AS main, COUNT(CASE WHEN channel_primary = 0 THEN 1 ELSE NULL END) AS clones FROM channel WHERE NOT (channel_pageflags & %d)>0", intval(PAGE_REMOVED) ); if ($r) { -- cgit v1.2.3 From 0134a41015dd79092cb6a42ad0f7122d0af9bc6d Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Mar 2015 19:57:35 -0700 Subject: more work on queue optimisations --- mod/admin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 8fb9866a7..daab6c9f3 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -614,7 +614,7 @@ function admin_page_queue($a) { } - $r = q("select count(outq_posturl) as total, outq_posturl from outq + $r = q("select count(outq_posturl) as total, max(outq_priority) as priority, outq_posturl from outq where outq_delivered = 0 group by outq_posturl order by total desc"); for($x = 0; $x < count($r); $x ++) { @@ -626,6 +626,7 @@ function admin_page_queue($a) { $o = replace_macros(get_markup_template('admin_queue.tpl'), array( '$banner' => t('Queue Statistics'), '$numentries' => t('Total Entries'), + '$priority' => t('Priority'), '$desturl' => t('Destination URL'), '$nukehub' => t('Mark hub permanently offline'), '$empty' => t('Empty queue for this hub'), -- cgit v1.2.3 From 98dffd77efbad934a26fb4abee9b3e42eeb7b6d2 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Mar 2015 02:23:14 -0700 Subject: channel delegation --- mod/admin.php | 5 +++-- mod/magic.php | 29 +++++++++++++++++++++++++++-- mod/manage.php | 25 ++++++++++++++++++++++--- mod/post.php | 52 ++++++++++++++++++++++++++++++++++++++++------------ mod/settings.php | 12 +++++++++--- 5 files changed, 101 insertions(+), 22 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index daab6c9f3..5d8faf424 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -13,7 +13,7 @@ function admin_post(&$a){ logger('admin_post', LOGGER_DEBUG); - if(!is_site_admin()) { + if((!is_site_admin()) || ($_SESSION['delegate'])) { return; } @@ -79,7 +79,8 @@ function admin_post(&$a){ function admin_content(&$a) { logger('admin_content', LOGGER_DEBUG); - if(!is_site_admin()) { + + if((!is_site_admin()) || ($_SESSION['delegate'])) { return login(false); } diff --git a/mod/magic.php b/mod/magic.php index c31fa71ae..df8ac39a8 100644 --- a/mod/magic.php +++ b/mod/magic.php @@ -10,11 +10,10 @@ function magic_init(&$a) { logger('mod_magic: args: ' . print_r($_REQUEST,true),LOGGER_DATA); $addr = ((x($_REQUEST,'addr')) ? $_REQUEST['addr'] : ''); - $hash = ((x($_REQUEST,'hash')) ? $_REQUEST['hash'] : ''); $dest = ((x($_REQUEST,'dest')) ? $_REQUEST['dest'] : ''); $test = ((x($_REQUEST,'test')) ? intval($_REQUEST['test']) : 0); $rev = ((x($_REQUEST,'rev')) ? intval($_REQUEST['rev']) : 0); - + $delegate = ((x($_REQUEST,'delegate')) ? $_REQUEST['delegate'] : ''); $parsed = parse_url($dest); if(! $parsed) { @@ -100,6 +99,29 @@ function magic_init(&$a) { $ret['message'] .= 'Local site - you are already authenticated.' . EOL; return $ret; } + + $delegation_success = false; + if($delegate) { + $r = q("select * from channel left join hubloc on channel_hash = hubloc_hash where hubloc_addr = '%s' limit 1", + dbesc($delegate) + ); + if($r && intval($r[0]['channel_id'])) { + $allowed = perm_is_allowed($r[0]['channel_id'],get_observer_hash(),'delegate'); + if($allowed) { + $_SESSION['delegate_channel'] = $r[0]['channel_id']; + $_SESSION['delegate'] = get_observer_hash(); + $_SESSION['account_id'] = intval($r[0]['channel_account_id']); + change_channel($r[0]['channel_id']); + $delegation_success = true; + } + } + } + + + + // FIXME: check and honour local delegation + + goaway($dest); } @@ -123,6 +145,9 @@ function magic_init(&$a) { $target_url = $x[0]['hubloc_callback'] . '/?f=&auth=' . urlencode($channel['channel_address'] . '@' . $a->get_hostname()) . '&sec=' . $token . '&dest=' . urlencode($dest) . '&version=' . ZOT_REVISION; + if($delegate) + $target_url .= '&delegate=' . urlencode($delegate); + logger('mod_magic: redirecting to: ' . $target_url, LOGGER_DEBUG); if($test) { diff --git a/mod/manage.php b/mod/manage.php index cb46a1b76..54a65dbbf 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -2,7 +2,7 @@ function manage_content(&$a) { - if(! get_account_id()) { + if((! get_account_id()) || ($_SESSION['delegate'])) { notice( t('Permission denied.') . EOL); return; } @@ -144,6 +144,22 @@ function manage_content(&$a) { array( 'new_channel', t('Create a new channel'), t('Create a new channel')) ); + $delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where + abook_channel = %d and (abook_their_perms & %d) > 0", + intval(local_channel()), + intval(PERMS_A_DELEGATE) + ); + if(! $delegates) + $delegates = null; + + if($delegates) { + for($x = 0; $x < count($delegates); $x ++) { + $delegates[$x]['link'] = 'magic?f=&dest=' . urlencode($delegates[$x]['xchan_url']) . '&delegate=' . urlencode($delegates[$x]['xchan_addr']); + } + } + + + $o = replace_macros(get_markup_template('channels.tpl'), array( '$header' => t('Channel Manager'), '$msg_selected' => t('Current Channel'), @@ -153,9 +169,12 @@ function manage_content(&$a) { '$msg_make_default' => t('Make Default'), '$links' => $links, '$all_channels' => $channels, - '$mail_format' => t('%d new messages'), - '$intros_format' => t('%d new introductions'), + '$mail_format' => t('%d new messages'), + '$intros_format' => t('%d new introductions'), '$channel_usage_message' => $channel_usage_message, + '$delegate_header' => t('Delegated Channels'), + '$delegates' => $delegates, + )); diff --git a/mod/post.php b/mod/post.php index 6e35632da..2fcc74963 100644 --- a/mod/post.php +++ b/mod/post.php @@ -30,6 +30,7 @@ function post_init(&$a) { ** dest => the desired destination URL (urlencoded) ** sec => a random string which is also stored on $mysite for use during the verification phase. ** version => the zot revision + ** delegate => optional urlencoded webbie of a local channel to invoke delegation rights for * * When this packet is received, an "auth-check" zot message is sent to $mysite. * (e.g. if $_GET['auth'] is foobar@podunk.edu, a zot packet is sent to the podunk.edu zot endpoint, which is typically /post) @@ -88,10 +89,12 @@ function post_init(&$a) { $ret = array('success' => false, 'message' => ''); logger('mod_zot: auth request received.'); - $address = $_REQUEST['auth']; - $desturl = $_REQUEST['dest']; - $sec = $_REQUEST['sec']; - $version = $_REQUEST['version']; + $address = $_REQUEST['auth']; + $desturl = $_REQUEST['dest']; + $sec = $_REQUEST['sec']; + $version = $_REQUEST['version']; + $delegate = $_REQUEST['delegate']; + $test = ((x($_REQUEST,'test')) ? intval($_REQUEST['test']) : 0); // They are authenticating ultimately to the site and not to a particular channel. @@ -158,6 +161,8 @@ function post_init(&$a) { // Also check that they are coming from the same site as they authenticated with originally. $already_authed = ((($remote) && ($x[0]['hubloc_hash'] == $remote) && ($x[0]['hubloc_url'] === $_SESSION['remote_hub'])) ? true : false); + if($delegate && $delegate !== $_SESSION['delegate_channel']) + $already_authed = false; $j = array(); @@ -235,6 +240,8 @@ function post_init(&$a) { } goaway($desturl); } + + // log them in if($test) { @@ -243,16 +250,37 @@ function post_init(&$a) { json_return_and_die($ret); } + $delegation_success = false; + if($delegate) { + $r = q("select * from channel left join xchan on channel_hash = xchan_hash where xchan_addr = '%s' limit 1", + dbesc($delegate) + ); + if($r && intval($r[0]['channel_id'])) { + $allowed = perm_is_allowed($r[0]['channel_id'],$x[0]['xchan_hash'],'delegate'); + if($allowed) { + $_SESSION['delegate_channel'] = $r[0]['channel_id']; + $_SESSION['delegate'] = $x[0]['xchan_hash']; + $_SESSION['account_id'] = intval($r[0]['channel_account_id']); + change_channel($r[0]['channel_id']); + $delegation_success = true; + } + } + } + + + $_SESSION['authenticated'] = 1; - $_SESSION['visitor_id'] = $x[0]['xchan_hash']; - $_SESSION['my_url'] = $x[0]['xchan_url']; - $_SESSION['my_address'] = $address; - $_SESSION['remote_service_class'] = $remote_service_class; - $_SESSION['remote_level'] = $remote_level; - $_SESSION['remote_hub'] = $remote_hub; - $_SESSION['DNT'] = $DNT; - + if(! $delegation_success) { + $_SESSION['visitor_id'] = $x[0]['xchan_hash']; + $_SESSION['my_url'] = $x[0]['xchan_url']; + $_SESSION['my_address'] = $address; + $_SESSION['remote_service_class'] = $remote_service_class; + $_SESSION['remote_level'] = $remote_level; + $_SESSION['remote_hub'] = $remote_hub; + $_SESSION['DNT'] = $DNT; + } + $arr = array('xchan' => $x[0], 'url' => $desturl, 'session' => $_SESSION); call_hooks('magic_auth_success',$arr); $a->set_observer($x[0]); diff --git a/mod/settings.php b/mod/settings.php index 595878543..afc05f095 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -19,6 +19,9 @@ function settings_init(&$a) { if(! local_channel()) return; + if($_SESSION['delegate']) + return; + $a->profile_uid = local_channel(); // default is channel settings in the absence of other arguments @@ -39,6 +42,9 @@ function settings_post(&$a) { if(! local_channel()) return; + if($_SESSION['delegate']) + return; + $channel = $a->get_channel(); logger('mod_settings: ' . print_r($_REQUEST,true)); @@ -550,14 +556,14 @@ function settings_post(&$a) { } -if(! function_exists('settings_content')) { + function settings_content(&$a) { $o = ''; nav_set_selected('settings'); - if(! local_channel()) { + if((! local_channel()) || ($_SESSION['delegate'])) { notice( t('Permission denied.') . EOL ); return login(); } @@ -1137,5 +1143,5 @@ function settings_content(&$a) { return $o; } -}} +} -- cgit v1.2.3 From 346654778485416b8643981eae53b9dbd64e084d Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Mar 2015 02:27:10 -0700 Subject: missing include --- mod/post.php | 1 + 1 file changed, 1 insertion(+) (limited to 'mod') diff --git a/mod/post.php b/mod/post.php index 2fcc74963..31b688221 100644 --- a/mod/post.php +++ b/mod/post.php @@ -261,6 +261,7 @@ function post_init(&$a) { $_SESSION['delegate_channel'] = $r[0]['channel_id']; $_SESSION['delegate'] = $x[0]['xchan_hash']; $_SESSION['account_id'] = intval($r[0]['channel_account_id']); + require_once('include/security.php'); change_channel($r[0]['channel_id']); $delegation_success = true; } -- cgit v1.2.3 From 5b35f1e6c4fbf0fd941c6d292b9c9b5847b64d0b Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Mar 2015 15:43:15 -0700 Subject: Change logic of "don't create a status post for this photo upload" and turn it into a bona-fide on/off toggle. This takes up one more vertical line, but we have it to spare, and the single button (while concise visually) provided no feedback of the current state, or indicate whether a second click toggled it. Some addons use this setting so addons will need to be pulled when this is pulled in order to remain in sync. --- mod/photos.php | 2 +- mod/wall_upload.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/photos.php b/mod/photos.php index 297790f6e..58a38f3f3 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -553,7 +553,7 @@ function photos_content(&$a) { '$nickname' => $a->data['channel']['channel_address'], '$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'), + '$visible' => array('visible', t('Create a status post for this upload'),0,''), '$albums' => $albums['albums'], '$selname' => $selname, '$permissions' => t('Permissions'), diff --git a/mod/wall_upload.php b/mod/wall_upload.php index 81ca643df..31a497f0f 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -32,7 +32,7 @@ function wall_upload_post(&$a) { $observer = $a->get_observer(); - $args = array( 'source' => 'editor', 'not_visible' => 1, 'contact_allow' => array($channel['channel_hash'])); + $args = array( 'source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash'])); $ret = photo_upload($channel,$observer,$args); -- cgit v1.2.3 From 9d1df58759b4eff9439c12d081ba5e1264f900a3 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Mar 2015 18:55:56 -0700 Subject: sql optimisation for affinity searches. A new index was added which wasn't added retro-actively to existing DBs as an update. It isn't clear if this helps sites any more than just restricting the abook table to certain channel_id's is (and this field is already indexed). --- mod/network.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index 161b06804..d24d665d8 100644 --- a/mod/network.php +++ b/mod/network.php @@ -342,9 +342,11 @@ function network_content(&$a, $update = 0, $load = false) { $sys = get_sys_channel(); $uids = " and item.uid = " . intval($sys['channel_id']) . " "; $a->data['firehose'] = intval($sys['channel_id']); + $abook_uids = ""; } else { $uids = " and item.uid = " . local_channel() . " "; + $abook_uids = " and abook.abook_channel = " . local_channel() . " "; } if(get_pconfig(local_channel(),'system','network_list_mode')) @@ -376,7 +378,7 @@ function network_content(&$a, $update = 0, $load = false) { $items = q("SELECT item.*, item.id AS item_id, received FROM item left join abook on item.author_xchan = abook.abook_xchan - WHERE true $uids AND item_restrict = 0 + WHERE true $uids $abook_uids AND item_restrict = 0 and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $simple_update $sql_extra $sql_nets @@ -407,7 +409,7 @@ function network_content(&$a, $update = 0, $load = false) { $r = q("SELECT distinct item.id AS item_id, $ordering FROM item left join abook on item.author_xchan = abook.abook_xchan - WHERE true $uids AND item.item_restrict = 0 + WHERE true $uids $abook_uids AND item.item_restrict = 0 AND item.parent = item.id and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets @@ -421,7 +423,7 @@ function network_content(&$a, $update = 0, $load = false) { // update $r = q("SELECT item.parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan - WHERE true $uids AND item.item_restrict = 0 $simple_update + WHERE true $uids $abook_uids AND item.item_restrict = 0 $simple_update and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets ", intval(ABOOK_FLAG_BLOCKED) -- cgit v1.2.3 From 844b2ae5873ea2e53bf284abe39ad7a19fe27256 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Mar 2015 20:19:17 -0700 Subject: cleanup of old delegation stuff --- mod/admin.php | 4 +- mod/delegate.php | 139 -------------------------------------------------- mod/regmod.php | 2 +- mod/removeaccount.php | 2 +- mod/removeme.php | 2 +- mod/settings.php | 8 --- 6 files changed, 5 insertions(+), 152 deletions(-) delete mode 100644 mod/delegate.php (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 5d8faf424..e991fee27 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -13,7 +13,7 @@ function admin_post(&$a){ logger('admin_post', LOGGER_DEBUG); - if((!is_site_admin()) || ($_SESSION['delegate'])) { + if(! is_site_admin()) { return; } @@ -80,7 +80,7 @@ function admin_content(&$a) { logger('admin_content', LOGGER_DEBUG); - if((!is_site_admin()) || ($_SESSION['delegate'])) { + if(! is_site_admin()) { return login(false); } diff --git a/mod/delegate.php b/mod/delegate.php deleted file mode 100644 index cc399b6e5..000000000 --- a/mod/delegate.php +++ /dev/null @@ -1,139 +0,0 @@ -argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) { - - // delegated admins can view but not change delegation permissions - - if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) - goaway($a->get_baseurl() . '/delegate'); - - - $id = $a->argv[2]; - - $r = q("select `nickname` from user where uid = %d limit 1", - intval($id) - ); - if(count($r)) { - $r = q("select id from contact where uid = %d and nurl = '%s' limit 1", - intval(local_channel()), - dbesc(normalise_link($a->get_baseurl() . '/channel/' . $r[0]['nickname'])) - ); - if(count($r)) { - q("insert into manage ( uid, mid ) values ( %d , %d ) ", - intval($a->argv[2]), - intval(local_channel()) - ); - } - } - goaway($a->get_baseurl() . '/delegate'); - } - - if($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) { - - // delegated admins can view but not change delegation permissions - - if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) - goaway($a->get_baseurl() . '/delegate'); - - q("delete from manage where uid = %d and mid = %d", - intval($a->argv[2]), - intval(local_channel()) - ); - goaway($a->get_baseurl() . '/delegate'); - - } - - $full_managers = array(); - - // These people can manage this account/page with full privilege - - $r = q("SELECT * FROM `user` WHERE `email` = '%s' AND `password` = '%s' ", - dbesc($a->user['email']), - dbesc($a->user['password']) - ); - if(count($r)) - $full_managers = $r; - - $delegates = array(); - - // find everybody that currently has delegated management to this account/page - - $r = q("select * from user where uid in ( select uid from manage where mid = %d ) ", - intval(local_channel()) - ); - - if(count($r)) - $delegates = $r; - - $uids = array(); - - if(count($full_managers)) - foreach($full_managers as $rr) - $uids[] = $rr['uid']; - - if(count($delegates)) - foreach($delegates as $rr) - $uids[] = $rr['uid']; - - // find every contact who might be a candidate for delegation - - $r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s' - and contact.uid = %d and contact.self = 0 and network = '%s' ", - dbesc(normalise_link($a->get_baseurl())), - intval(local_channel()), - dbesc(NETWORK_DFRN) - ); - - if(! count($r)) { - notice( t('No potential page delegates located.') . EOL); - return; - } - - $nicknames = array(); - - if(count($r)) { - foreach($r as $rr) { - $nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'"; - } - } - - $potentials = array(); - - $nicks = implode(',',$nicknames); - - // get user records for all potential page delegates who are not already delegates or managers - - $r = q("select `uid`, `username`, `nickname` from user where nickname in ( $nicks )"); - - if(count($r)) - foreach($r as $rr) - if(! in_array($rr['uid'],$uids)) - $potentials[] = $rr; - - $o = replace_macros(get_markup_template('delegate.tpl'),array( - '$header' => t('Delegate Page Management'), - '$base' => $a->get_baseurl(), - '$desc' => t('Delegates are able to manage all aspects of this account/page except for basic account settings. Please do not delegate your personal account to anybody that you do not trust completely.'), - '$head_managers' => t('Existing Page Managers'), - '$managers' => $full_managers, - '$head_delegates' => t('Existing Page Delegates'), - '$delegates' => $delegates, - '$head_potentials' => t('Potential Delegates'), - '$potentials' => $potentials, - '$remove' => t('Remove'), - '$add' => t('Add'), - '$none' => t('No entries.') - )); - - - return $o; - - -} \ No newline at end of file diff --git a/mod/regmod.php b/mod/regmod.php index bdb794347..c0a75ef48 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -13,7 +13,7 @@ function regmod_content(&$a) { return $o; } - if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) { + if(! is_site_admin()) { notice( t('Permission denied.') . EOL); return ''; } diff --git a/mod/removeaccount.php b/mod/removeaccount.php index 70979ec15..f3fa53f75 100644 --- a/mod/removeaccount.php +++ b/mod/removeaccount.php @@ -5,7 +5,7 @@ function removeaccount_post(&$a) { if(! local_channel()) return; - if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) + if($_SESSION['delegate']) return; if((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password'])))) diff --git a/mod/removeme.php b/mod/removeme.php index ff955775a..b604bc7db 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -5,7 +5,7 @@ function removeme_post(&$a) { if(! local_channel()) return; - if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) + if($_SESSION['delegate']) return; if((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password'])))) diff --git a/mod/settings.php b/mod/settings.php index afc05f095..8752a47b2 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -49,9 +49,6 @@ function settings_post(&$a) { logger('mod_settings: ' . print_r($_REQUEST,true)); - if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) - return; - if((argc() > 1) && (argv(1) === 'oauth') && x($_POST,'remove')){ check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth'); @@ -573,11 +570,6 @@ function settings_content(&$a) { if($channel) head_set_icon($channel['xchan_photo_s']); -// if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) { -// notice( t('Permission denied.') . EOL ); -// return; -// } - $yes_no = array(t('No'),t('Yes')); if((argc() > 1) && (argv(1) === 'oauth')) { -- cgit v1.2.3 From bfd123c59a61be1d667648263aa44c4a9e14a5fc Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 11 Mar 2015 01:03:14 -0700 Subject: openid server --- mod/id.php | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 mod/id.php (limited to 'mod') diff --git a/mod/id.php b/mod/id.php new file mode 100644 index 000000000..852c73163 --- /dev/null +++ b/mod/id.php @@ -0,0 +1,237 @@ +dh = false; + * However, the latter one would disable stateful mode, unless connecting via HTTPS. + */ +require 'library/openid/provider/provider.php'; + + +function getUserData($handle=null) +{ + if(! local_channel()) { + notice( t('Permission denied.') . EOL); + get_app()->page['content'] = login(); + } + + + if($handle) { + $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_hash = '%s' limit 1", + dbesc($handle) + ); + } + else { + $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d", + intval(local_channel()) + ); + } + + return $r; + +/* + if(isset($_POST['login'],$_POST['password'])) { + $login = mysql_real_escape_string($_POST['login']); + $password = sha1($_POST['password']); + $q = mysql_query("SELECT * FROM Users WHERE login = '$login' AND password = '$password'"); + if($data = mysql_fetch_assoc($q)) { + return $data; + } + if($handle) { + echo 'Wrong login/password.'; + } + } + if($handle) { + ?> +
+ + Login:
+ Password:
+ +
+ 'First name', + 'namePerson/last' => 'Last name', + 'namePerson/friendly' => 'Nickname (login)' + ); + + private $attrFieldMap = array( + 'namePerson/first' => 'firstName', + 'namePerson/last' => 'lastName', + 'namePerson/friendly' => 'login' + ); + + function setup($identity, $realm, $assoc_handle, $attributes) + { + $data = getUserData($assoc_handle); + $o .= '
' + . '' + . '' + . '' + . "$realm wishes to authenticate you."; + if($attributes['required'] || $attributes['optional']) { + $o .= " It also requests following information (required fields marked with *):" + . '
    '; + + foreach($attributes['required'] as $attr) { + if(isset($this->attrMap[$attr])) { + $o .= '
  • ' + . ' ' + . $this->attrMap[$attr] . '(*)
  • '; + } + } + + foreach($attributes['optional'] as $attr) { + if(isset($this->attrMap[$attr])) { + $o .= '
  • ' + . ' ' + . $this->attrMap[$attr] . '
  • '; + } + } + $o .= '
'; + } + $o .= '
' + . ' ' + . ' ' + . ' ' + . '
'; + + get_app()->page['content'] = $o; + + } + + function checkid($realm, &$attributes) + { + if(isset($_POST['cancel'])) { + $this->cancel(); + } + + $data = getUserData(); + if(!$data) { + return false; + } + $realm = mysql_real_escape_string($realm); + + + $q = mysql_query("SELECT attributes FROM AllowedSites WHERE user = '{$data['id']}' AND realm = '$realm'"); + + $attrs = array(); + if($attrs = mysql_fetch_row($q)) { + $attrs = explode(',', $attributes[0]); + } elseif(isset($_POST['attributes'])) { + $attrs = array_keys($_POST['attributes']); + } elseif(!isset($_POST['once']) && !isset($_POST['always'])) { + return false; + } + + $attributes = array(); + foreach($attrs as $attr) { + if(isset($this->attrFieldMap[$attr])) { + $attributes[$attr] = $data[$this->attrFieldMap[$attr]]; + } + } + + if(isset($_POST['always'])) { + $attrs = mysql_real_escape_string(implode(',', array_keys($attributes))); + mysql_query("REPLACE INTO AllowedSites VALUES('{$data['id']}', '$realm', '$attrs')"); + } + + return $this->serverLocation . '?' . $data['login']; + } + + function assoc_handle() + { + # We generate an integer assoc handle, because it's just faster to look up an integer later. + $q = mysql_query("SELECT MAX(id) FROM Associations"); + $result = mysql_fetch_row($q); + return $q[0]+1; + } + + function setAssoc($handle, $data) + { + $data = mysql_real_escape_string(serialize($data)); + mysql_query("REPLACE INTO Associations VALUES('$handle', '$data')"); + } + + function getAssoc($handle) + { + if(!is_numeric($handle)) { + return false; + } + $q = mysql_query("SELECT data FROM Associations WHERE id = '$handle'"); + $data = mysql_fetch_row($q); + if(!$data) { + return false; + } + return unserialize($data[0]); + } + + function delAssoc($handle) + { + if(!is_numeric($handle)) { + return false; + } + mysql_query("DELETE FROM Associations WHERE id = '$handle'"); + } + +} +$op = new MysqlProvider; +$op->server(); + +} + + + + + + + + + + + -- cgit v1.2.3 From d6ce32ef7885579ba0503bc7a826ded2ddac4d71 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 11 Mar 2015 17:31:15 -0700 Subject: parse_url changes for oembed/zvideo/etc. --- mod/parse_url.php | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'mod') diff --git a/mod/parse_url.php b/mod/parse_url.php index 49d5cae76..b6c0559f9 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -1,5 +1,6 @@ true, 'nobody' => true)); if($result['success']) { $hdrs=array(); @@ -261,25 +264,31 @@ function parse_url_content(&$a) { if (array_key_exists('Content-Type', $hdrs)) $type = $hdrs['Content-Type']; if($type) { - if(in_array($type,array('image/jpeg','image/gif','image/png'))) { - $s = $br . '[img]' . $url . '[/img]' . $br; - $s = preg_replace_callback('/\[img(.*?)\](.*?)\[\/img\]/ism','red_zrlify_img_callback',$s); - echo $s; + $zrl = is_matrix_url($url); + if(stripos($type,'image/') !== false) { + if($zrl) + echo $br . '[zmg]' . $url . '[/zmg]' . $br; + else + echo $br . '[img]' . $url . '[/img]' . $br; killme(); } if(stripos($type,'video/') !== false) { - echo $br . '[video]' . $url . '[/video]' . $br; + if($zrl) + echo $br . '[zvideo]' . $url . '[/zvideo]' . $br; + else + echo $br . '[video]' . $url . '[/video]' . $br; killme(); } if(stripos($type,'audio/') !== false) { - echo $br . '[audio]' . $url . '[/audio]' . $br; + if($zrl) + echo $br . '[zaudio]' . $url . '[/zaudio]' . $br; + else + echo $br . '[audio]' . $url . '[/audio]' . $br; killme(); } } } - logger('parse_url: ' . $url); - $template = $br . '#^[url=%s]%s[/url]%s' . $br; $arr = array('url' => $url, 'text' => ''); @@ -291,6 +300,11 @@ function parse_url_content(&$a) { killme(); } + $x = oembed_process($url); + if($x) { + echo $x; + killme(); + } if($url && $title && $text) { -- cgit v1.2.3 From b3a9a6c802170a15cc58fd3af966b35f81c50818 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 11 Mar 2015 18:56:28 -0700 Subject: remove the now redundant audio/video buttons and label the editor text style buttons which didn't have them. Unused editor buttons were commented in case we need to bring them back. If things go smoothly we can remove them. Use the link icon going forward - for all links. --- mod/editblock.php | 5 +++++ mod/editlayout.php | 5 +++++ mod/editpost.php | 5 +++++ mod/editwebpage.php | 5 +++++ 4 files changed, 20 insertions(+) (limited to 'mod') diff --git a/mod/editblock.php b/mod/editblock.php index 46126f94e..cacb5c27d 100644 --- a/mod/editblock.php +++ b/mod/editblock.php @@ -141,6 +141,11 @@ function editblock_content(&$a) { '$action' => 'item', '$webpage' => ITEM_BUILDBLOCK, '$share' => t('Edit'), + '$bold' => t('Bold'), + '$italic' => t('Italic'), + '$underline' => t('Underline'), + '$quote' => t('Quote'), + '$code' => t('Code'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), diff --git a/mod/editlayout.php b/mod/editlayout.php index 847a64320..21607de8c 100644 --- a/mod/editlayout.php +++ b/mod/editlayout.php @@ -137,6 +137,11 @@ function editlayout_content(&$a) { '$action' => 'item', '$webpage' => ITEM_PDL, '$share' => t('Edit'), + '$bold' => t('Bold'), + '$italic' => t('Italic'), + '$underline' => t('Underline'), + '$quote' => t('Quote'), + '$code' => t('Code'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), diff --git a/mod/editpost.php b/mod/editpost.php index bdd3be450..edc5fa1b7 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -111,6 +111,11 @@ function editpost_content(&$a) { '$return_path' => $_SESSION['return_url'], '$action' => 'item', '$share' => t('Edit'), + '$bold' => t('Bold'), + '$italic' => t('Italic'), + '$underline' => t('Underline'), + '$quote' => t('Quote'), + '$code' => t('Code'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), diff --git a/mod/editwebpage.php b/mod/editwebpage.php index c07efc7ee..3e0bd9ff4 100644 --- a/mod/editwebpage.php +++ b/mod/editwebpage.php @@ -172,6 +172,11 @@ function editwebpage_content(&$a) { '$action' => 'item', '$share' => t('Edit'), + '$bold' => t('Bold'), + '$italic' => t('Italic'), + '$underline' => t('Underline'), + '$quote' => t('Quote'), + '$code' => t('Code'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), -- cgit v1.2.3 From 76fedfe1f89e671c625598d48508195bab98e969 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 11 Mar 2015 21:49:29 -0700 Subject: openid stuff --- mod/id.php | 84 ++++++++++++++++++++++++++++++++++------------------------ mod/openid.php | 2 +- 2 files changed, 50 insertions(+), 36 deletions(-) (limited to 'mod') diff --git a/mod/id.php b/mod/id.php index 852c73163..760a29c01 100644 --- a/mod/id.php +++ b/mod/id.php @@ -51,9 +51,10 @@ function getUserData($handle=null) get_app()->page['content'] = login(); } + logger('handle: ' . $handle); if($handle) { - $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_hash = '%s' limit 1", + $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1", dbesc($handle) ); } @@ -63,7 +64,7 @@ function getUserData($handle=null) ); } - return $r; + return $r[0]; /* if(isset($_POST['login'],$_POST['password'])) { @@ -108,6 +109,12 @@ class MysqlProvider extends LightOpenIDProvider function setup($identity, $realm, $assoc_handle, $attributes) { + + logger('identity: ' . $identity); + logger('realm: ' . $realm); + logger('assoc_handle: ' . $assoc_handle); + logger('attributes: ' . print_r($attributes,true)); + $data = getUserData($assoc_handle); $o .= '
' . '' @@ -141,34 +148,42 @@ class MysqlProvider extends LightOpenIDProvider . ' ' . '
'; - get_app()->page['content'] = $o; + get_app()->page['content'] .= $o; } function checkid($realm, &$attributes) { + + logger('checkid: ' . $realm); + + logger('checkid attrs: ' . print_r($attributes,true)); + + if(isset($_POST['cancel'])) { $this->cancel(); } $data = getUserData(); - if(!$data) { + if(! $data) { return false; } - $realm = mysql_real_escape_string($realm); - - $q = mysql_query("SELECT attributes FROM AllowedSites WHERE user = '{$data['id']}' AND realm = '$realm'"); - - $attrs = array(); - if($attrs = mysql_fetch_row($q)) { - $attrs = explode(',', $attributes[0]); + + logger('checkid: checkpoint1'); + + + $q = get_pconfig(local_channel(),'openid',$realm); + + $attrs = array(); + if($q) { + $attrs = $q; } elseif(isset($_POST['attributes'])) { $attrs = array_keys($_POST['attributes']); } elseif(!isset($_POST['once']) && !isset($_POST['always'])) { return false; } - + $attributes = array(); foreach($attrs as $attr) { if(isset($this->attrFieldMap[$attr])) { @@ -177,46 +192,45 @@ class MysqlProvider extends LightOpenIDProvider } if(isset($_POST['always'])) { - $attrs = mysql_real_escape_string(implode(',', array_keys($attributes))); - mysql_query("REPLACE INTO AllowedSites VALUES('{$data['id']}', '$realm', '$attrs')"); + set_pconfig(local_channel(),'openid',$realm,array_keys($attributes)); } - - return $this->serverLocation . '?' . $data['login']; + + return z_root() . '/id/' . $data['channel_address']; } function assoc_handle() { - # We generate an integer assoc handle, because it's just faster to look up an integer later. - $q = mysql_query("SELECT MAX(id) FROM Associations"); - $result = mysql_fetch_row($q); - return $q[0]+1; + + $channel = get_app()->get_channel(); + return z_root() . '/id/' . $channel['channel_address']; + } function setAssoc($handle, $data) { - $data = mysql_real_escape_string(serialize($data)); - mysql_query("REPLACE INTO Associations VALUES('$handle', '$data')"); + logger('setAssoc'); + $channel = channelx_by_nick(basename($handle)); + if($channel) + set_pconfig($channel['channel_id'],'openid','associate',$data); + } function getAssoc($handle) { - if(!is_numeric($handle)) { - return false; - } - $q = mysql_query("SELECT data FROM Associations WHERE id = '$handle'"); - $data = mysql_fetch_row($q); - if(!$data) { - return false; - } - return unserialize($data[0]); + logger('getAssoc: ' . $handle); + + $channel = channelx_by_nick(basename($handle)); + if($channel) + return get_pconfig($channel['channel_id'],'openid','associate'); + return false; } function delAssoc($handle) { - if(!is_numeric($handle)) { - return false; - } - mysql_query("DELETE FROM Associations WHERE id = '$handle'"); + logger('delAssoc'); + $channel = channelx_by_nick(basename($handle)); + if($channel) + return del_pconfig($channel['channel_id'],'openid','associate'); } } diff --git a/mod/openid.php b/mod/openid.php index 9752db440..1af95a81c 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -85,7 +85,7 @@ function openid_content(&$a) { $url = trim($_REQUEST['openid_identity'],'/'); if(strpos($url,'http') === false) $url = 'https://' . $url; - $pphoto = get_default_profile_photo(); + $pphoto = z_root() . '/' . get_default_profile_photo(); $parsed = @parse_url($url); if($parsed) { $host = $parsed['host']; -- cgit v1.2.3 From 1578c49976110c6c4c0a0dcf63ba40be4529045c Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Thu, 12 Mar 2015 00:28:49 -0700 Subject: substr() is a mysql alias for substring(). substring() is in the SQL standard and is supported by both databases. --- mod/dirsearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index b4154c1eb..07621aaef 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -195,7 +195,7 @@ function dirsearch_content(&$a) { // This will make a handful of channels whose names begin with // punctuation un-searchable in this mode - $safesql .= " and ascii(substr(xchan_name FROM 1 FOR 1)) > 64 "; + $safesql .= " and ascii(substring(xchan_name FROM 1 FOR 1)) > 64 "; } elseif($sort_order == 'reverse') $order = " order by xchan_name desc "; -- cgit v1.2.3 From 8113ee1c4aeb2b9586c1736c38faafce53dc8e53 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 12 Mar 2015 10:19:56 +0100 Subject: some work on feature/addon settings --- mod/settings.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 8752a47b2..c47d21d02 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -678,11 +678,9 @@ function settings_content(&$a) { '$title' => t('Feature/Addon Settings'), '$diaspora_enabled' => $diaspora_enabled, '$dsprdesc' => t('Settings for the built-in Diaspora emulator'), - '$pubcomments' => $pubcomments, + '$pubcomments' => array('dspr_pubcomment', t('Allow any Diaspora member to comment on your public posts'), $pubcomments, '', $yes_no), '$dsprtitle' => t('Diaspora Policy Settings'), - '$dsprhelp' => t('Allow any Diaspora member to comment on your public posts.'), - '$dsprhijack' => t('Prevent your hashtags from being redirected to other sites'), - '$hijacking' => $hijacking, + '$hijacking' => array('dspr_hijack', t('Prevent your hashtags from being redirected to other sites'), $hijacking, '', $yes_no), '$dsprsubmit' => t('Submit Diaspora Policy Settings'), '$settings_addons' => $settings_addons )); -- cgit v1.2.3 From d11bec6f584574ae6045e0fe09b544d920e53f2a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 12 Mar 2015 22:22:52 +0100 Subject: add generic_addon_settings template and minor fixes --- mod/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index c47d21d02..56949f9d4 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -681,7 +681,7 @@ function settings_content(&$a) { '$pubcomments' => array('dspr_pubcomment', t('Allow any Diaspora member to comment on your public posts'), $pubcomments, '', $yes_no), '$dsprtitle' => t('Diaspora Policy Settings'), '$hijacking' => array('dspr_hijack', t('Prevent your hashtags from being redirected to other sites'), $hijacking, '', $yes_no), - '$dsprsubmit' => t('Submit Diaspora Policy Settings'), + '$dsprsubmit' => t('Submit'), '$settings_addons' => $settings_addons )); return $o; -- cgit v1.2.3 From 71f2a797cbc07e4e5c996d0a7ab7194adba071ec Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Mar 2015 15:19:54 -0700 Subject: try and add some regs --- mod/rmagic.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mod') diff --git a/mod/rmagic.php b/mod/rmagic.php index 49525bd32..597c6ed9c 100644 --- a/mod/rmagic.php +++ b/mod/rmagic.php @@ -33,6 +33,8 @@ function rmagic_post(&$a) { $openid = new LightOpenID(z_root()); $openid->identity = $address; $openid->returnUrl = z_root() . '/openid'; + $openid->required = array('namePerson/friendly', 'namePerson'); + $openid->optional = array('namePerson/first','media/image/aspect11','media/image/default'); goaway($openid->authUrl()); } catch (Exception $e) { notice( t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.').'

'. t('The error message was:').' '.$e->getMessage()); -- cgit v1.2.3 From 02a58dc5b05a39eee9784261c5010c0f1765588f Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Mar 2015 16:20:29 -0700 Subject: more JS=1 weirdness --- mod/network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index d24d665d8..b2888b223 100644 --- a/mod/network.php +++ b/mod/network.php @@ -13,7 +13,7 @@ function network_init(&$a) { return; } - if(count($_GET) < 2) { + if((count($_GET) < 2) || (count($_GET) < 3 && $_GET['JS'])) { $network_options = get_pconfig(local_channel(),'system','network_page_default'); if($network_options) goaway('network' . '?f=&' . $network_options); -- cgit v1.2.3 From f2d84608af74e66fe6c5d21369cd5d3cfe4803de Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Mar 2015 18:48:32 -0700 Subject: Add some AX vars to openid server. --- mod/id.php | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'mod') diff --git a/mod/id.php b/mod/id.php index 760a29c01..4a6f5683c 100644 --- a/mod/id.php +++ b/mod/id.php @@ -49,9 +49,10 @@ function getUserData($handle=null) if(! local_channel()) { notice( t('Permission denied.') . EOL); get_app()->page['content'] = login(); + return false; } - logger('handle: ' . $handle); +// logger('handle: ' . $handle); if($handle) { $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1", @@ -64,6 +65,19 @@ function getUserData($handle=null) ); } + if(! r) + return false; + + $x = q("select * from account where account_id = %d limit 1", + intval($r[0]['channel_account_id']) + ); + if($x) + $r[0]['email'] = $x[0]['account_email']; + + $r[0]['firstName'] = ((strpos($r[0]['channel_name'],' ')) ? substr($r[0]['channel_name'],0,strpos($r[0]['channel_name'],' ')) : $r[0]['channel_name']); + $r[0]['lastName'] = ((strpos($r[0]['channel_name'],' ')) ? substr($r[0]['channel_name'],strpos($r[0]['channel_name'],' ')+1) : ''); + + return $r[0]; /* @@ -96,26 +110,29 @@ function getUserData($handle=null) class MysqlProvider extends LightOpenIDProvider { private $attrMap = array( - 'namePerson/first' => 'First name', - 'namePerson/last' => 'Last name', - 'namePerson/friendly' => 'Nickname (login)' + 'namePerson/first' => 'First name', + 'namePerson/last' => 'Last name', + 'namePerson/friendly' => 'Nickname', + 'contact/internet/email' => 'Email' ); private $attrFieldMap = array( - 'namePerson/first' => 'firstName', - 'namePerson/last' => 'lastName', - 'namePerson/friendly' => 'login' + 'namePerson/first' => 'firstName', + 'namePerson/last' => 'lastName', + 'namePerson/friendly' => 'channel_address', + 'contact/internet/email' => 'email' ); function setup($identity, $realm, $assoc_handle, $attributes) { - logger('identity: ' . $identity); - logger('realm: ' . $realm); - logger('assoc_handle: ' . $assoc_handle); - logger('attributes: ' . print_r($attributes,true)); +// logger('identity: ' . $identity); +// logger('realm: ' . $realm); +// logger('assoc_handle: ' . $assoc_handle); +// logger('attributes: ' . print_r($attributes,true)); $data = getUserData($assoc_handle); + $o .= '
' . '' . '' -- cgit v1.2.3 From d60cb14c2f23f372dec5fed78420f8ced3942ea6 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Mar 2015 20:05:43 -0700 Subject: support a fair number of the common AX regs --- mod/id.php | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 5 deletions(-) (limited to 'mod') diff --git a/mod/id.php b/mod/id.php index 4a6f5683c..00138cd29 100644 --- a/mod/id.php +++ b/mod/id.php @@ -73,11 +73,36 @@ function getUserData($handle=null) ); if($x) $r[0]['email'] = $x[0]['account_email']; + + $p = q("select * from profile where is_default = 1 and uid = %d limit 1", + intval($r[0]['channel_account_id']) + ); + + $gender = ''; + if($p[0]['gender'] == t('Male')) + $gender = 'M'; + if($p[0]['gender'] == t('Female')) + $gender = 'F'; $r[0]['firstName'] = ((strpos($r[0]['channel_name'],' ')) ? substr($r[0]['channel_name'],0,strpos($r[0]['channel_name'],' ')) : $r[0]['channel_name']); $r[0]['lastName'] = ((strpos($r[0]['channel_name'],' ')) ? substr($r[0]['channel_name'],strpos($r[0]['channel_name'],' ')+1) : ''); + $r[0]['namePerson'] = $r[0]['channel_name']; + $r[0]['pphoto'] = $r[0]['xchan_photo_l']; + $r[0]['pphoto16'] = z_root() . '/photo/profile/16/' . $r[0]['channel_id'] . '.jpg'; + $r[0]['pphoto32'] = z_root() . '/photo/profile/32/' . $r[0]['channel_id'] . '.jpg'; + $r[0]['pphoto48'] = z_root() . '/photo/profile/48/' . $r[0]['channel_id'] . '.jpg'; + $r[0]['pphoto64'] = z_root() . '/photo/profile/64/' . $r[0]['channel_id'] . '.jpg'; + $r[0]['pphoto80'] = z_root() . '/photo/profile/80/' . $r[0]['channel_id'] . '.jpg'; + $r[0]['pphoto128'] = z_root() . '/photo/profile/128/' . $r[0]['channel_id'] . '.jpg'; + $r[0]['timezone'] = $r[0]['channel_timezone']; + $r[0]['url'] = $r[0]['xchan_url']; + $r[0]['language'] = (($x[0]['account_language']) ? $x[0]['account_language'] : 'en'); + $r[0]['birthyear'] = ((intval(substr($p[0]['dob'],0,4))) ? intval(substr($p[0]['dob'],0,4)) : ''); + $r[0]['birthmonth'] = ((intval(substr($p[0]['dob'],5,2))) ? intval(substr($p[0]['dob'],5,2)) : ''); + $r[0]['birthday'] = ((intval(substr($p[0]['dob'],8,2))) ? intval(substr($p[0]['dob'],8,2)) : ''); + $r[0]['birthdate'] = (($r[0]['birthyear'] && $r[0]['birthmonth'] && $r[0]['birthday']) ? $p[0]['dob'] : ''); + $r[0]['gender'] = $gender; - return $r[0]; /* @@ -110,17 +135,55 @@ function getUserData($handle=null) class MysqlProvider extends LightOpenIDProvider { private $attrMap = array( - 'namePerson/first' => 'First name', - 'namePerson/last' => 'Last name', + 'namePerson/first' => 'First Name', + 'namePerson/last' => 'Last Name', 'namePerson/friendly' => 'Nickname', - 'contact/internet/email' => 'Email' + 'namePerson' => 'Full Name', + 'contact/internet/email' => 'Email', + 'contact/email' => 'Email', + 'media/image/aspect11' => 'Profile Photo', + 'media/image' => 'Profile Photo', + 'media/image/default' => 'Profile Photo', + 'media/image/16x16' => 'Profile Photo 16px', + 'media/image/32x32' => 'Profile Photo 32px', + 'media/image/48x48' => 'Profile Photo 48px', + 'media/image/64x64' => 'Profile Photo 64px', + 'media/image/80x80' => 'Profile Photo 80px', + 'media/image/128x128' => 'Profile Photo 128px', + 'timezone' => 'Timezone', + 'contact/web/default' => 'Homepage URL', + 'language/pref' => 'Language', + 'birthDate/birthYear' => 'Birth Year', + 'birthDate/birthMonth' => 'Birth Month', + 'birthDate/birthday' => 'Birth Day', + 'birthDate' => 'Birthdate', + 'gender' => 'Gender', ); private $attrFieldMap = array( 'namePerson/first' => 'firstName', 'namePerson/last' => 'lastName', 'namePerson/friendly' => 'channel_address', - 'contact/internet/email' => 'email' + 'namePerson' => 'namePerson', + 'contact/internet/email' => 'email', + 'contact/email' => 'email', + 'media/image/aspect11' => 'pphoto', + 'media/image' => 'pphoto', + 'media/image/default' => 'pphoto', + 'media/image/16x16' => 'pphoto16', + 'media/image/32x32' => 'pphoto32', + 'media/image/48x48' => 'pphoto48', + 'media/image/64x64' => 'pphoto64', + 'media/image/80x80' => 'pphoto80', + 'media/image/128x128' => 'pphoto128', + 'timezone' => 'timezone', + 'contact/web/default' => 'url', + 'language/pref' => 'language', + 'birthDate/birthYear' => 'birthyear', + 'birthDate/birthMonth' => 'birthmonth', + 'birthDate/birthday' => 'birthday', + 'birthDate' => 'birthdate', + 'gender' => 'gender', ); function setup($identity, $realm, $assoc_handle, $attributes) -- cgit v1.2.3 From 93caead072e3b5f1623fe0c61206e57da7ca20b3 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Mar 2015 20:43:53 -0700 Subject: try to allow translation of ax regs --- mod/id.php | 81 ++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 29 deletions(-) (limited to 'mod') diff --git a/mod/id.php b/mod/id.php index 00138cd29..d2776830d 100644 --- a/mod/id.php +++ b/mod/id.php @@ -78,6 +78,9 @@ function getUserData($handle=null) intval($r[0]['channel_account_id']) ); + + + $gender = ''; if($p[0]['gender'] == t('Male')) $gender = 'M'; @@ -132,34 +135,50 @@ function getUserData($handle=null) } + +function translate_regs() { + + // This exists to get around scoping rules + + $attrMap = array( + 'namePerson/first' => t('First Name'), + 'namePerson/last' => t('Last Name'), + 'namePerson/friendly' => t('Nickname'), + 'namePerson' => t('Full Name'), + 'contact/internet/email' => t('Email'), + 'contact/email' => t('Email'), + 'media/image/aspect11' => t('Profile Photo'), + 'media/image' => t('Profile Photo'), + 'media/image/default' => t('Profile Photo'), + 'media/image/16x16' => t('Profile Photo 16px'), + 'media/image/32x32' => t('Profile Photo 32px'), + 'media/image/48x48' => t('Profile Photo 48px'), + 'media/image/64x64' => t('Profile Photo 64px'), + 'media/image/80x80' => t('Profile Photo 80px'), + 'media/image/128x128' => t('Profile Photo 128px'), + 'timezone' => t('Timezone'), + 'contact/web/default' => t('Homepage URL'), + 'language/pref' => t('Language'), + 'birthDate/birthYear' => t('Birth Year'), + 'birthDate/birthMonth' => t('Birth Month'), + 'birthDate/birthday' => t('Birth Day'), + 'birthDate' => t('Birthdate'), + 'gender' => t('Gender'), + ); + + return $attrMap; +} + + class MysqlProvider extends LightOpenIDProvider { - private $attrMap = array( - 'namePerson/first' => 'First Name', - 'namePerson/last' => 'Last Name', - 'namePerson/friendly' => 'Nickname', - 'namePerson' => 'Full Name', - 'contact/internet/email' => 'Email', - 'contact/email' => 'Email', - 'media/image/aspect11' => 'Profile Photo', - 'media/image' => 'Profile Photo', - 'media/image/default' => 'Profile Photo', - 'media/image/16x16' => 'Profile Photo 16px', - 'media/image/32x32' => 'Profile Photo 32px', - 'media/image/48x48' => 'Profile Photo 48px', - 'media/image/64x64' => 'Profile Photo 64px', - 'media/image/80x80' => 'Profile Photo 80px', - 'media/image/128x128' => 'Profile Photo 128px', - 'timezone' => 'Timezone', - 'contact/web/default' => 'Homepage URL', - 'language/pref' => 'Language', - 'birthDate/birthYear' => 'Birth Year', - 'birthDate/birthMonth' => 'Birth Month', - 'birthDate/birthday' => 'Birth Day', - 'birthDate' => 'Birthdate', - 'gender' => 'Gender', - ); - + + // See http://openid.net/specs/openid-attribute-properties-list-1_0-01.html + // This list contains a few variations of these attributes to maintain + // compatibility with legacy clients + + private $attrMap; + private $attrFieldMap = array( 'namePerson/first' => 'firstName', 'namePerson/last' => 'lastName', @@ -181,11 +200,15 @@ class MysqlProvider extends LightOpenIDProvider 'language/pref' => 'language', 'birthDate/birthYear' => 'birthyear', 'birthDate/birthMonth' => 'birthmonth', - 'birthDate/birthday' => 'birthday', + 'birthDate/birthday' => 'birthday', 'birthDate' => 'birthdate', 'gender' => 'gender', ); - + + function __construct() { + $this->attrMap = translate_regs(); + } + function setup($identity, $realm, $assoc_handle, $attributes) { @@ -209,7 +232,7 @@ class MysqlProvider extends LightOpenIDProvider if(isset($this->attrMap[$attr])) { $o .= '
  • ' . ' ' - . $this->attrMap[$attr] . '(*)
  • '; + . $this->attrMap[$attr] . ' *'; } } -- cgit v1.2.3 From c412e6e640af11a51ff569fe86fcc381291683b9 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Mar 2015 20:51:36 -0700 Subject: revert that --- mod/id.php | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/id.php b/mod/id.php index d2776830d..378022717 100644 --- a/mod/id.php +++ b/mod/id.php @@ -177,7 +177,31 @@ class MysqlProvider extends LightOpenIDProvider // This list contains a few variations of these attributes to maintain // compatibility with legacy clients - private $attrMap; + private $attrMap = array( + 'namePerson/first' => 'First Name', + 'namePerson/last' => 'Last Name', + 'namePerson/friendly' => 'Nickname', + 'namePerson' => 'Full Name', + 'contact/internet/email' => 'Email', + 'contact/email' => 'Email', + 'media/image/aspect11' => 'Profile Photo', + 'media/image' => 'Profile Photo', + 'media/image/default' => 'Profile Photo', + 'media/image/16x16' => 'Profile Photo 16px', + 'media/image/32x32' => 'Profile Photo 32px', + 'media/image/48x48' => 'Profile Photo 48px', + 'media/image/64x64' => 'Profile Photo 64px', + 'media/image/80x80' => 'Profile Photo 80px', + 'media/image/128x128' => 'Profile Photo 128px', + 'timezone' => 'Timezone', + 'contact/web/default' => 'Homepage URL', + 'language/pref' => 'Language', + 'birthDate/birthYear' => 'Birth Year', + 'birthDate/birthMonth' => 'Birth Month', + 'birthDate/birthday' => 'Birth Day', + 'birthDate' => 'Birthdate', + 'gender' => 'Gender', + ); private $attrFieldMap = array( 'namePerson/first' => 'firstName', @@ -205,9 +229,6 @@ class MysqlProvider extends LightOpenIDProvider 'gender' => 'gender', ); - function __construct() { - $this->attrMap = translate_regs(); - } function setup($identity, $realm, $assoc_handle, $attributes) { -- cgit v1.2.3 From 7d5efe88e0c97cea34d5290442d375c0cd609d34 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 13 Mar 2015 15:39:19 -0700 Subject: use local_channel() connnections to match the abook against when joining the abook on the discover tab. --- mod/network.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index b2888b223..691e860d7 100644 --- a/mod/network.php +++ b/mod/network.php @@ -337,16 +337,16 @@ function network_content(&$a, $update = 0, $load = false) { } + $abook_uids = " and abook.abook_channel = " . local_channel() . " "; + if($firehose && (! get_config('system','disable_discover_tab'))) { require_once('include/identity.php'); $sys = get_sys_channel(); $uids = " and item.uid = " . intval($sys['channel_id']) . " "; $a->data['firehose'] = intval($sys['channel_id']); - $abook_uids = ""; } else { $uids = " and item.uid = " . local_channel() . " "; - $abook_uids = " and abook.abook_channel = " . local_channel() . " "; } if(get_pconfig(local_channel(),'system','network_list_mode')) -- cgit v1.2.3 From e732fbe8e8a876ff76cbc7930a34f5adca4ffbd6 Mon Sep 17 00:00:00 2001 From: zottel Date: Sat, 14 Mar 2015 00:22:47 +0100 Subject: fix posts not showing up in network if author is not in connections --- mod/network.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index 691e860d7..642fc4f43 100644 --- a/mod/network.php +++ b/mod/network.php @@ -377,7 +377,7 @@ function network_content(&$a, $update = 0, $load = false) { // "New Item View" - show all items unthreaded in reverse created date order $items = q("SELECT item.*, item.id AS item_id, received FROM item - left join abook on item.author_xchan = abook.abook_xchan + left join abook on item.owner_xchan = abook.abook_xchan WHERE true $uids $abook_uids AND item_restrict = 0 and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $simple_update @@ -408,7 +408,7 @@ function network_content(&$a, $update = 0, $load = false) { // Fetch a page full of parent items for this page $r = q("SELECT distinct item.id AS item_id, $ordering FROM item - left join abook on item.author_xchan = abook.abook_xchan + left join abook on item.owner_xchan = abook.abook_xchan WHERE true $uids $abook_uids AND item.item_restrict = 0 AND item.parent = item.id and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) @@ -422,7 +422,7 @@ function network_content(&$a, $update = 0, $load = false) { if(! $firehose) { // update $r = q("SELECT item.parent AS item_id FROM item - left join abook on item.author_xchan = abook.abook_xchan + left join abook on item.owner_xchan = abook.abook_xchan WHERE true $uids $abook_uids AND item.item_restrict = 0 $simple_update and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets ", -- cgit v1.2.3 From b76cdf82d298c92bdf5a59b6bf6b55da504a46ea Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 13 Mar 2015 19:24:17 -0700 Subject: create terms for Diaspora mention tags - which in Diaspora are handled differently than other tag links and have to be done separately; they aren't processed by linkify_tags which handles all of our other tag processing. Also move the abook_channel clause in mod_network to the join statement. This works fine in mysql and achievies the desired result. I hope postgres can handle an expression as a join clause. --- mod/network.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index 642fc4f43..d2b9bc64c 100644 --- a/mod/network.php +++ b/mod/network.php @@ -377,8 +377,8 @@ function network_content(&$a, $update = 0, $load = false) { // "New Item View" - show all items unthreaded in reverse created date order $items = q("SELECT item.*, item.id AS item_id, received FROM item - left join abook on item.owner_xchan = abook.abook_xchan - WHERE true $uids $abook_uids AND item_restrict = 0 + left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) + WHERE true $uids AND item_restrict = 0 and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $simple_update $sql_extra $sql_nets @@ -408,8 +408,8 @@ function network_content(&$a, $update = 0, $load = false) { // Fetch a page full of parent items for this page $r = q("SELECT distinct item.id AS item_id, $ordering FROM item - left join abook on item.owner_xchan = abook.abook_xchan - WHERE true $uids $abook_uids AND item.item_restrict = 0 + left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) + WHERE true $uids AND item.item_restrict = 0 AND item.parent = item.id and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets @@ -422,8 +422,8 @@ function network_content(&$a, $update = 0, $load = false) { if(! $firehose) { // update $r = q("SELECT item.parent AS item_id FROM item - left join abook on item.owner_xchan = abook.abook_xchan - WHERE true $uids $abook_uids AND item.item_restrict = 0 $simple_update + left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) + WHERE true $uids AND item.item_restrict = 0 $simple_update and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets ", intval(ABOOK_FLAG_BLOCKED) -- cgit v1.2.3 From 88167718baba7ea9aa1e2055a3071091877f9733 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 14 Mar 2015 00:51:16 -0700 Subject: revert and rethink --- mod/network.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index d2b9bc64c..30e046462 100644 --- a/mod/network.php +++ b/mod/network.php @@ -377,7 +377,7 @@ function network_content(&$a, $update = 0, $load = false) { // "New Item View" - show all items unthreaded in reverse created date order $items = q("SELECT item.*, item.id AS item_id, received FROM item - left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) + left join abook on item.owner_xchan = abook.abook_xchan WHERE true $uids AND item_restrict = 0 and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $simple_update @@ -408,7 +408,7 @@ function network_content(&$a, $update = 0, $load = false) { // Fetch a page full of parent items for this page $r = q("SELECT distinct item.id AS item_id, $ordering FROM item - left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) + left join abook on item.owner_xchan = abook.abook_xchan WHERE true $uids AND item.item_restrict = 0 AND item.parent = item.id and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) @@ -422,7 +422,7 @@ function network_content(&$a, $update = 0, $load = false) { if(! $firehose) { // update $r = q("SELECT item.parent AS item_id FROM item - left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) + left join abook on item.owner_xchan = abook.abook_xchan WHERE true $uids AND item.item_restrict = 0 $simple_update and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets ", -- cgit v1.2.3 From cc2c7bbcd89bf3b937b1248519d23bde1179190f Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 14 Mar 2015 01:03:37 -0700 Subject: revert the revert - that is working. My test was bad. --- mod/network.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index 30e046462..d2b9bc64c 100644 --- a/mod/network.php +++ b/mod/network.php @@ -377,7 +377,7 @@ function network_content(&$a, $update = 0, $load = false) { // "New Item View" - show all items unthreaded in reverse created date order $items = q("SELECT item.*, item.id AS item_id, received FROM item - left join abook on item.owner_xchan = abook.abook_xchan + left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) WHERE true $uids AND item_restrict = 0 and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $simple_update @@ -408,7 +408,7 @@ function network_content(&$a, $update = 0, $load = false) { // Fetch a page full of parent items for this page $r = q("SELECT distinct item.id AS item_id, $ordering FROM item - left join abook on item.owner_xchan = abook.abook_xchan + left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) WHERE true $uids AND item.item_restrict = 0 AND item.parent = item.id and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) @@ -422,7 +422,7 @@ function network_content(&$a, $update = 0, $load = false) { if(! $firehose) { // update $r = q("SELECT item.parent AS item_id FROM item - left join abook on item.owner_xchan = abook.abook_xchan + left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) WHERE true $uids AND item.item_restrict = 0 $simple_update and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets ", -- cgit v1.2.3 From 6537a65053f456870e6f03cdb5bca9a9907426eb Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Mar 2015 15:36:01 -0700 Subject: mysql schema typo, do the install check for store before chcking smarty, as that is where the dir is created, change install doc to point to install/schema_xxxxx.sql instead of database.sql --- mod/setup.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/setup.php b/mod/setup.php index adcbbef16..b885388be 100755 --- a/mod/setup.php +++ b/mod/setup.php @@ -233,10 +233,10 @@ function setup_content(&$a) { check_htconfig($checks); - check_smarty3($checks); - check_store($checks); + check_smarty3($checks); + check_keys($checks); if(x($_POST,'phpath')) -- cgit v1.2.3 From 6da40fc559f540e67802f771411aa9f85dc8d64d Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Mar 2015 16:48:45 -0700 Subject: mod_id: load profile so the sidebar profile will work --- mod/channel.php | 5 +++++ mod/id.php | 54 +++++++++++++++--------------------------------------- 2 files changed, 20 insertions(+), 39 deletions(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 109c9a596..3216da7e1 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -36,6 +36,11 @@ function channel_init(&$a) { $a->page['htmlhead'] .= '' . "\r\n" ; + +// Not yet ready for prime time +// $a->page['htmlhead'] .= '' . "\r\n" ; +// $a->page['htmlhead'] .= '' . "\r\n" ; + // Run profile_load() here to make sure the theme is set before // we start loading content diff --git a/mod/id.php b/mod/id.php index 378022717..6678004c5 100644 --- a/mod/id.php +++ b/mod/id.php @@ -2,45 +2,21 @@ function id_init(&$a) { -logger('id: ' . print_r($_REQUEST,true)); - -/** - * This example shows several things: - * - How a setup interface should look like. - * - How to use a mysql table for authentication - * - How to store associations in mysql table, instead of php sessions. - * - How to store realm authorizations. - * - How to send AX/SREG parameters. - * For the example to work, you need to create the necessary tables: -CREATE TABLE Users ( - id INT NOT NULL auto_increment PRIMARY KEY, - login VARCHAR(32) NOT NULL, - password CHAR(40) NOT NULL, - firstName VARCHAR(32) NOT NULL, - lastName VARCHAR(32) NOT NULL -); - -CREATE TABLE AllowedSites ( - user INT NOT NULL, - realm TEXT NOT NULL, - attributes TEXT NOT NULL, - INDEX(user) -); - -CREATE TABLE Associations ( - id INT NOT NULL PRIMARY KEY, - data TEXT NOT NULL -); - * - * This is only an example. Don't use it in your code as-is. - * It has several security flaws, which you shouldn't copy (like storing plaintext login and password in forms). - * - * This setup could be very easily flooded with many associations, - * since non-private ones aren't automatically deleted. - * You could prevent this by storing a date of association and removing old ones, - * or by setting $this->dh = false; - * However, the latter one would disable stateful mode, unless connecting via HTTPS. - */ + logger('id: ' . print_r($_REQUEST,true)); + + + if(argc() > 1) + $which = argv(1); + else { + $a->error = 404; + return; + } + + $profile = ''; + $channel = $a->get_channel(); + profile_load($a,$which,$profile); + + require 'library/openid/provider/provider.php'; -- cgit v1.2.3 From 52374bcd6e5726828219bed7a8c04f5456b167d5 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Mar 2015 15:33:08 -0700 Subject: phase one of the great file storage unification - use one button for uploads of any type (image or attachment). We'll sort out which one it is and deal with it appropriately. --- mod/wall_attach.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 47c097416..465c3e1cc 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -2,15 +2,42 @@ require_once('include/attach.php'); require_once('include/identity.php'); +require_once('include/photos.php'); function wall_attach_post(&$a) { if(argc() > 1) $channel = get_channel_by_nick(argv(1)); - else + elseif($_FILES['media']) { + require_once('include/api.php'); + $user_info = api_get_user($a); + $nick = $user_info['screen_name']; + $channel = get_channel_by_nick($user_info['screen_name']); + } + + if(! $channel) killme(); - $r = attach_store($channel,get_observer_hash()); + $observer = $a->get_observer(); + + + if($_FILES['userfile']['tmp_name']) { + $x = getimagesize($_FILES['userfile']['tmp_name']); + if(($x) && ($x[2] === IMG_GIF || $x[2] === IMG_JPG || $x[2] === IMG_JPEG || $x[2] === IMG_PNG)) { + $args = array( 'source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash'])); + $ret = photo_upload($channel,$observer,$args); + if($ret['success']) { + echo "\n\n" . $ret['body'] . "\n\n"; + killme(); + } + if($using_api) + return; + notice($ret['message']); + killme(); + } + } + + $r = attach_store($channel,(($observer) ? $observer['xchan_hash'] : '')); if(! $r['success']) { notice( $r['message'] . EOL); -- cgit v1.2.3 From ccf4734f7bb525ae6b1ebe63e3a2b6b00c4f823b Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Mar 2015 15:50:45 -0700 Subject: make sure this sucker is quiet --- mod/wall_attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 465c3e1cc..498389986 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -22,7 +22,7 @@ function wall_attach_post(&$a) { if($_FILES['userfile']['tmp_name']) { - $x = getimagesize($_FILES['userfile']['tmp_name']); + $x = @getimagesize($_FILES['userfile']['tmp_name']); if(($x) && ($x[2] === IMG_GIF || $x[2] === IMG_JPG || $x[2] === IMG_JPEG || $x[2] === IMG_PNG)) { $args = array( 'source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash'])); $ret = photo_upload($channel,$observer,$args); -- cgit v1.2.3 From 178b768e3ce43f3c75abec1540fcdc909c8c2197 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Mar 2015 17:08:50 -0700 Subject: openid cleanup --- mod/channel.php | 2 +- mod/id.php | 164 +++++++++++++++++++++++--------------------------------- 2 files changed, 68 insertions(+), 98 deletions(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 3216da7e1..2a0373a81 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -39,7 +39,7 @@ function channel_init(&$a) { // Not yet ready for prime time // $a->page['htmlhead'] .= '' . "\r\n" ; -// $a->page['htmlhead'] .= '' . "\r\n" ; +// $a->page['htmlhead'] .= '' . "\r\n" ; // Run profile_load() here to make sure the theme is set before // we start loading content diff --git a/mod/id.php b/mod/id.php index 6678004c5..05a2f3dc5 100644 --- a/mod/id.php +++ b/mod/id.php @@ -1,5 +1,37 @@ t('First Name'), + 'namePerson/last' => t('Last Name'), + 'namePerson/friendly' => t('Nickname'), + 'namePerson' => t('Full Name'), + 'contact/internet/email' => t('Email'), + 'contact/email' => t('Email'), + 'media/image/aspect11' => t('Profile Photo'), + 'media/image' => t('Profile Photo'), + 'media/image/default' => t('Profile Photo'), + 'media/image/16x16' => t('Profile Photo 16px'), + 'media/image/32x32' => t('Profile Photo 32px'), + 'media/image/48x48' => t('Profile Photo 48px'), + 'media/image/64x64' => t('Profile Photo 64px'), + 'media/image/80x80' => t('Profile Photo 80px'), + 'media/image/128x128' => t('Profile Photo 128px'), + 'timezone' => t('Timezone'), + 'contact/web/default' => t('Homepage URL'), + 'language/pref' => t('Language'), + 'birthDate/birthYear' => t('Birth Year'), + 'birthDate/birthMonth' => t('Birth Month'), + 'birthDate/birthday' => t('Birth Day'), + 'birthDate' => t('Birthdate'), + 'gender' => t('Gender'), + ); + + + function id_init(&$a) { logger('id: ' . print_r($_REQUEST,true)); @@ -17,11 +49,14 @@ function id_init(&$a) { profile_load($a,$which,$profile); -require 'library/openid/provider/provider.php'; + $op = new MysqlProvider; + $op->server(); -function getUserData($handle=null) -{ +} + + +function getUserData($handle=null) { if(! local_channel()) { notice( t('Permission denied.') . EOL); get_app()->page['content'] = login(); @@ -54,9 +89,6 @@ function getUserData($handle=null) intval($r[0]['channel_account_id']) ); - - - $gender = ''; if($p[0]['gender'] == t('Male')) $gender = 'M'; @@ -85,100 +117,43 @@ function getUserData($handle=null) return $r[0]; /* - if(isset($_POST['login'],$_POST['password'])) { - $login = mysql_real_escape_string($_POST['login']); - $password = sha1($_POST['password']); - $q = mysql_query("SELECT * FROM Users WHERE login = '$login' AND password = '$password'"); - if($data = mysql_fetch_assoc($q)) { - return $data; - } - if($handle) { - echo 'Wrong login/password.'; - } - } - if($handle) { - ?> - - - Login:
    - Password:
    - - - +*
    +* +* Login:
    +* Password:
    +* +*
    +* t('First Name'), - 'namePerson/last' => t('Last Name'), - 'namePerson/friendly' => t('Nickname'), - 'namePerson' => t('Full Name'), - 'contact/internet/email' => t('Email'), - 'contact/email' => t('Email'), - 'media/image/aspect11' => t('Profile Photo'), - 'media/image' => t('Profile Photo'), - 'media/image/default' => t('Profile Photo'), - 'media/image/16x16' => t('Profile Photo 16px'), - 'media/image/32x32' => t('Profile Photo 32px'), - 'media/image/48x48' => t('Profile Photo 48px'), - 'media/image/64x64' => t('Profile Photo 64px'), - 'media/image/80x80' => t('Profile Photo 80px'), - 'media/image/128x128' => t('Profile Photo 128px'), - 'timezone' => t('Timezone'), - 'contact/web/default' => t('Homepage URL'), - 'language/pref' => t('Language'), - 'birthDate/birthYear' => t('Birth Year'), - 'birthDate/birthMonth' => t('Birth Month'), - 'birthDate/birthday' => t('Birth Day'), - 'birthDate' => t('Birthdate'), - 'gender' => t('Gender'), - ); - - return $attrMap; -} class MysqlProvider extends LightOpenIDProvider { + // See http://openid.net/specs/openid-attribute-properties-list-1_0-01.html // This list contains a few variations of these attributes to maintain // compatibility with legacy clients - private $attrMap = array( - 'namePerson/first' => 'First Name', - 'namePerson/last' => 'Last Name', - 'namePerson/friendly' => 'Nickname', - 'namePerson' => 'Full Name', - 'contact/internet/email' => 'Email', - 'contact/email' => 'Email', - 'media/image/aspect11' => 'Profile Photo', - 'media/image' => 'Profile Photo', - 'media/image/default' => 'Profile Photo', - 'media/image/16x16' => 'Profile Photo 16px', - 'media/image/32x32' => 'Profile Photo 32px', - 'media/image/48x48' => 'Profile Photo 48px', - 'media/image/64x64' => 'Profile Photo 64px', - 'media/image/80x80' => 'Profile Photo 80px', - 'media/image/128x128' => 'Profile Photo 128px', - 'timezone' => 'Timezone', - 'contact/web/default' => 'Homepage URL', - 'language/pref' => 'Language', - 'birthDate/birthYear' => 'Birth Year', - 'birthDate/birthMonth' => 'Birth Month', - 'birthDate/birthday' => 'Birth Day', - 'birthDate' => 'Birthdate', - 'gender' => 'Gender', - ); - private $attrFieldMap = array( 'namePerson/first' => 'firstName', 'namePerson/last' => 'lastName', @@ -208,6 +183,7 @@ class MysqlProvider extends LightOpenIDProvider function setup($identity, $realm, $assoc_handle, $attributes) { + global $attrMap; // logger('identity: ' . $identity); // logger('realm: ' . $realm); @@ -216,6 +192,9 @@ class MysqlProvider extends LightOpenIDProvider $data = getUserData($assoc_handle); + +// FIXME this needs to be a template with localised strings + $o .= '
    ' . '' . '' @@ -269,10 +248,6 @@ class MysqlProvider extends LightOpenIDProvider return false; } - - logger('checkid: checkpoint1'); - - $q = get_pconfig(local_channel(),'openid',$realm); $attrs = array(); @@ -300,9 +275,9 @@ class MysqlProvider extends LightOpenIDProvider function assoc_handle() { - + logger('assoc_handle'); $channel = get_app()->get_channel(); - return z_root() . '/id/' . $channel['channel_address']; + return z_root() . '/channel/' . $channel['channel_address']; } @@ -312,7 +287,6 @@ class MysqlProvider extends LightOpenIDProvider $channel = channelx_by_nick(basename($handle)); if($channel) set_pconfig($channel['channel_id'],'openid','associate',$data); - } function getAssoc($handle) @@ -334,10 +308,6 @@ class MysqlProvider extends LightOpenIDProvider } } -$op = new MysqlProvider; -$op->server(); - -} -- cgit v1.2.3 From bc22df9057198018f9cc490d0e3e013692f52b90 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Mar 2015 22:06:03 -0700 Subject: display a map for photos if allowed. Note: there is a bug in that if the map div starts with display:none one needs to reload the frame or zoom in or they end up at minimum resolution. Still trying to sort this out. --- mod/photos.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mod') diff --git a/mod/photos.php b/mod/photos.php index 58a38f3f3..503a113dc 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -843,6 +843,8 @@ function photos_content(&$a) { dbesc($datum) ); + $map = null; + if($linked_items) { xchan_query($linked_items); @@ -882,6 +884,10 @@ function photos_content(&$a) { intval(local_channel()) ); } + + if($link_item['coord']) { + $map = generate_map($link_item['coord']); + } } // logger('mod_photo: link_item' . print_r($link_item,true)); @@ -1115,6 +1121,8 @@ function photos_content(&$a) { '$tags' => $tags, 'responses' => $responses, '$edit' => $edit, + '$map' => $map, + '$map_text' => t('Map'), '$likebuttons' => $likebuttons, '$like' => $like_e, '$dislike' => $dislike_e, -- cgit v1.2.3 From 7af012b1f95fb329c9bf127a60e0a383d853e37d Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Mar 2015 00:13:47 -0700 Subject: The random bad signatures are because something somewhere is trimming the body text. It could be any one of hundreds of functions that touch the message body. We really want to trim the body text, so I'm putting back all the trim statements - in mod/item and item_store and item_store_update. The last fix for random bad sigs noted that one of the trims wasn't there, so the others were removed. The correct fix is for all the trims to be there. We will probably have a few (quite a few) bad sigs during the transition back to trimmed text but this should nail it for anybody on recent code and with new content. --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 8b45f5db9..dad883f50 100644 --- a/mod/item.php +++ b/mod/item.php @@ -385,7 +385,7 @@ function item_post(&$a) { $coord = notags(trim($_REQUEST['coord'])); $verb = notags(trim($_REQUEST['verb'])); $title = escape_tags(trim($_REQUEST['title'])); - $body = $_REQUEST['body']; + $body = trim($_REQUEST['body']); $postopts = ''; $private = ( -- cgit v1.2.3 From 629f6bec74bcc5f1bd6ea40bf020a8107bc54fb0 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Mar 2015 15:45:08 -0700 Subject: ok it has to be owner. --- mod/network.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index d2b9bc64c..0eeeedbe9 100644 --- a/mod/network.php +++ b/mod/network.php @@ -377,7 +377,7 @@ function network_content(&$a, $update = 0, $load = false) { // "New Item View" - show all items unthreaded in reverse created date order $items = q("SELECT item.*, item.id AS item_id, received FROM item - left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) + left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE true $uids AND item_restrict = 0 and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $simple_update @@ -408,7 +408,7 @@ function network_content(&$a, $update = 0, $load = false) { // Fetch a page full of parent items for this page $r = q("SELECT distinct item.id AS item_id, $ordering FROM item - left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) + left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE true $uids AND item.item_restrict = 0 AND item.parent = item.id and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) @@ -422,7 +422,7 @@ function network_content(&$a, $update = 0, $load = false) { if(! $firehose) { // update $r = q("SELECT item.parent AS item_id FROM item - left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) + left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE true $uids AND item.item_restrict = 0 $simple_update and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets ", -- cgit v1.2.3 From 63683734a21e90149c464f7e9b03e7aedc29868e Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 18 Mar 2015 19:06:05 -0700 Subject: make the channel item query match recent changes to network item query (and some slightly older changes in display item query), and allow '@' in linkified urls. --- mod/channel.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 2a0373a81..9df400cbe 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -149,17 +149,19 @@ function channel_content(&$a, $update = 0, $load = false) { $page_mode = 'client'; + $abook_uids = " and abook.abook_channel = " . intval($a->profile['profile_uid']) . " "; + if(($update) && (! $load)) { if ($mid) { - $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0 + $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d AND item_restrict = 0 AND (item_flags & %d) > 0 AND item_unseen = 1 $sql_extra limit 1", - dbesc($mid), + dbesc($mid . '%'), intval($a->profile['profile_uid']), intval(ITEM_WALL) ); } else { $r = q("SELECT distinct parent AS `item_id`, created from item - left join abook on item.author_xchan = abook.abook_xchan + left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE uid = %d AND item_restrict = 0 AND (item_flags & %d) > 0 AND item_unseen = 1 AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) -- cgit v1.2.3 From b1fd6c53a5f86fd752db9c5394cae8f67492f07e Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Mar 2015 15:56:30 -0700 Subject: tweaks to directory registrations which don't seem to be happening, also downgrade any directory that claims to be a primary directory for RED_GLOBAL. --- mod/regdir.php | 4 ++-- mod/zfinger.php | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/regdir.php b/mod/regdir.php index f12659dad..5331c1dd4 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -78,11 +78,11 @@ function regdir_init(&$a) { } else { - // We can put this in the sql without the condition after 31 march 2015 assuming + // We can put this in the sql without the condition after 31 april 2015 assuming // most directory servers will have updated by then // This just makes sure it happens if I forget - $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-03-31')) ? ' and site_valid = 1 ' : '' ); + $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-04-31')) ? ' and site_valid = 1 ' : '' ); if($dirmode == DIRECTORY_MODE_STANDALONE) { $r = array(array('site_url' => z_root())); } diff --git a/mod/zfinger.php b/mod/zfinger.php index f4b7efd96..e236a1e73 100644 --- a/mod/zfinger.php +++ b/mod/zfinger.php @@ -239,11 +239,6 @@ function zfinger_init(&$a) { if(($dirmode === false) || ($dirmode == DIRECTORY_MODE_NORMAL)) $ret['site']['directory_mode'] = 'normal'; - // downgrade mis-configured primaries - - if($dirmode == DIRECTORY_MODE_PRIMARY && z_root() != get_directory_primary()) - $dirmode = DIRECTORY_MODE_SECONDARY; - if($dirmode == DIRECTORY_MODE_PRIMARY) $ret['site']['directory_mode'] = 'primary'; elseif($dirmode == DIRECTORY_MODE_SECONDARY) -- cgit v1.2.3 From 274a30f2dbb31cd0b0987846b64345027aad20d0 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Mar 2015 16:41:41 -0700 Subject: call parse_url from rpost and add the result to the content body if invoked with a url argument --- mod/rpost.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mod') diff --git a/mod/rpost.php b/mod/rpost.php index 2bea18c43..398d2bf0f 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -107,6 +107,11 @@ function rpost_content(&$a) { // )); + if($_REQUEST['url']) { + $x = z_fetch_url(z_root() . '/parse_url?f=&url=' . urlencode($_REQUEST['url'])); + if($x['success']) + $_REQUEST['body'] = $_REQUEST['body'] . $x['body']; + } $x = array( 'is_owner' => true, -- cgit v1.2.3 From 6698d7b03a88533eda8d79581b7e13565d36fa7e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 20 Mar 2015 17:37:01 +0100 Subject: possible improvement regarding deletion --- mod/filestorage.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/filestorage.php b/mod/filestorage.php index 92474f336..07987e4c4 100644 --- a/mod/filestorage.php +++ b/mod/filestorage.php @@ -32,13 +32,15 @@ function filestorage_post(&$a) { $str_contact_allow = perms2str($_REQUEST['contact_allow']); $str_group_deny = perms2str($_REQUEST['group_deny']); $str_contact_deny = perms2str($_REQUEST['contact_deny']); - + + //get the object before permissions change so we can catch eventual former allowed members + $object = get_file_activity_object($channel_id, $resource, $cloudPath); + attach_change_permissions($channel_id, $resource, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, $recurse); //Build directory tree and redirect $channel = $a->get_channel(); $cloudPath = get_parent_cloudpath($channel_id, $channel['channel_address'], $resource); - $object = get_file_activity_object($channel_id, $resource, $cloudPath); file_activity($channel_id, $object, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, 'post', $no_activity); -- cgit v1.2.3 From 9a2ef382679fb7f3cf3f87bc1abaf74835ea273b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 20 Mar 2015 18:04:22 +0100 Subject: need the cloudpath before creating the object --- mod/filestorage.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/filestorage.php b/mod/filestorage.php index 07987e4c4..f2c795379 100644 --- a/mod/filestorage.php +++ b/mod/filestorage.php @@ -33,15 +33,14 @@ function filestorage_post(&$a) { $str_group_deny = perms2str($_REQUEST['group_deny']); $str_contact_deny = perms2str($_REQUEST['contact_deny']); + $channel = $a->get_channel(); + $cloudPath = get_parent_cloudpath($channel_id, $channel['channel_address'], $resource); + //get the object before permissions change so we can catch eventual former allowed members $object = get_file_activity_object($channel_id, $resource, $cloudPath); attach_change_permissions($channel_id, $resource, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, $recurse); - //Build directory tree and redirect - $channel = $a->get_channel(); - $cloudPath = get_parent_cloudpath($channel_id, $channel['channel_address'], $resource); - file_activity($channel_id, $object, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, 'post', $no_activity); goaway($cloudPath); -- cgit v1.2.3 From ead45292e134fa03726912905ca1ca58ccb12fec Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 21 Mar 2015 00:06:18 +0100 Subject: some tabs title statuseditor restructuring --- mod/network.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index 0eeeedbe9..7f8d39044 100644 --- a/mod/network.php +++ b/mod/network.php @@ -119,13 +119,16 @@ function network_content(&$a, $update = 0, $load = false) { if($cid) $def_acl = array('allow_cid' => '<' . intval($cid) . '>'); - if(! $update) { - $o .= network_tabs(); + $tabs = network_tabs(); + $o .= $tabs; // search terms header - if($search) - $o .= '

    ' . t('Search Results For:') . ' ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') . '

    '; + if($search) { + $o .= replace_macros(get_markup_template("section_title.tpl"),array( + '$title' => t('Search Results For:') . ' ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') + )); + } nav_set_selected('network'); @@ -136,7 +139,6 @@ function network_content(&$a, $update = 0, $load = false) { 'deny_gid' => $channel['channel_deny_gid'] ); - $x = array( 'is_owner' => true, 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''), @@ -149,8 +151,8 @@ function network_content(&$a, $update = 0, $load = false) { 'profile_uid' => local_channel() ); - $o .= status_editor($a,$x); - + $status_editor = status_editor($a,$x); + $o .= $status_editor; } @@ -186,9 +188,15 @@ function network_content(&$a, $update = 0, $load = false) { $x = group_rec_byhash(local_channel(), $group_hash); - if($x) - $o = '

    ' . t('Collection: ') . $x['name'] . '

    ' . $o; + if($x) { + $title = replace_macros(get_markup_template("section_title.tpl"),array( + '$title' => t('Collection: ') . $x['name'] + )); + } + $o = $tabs; + $o .= $title; + $o .= $status_editor; } @@ -200,7 +208,12 @@ function network_content(&$a, $update = 0, $load = false) { ); if($r) { $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) and item_restrict = 0 ) "; - $o = '

    ' . t('Connection: ') . $r[0]['xchan_name'] . '

    ' . $o; + $title = replace_macros(get_markup_template("section_title.tpl"),array( + '$title' => t('Connection: ') . $r[0]['xchan_name'] + )); + $o = $tabs; + $o .= $title; + $o .= $status_editor; } else { notice( t('Invalid connection.') . EOL); -- cgit v1.2.3 From 01716dea3d930e6c6b7dd20d5aa6a7fe94db16d1 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 20 Mar 2015 16:46:07 -0700 Subject: config to hide version tag from siteinfo - on my site it's meaningless. --- mod/rpost.php | 12 +----------- mod/siteinfo.php | 3 ++- 2 files changed, 3 insertions(+), 12 deletions(-) (limited to 'mod') diff --git a/mod/rpost.php b/mod/rpost.php index 398d2bf0f..10ae6b8ab 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -17,6 +17,7 @@ require_once('include/zot.php'); * f= placeholder, often required * title= Title of post * body= Body of post + * url= URL which will be parsed and the results appended to the body * source= Source application * remote_return= absolute URL to return after posting is finished * type= choices are 'html' or 'bbcode', default is 'bbcode' @@ -97,16 +98,6 @@ function rpost_content(&$a) { '$title' => t('Edit post') )); - -// $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( -// '$baseurl' => $a->get_baseurl(), -// '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), -// '$ispublic' => ' ', // t('Visible to everybody'), -// '$geotag' => $geotag, -// '$nickname' => $channel['channel_address'] -// )); - - if($_REQUEST['url']) { $x = z_fetch_url(z_root() . '/parse_url?f=&url=' . urlencode($_REQUEST['url'])); if($x['success']) @@ -122,7 +113,6 @@ function rpost_content(&$a) { || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), 'acl' => populate_acl($channel), 'bang' => '', -// 'channel_select' => true, 'visitor' => true, 'profile_uid' => local_channel(), 'title' => $_REQUEST['title'], diff --git a/mod/siteinfo.php b/mod/siteinfo.php index e6798ce50..b69c56ecb 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -54,7 +54,8 @@ function siteinfo_init(&$a) { $version = RED_VERSION; if(@is_dir('.git') && function_exists('shell_exec')) { $commit = trim( @shell_exec('git log -1 --format="%h"')); - $tag = trim( @shell_exec('git describe --tags --abbrev=0')); + if(! get_config('system','hidden_tag_siteinfo')) + $tag = trim( @shell_exec('git describe --tags --abbrev=0')); } if(! isset($commit) || strlen($commit) > 16) $commit = ''; -- cgit v1.2.3 From 96afe7bf425ae5d2096f078358e174b29365c0f2 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 20 Mar 2015 16:49:49 -0700 Subject: set to empty string so it doesn't get mis-handled as a null --- mod/siteinfo.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mod') diff --git a/mod/siteinfo.php b/mod/siteinfo.php index b69c56ecb..2ad9f7cde 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -56,6 +56,8 @@ function siteinfo_init(&$a) { $commit = trim( @shell_exec('git log -1 --format="%h"')); if(! get_config('system','hidden_tag_siteinfo')) $tag = trim( @shell_exec('git describe --tags --abbrev=0')); + else + $tag = ''; } if(! isset($commit) || strlen($commit) > 16) $commit = ''; -- cgit v1.2.3 From 9980645ab8bf061decc36837ceea1dc5ead9f824 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 21 Mar 2015 13:37:55 +0100 Subject: fix acl for if we have an cid in /network and make $bang better visible --- mod/network.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index 7f8d39044..a145aca36 100644 --- a/mod/network.php +++ b/mod/network.php @@ -116,8 +116,21 @@ function network_content(&$a, $update = 0, $load = false) { if(x($_GET,'search') || x($_GET,'file')) $nouveau = true; - if($cid) - $def_acl = array('allow_cid' => '<' . intval($cid) . '>'); + if($cid) { + $r = q("SELECT abook_xchan FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1", + intval($cid), + intval(local_channel()) + ); + if(! $r) { + if($update) { + killme(); + } + notice( t('No such channel') . EOL ); + goaway($a->get_baseurl(true) . '/network'); + // NOTREACHED + } + $def_acl = array('allow_cid' => '<' . $r[0]['abook_xchan'] . '>'); + } if(! $update) { $tabs = network_tabs(); -- cgit v1.2.3 From a2e3ca6fd8ba8c0630de089d772fdd668b84428b Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 21 Mar 2015 16:46:28 -0700 Subject: add loadtime search to channel and fix it for home. display and search need further investigation --- mod/channel.php | 21 +++++++++++++++++++-- mod/display.php | 13 +++++++++++++ mod/home.php | 17 +++++++++++++++-- mod/network.php | 5 ++--- mod/search.php | 4 ++++ 5 files changed, 53 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 9df400cbe..3fc4a9269 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -50,6 +50,11 @@ function channel_init(&$a) { function channel_content(&$a, $update = 0, $load = false) { + + if($load) + $_SESSION['loadtime'] = datetime_convert(); + + $category = $datequery = $datequery2 = ''; $mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : ''); @@ -151,10 +156,19 @@ function channel_content(&$a, $update = 0, $load = false) { $abook_uids = " and abook.abook_channel = " . intval($a->profile['profile_uid']) . " "; + $simple_update = (($update) ? " AND item_unseen = 1 " : ''); + + + if($update && $_SESSION['loadtime']) + $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + if($load) + $simple_update = ''; + + if(($update) && (! $load)) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND item_unseen = 1 $sql_extra limit 1", + AND (item_flags & %d) > 0 $simple_update $sql_extra limit 1", dbesc($mid . '%'), intval($a->profile['profile_uid']), intval(ITEM_WALL) @@ -163,7 +177,7 @@ function channel_content(&$a, $update = 0, $load = false) { $r = q("SELECT distinct parent AS `item_id`, created from item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND item_unseen = 1 + AND (item_flags & %d) > 0 $simple_update AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra ORDER BY created DESC", @@ -254,6 +268,9 @@ function channel_content(&$a, $update = 0, $load = false) { } + + + if((! $update) && (! $load)) { // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, diff --git a/mod/display.php b/mod/display.php index d4a1acc5d..b5daea2de 100644 --- a/mod/display.php +++ b/mod/display.php @@ -5,6 +5,10 @@ function display_content(&$a, $update = 0, $load = false) { // logger("mod-display: update = $update load = $load"); + if($load) + $_SESSION['loadtime'] = datetime_convert(); + + if(intval(get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { notice( t('Public access denied.') . EOL); return; @@ -105,6 +109,15 @@ function display_content(&$a, $update = 0, $load = false) { } + $simple_update = (($update) ? " AND item_unseen = 1 " : ''); + + if($update && $_SESSION['loadtime']) + $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + if($load) + $simple_update = ''; + + + if((! $update) && (! $load)) { diff --git a/mod/home.php b/mod/home.php index 6d5c7db25..c449a0561 100644 --- a/mod/home.php +++ b/mod/home.php @@ -7,6 +7,7 @@ require_once('include/conversation.php'); function home_init(&$a) { $ret = array(); + call_hooks('home_init',$ret); $splash = ((argc() > 1 && argv(1) === 'splash') ? true : false); @@ -35,6 +36,10 @@ function home_content(&$a, $update = 0, $load = false) { $o = ''; + + if($load) + $_SESSION['loadtime'] = datetime_convert(); + if(x($_SESSION,'theme')) unset($_SESSION['theme']); if(x($_SESSION,'mobile_theme')) @@ -192,8 +197,6 @@ function home_content(&$a, $update = 0, $load = false) { if($load) { - $_SESSION['loadtime'] = datetime_convert(); - // Fetch a page full of parent items for this page $r = q("SELECT distinct item.id AS item_id, $ordering FROM item @@ -208,7 +211,17 @@ function home_content(&$a, $update = 0, $load = false) { } + elseif($update) { + $r = q("SELECT distinct item.id AS item_id, $ordering FROM item + left join abook on item.author_xchan = abook.abook_xchan + WHERE true $uids AND item.item_restrict = 0 + AND item.parent = item.id $simple_update + and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) + $sql_extra3 $sql_extra $sql_nets", + intval(ABOOK_FLAG_BLOCKED) + ); + } // Then fetch all the children of the parents that are on this page $parents_str = ''; $update_unseen = ''; diff --git a/mod/network.php b/mod/network.php index 7f8d39044..ecbeb4085 100644 --- a/mod/network.php +++ b/mod/network.php @@ -27,12 +27,13 @@ function network_init(&$a) { function network_content(&$a, $update = 0, $load = false) { - if(! local_channel()) { $_SESSION['return_url'] = $a->query_string; return login(false); } + if($load) + $_SESSION['loadtime'] = datetime_convert(); $arr = array('query' => $a->query_string); @@ -416,8 +417,6 @@ function network_content(&$a, $update = 0, $load = false) { if($load) { - $_SESSION['loadtime'] = datetime_convert(); - // Fetch a page full of parent items for this page $r = q("SELECT distinct item.id AS item_id, $ordering FROM item diff --git a/mod/search.php b/mod/search.php index 02b250bbe..4d66086f8 100644 --- a/mod/search.php +++ b/mod/search.php @@ -14,6 +14,10 @@ function search_content(&$a,$update = 0, $load = false) { return; } } + + if($load) + $_SESSION['loadtime'] = datetime_convert(); + nav_set_selected('search'); require_once("include/bbcode.php"); -- cgit v1.2.3 From 1b17b0193ec08936b5485216ba6bbe9a46ede187 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 21 Mar 2015 17:14:12 -0700 Subject: fix multiple vote issues --- mod/like.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/like.php b/mod/like.php index 47251935a..dc4531fbb 100755 --- a/mod/like.php +++ b/mod/like.php @@ -303,7 +303,6 @@ function like_content(&$a) { $multi_undo = 1; } - $r = q("SELECT id FROM item WHERE verb in ( $verbs ) AND item_restrict = 0 AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ", dbesc($observer['xchan_hash']), @@ -316,10 +315,12 @@ function like_content(&$a) { // already liked it. Drop that item. require_once('include/items.php'); foreach($r as $rr) { - drop_item($rr['id'],true,DROPITEM_PHASE1); + drop_item($rr['id'],false,DROPITEM_PHASE1); } + if($interactive) return; + if(! $multi_undo) killme(); } -- cgit v1.2.3 From e345d6793d5f6910dd230f661ca5d1a837b1b504 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 22 Mar 2015 16:29:57 +0100 Subject: move the maintenance part to include/sharedwithme.php --- mod/sharedwithme.php | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'mod') diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php index d91987027..b77c9dad1 100644 --- a/mod/sharedwithme.php +++ b/mod/sharedwithme.php @@ -12,33 +12,9 @@ function sharedwithme_content(&$a) { $is_owner = (local_channel() && (local_channel() == $channel['channel_id'])); - //maintenance - see if a file got dropped and remove it systemwide - this should possibly go to include/poller - $x = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d", - dbesc(ACTIVITY_UPDATE), - dbesc(ACTIVITY_OBJ_FILE), - intval(local_channel()) - ); - - if($x) { - - foreach($x as $xx) { - - $object = json_decode($xx['object'],true); - - $d_mid = $object['d_mid']; - $u_mid = $xx['mid']; - - $y = q("DELETE FROM item WHERE obj_type = '%s' AND (verb = '%s' AND mid = '%s') OR (verb = '%s' AND mid = '%s')", - dbesc(ACTIVITY_OBJ_FILE), - dbesc(ACTIVITY_POST), - dbesc($d_mid), - dbesc(ACTIVITY_UPDATE), - dbesc($u_mid) - ); - - } - - } + //check for updated items and remove them + require_once('include/sharedwithme.php'); + apply_updates(); //drop single file - localuser if((argc() > 2) && (argv(2) === 'drop')) { -- cgit v1.2.3 From 6631540d20068d3c4ee221518e8f430507662e27 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Mar 2015 12:55:13 -0700 Subject: provide visual feedback when deleting a like by liking it again. --- mod/channel.php | 5 ++--- mod/home.php | 3 ++- mod/like.php | 8 +++++++- mod/network.php | 5 +++-- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 3fc4a9269..16aac2e51 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -158,13 +158,11 @@ function channel_content(&$a, $update = 0, $load = false) { $simple_update = (($update) ? " AND item_unseen = 1 " : ''); - if($update && $_SESSION['loadtime']) - $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + $simple_update = " AND ( item_unseen = 1 or item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; - if(($update) && (! $load)) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d AND item_restrict = 0 @@ -185,6 +183,7 @@ function channel_content(&$a, $update = 0, $load = false) { intval(ITEM_WALL), intval(ABOOK_FLAG_BLOCKED) ); + $_SESSION['loadtime'] = datetime_convert(); } } diff --git a/mod/home.php b/mod/home.php index c449a0561..9b2cc0e6d 100644 --- a/mod/home.php +++ b/mod/home.php @@ -185,7 +185,7 @@ function home_content(&$a, $update = 0, $load = false) { $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); if($update && $_SESSION['loadtime']) - $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + $simple_update = " AND ( item_unseen = 1 or item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; @@ -221,6 +221,7 @@ function home_content(&$a, $update = 0, $load = false) { $sql_extra3 $sql_extra $sql_nets", intval(ABOOK_FLAG_BLOCKED) ); + $_SESSION['loadtime'] = datetime_convert(); } // Then fetch all the children of the parents that are on this page $parents_str = ''; diff --git a/mod/like.php b/mod/like.php index dc4531fbb..cfd848636 100755 --- a/mod/like.php +++ b/mod/like.php @@ -303,7 +303,7 @@ function like_content(&$a) { $multi_undo = 1; } - $r = q("SELECT id FROM item WHERE verb in ( $verbs ) AND item_restrict = 0 + $r = q("SELECT id, parent, uid FROM item WHERE verb in ( $verbs ) AND item_restrict = 0 AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ", dbesc($observer['xchan_hash']), intval($item_id), @@ -316,6 +316,12 @@ function like_content(&$a) { require_once('include/items.php'); foreach($r as $rr) { drop_item($rr['id'],false,DROPITEM_PHASE1); + // set the changed timestamp on the parent so we'll see the update without a page reload + $z = q("update item set changed = '%s' where id = %d and uid = %d", + dbesc(datetime_convert()), + intval($rr['parent']), + intval($rr['uid']) + ); } if($interactive) diff --git a/mod/network.php b/mod/network.php index f71a7569a..0cf535769 100644 --- a/mod/network.php +++ b/mod/network.php @@ -396,7 +396,7 @@ function network_content(&$a, $update = 0, $load = false) { // which are both ITEM_UNSEEN and have "changed" since that time. Cross fingers... if($update && $_SESSION['loadtime']) - $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + $simple_update = " AND ( item_unseen = 1 or item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; @@ -445,7 +445,7 @@ function network_content(&$a, $update = 0, $load = false) { } else { if(! $firehose) { - // update + // this is an update $r = q("SELECT item.parent AS item_id FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE true $uids AND item.item_restrict = 0 $simple_update @@ -453,6 +453,7 @@ function network_content(&$a, $update = 0, $load = false) { $sql_extra3 $sql_extra $sql_nets ", intval(ABOOK_FLAG_BLOCKED) ); + $_SESSION['loadtime'] = datetime_convert(); } } -- cgit v1.2.3 From f5f194c92bf0992b3a24e7b62cf6f9556a6335c4 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Mar 2015 14:55:41 -0700 Subject: allow complete undo of a vote, not just a change of vote --- mod/like.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/like.php b/mod/like.php index cfd848636..d3b6f3ecf 100755 --- a/mod/like.php +++ b/mod/like.php @@ -303,7 +303,7 @@ function like_content(&$a) { $multi_undo = 1; } - $r = q("SELECT id, parent, uid FROM item WHERE verb in ( $verbs ) AND item_restrict = 0 + $r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) AND item_restrict = 0 AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ", dbesc($observer['xchan_hash']), intval($item_id), @@ -322,6 +322,10 @@ function like_content(&$a) { intval($rr['parent']), intval($rr['uid']) ); + // Prior activity was a duplicate of the one we're submitting, just undo it; + // don't fall through and create another + if(activity_match($rr['verb'],$activity)) + $multi_undo = false; } if($interactive) -- cgit v1.2.3 From 2bd19e6b51ff7331c04f23c0ab78f1e16b5a054e Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Mar 2015 15:00:41 -0700 Subject: $simple_update isn't so simple any more. Make sure we don't re-itnroduce the bug that session['loadtime'] was created to fix. It's questionable whether we still need to even look for item_unseen but I won't make that call today. We can also eliminate the restriction on not doing live updates from the discover tab since we aren't relying completely on item_unseen (which can only be set by the owner and won't work on a page with virtual owners). --- mod/channel.php | 2 +- mod/home.php | 2 +- mod/network.php | 22 ++++++++++------------ 3 files changed, 12 insertions(+), 14 deletions(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 16aac2e51..022def2a8 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -159,7 +159,7 @@ function channel_content(&$a, $update = 0, $load = false) { $simple_update = (($update) ? " AND item_unseen = 1 " : ''); if($update && $_SESSION['loadtime']) - $simple_update = " AND ( item_unseen = 1 or item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; + $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; diff --git a/mod/home.php b/mod/home.php index 9b2cc0e6d..f4358da5c 100644 --- a/mod/home.php +++ b/mod/home.php @@ -185,7 +185,7 @@ function home_content(&$a, $update = 0, $load = false) { $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); if($update && $_SESSION['loadtime']) - $simple_update = " AND ( item_unseen = 1 or item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; + $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; diff --git a/mod/network.php b/mod/network.php index 0cf535769..8db3bfd58 100644 --- a/mod/network.php +++ b/mod/network.php @@ -396,7 +396,7 @@ function network_content(&$a, $update = 0, $load = false) { // which are both ITEM_UNSEEN and have "changed" since that time. Cross fingers... if($update && $_SESSION['loadtime']) - $simple_update = " AND ( item_unseen = 1 or item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; + $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; @@ -444,17 +444,15 @@ function network_content(&$a, $update = 0, $load = false) { } else { - if(! $firehose) { - // this is an update - $r = q("SELECT item.parent AS item_id FROM item - left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) - WHERE true $uids AND item.item_restrict = 0 $simple_update - and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets ", - intval(ABOOK_FLAG_BLOCKED) - ); - $_SESSION['loadtime'] = datetime_convert(); - } + // this is an update + $r = q("SELECT item.parent AS item_id FROM item + left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) + WHERE true $uids AND item.item_restrict = 0 $simple_update + and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) + $sql_extra3 $sql_extra $sql_nets ", + intval(ABOOK_FLAG_BLOCKED) + ); + $_SESSION['loadtime'] = datetime_convert(); } // Then fetch all the children of the parents that are on this page -- cgit v1.2.3 From 62b2fa6ac7ee85c8572eb868eb30dc2e20cf3040 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Mar 2015 20:30:23 -0700 Subject: operation snakebite, cont. --- mod/item.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index dad883f50..6644be291 100644 --- a/mod/item.php +++ b/mod/item.php @@ -35,6 +35,23 @@ function item_post(&$a) { $channel = null; $observer = null; + + /** + * Is this a reply to something? + */ + + $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0); + $parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : ''); + + $remote_xchan = ((x($_REQUEST,'remote_xchan')) ? trim($_REQUEST['remote_xchan']) : false); + $r = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($remote_xchan) + ); + if($r) + $remote_observer = $r[0]; + else + $remote_xchan = $remote_observer = false; + $profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0); require_once('include/identity.php'); $sys = get_sys_channel(); @@ -116,13 +133,6 @@ function item_post(&$a) { $item_flags = $item_restrict = 0; - /** - * Is this a reply to something? - */ - - $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; @@ -275,6 +285,9 @@ function item_post(&$a) { $walltowall = false; $walltowall_comment = false; + if($remote_xchan) + $observer = $remote_observer; + if($observer) { logger('mod_item: post accepted from ' . $observer['xchan_name'] . ' for ' . $owner_xchan['xchan_name'], LOGGER_DEBUG); -- cgit v1.2.3 From d6ad74c649c411190ac7a910888ef426ab14ad55 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 23 Mar 2015 10:59:54 +0100 Subject: indicate new or updated items --- mod/sharedwithme.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php index b77c9dad1..8874a7898 100644 --- a/mod/sharedwithme.php +++ b/mod/sharedwithme.php @@ -42,7 +42,7 @@ function sharedwithme_content(&$a) { } //list files - $r = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'", + $r = q("SELECT id, uid, object, item_unseen FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'", dbesc(ACTIVITY_POST), dbesc(ACTIVITY_OBJ_FILE), intval(local_channel()), @@ -50,8 +50,10 @@ function sharedwithme_content(&$a) { ); $items =array(); + $ids = ''; if($r) { + foreach($r as $rr) { $object = json_decode($rr['object'],true); @@ -63,10 +65,27 @@ function sharedwithme_content(&$a) { $item['objfilename'] = $object['filename']; $item['objfilesize'] = userReadableSize($object['filesize']); $item['objedited'] = $object['edited']; + $item['unseen'] = $rr['item_unseen']; $items[] = $item; + if($item['unseen'] > 0) { + $ids .= " '" . $rr['id'] . "',"; + } + } + + } + + if($ids) { + + //remove trailing , + $ids = rtrim($ids, ","); + + q("UPDATE item SET item_unseen = 0 WHERE id in ( $ids ) AND uid = %d", + intval(local_channel()) + ); + } $o = profile_tabs($a, $is_owner, $channel['channel_address']); @@ -74,6 +93,7 @@ function sharedwithme_content(&$a) { $o .= replace_macros(get_markup_template('sharedwithme.tpl'), array( '$header' => t('Files: shared with me'), '$name' => t('Name'), + '$label_new' => t('NEW'), '$size' => t('Size'), '$lastmod' => t('Last Modified'), '$dropall' => t('Remove all files'), -- cgit v1.2.3 From dd930f180ebb1983dd634fcf0d14369797425b55 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 23 Mar 2015 11:06:13 +0100 Subject: sql in -> IN --- mod/sharedwithme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php index 8874a7898..bee072ea7 100644 --- a/mod/sharedwithme.php +++ b/mod/sharedwithme.php @@ -82,7 +82,7 @@ function sharedwithme_content(&$a) { //remove trailing , $ids = rtrim($ids, ","); - q("UPDATE item SET item_unseen = 0 WHERE id in ( $ids ) AND uid = %d", + q("UPDATE item SET item_unseen = 0 WHERE id IN ( $ids ) AND uid = %d", intval(local_channel()) ); -- cgit v1.2.3 From f2127d4ba717484140530e17eb8ae495cab349d7 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 23 Mar 2015 15:36:17 -0700 Subject: limit notification detail queries for items and events --- mod/ping.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/ping.php b/mod/ping.php index 001c5594d..b676726fe 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -274,7 +274,7 @@ function ping_init(&$a) { $r = q("SELECT * FROM item WHERE item_restrict = 0 and item_unseen = 1 and uid = %d - and author_xchan != '%s' ORDER BY created DESC", + and author_xchan != '%s' ORDER BY created DESC limit 300", intval(local_channel()), dbesc($ob_hash) ); @@ -295,7 +295,7 @@ function ping_init(&$a) { if(argc() > 1 && (argv(1) === 'intros')) { $result = array(); - $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0) ORDER BY abook_created DESC", + $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0) ORDER BY abook_created DESC LIMIT 50", intval(local_channel()), intval(ABOOK_FLAG_PENDING), intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED), @@ -327,7 +327,7 @@ function ping_init(&$a) { $r = q("SELECT * FROM event left join xchan on event_xchan = xchan_hash WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0 - ORDER BY `start` DESC ", + ORDER BY `start` DESC LIMIT 1000", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) -- cgit v1.2.3 From c2acab21d44bfaa8e051a42a13b72c056c95b0a3 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 23 Mar 2015 19:56:10 -0700 Subject: improve performance of the zotfeed queries --- mod/zotfeed.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/zotfeed.php b/mod/zotfeed.php index 7bf91d4db..78a667330 100644 --- a/mod/zotfeed.php +++ b/mod/zotfeed.php @@ -9,7 +9,7 @@ function zotfeed_init(&$a) { $mindate = (($_REQUEST['mindate']) ? datetime_convert('UTC','UTC',$_REQUEST['mindate']) : ''); if(! $mindate) - $mindate = datetime_convert('UTC','UTC', 'now - 1 month'); + $mindate = datetime_convert('UTC','UTC', 'now - 4 days'); if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) { $result['message'] = 'Public access denied'; @@ -21,7 +21,7 @@ function zotfeed_init(&$a) { $channel_address = ((argc() > 1) ? argv(1) : ''); if($channel_address) { - $r = q("select channel_id, channel_name from channel where channel_address = '%s' and not (channel_pageflags & %d)>0 limit 1", + $r = q("select channel_id, channel_name from channel where channel_address = '%s' and not (channel_pageflags & %d) > 0 limit 1", dbesc(argv(1)), intval(PAGE_REMOVED) ); @@ -30,6 +30,7 @@ function zotfeed_init(&$a) { $x = get_sys_channel(); if($x) $r = array($x); + $mindate = datetime_convert('UTC','UTC', 'now - 2 days'); } if(! $r) { $result['message'] = 'Channel not found.'; -- cgit v1.2.3 From 022305fe8383be238a442efdbd5ba3463d15b7ab Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 24 Mar 2015 20:38:53 -0700 Subject: also allow service classes to set post expiration. These take priority over the site default. --- mod/siteinfo.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/siteinfo.php b/mod/siteinfo.php index 2ad9f7cde..ab6891e25 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -72,6 +72,8 @@ function siteinfo_init(&$a) { $channels_active_monthly_stat = intval(get_config('system','channels_active_monthly_stat')); $local_posts_stat = intval(get_config('system','local_posts_stat')); $hide_in_statistics = intval(get_config('system','hide_in_statistics')); + $site_expire = intval(get_config('system', 'default_expire_days')); + $data = Array( 'version' => $version, @@ -84,6 +86,7 @@ function siteinfo_init(&$a) { 'language' => get_config('system','language'), 'diaspora_emulation' => get_config('system','diaspora_enabled'), 'rss_connections' => get_config('system','feed_contacts'), + 'expiration' => $site_expire, 'default_service_restrictions' => $service_class, 'admin' => $admin, 'site_name' => (($site_name) ? $site_name : ''), @@ -150,7 +153,7 @@ function siteinfo_content(&$a) { $o = replace_macros(get_markup_template('siteinfo.tpl'), array( '$title' => t('Red'), - '$description' => t('This is a hub of the Red Matrix - a global cooperative network of decentralized privacy enhanced websites.'), + '$description' => t('This is a hub of redmatrix - a global cooperative network of decentralized privacy enhanced websites.'), '$version' => $version, '$tag_txt' => t('Tag: '), '$tag' => $tag, @@ -158,7 +161,7 @@ function siteinfo_content(&$a) { '$lastpoll' => get_poller_runtime(), '$commit' => $commit, '$web_location' => t('Running at web location') . ' ' . z_root(), - '$visit' => t('Please visit RedMatrix.me to learn more about the Red Matrix.'), + '$visit' => t('Please visit redmatrix.me to learn more about the Red Matrix.'), '$bug_text' => t('Bug reports and issues: please visit'), '$bug_link_url' => 'https://github.com/friendica/red/issues', '$bug_link_text' => 'redmatrix issues', -- cgit v1.2.3 From 75f3f4a80868bf3b60c4b21d2492d5da59c0d502 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 25 Mar 2015 17:43:02 -0700 Subject: admin config for default expiration --- mod/admin.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index e991fee27..a48d984e0 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -277,15 +277,16 @@ function admin_page_site_post(&$a){ $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : ''); - $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); - $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : ''); - $not_allowed_email = ((x($_POST,'not_allowed_email')) ? notags(trim($_POST['not_allowed_email'])) : ''); - $block_public = ((x($_POST,'block_public')) ? True : False); - $force_publish = ((x($_POST,'publish_all')) ? True : False); - $disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? True : False); - $no_login_on_homepage = ((x($_POST,'no_login_on_homepage')) ? True : False); - $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); - $no_community_page = !((x($_POST,'no_community_page')) ? True : False); + $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); + $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : ''); + $not_allowed_email = ((x($_POST,'not_allowed_email')) ? notags(trim($_POST['not_allowed_email'])) : ''); + $block_public = ((x($_POST,'block_public')) ? True : False); + $force_publish = ((x($_POST,'publish_all')) ? True : False); + $disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? True : False); + $no_login_on_homepage = ((x($_POST,'no_login_on_homepage')) ? True : False); + $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); + $no_community_page = !((x($_POST,'no_community_page')) ? True : False); + $default_expire_days = ((array_key_exists('default_expire_days',$_POST)) ? intval($_POST['default_expire_days']) : 0); $verifyssl = ((x($_POST,'verifyssl')) ? True : False); $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : ''); @@ -306,6 +307,7 @@ function admin_page_site_post(&$a){ set_config('system', 'sitename', $sitename); set_config('system', 'no_login_on_homepage', $no_login_on_homepage); set_config('system', 'verify_email', $verify_email); + set_config('system','default_expire_days', $default_expire_days); if ($banner == '') { del_config('system', 'banner'); @@ -475,6 +477,7 @@ function admin_page_site(&$a) { '$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")), '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), + '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported content'), intval(get_config('system','default_expire_days')), t('0 for no expiration of imported content')), '$form_security_token' => get_form_security_token("admin_site"), )); -- cgit v1.2.3 From 296c4c38bc89f9d756292542554d6092094ad7d0 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 25 Mar 2015 17:46:38 -0700 Subject: improve description of that setting --- mod/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index a48d984e0..7182bb9e5 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -477,7 +477,7 @@ function admin_page_site(&$a) { '$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")), '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), - '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported content'), intval(get_config('system','default_expire_days')), t('0 for no expiration of imported content')), + '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported (matrix/network) content'), intval(get_config('system','default_expire_days')), t('0 for no expiration of imported content')), '$form_security_token' => get_form_security_token("admin_site"), )); -- cgit v1.2.3 From f1a16607095e0ebbd8ce2201a2f087557b39f282 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 25 Mar 2015 19:13:53 -0700 Subject: item_check_service_class - the join is totally unnecessary --- mod/item.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 6644be291..8aa3d8136 100644 --- a/mod/item.php +++ b/mod/item.php @@ -1071,37 +1071,37 @@ function fix_attached_file_permissions($channel,$observer_hash,$body, function item_check_service_class($channel_id,$iswebpage) { $ret = array('success' => false, $message => ''); + if ($iswebpage) { - $r = q("select count(i.id) as total from item i - right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id ) - and i.parent=i.id and (i.item_restrict & %d)>0 and not (i.item_restrict & %d)>0 and i.uid= %d ", + $r = q("select count(id) as total from item where parent = id + and ( item_restrict & %d ) > 0 and ( item_restrict & %d ) = 0 and uid = %d ", intval(ITEM_WEBPAGE), intval(ITEM_DELETED), - intval($channel_id) - ); + intval($channel_id) + ); } else { - $r = q("select count(i.id) as total from item i - right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id ) - and i.parent=i.id and (i.item_restrict=0) and i.uid= %d ", - intval($channel_id) - ); + $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and uid = %d ", + intval($channel_id) + ); } - if(! ($r && count($r))) { - $ret['message'] = t('Unable to obtain identity information from database'); + + if(! $r) { + $ret['message'] = t('Unable to obtain post information from database.'); return $ret; } + if (!$iswebpage) { - if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) { - $result['message'] .= upgrade_message().sprintf(t("You have reached your limit of %1$.0f top level posts."),$r[0]['total']); - return $result; - } + if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) { + $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f top level posts.'),$r[0]['total']); + return $result; + } } else { - if(! service_class_allows($channel_id,'total_pages',$r[0]['total'])) { - $result['message'] .= upgrade_message().sprintf(t("You have reached your limit of %1$.0f webpages."),$r[0]['total']); - return $result; - } + if(! service_class_allows($channel_id,'total_pages',$r[0]['total'])) { + $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f webpages.'),$r[0]['total']); + return $result; + } } $ret['success'] = true; -- cgit v1.2.3 From 47292c612c5a2a6d3819ca3c415fa2d99ab2ee7f Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 26 Mar 2015 18:03:39 -0700 Subject: provide ways to over-ride the datetime pickers --- mod/events.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 010f1f7c4..289ddfb15 100755 --- a/mod/events.php +++ b/mod/events.php @@ -548,12 +548,14 @@ function events_content(&$a) { if(! x($orig_event)) $sh_checked = ''; else - $sh_checked = (($orig_event['allow_cid'] === '<' . $channel['channel_hash'] . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' ); + $sh_checked = ((($orig_event['allow_cid'] === '<' . $channel['channel_hash'] . '>' || (! $orig_event['allow_cid'])) && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' ); if($orig_event['event_xchan']) $sh_checked .= ' disabled="disabled" '; + + $sdt = ((x($orig_event)) ? $orig_event['start'] : 'now'); $fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now'); -- cgit v1.2.3 From 0bb89778d382fc5758354c6986130ce1ddba7d4c Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 26 Mar 2015 19:55:52 -0700 Subject: add channel_lastpost timestamp to help optimise some outrageously expensive queries. --- mod/item.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 8aa3d8136..fa40aea03 100644 --- a/mod/item.php +++ b/mod/item.php @@ -860,6 +860,13 @@ function item_post(&$a) { 'otype' => 'item' )); } + + if($uid && $uid == $profile_uid && (! $datarray['item_restrict'])) { + q("update channel set channel_lastpost = '%s' where channel_id = %d", + dbesc(datetime_convert()), + intval($uid) + ); + } } // photo comments turn the corresponding item visible to the profile wall -- cgit v1.2.3 From d0361582b0b620064aff90bf88f01d1072b308fe Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sun, 22 Mar 2015 00:06:08 +0100 Subject: Correcting reported Doxygen syntax warnings. Fixed wrong Doxygen syntax and add some of the available FIXME to Doxygen documentation. Updated Doxygen configuration to add also all capital letter tags. Adding some more Doxygen documentation. --- mod/admin.php | 74 ++++---- mod/id.php | 231 ++++++++++++------------ mod/match.php | 51 +++--- mod/post.php | 529 +++++++++++++++++++++++++++---------------------------- mod/randprof.php | 3 +- mod/regdir.php | 45 +++-- mod/share.php | 20 +-- mod/thing.php | 43 ++--- 8 files changed, 477 insertions(+), 519 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 7182bb9e5..fd2ba510b 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -73,7 +73,7 @@ function admin_post(&$a){ } /** - * @param App $$a + * @param App &$a * @return string */ function admin_content(&$a) { @@ -84,7 +84,7 @@ function admin_content(&$a) { return login(false); } - /** + /* * Side bar links */ @@ -125,7 +125,7 @@ function admin_content(&$a) { )); - /** + /* * Page content */ $o = ''; @@ -183,7 +183,7 @@ function admin_content(&$a) { /** * @brief Returns content for Admin Summary Page. * - * @param App $$a + * @param App &$a * @return string HTML from parsed admin_summary.tpl */ function admin_page_summary(&$a) { @@ -252,8 +252,9 @@ function admin_page_summary(&$a) { /** - * Admin Site Page - * @param App $a + * @brief POST handler for Admin Site Page. + * + * @param App &$a */ function admin_page_site_post(&$a){ if (!x($_POST, 'page_site')){ @@ -277,15 +278,15 @@ function admin_page_site_post(&$a){ $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : ''); - $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); - $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : ''); - $not_allowed_email = ((x($_POST,'not_allowed_email')) ? notags(trim($_POST['not_allowed_email'])) : ''); - $block_public = ((x($_POST,'block_public')) ? True : False); - $force_publish = ((x($_POST,'publish_all')) ? True : False); - $disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? True : False); - $no_login_on_homepage = ((x($_POST,'no_login_on_homepage')) ? True : False); - $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); - $no_community_page = !((x($_POST,'no_community_page')) ? True : False); + $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); + $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : ''); + $not_allowed_email = ((x($_POST,'not_allowed_email')) ? notags(trim($_POST['not_allowed_email'])) : ''); + $block_public = ((x($_POST,'block_public')) ? True : False); + $force_publish = ((x($_POST,'publish_all')) ? True : False); + $disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? True : False); + $no_login_on_homepage = ((x($_POST,'no_login_on_homepage')) ? True : False); + $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); + $no_community_page = !((x($_POST,'no_community_page')) ? True : False); $default_expire_days = ((array_key_exists('default_expire_days',$_POST)) ? intval($_POST['default_expire_days']) : 0); $verifyssl = ((x($_POST,'verifyssl')) ? True : False); @@ -307,7 +308,7 @@ function admin_page_site_post(&$a){ set_config('system', 'sitename', $sitename); set_config('system', 'no_login_on_homepage', $no_login_on_homepage); set_config('system', 'verify_email', $verify_email); - set_config('system','default_expire_days', $default_expire_days); + set_config('system', 'default_expire_days', $default_expire_days); if ($banner == '') { del_config('system', 'banner'); @@ -360,6 +361,8 @@ function admin_page_site_post(&$a){ } /** + * @brief Admin page site. + * * @param App $a * @return string */ @@ -480,8 +483,8 @@ function admin_page_site(&$a) { '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported (matrix/network) content'), intval(get_config('system','default_expire_days')), t('0 for no expiration of imported content')), '$form_security_token' => get_form_security_token("admin_site"), )); - } + function admin_page_hubloc_post(&$a){ check_form_security_token_redirectOnErr('/admin/hubloc', 'admin_hubloc'); require_once('include/zot.php'); @@ -617,7 +620,6 @@ function admin_page_queue($a) { ); } - $r = q("select count(outq_posturl) as total, max(outq_priority) as priority, outq_posturl from outq where outq_delivered = 0 group by outq_posturl order by total desc"); @@ -626,7 +628,6 @@ function admin_page_queue($a) { $r[$x]['connected'] = datetime_convert('UTC',date_default_timezone_get(),$r[$x]['connected'],'Y-m-d'); } - $o = replace_macros(get_markup_template('admin_queue.tpl'), array( '$banner' => t('Queue Statistics'), '$numentries' => t('Total Entries'), @@ -763,13 +764,11 @@ function admin_page_users(&$a){ } -// WEe'll still need to link email addresses to admin/users/channels or some such, but this bit doesn't exist yet. +// We'll still need to link email addresses to admin/users/channels or some such, but this bit doesn't exist yet. // That's where we need to be doing last post/channel flags/etc, not here. - $serviceclass = (($_REQUEST['class']) ? " and account_service_class = '" . dbesc($_REQUEST['class']) . "' " : ''); - $order = " order by account_email asc "; if($_REQUEST['order'] === 'expires') $order = " order by account_expires desc "; @@ -803,7 +802,6 @@ function admin_page_users(&$a){ // } // $users = array_map("_setup_users", $users); - $t = get_markup_template('admin_users.tpl'); $o = replace_macros($t, array( // strings // @@ -841,9 +839,9 @@ function admin_page_users(&$a){ /** - * Channels admin page + * @brief Channels admin page. * - * @param App $a + * @param App &$a */ function admin_page_channels_post(&$a) { $channels = ( x($_POST, 'channel') ? $_POST['channel'] : Array() ); @@ -872,7 +870,9 @@ function admin_page_channels_post(&$a) { } /** - * @param App $a + * @brief + * + * @param App &$a * @return string */ function admin_page_channels(&$a){ @@ -975,7 +975,7 @@ function admin_page_channels(&$a){ */ function admin_page_plugins(&$a){ - /** + /* * Single plugin */ if ($a->argc == 3){ @@ -1055,7 +1055,7 @@ function admin_page_plugins(&$a){ } - /** + /* * List plugins */ $plugins = array(); @@ -1087,7 +1087,7 @@ function admin_page_plugins(&$a){ * @param string $th * @param int $result */ -function toggle_theme(&$themes,$th,&$result) { +function toggle_theme(&$themes, $th, &$result) { for($x = 0; $x < count($themes); $x ++) { if($themes[$x]['name'] === $th) { if($themes[$x]['allowed']) { @@ -1142,9 +1142,9 @@ function rebuild_theme_table($themes) { /** - * Themes admin page + * @brief Themes admin page. * - * @param App $a + * @param App &$a * @return string */ function admin_page_themes(&$a){ @@ -1174,7 +1174,7 @@ function admin_page_themes(&$a){ return ''; } - /** + /* * Single theme */ @@ -1253,8 +1253,7 @@ function admin_page_themes(&$a){ )); } - - /** + /* * List themes */ @@ -1281,9 +1280,9 @@ function admin_page_themes(&$a){ /** - * Logs admin page + * @brief POST handler for logs admin page. * - * @param App $a + * @param App &$a */ function admin_page_logs_post(&$a) { if (x($_POST, 'page_logs')) { @@ -1303,6 +1302,8 @@ function admin_page_logs_post(&$a) { } /** + * @brief Logs admin page. + * * @param App $a * @return string */ @@ -1435,5 +1436,4 @@ function admin_page_profs(&$a) { '$submit' => t('Save') )); } - } \ No newline at end of file diff --git a/mod/id.php b/mod/id.php index 05a2f3dc5..bd4c1fa89 100644 --- a/mod/id.php +++ b/mod/id.php @@ -1,45 +1,51 @@ t('First Name'), - 'namePerson/last' => t('Last Name'), - 'namePerson/friendly' => t('Nickname'), - 'namePerson' => t('Full Name'), - 'contact/internet/email' => t('Email'), - 'contact/email' => t('Email'), - 'media/image/aspect11' => t('Profile Photo'), - 'media/image' => t('Profile Photo'), - 'media/image/default' => t('Profile Photo'), - 'media/image/16x16' => t('Profile Photo 16px'), - 'media/image/32x32' => t('Profile Photo 32px'), - 'media/image/48x48' => t('Profile Photo 48px'), - 'media/image/64x64' => t('Profile Photo 64px'), - 'media/image/80x80' => t('Profile Photo 80px'), - 'media/image/128x128' => t('Profile Photo 128px'), - 'timezone' => t('Timezone'), - 'contact/web/default' => t('Homepage URL'), - 'language/pref' => t('Language'), - 'birthDate/birthYear' => t('Birth Year'), - 'birthDate/birthMonth' => t('Birth Month'), - 'birthDate/birthday' => t('Birth Day'), - 'birthDate' => t('Birthdate'), - 'gender' => t('Gender'), - ); - - - +/** + * @file mod/id.php + * @brief OpenID implementation + */ + +require 'library/openid/provider/provider.php'; + + +$attrMap = array( + 'namePerson/first' => t('First Name'), + 'namePerson/last' => t('Last Name'), + 'namePerson/friendly' => t('Nickname'), + 'namePerson' => t('Full Name'), + 'contact/internet/email' => t('Email'), + 'contact/email' => t('Email'), + 'media/image/aspect11' => t('Profile Photo'), + 'media/image' => t('Profile Photo'), + 'media/image/default' => t('Profile Photo'), + 'media/image/16x16' => t('Profile Photo 16px'), + 'media/image/32x32' => t('Profile Photo 32px'), + 'media/image/48x48' => t('Profile Photo 48px'), + 'media/image/64x64' => t('Profile Photo 64px'), + 'media/image/80x80' => t('Profile Photo 80px'), + 'media/image/128x128' => t('Profile Photo 128px'), + 'timezone' => t('Timezone'), + 'contact/web/default' => t('Homepage URL'), + 'language/pref' => t('Language'), + 'birthDate/birthYear' => t('Birth Year'), + 'birthDate/birthMonth' => t('Birth Month'), + 'birthDate/birthday' => t('Birth Day'), + 'birthDate' => t('Birthdate'), + 'gender' => t('Gender'), +); + + +/** + * @brief Entrypoint for the OpenID implementation. + * + * @param App &$a + */ function id_init(&$a) { - logger('id: ' . print_r($_REQUEST,true)); - + logger('id: ' . print_r($_REQUEST, true)); - if(argc() > 1) + if(argc() > 1) { $which = argv(1); - else { + } else { $a->error = 404; return; } @@ -48,41 +54,45 @@ function id_init(&$a) { $channel = $a->get_channel(); profile_load($a,$which,$profile); - - $op = new MysqlProvider; $op->server(); - } - -function getUserData($handle=null) { - if(! local_channel()) { +/** + * @brief Returns user data needed for OpenID. + * + * If no $handle is provided we will use local_channel() by default. + * + * @param string $handle (default null) + * @return boolean|array + */ +function getUserData($handle = null) { + if (! local_channel()) { notice( t('Permission denied.') . EOL); get_app()->page['content'] = login(); + return false; } // logger('handle: ' . $handle); - if($handle) { + if ($handle) { $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1", dbesc($handle) ); - } - else { + } else { $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d", intval(local_channel()) ); } - if(! r) + if (! r) return false; $x = q("select * from account where account_id = %d limit 1", intval($r[0]['channel_account_id']) ); - if($x) + if ($x) $r[0]['email'] = $x[0]['account_email']; $p = q("select * from profile where is_default = 1 and uid = %d limit 1", @@ -90,11 +100,11 @@ function getUserData($handle=null) { ); $gender = ''; - if($p[0]['gender'] == t('Male')) + if ($p[0]['gender'] == t('Male')) $gender = 'M'; - if($p[0]['gender'] == t('Female')) + if ($p[0]['gender'] == t('Female')) $gender = 'F'; - + $r[0]['firstName'] = ((strpos($r[0]['channel_name'],' ')) ? substr($r[0]['channel_name'],0,strpos($r[0]['channel_name'],' ')) : $r[0]['channel_name']); $r[0]['lastName'] = ((strpos($r[0]['channel_name'],' ')) ? substr($r[0]['channel_name'],strpos($r[0]['channel_name'],' ')+1) : ''); $r[0]['namePerson'] = $r[0]['channel_name']; @@ -113,7 +123,7 @@ function getUserData($handle=null) { $r[0]['birthday'] = ((intval(substr($p[0]['dob'],8,2))) ? intval(substr($p[0]['dob'],8,2)) : ''); $r[0]['birthdate'] = (($r[0]['birthyear'] && $r[0]['birthmonth'] && $r[0]['birthday']) ? $p[0]['dob'] : ''); $r[0]['gender'] = $gender; - + return $r[0]; /* @@ -144,20 +154,20 @@ function getUserData($handle=null) { } - - -class MysqlProvider extends LightOpenIDProvider -{ - +/** + * @brief MySQL provider for OpenID implementation. + * + */ +class MysqlProvider extends LightOpenIDProvider { // See http://openid.net/specs/openid-attribute-properties-list-1_0-01.html // This list contains a few variations of these attributes to maintain // compatibility with legacy clients - private $attrFieldMap = array( - 'namePerson/first' => 'firstName', - 'namePerson/last' => 'lastName', - 'namePerson/friendly' => 'channel_address', + private $attrFieldMap = array( + 'namePerson/first' => 'firstName', + 'namePerson/last' => 'lastName', + 'namePerson/friendly' => 'channel_address', 'namePerson' => 'namePerson', 'contact/internet/email' => 'email', 'contact/email' => 'email', @@ -178,11 +188,9 @@ class MysqlProvider extends LightOpenIDProvider 'birthDate/birthday' => 'birthday', 'birthDate' => 'birthdate', 'gender' => 'gender', - ); - - - function setup($identity, $realm, $assoc_handle, $attributes) - { + ); + + function setup($identity, $realm, $assoc_handle, $attributes) { global $attrMap; // logger('identity: ' . $identity); @@ -190,10 +198,10 @@ class MysqlProvider extends LightOpenIDProvider // logger('assoc_handle: ' . $assoc_handle); // logger('attributes: ' . print_r($attributes,true)); - $data = getUserData($assoc_handle); + $data = getUserData($assoc_handle); -// FIXME this needs to be a template with localised strings +/** @FIXME this needs to be a template with localised strings */ $o .= '' . '' @@ -203,7 +211,7 @@ class MysqlProvider extends LightOpenIDProvider if($attributes['required'] || $attributes['optional']) { $o .= " It also requests following information (required fields marked with *):" . '
      '; - + foreach($attributes['required'] as $attr) { if(isset($this->attrMap[$attr])) { $o .= '
    • ' @@ -211,7 +219,7 @@ class MysqlProvider extends LightOpenIDProvider . $this->attrMap[$attr] . ' *
    • '; } } - + foreach($attributes['optional'] as $attr) { if(isset($this->attrMap[$attr])) { $o .= '
    • ' @@ -228,27 +236,23 @@ class MysqlProvider extends LightOpenIDProvider . '
    • '; get_app()->page['content'] .= $o; + } - } - - function checkid($realm, &$attributes) - { + function checkid($realm, &$attributes) { logger('checkid: ' . $realm); - logger('checkid attrs: ' . print_r($attributes,true)); + if(isset($_POST['cancel'])) { + $this->cancel(); + } - if(isset($_POST['cancel'])) { - $this->cancel(); - } - - $data = getUserData(); - if(! $data) { - return false; - } + $data = getUserData(); + if(! $data) { + return false; + } - $q = get_pconfig(local_channel(),'openid',$realm); + $q = get_pconfig(local_channel(), 'openid', $realm); $attrs = array(); if($q) { @@ -265,57 +269,42 @@ class MysqlProvider extends LightOpenIDProvider $attributes[$attr] = $data[$this->attrFieldMap[$attr]]; } } - - if(isset($_POST['always'])) { + + if(isset($_POST['always'])) { set_pconfig(local_channel(),'openid',$realm,array_keys($attributes)); - } - - return z_root() . '/id/' . $data['channel_address']; - } - - function assoc_handle() - { - logger('assoc_handle'); + } + + return z_root() . '/id/' . $data['channel_address']; + } + + function assoc_handle() { + logger('assoc_handle'); $channel = get_app()->get_channel(); + return z_root() . '/channel/' . $channel['channel_address']; + } - } - - function setAssoc($handle, $data) - { + function setAssoc($handle, $data) { logger('setAssoc'); $channel = channelx_by_nick(basename($handle)); if($channel) set_pconfig($channel['channel_id'],'openid','associate',$data); - } - - function getAssoc($handle) - { + } + + function getAssoc($handle) { logger('getAssoc: ' . $handle); $channel = channelx_by_nick(basename($handle)); if($channel) - return get_pconfig($channel['channel_id'],'openid','associate'); + return get_pconfig($channel['channel_id'], 'openid', 'associate'); + return false; - } - - function delAssoc($handle) - { + } + + function delAssoc($handle) { logger('delAssoc'); $channel = channelx_by_nick(basename($handle)); if($channel) - return del_pconfig($channel['channel_id'],'openid','associate'); - } - + return del_pconfig($channel['channel_id'], 'openid', 'associate'); + } } - - - - - - - - - - - diff --git a/mod/match.php b/mod/match.php index 5a01ba645..fd739ba2c 100644 --- a/mod/match.php +++ b/mod/match.php @@ -1,14 +1,20 @@ get_baseurl() . '/' . $a->cmd; @@ -18,22 +24,22 @@ function match_content(&$a) { $r = q("SELECT `keywords` FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_channel()) ); - if(! count($r)) - return; - if(! $r[0]['keywords']) { - notice( t('No keywords to match. Please add keywords to your default profile.') . EOL); + if (! count($r)) return; + if (! $r[0]['keywords']) { + notice( t('No keywords to match. Please add keywords to your default profile.') . EOL); + return; } $params = array(); $tags = trim($r[0]['keywords']); - - if($tags) { + + if ($tags) { $params['s'] = $tags; - if($a->pager['page'] != 1) + if ($a->pager['page'] != 1) $params['p'] = $a->pager['page']; - + // if(strlen(get_config('system','directory_submit_url'))) // $x = post_url('http://dir.friendica.com/msearch', $params); // else @@ -41,18 +47,14 @@ function match_content(&$a) { $j = json_decode($x); - if($j->total) { + if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } - if(count($j->results)) { - - - + if (count($j->results)) { $tpl = get_markup_template('match.tpl'); - foreach($j->results as $jj) { - + foreach ($j->results as $jj) { $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; $o .= replace_macros($tpl,array( '$url' => zid($jj->url), @@ -64,14 +66,13 @@ function match_content(&$a) { '$tags' => $jj->tags )); } - } - else { + } else { info( t('No matches') . EOL); - } - + } } $o .= cleardiv(); $o .= paginate($a); + return $o; } diff --git a/mod/post.php b/mod/post.php index 31b688221..37002b249 100644 --- a/mod/post.php +++ b/mod/post.php @@ -1,20 +1,21 @@ - the urlencoded webbie (channel@host.domain) of the channel requesting access - ** dest => the desired destination URL (urlencoded) - ** sec => a random string which is also stored on $mysite for use during the verification phase. - ** version => the zot revision - ** delegate => optional urlencoded webbie of a local channel to invoke delegation rights for + * Five GET parameters are supplied: + * * auth => the urlencoded webbie (channel@host.domain) of the channel requesting access + * * dest => the desired destination URL (urlencoded) + * * sec => a random string which is also stored on $mysite for use during the verification phase. + * * version => the zot revision + * * delegate => optional urlencoded webbie of a local channel to invoke delegation rights for * * When this packet is received, an "auth-check" zot message is sent to $mysite. * (e.g. if $_GET['auth'] is foobar@podunk.edu, a zot packet is sent to the podunk.edu zot endpoint, which is typically /post) * If no information has been recorded about the requesting identity a zot information packet will be retrieved before * continuing. - * + * * The sender of this packet is an arbitrary/random site channel. The recipients will be a single recipient corresponding * to the guid and guid_sig we have associated with the requesting auth identity * - * - * { - * "type":"auth_check", - * "sender":{ - * "guid":"kgVFf_...", - * "guid_sig":"PT9-TApz...", - * "url":"http:\/\/podunk.edu", - * "url_sig":"T8Bp7j..." - * }, - * "recipients":{ - * { - * "guid":"ZHSqb...", - * "guid_sig":"JsAAXi..." - * } - * } - * "callback":"\/post", - * "version":1, - * "secret":"1eaa661", - * "secret_sig":"eKV968b1..." - * } - * + * \code{.json} + * { + * "type":"auth_check", + * "sender":{ + * "guid":"kgVFf_...", + * "guid_sig":"PT9-TApz...", + * "url":"http:\/\/podunk.edu", + * "url_sig":"T8Bp7j..." + * }, + * "recipients":{ + * { + * "guid":"ZHSqb...", + * "guid_sig":"JsAAXi..." + * } + * } + * "callback":"\/post", + * "version":1, + * "secret":"1eaa661", + * "secret_sig":"eKV968b1..." + * } + * \endcode * * auth_check messages MUST use encapsulated encryption. This message is sent to the origination site, which checks the 'secret' to see * if it is the same as the 'sec' which it passed originally. It also checks the secret_sig which is the secret signed by the * destination channel's private key and base64url encoded. If everything checks out, a json packet is returned: * - * { - * "success":1, - * "confirm":"q0Ysovd1u..." - * "service_class":(optional) - * "level":(optional) - * } + * \code{.json} + * { + * "success":1, + * "confirm":"q0Ysovd1u...", + * "service_class":(optional) + * "level":(optional) + * } + * \endcode * * 'confirm' in this case is the base64url encoded RSA signature of the concatenation of 'secret' with the * base64url encoded whirlpool hash of the requestor's guid and guid_sig; signed with the source channel private key. * This prevents a man-in-the-middle from inserting a rogue success packet. Upon receipt and successful * verification of this packet, the destination site will redirect to the original destination URL and indicate a successful remote login. * Service_class can be used by cooperating sites to provide different access rights based on account rights and subscription plans. It is - * a string whose contents are not defined by protocol. Example: "basic" or "gold". - * - * + * a string whose contents are not defined by protocol. Example: "basic" or "gold". * + * @param[in,out] App &$a */ - - if(array_key_exists('auth',$_REQUEST)) { +function post_init(&$a) { + + if (array_key_exists('auth', $_REQUEST)) { $ret = array('success' => false, 'message' => ''); @@ -95,7 +97,7 @@ function post_init(&$a) { $version = $_REQUEST['version']; $delegate = $_REQUEST['delegate']; - $test = ((x($_REQUEST,'test')) ? intval($_REQUEST['test']) : 0); + $test = ((x($_REQUEST, 'test')) ? intval($_REQUEST['test']) : 0); // They are authenticating ultimately to the site and not to a particular channel. // Any channel will do, providing it's currently active. We just need to have an @@ -105,10 +107,10 @@ function post_init(&$a) { intval(PAGE_REMOVED) ); - if(! $c) { + if (! $c) { // nobody here logger('mod_zot: auth: unable to find a response channel'); - if($test) { + if ($test) { $ret['message'] .= 'no local channels found.' . EOL; json_return_and_die($ret); } @@ -121,12 +123,12 @@ function post_init(&$a) { dbesc($address) ); - if(! $x) { + if (! $x) { // finger them if they can't be found. - $ret = zot_finger($address,null); - if($ret['success']) { - $j = json_decode($ret['body'],true); - if($j) + $ret = zot_finger($address, null); + if ($ret['success']) { + $j = json_decode($ret['body'], true); + if ($j) import_xchan($j); $x = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash where hubloc_addr = '%s' order by hubloc_id desc limit 1", dbesc($address) @@ -166,61 +168,60 @@ function post_init(&$a) { $j = array(); - if(! $already_authed) { + if (! $already_authed) { // Auth packets MUST use ultra top-secret hush-hush mode - e.g. the entire packet is encrypted using the site private key // The actual channel sending the packet ($c[0]) is not important, but this provides a generic zot packet with a sender // which can be verified $p = zot_build_packet($c[0],$type = 'auth_check', array(array('guid' => $x[0]['hubloc_guid'],'guid_sig' => $x[0]['hubloc_guid_sig'])), $x[0]['hubloc_sitekey'], $sec); - if($test) { + if ($test) { $ret['message'] .= 'auth check packet created using sitekey ' . $x[0]['hubloc_sitekey'] . EOL; $ret['message'] .= 'packet contents: ' . $p . EOL; } $result = zot_zot($x[0]['hubloc_callback'],$p); - - if(! $result['success']) { + if (! $result['success']) { logger('mod_zot: auth_check callback failed.'); - if($test) { + if ($test) { $ret['message'] .= 'auth check request to your site returned .' . print_r($result, true) . EOL; json_return_and_die($ret); } goaway($desturl); } - $j = json_decode($result['body'],true); - if(! $j) { + $j = json_decode($result['body'], true); + if (! $j) { logger('mod_zot: auth_check json data malformed.'); if($test) { $ret['message'] .= 'json malformed: ' . $result['body'] . EOL; json_return_and_die($ret); } - } + } } - if($test) { + if ($test) { $ret['message'] .= 'auth check request returned .' . print_r($j, true) . EOL; - } + } - if($already_authed || $j['success']) { - if($j['success']) { + if ($already_authed || $j['success']) { + if ($j['success']) { // legit response, but we do need to check that this wasn't answered by a man-in-middle - if(! rsa_verify($sec . $x[0]['xchan_hash'],base64url_decode($j['confirm']),$x[0]['xchan_pubkey'])) { + if (! rsa_verify($sec . $x[0]['xchan_hash'],base64url_decode($j['confirm']),$x[0]['xchan_pubkey'])) { logger('mod_zot: auth: final confirmation failed.'); - if($test) { + if ($test) { $ret['message'] .= 'final confirmation failed. ' . $sec . print_r($j,true) . print_r($x[0],true); json_return_and_die($ret); } - + goaway($desturl); } - if(array_key_exists('service_class',$j)) + if (array_key_exists('service_class',$j)) $remote_service_class = $j['service_class']; - if(array_key_exists('level',$j)) + if (array_key_exists('level',$j)) $remote_level = $j['level']; - if(array_key_exists('DNT',$j)) + if (array_key_exists('DNT',$j)) $DNT = $j['DNT']; } // everything is good... maybe @@ -229,35 +230,33 @@ function post_init(&$a) { // tell them to logout if they're logged in locally as anything but the target remote account // in which case just shut up because they don't need to be doing this at all. - if($a->channel['channel_hash'] != $x[0]['xchan_hash']) { + if ($a->channel['channel_hash'] != $x[0]['xchan_hash']) { logger('mod_zot: auth: already authenticated locally as somebody else.'); notice( t('Remote authentication blocked. You are logged into this site locally. Please logout and retry.') . EOL); - if($test) { + if ($test) { $ret['message'] .= 'already logged in locally with a conflicting identity.' . EOL; json_return_and_die($ret); } - } goaway($desturl); } - // log them in - if($test) { + if ($test) { $ret['success'] = true; $ret['message'] .= 'Authentication Success!' . EOL; json_return_and_die($ret); } $delegation_success = false; - if($delegate) { + if ($delegate) { $r = q("select * from channel left join xchan on channel_hash = xchan_hash where xchan_addr = '%s' limit 1", dbesc($delegate) ); - if($r && intval($r[0]['channel_id'])) { + if ($r && intval($r[0]['channel_id'])) { $allowed = perm_is_allowed($r[0]['channel_id'],$x[0]['xchan_hash'],'delegate'); - if($allowed) { + if ($allowed) { $_SESSION['delegate_channel'] = $r[0]['channel_id']; $_SESSION['delegate'] = $x[0]['xchan_hash']; $_SESSION['account_id'] = intval($r[0]['channel_account_id']); @@ -267,12 +266,9 @@ function post_init(&$a) { } } } - - - $_SESSION['authenticated'] = 1; - if(! $delegation_success) { + if (! $delegation_success) { $_SESSION['visitor_id'] = $x[0]['xchan_hash']; $_SESSION['my_url'] = $x[0]['xchan_url']; $_SESSION['my_address'] = $address; @@ -289,18 +285,15 @@ function post_init(&$a) { $a->set_groups(init_groups_visitor($_SESSION['visitor_id'])); info(sprintf( t('Welcome %s. Remote authentication successful.'),$x[0]['xchan_name'])); logger('mod_zot: auth success from ' . $x[0]['xchan_addr']); - q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ", - intval(HUBLOC_WORKS), - intval($x[0]['hubloc_id']) - ); - - + q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ", + intval(HUBLOC_WORKS), + intval($x[0]['hubloc_id']) + ); } else { - if($test) { + if ($test) { $ret['message'] .= 'auth failure. ' . print_r($_REQUEST,true) . print_r($j,true) . EOL; json_return_and_die($ret); } - logger('mod_zot: magic-auth failure - not authenticated: ' . $x[0]['xchan_addr']); q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ", intval(HUBLOC_RECEIVE_ERROR), @@ -308,11 +301,14 @@ function post_init(&$a) { ); } - // FIXME - we really want to save the return_url in the session before we visit rmagic. - // This does however prevent a recursion if you visit rmagic directly, as it would otherwise send you back here again. - // But z_root() probably isn't where you really want to go. + /** + * @FIXME we really want to save the return_url in the session before we + * visit rmagic. This does however prevent a recursion if you visit + * rmagic directly, as it would otherwise send you back here again. + * But z_root() probably isn't where you really want to go. + */ - if($test) { + if ($test) { $ret['message'] .= 'auth failure fallthrough ' . print_r($_REQUEST,true) . print_r($j,true) . EOL; json_return_and_die($ret); } @@ -322,41 +318,40 @@ function post_init(&$a) { goaway($desturl); } - return; } /** - * @function post_post(&$a) - * zot communications and messaging + * @brief zot communications and messaging. * - * Sender HTTP posts to this endpoint ($site/post typically) with 'data' parameter set to json zot message packet. - * This packet is optionally encrypted, which we will discover if the json has an 'iv' element. - * $contents => array( 'alg' => 'aes256cbc', 'iv' => initialisation vector, 'key' => decryption key, 'data' => encrypted data); - * $contents->iv and $contents->key are random strings encrypted with this site's RSA public key and then base64url encoded. - * Currently only 'aes256cbc' is used, but this is extensible should that algorithm prove inadequate. + * Sender HTTP posts to this endpoint ($site/post typically) with 'data' parameter set to json zot message packet. + * This packet is optionally encrypted, which we will discover if the json has an 'iv' element. + * $contents => array( 'alg' => 'aes256cbc', 'iv' => initialisation vector, 'key' => decryption key, 'data' => encrypted data); + * $contents->iv and $contents->key are random strings encrypted with this site's RSA public key and then base64url encoded. + * Currently only 'aes256cbc' is used, but this is extensible should that algorithm prove inadequate. * - * Once decrypted, one will find the normal json_encoded zot message packet. + * Once decrypted, one will find the normal json_encoded zot message packet. * * Defined packet types are: notify, purge, refresh, force_refresh, auth_check, ping, and pickup * * Standard packet: (used by notify, purge, refresh, force_refresh, and auth_check) - * + * \code{.json} * { - * "type": "notify", - * "sender":{ - * "guid":"kgVFf_1...", - * "guid_sig":"PT9-TApzp...", - * "url":"http:\/\/podunk.edu", - * "url_sig":"T8Bp7j5...", - * }, - * "recipients": { optional recipient array }, - * "callback":"\/post", - * "version":1, - * "secret":"1eaa...", - * "secret_sig": "df89025470fac8..." + * "type": "notify", + * "sender":{ + * "guid":"kgVFf_1...", + * "guid_sig":"PT9-TApzp...", + * "url":"http:\/\/podunk.edu", + * "url_sig":"T8Bp7j5...", + * }, + * "recipients": { optional recipient array }, + * "callback":"\/post", + * "version":1, + * "secret":"1eaa...", + * "secret_sig": "df89025470fac8..." * } - * + * \endcode + * * Signature fields are all signed with the sender channel private key and base64url encoded. * Recipients are arrays of guid and guid_sig, which were previously signed with the recipients private * key and base64url encoded and later obtained via channel discovery. Absence of recipients indicates @@ -364,108 +359,116 @@ function post_init(&$a) { * * "pickup" packet: * The pickup packet is sent in response to a notify packet from another site - * + * \code{.json} * { - * "type":"pickup", - * "url":"http:\/\/example.com", - * "callback":"http:\/\/example.com\/post", - * "callback_sig":"teE1_fLI...", - * "secret":"1eaa...", - * "secret_sig":"O7nB4_..." + * "type":"pickup", + * "url":"http:\/\/example.com", + * "callback":"http:\/\/example.com\/post", + * "callback_sig":"teE1_fLI...", + * "secret":"1eaa...", + * "secret_sig":"O7nB4_..." * } + * \endcode * - * In the pickup packet, the sig fields correspond to the respective data element signed with this site's system - * private key and then base64url encoded. + * In the pickup packet, the sig fields correspond to the respective data + * element signed with this site's system private key and then base64url encoded. * The "secret" is the same as the original secret from the notify packet. * - * If verification is successful, a json structure is returned - * containing a success indicator and an array of type 'pickup'. - * Each pickup element contains the original notify request and a message field whose contents are - * dependent on the message type + * If verification is successful, a json structure is returned containing a + * success indicator and an array of type 'pickup'. + * Each pickup element contains the original notify request and a message field + * whose contents are dependent on the message type. * - * This JSON array is AES encapsulated using the site public key of the site that sent the initial zot pickup packet. + * This JSON array is AES encapsulated using the site public key of the site + * that sent the initial zot pickup packet. * Using the above example, this would be example.com. - * - * + * + * \code{.json} * { - * "success":1, - * "pickup":{ - * "notify":{ - * "type":"notify", - * "sender":{ - * "guid":"kgVFf_...", - * "guid_sig":"PT9-TApz...", - * "url":"http:\/\/z.podunk.edu", - * "url_sig":"T8Bp7j5D..." - * }, - * "callback":"\/post", - * "version":1, - * "secret":"1eaa661..." - * }, - * "message":{ - * "type":"activity", - * "message_id":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", - * "message_top":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", - * "message_parent":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", - * "created":"2012-11-20 04:04:16", - * "edited":"2012-11-20 04:04:16", - * "title":"", - * "body":"Hi Nickordo", - * "app":"", - * "verb":"post", - * "object_type":"", - * "target_type":"", - * "permalink":"", - * "location":"", - * "longlat":"", - * "owner":{ - * "name":"Indigo", - * "address":"indigo@podunk.edu", - * "url":"http:\/\/podunk.edu", - * "photo":{ - * "mimetype":"image\/jpeg", - * "src":"http:\/\/podunk.edu\/photo\/profile\/m\/5" + * "success":1, + * "pickup":{ + * "notify":{ + * "type":"notify", + * "sender":{ + * "guid":"kgVFf_...", + * "guid_sig":"PT9-TApz...", + * "url":"http:\/\/z.podunk.edu", + * "url_sig":"T8Bp7j5D..." * }, - * "guid":"kgVFf_...", - * "guid_sig":"PT9-TAp...", + * "callback":"\/post", + * "version":1, + * "secret":"1eaa661..." * }, - * "author":{ - * "name":"Indigo", - * "address":"indigo@podunk.edu", - * "url":"http:\/\/podunk.edu", - * "photo":{ - * "mimetype":"image\/jpeg", - * "src":"http:\/\/podunk.edu\/photo\/profile\/m\/5" + * "message":{ + * "type":"activity", + * "message_id":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", + * "message_top":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", + * "message_parent":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", + * "created":"2012-11-20 04:04:16", + * "edited":"2012-11-20 04:04:16", + * "title":"", + * "body":"Hi Nickordo", + * "app":"", + * "verb":"post", + * "object_type":"", + * "target_type":"", + * "permalink":"", + * "location":"", + * "longlat":"", + * "owner":{ + * "name":"Indigo", + * "address":"indigo@podunk.edu", + * "url":"http:\/\/podunk.edu", + * "photo":{ + * "mimetype":"image\/jpeg", + * "src":"http:\/\/podunk.edu\/photo\/profile\/m\/5" + * }, + * "guid":"kgVFf_...", + * "guid_sig":"PT9-TAp...", * }, - * "guid":"kgVFf_...", - * "guid_sig":"PT9-TAp..." + * "author":{ + * "name":"Indigo", + * "address":"indigo@podunk.edu", + * "url":"http:\/\/podunk.edu", + * "photo":{ + * "mimetype":"image\/jpeg", + * "src":"http:\/\/podunk.edu\/photo\/profile\/m\/5" + * }, + * "guid":"kgVFf_...", + * "guid_sig":"PT9-TAp..." + * } * } * } * } - *} + * \endcode * - * Currently defined message types are 'activity', 'mail', 'profile', 'location' and 'channel_sync', - * which each have different content schemas. + * Currently defined message types are 'activity', 'mail', 'profile', 'location' + * and 'channel_sync', which each have different content schemas. * * Ping packet: - * A ping packet does not require any parameters except the type. It may or may not be encrypted. - * + * A ping packet does not require any parameters except the type. It may or may + * not be encrypted. + * + * \code{.json} * { - * "type": "ping" + * "type": "ping" * } - * + * \endcode + * * On receipt of a ping packet a ping response will be returned: * + * \code{.json} * { * "success" : 1, * "site" { - * "url":"http:\/\/podunk.edu", - * "url_sig":"T8Bp7j5...", - * "sitekey": "-----BEGIN PUBLIC KEY----- - * MIICIjANBgkqhkiG9w0BAQE..." - * } + * "url": "http:\/\/podunk.edu", + * "url_sig": "T8Bp7j5...", + * "sitekey": "-----BEGIN PUBLIC KEY----- + * MIICIjANBgkqhkiG9w0BAQE..." + * } * } - * + * \endcode + * * The ping packet can be used to verify that a site has not been re-installed, and to * initiate corrective action if it has. The url_sig is signed with the site private key * and base64url encoded - and this should verify with the enclosed sitekey. Failure to @@ -479,21 +482,19 @@ function post_init(&$a) { * If you have no records which match this url_sig and key - no corrective action should * be taken as this packet may have been returned by an imposter. * + * @param[in,out] App &$a */ - - function post_post(&$a) { - $encrypted_packet = false; $ret = array('success' => false); $data = json_decode($_REQUEST['data'],true); - - /** - * Many message packets will arrive encrypted. The existence of an 'iv' element - * tells us we need to unencapsulate the AES-256-CBC content using the site private key + /* + * Many message packets will arrive encrypted. The existence of an 'iv' + * element tells us we need to unencapsulate the AES-256-CBC content using + * the site private key. */ if($data && array_key_exists('iv',$data)) { @@ -539,12 +540,11 @@ function post_post(&$a) { if($msgtype === 'pickup') { - /** + /* * The 'pickup' message arrives with a tracking ID which is associated with a particular outq_hash * First verify that that the returned signatures verify, then check that we have an outbound queue item * with the correct hash. * If everything verifies, find any/all outbound messages in the queue for this hubloc and send them back - * */ if((! $data['secret']) || (! $data['secret_sig'])) { @@ -597,7 +597,7 @@ function post_post(&$a) { json_return_and_die($ret); } - /** + /* * If we made it to here, the signatures verify, but we still don't know if the tracking ID is valid. * It wouldn't be an error if the tracking ID isn't found, because we may have sent this particular * queue item with another pickup (after the tracking ID for the other pickup was verified). @@ -613,7 +613,7 @@ function post_post(&$a) { json_return_and_die($ret); } - /** + /* * Everything is good if we made it here, so find all messages that are going to this location * and send them all. */ @@ -651,33 +651,31 @@ function post_post(&$a) { $encrypted = crypto_encapsulate(json_encode($ret),$sitekey); json_return_and_die($encrypted); - /** pickup: end */ + /* pickup: end */ } - - - /** + /* * All other message types require us to verify the sender. This is a generic check, so we * will do it once here and bail if anything goes wrong. */ - if(array_key_exists('sender',$data)) { + if (array_key_exists('sender',$data)) { $sender = $data['sender']; - } + } - /** Check if the sender is already verified here */ + /* Check if the sender is already verified here */ $hub = zot_gethub($sender); - if(! $hub) { + if (! $hub) { - /** Have never seen this guid or this guid coming from this location. Check it and register it. */ + /* Have never seen this guid or this guid coming from this location. Check it and register it. */ // (!!) this will validate the sender $result = zot_register_hub($sender); - if((! $result['success']) || (! ($hub = zot_gethub($sender)))) { + if ((! $result['success']) || (! ($hub = zot_gethub($sender)))) { $ret['message'] = 'Hub not available.'; logger('mod_zot: no hub'); json_return_and_die($ret); @@ -695,12 +693,12 @@ function post_post(&$a) { // a dead hub came back to life - reset any tombstones we might have - if($hub['hubloc_status'] & HUBLOC_OFFLINE) { + if ($hub['hubloc_status'] & HUBLOC_OFFLINE) { q("update hubloc set hubloc_status = (hubloc_status & ~%d) where hubloc_id = %d", intval(HUBLOC_OFFLINE), intval($hub['hubloc_id']) ); - if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { + if ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d", intval(HUBLOC_FLAGS_ORPHANCHECK), intval($hub['hubloc_id']) @@ -711,15 +709,13 @@ function post_post(&$a) { intval(XCHAN_FLAGS_ORPHAN), dbesc($hub['hubloc_hash']) ); - } - + } - /** + /* * This hub has now been proven to be valid. * Any hub with the same URL and a different sitekey cannot be valid. * Get rid of them (mark them deleted). There's a good chance they were re-installs. - * */ q("update hubloc set hubloc_flags = ( hubloc_flags | %d ) where hubloc_url = '%s' and hubloc_sitekey != '%s' ", @@ -728,15 +724,15 @@ function post_post(&$a) { dbesc($hub['hubloc_sitekey']) ); - // TODO: check which hub is primary and take action if mismatched + /** @TODO check which hub is primary and take action if mismatched */ - if(array_key_exists('recipients',$data)) + if (array_key_exists('recipients', $data)) $recipients = $data['recipients']; - if($msgtype === 'auth_check') { + if ($msgtype === 'auth_check') { - /** + /* * Requestor visits /magic/?dest=somewhere on their own site with a browser * magic redirects them to $destsite/post [with auth args....] * $destsite sends an auth_check packet to originator site @@ -751,12 +747,12 @@ function post_post(&$a) { */ logger('mod_zot: auth_check', LOGGER_DEBUG); - if(! $encrypted_packet) { + if (! $encrypted_packet) { logger('mod_zot: auth_check packet was not encrypted.'); $ret['message'] .= 'no packet encryption' . EOL; json_return_and_die($ret); } - + $arr = $data['sender']; $sender_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']); @@ -774,7 +770,7 @@ function post_post(&$a) { // First verify their signature. We will have obtained a zot-info packet from them as part of the sender // verification. - if((! $y) || (! rsa_verify($data['secret'],base64url_decode($data['secret_sig']),$y[0]['xchan_pubkey']))) { + if ((! $y) || (! rsa_verify($data['secret'], base64url_decode($data['secret_sig']),$y[0]['xchan_pubkey']))) { logger('mod_zot: auth_check: sender not found or secret_sig invalid.'); $ret['message'] .= 'sender not found or sig invalid ' . print_r($y,true) . EOL; json_return_and_die($ret); @@ -784,14 +780,14 @@ function post_post(&$a) { $ret['message'] .= 'recipients ' . print_r($recipients,true) . EOL; - if($data['recipients']) { + if ($data['recipients']) { $arr = $data['recipients'][0]; - $recip_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']); + $recip_hash = make_xchan_hash($arr['guid'], $arr['guid_sig']); $c = q("select channel_id, channel_account_id, channel_prvkey from channel where channel_hash = '%s' limit 1", dbesc($recip_hash) ); - if(! $c) { + if (! $c) { logger('mod_zot: auth_check: recipient channel not found.'); $ret['message'] .= 'recipient not found.' . EOL; json_return_and_die($ret); @@ -807,7 +803,7 @@ function post_post(&$a) { dbesc($data['secret']), dbesc($data['sender']['url']) ); - if(! $z) { + if (! $z) { logger('mod_zot: auth_check: verification key not found.'); $ret['message'] .= 'verification key not found' . EOL; json_return_and_die($ret); @@ -823,70 +819,66 @@ function post_post(&$a) { logger('mod_zot: auth_check: success', LOGGER_DEBUG); $ret['success'] = true; $ret['confirm'] = $confirm; - if($u && $u[0]['account_service_class']) + if ($u && $u[0]['account_service_class']) $ret['service_class'] = $u[0]['account_service_class']; // Set "do not track" flag if this site or this channel's profile is restricted // in some way - if(intval(get_config('system','block_public'))) + if (intval(get_config('system','block_public'))) $ret['DNT'] = true; - if(! perm_is_allowed($c[0]['channel_id'],'','view_profile')) + if (! perm_is_allowed($c[0]['channel_id'],'','view_profile')) $ret['DNT'] = true; - if(get_pconfig($c[0]['channel_id'],'system','do_not_track')) + if (get_pconfig($c[0]['channel_id'],'system','do_not_track')) $ret['DNT'] = true; - if(get_pconfig($c[0]['channel_id'],'system','hide_online_status')) + if (get_pconfig($c[0]['channel_id'],'system','hide_online_status')) $ret['DNT'] = true; json_return_and_die($ret); - } json_return_and_die($ret); } - if($msgtype === 'request') { + 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) { + if ($msgtype === 'purge') { + if ($recipients) { // basically this means "unfriend" - foreach($recipients as $recip) { + foreach ($recipients as $recip) { $r = q("select channel.*,xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", dbesc($recip['guid']), dbesc($recip['guid_sig']) ); - if($r) { + if ($r) { $r = q("select abook_id from abook where uid = %d and abook_xchan = '%s' limit 1", intval($r[0]['channel_id']), dbesc(make_xchan_hash($sender['guid'],$sender['guid_sig'])) ); - if($r) { + if ($r) { contact_remove($r[0]['channel_id'],$r[0]['abook_id']); } } } - } - else { + } else { // Unfriend everybody - basically this means the channel has committed suicide $arr = $data['sender']; $sender_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']); - + require_once('include/Contact.php'); remove_all_xchan_resources($sender_hash); $ret['success'] = true; json_return_and_die($ret); - } } - if(($msgtype === 'refresh') || ($msgtype === 'force_refresh')) { + if (($msgtype === 'refresh') || ($msgtype === 'force_refresh')) { // remote channel info (such as permissions or photo or something) // has been updated. Grab a fresh copy and sync it. @@ -894,11 +886,11 @@ function post_post(&$a) { // force_refresh unconditionally creates a directory update record, // even if no changes were detected upon processing. - if($recipients) { + if ($recipients) { // This would be a permissions update, typically for one connection - foreach($recipients as $recip) { + foreach ($recipients as $recip) { $r = q("select channel.*,xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", @@ -910,44 +902,37 @@ function post_post(&$a) { 'xchan_guid' => $sender['guid'], 'xchan_guid_sig' => $sender['guid_sig'], 'hubloc_url' => $sender['url'] - ),$r[0], (($msgtype === 'force_refresh') ? true : false)); + ), $r[0], (($msgtype === 'force_refresh') ? true : false)); } - } - else { + } else { // system wide refresh - + $x = zot_refresh(array( 'xchan_guid' => $sender['guid'], 'xchan_guid_sig' => $sender['guid_sig'], 'hubloc_url' => $sender['url'] - ),null,(($msgtype === 'force_refresh') ? true : false)); + ), null, (($msgtype === 'force_refresh') ? true : false)); } $ret['success'] = true; json_return_and_die($ret); } - if($msgtype === 'notify') { + if ($msgtype === 'notify') { $async = get_config('system','queued_fetch'); - if($async) { + if ($async) { // add to receive queue // qreceive_add($data); - } - else { + } else { $x = zot_fetch($data); $ret['delivery_report'] = $x; } $ret['success'] = true; json_return_and_die($ret); - } - // catchall json_return_and_die($ret); - - } - diff --git a/mod/randprof.php b/mod/randprof.php index bddb3251a..9817685c8 100644 --- a/mod/randprof.php +++ b/mod/randprof.php @@ -6,6 +6,7 @@ function randprof_init(&$a) { $x = random_profile(); if($x) goaway(chanlink_url($x)); - // FIXME this doesn't work at the moment as a fallback + + /** FIXME this doesn't work at the moment as a fallback */ goaway($a->get_baseurl() . '/profile'); } diff --git a/mod/regdir.php b/mod/regdir.php index 5331c1dd4..025be220b 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -1,18 +1,17 @@ false); @@ -31,8 +30,7 @@ function regdir_init(&$a) { if($realm === DIRECTORY_REALM) { $valid = 1; - } - else { + } else { $token = get_config('system','realm_token'); if($token && $access_token != $token) { $result['message'] = 'This realm requires an access token'; @@ -40,19 +38,19 @@ function regdir_init(&$a) { } $valid = 1; } - + $dirmode = intval(get_config('system','directory_mode')); - if($dirmode == DIRECTORY_MODE_NORMAL) { + if ($dirmode == DIRECTORY_MODE_NORMAL) { $ret['message'] = t('This site is not a directory server'); json_return_and_die($ret); } $m = null; - if($url) { + if ($url) { $m = parse_url($url); - if((! $m) || (! @dns_get_record($m['host'], DNS_A + DNS_CNAME + DNS_PTR)) || (! filter_var($m['host'], FILTER_VALIDATE_IP) )) { + if ((! $m) || (! @dns_get_record($m['host'], DNS_A + DNS_CNAME + DNS_PTR)) || (! filter_var($m['host'], FILTER_VALIDATE_IP) )) { $result['message'] = 'unparseable url'; json_return_and_die($result); } @@ -75,31 +73,28 @@ function regdir_init(&$a) { ); json_return_and_die($result); - } - else { + } else { // We can put this in the sql without the condition after 31 april 2015 assuming // most directory servers will have updated by then // This just makes sure it happens if I forget $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-04-31')) ? ' and site_valid = 1 ' : '' ); - if($dirmode == DIRECTORY_MODE_STANDALONE) { + if ($dirmode == DIRECTORY_MODE_STANDALONE) { $r = array(array('site_url' => z_root())); - } - else { + } else { $r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s' $sql_extra ", dbesc(get_directory_realm()) ); } - if($r) { + if ($r) { $result['success'] = true; $result['directories'] = array(); - foreach($r as $rr) + foreach ($r as $rr) $result['directories'][] = $rr['site_url']; + json_return_and_die($result); } } json_return_and_die($result); - - -} \ No newline at end of file +} \ No newline at end of file diff --git a/mod/share.php b/mod/share.php index 923971694..d5a389bdf 100644 --- a/mod/share.php +++ b/mod/share.php @@ -13,7 +13,6 @@ function share_init(&$a) { if(! (local_channel() || remote_channel())) killme(); - $r = q("SELECT * from item left join xchan on author_xchan = xchan_hash WHERE id = %d LIMIT 1", intval($post_id) ); @@ -30,13 +29,12 @@ function share_init(&$a) { if(! $r) killme(); - // FIXME - we only share bbcode + /** @FIXME we only share bbcode */ if($r[0]['mimetype'] !== 'text/bbcode') killme(); - // FIXME - eventually we want to post remotely via rpost - // on your home site. + /** @FIXME eventually we want to post remotely via rpost on your home site */ // When that works remove this next bit: if(! local_channel()) @@ -64,20 +62,20 @@ function share_init(&$a) { echo $o; killme(); } - + $observer = $a->get_observer(); $parsed = $observer['xchan_url']; if($parsed) { $post_url = $parsed['scheme'] . ':' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '') . '/rpost'; - // FIXME - we were probably called from JS - // so we don't know the return page. - // in fact we won't be able to load the remote page. - // we might need an iframe + + /** + * @FIXME we were probably called from JS so we don't know the return page. + * In fact we won't be able to load the remote page. + * we might need an iframe + */ $x = z_post_url($post_url, array('f' => '', 'body' => $o )); killme(); } - - } diff --git a/mod/thing.php b/mod/thing.php index 4ec10f5a6..c6b70fbb4 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -1,4 +1,8 @@ -get_account(); $channel = $a->get_channel(); @@ -26,19 +27,18 @@ function thing_init(&$a) { $hash = random_string(); - $verbs = obj_verbs(); - /** + /** * verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants" * We use the first person form when creating an activity, but the third person for use in activities - * FIXME: There is no accounting for verb gender for languages where this is significant. We may eventually + * @FIXME There is no accounting for verb gender for languages where this is significant. We may eventually * require obj_verbs() to provide full conjugations and specify which form to use in the $_REQUEST params to this module. */ $translated_verb = $verbs[$verb][1]; - /** + /* * The site administrator can do things that normals cannot. * This is restricted because it will likely cause * an activitystreams protocol violation and the activity might @@ -50,14 +50,14 @@ function thing_init(&$a) { if(! $translated_verb) { if(is_site_admin()) $translated_verb = $verb; - } - - /** + } + + /* * Things, objects: We do not provide definite (a, an) or indefinite (the) articles or singular/plural designators * That needs to be specified in your thing. e.g. Mike has "a carrot", Greg wants "balls", Bob likes "the Boston Red Sox". */ - /** + /* * Future work on this module might produce more complex activities with targets, e.g. Phillip likes Karen's moustache * and to describe other non-thing objects like channels, such as Karl wants Susan - where Susan represents a channel profile. */ @@ -65,8 +65,6 @@ function thing_init(&$a) { if((! $name) || (! $translated_verb)) return; - - if($term_hash) { $t = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", intval(TERM_OBJ_THING), @@ -115,7 +113,6 @@ function thing_init(&$a) { $local_photo_type = $arr[3]; } - $r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1", intval(local_channel()), intval(TERM_OBJ_THING), @@ -159,14 +156,12 @@ function thing_init(&$a) { info( t('Thing added')); - if($activity) { $arr = array(); $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $term['url'])); if($local_photo) $links[] = array('rel' => 'photo', 'type' => $local_photo_type, 'href' => $local_photo); - $objtype = ACTIVITY_OBJ_THING; $obj = json_encode(array( @@ -182,9 +177,8 @@ function thing_init(&$a) { $arr['owner_xchan'] = $channel['channel_hash']; $arr['author_xchan'] = $channel['channel_hash']; - $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP; - + $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]'; $plink = '[zrl=' . $term['url'] . ']' . $term['term'] . '[/zrl]'; @@ -212,14 +206,14 @@ function thing_init(&$a) { else $arr['allow_cid'] = '<' . get_observer_hash() . '>'; } - + $ret = post_activity_item($arr); } } function thing_content(&$a) { - + if(argc() == 2) { $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", @@ -249,12 +243,10 @@ function thing_content(&$a) { } $thing_hash = ''; - if(argc() == 3 && argv(1) === 'edit') { $thing_hash = argv(2); - $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", intval(TERM_OBJ_THING), dbesc($thing_hash) @@ -265,7 +257,6 @@ function thing_content(&$a) { return ''; } - $o .= replace_macros(get_markup_template('thing_edit.tpl'),array( '$thing_hdr' => t('Edit Thing'), '$multiprof' => feature_enabled(local_channel(),'multi_profiles'), @@ -300,7 +291,6 @@ function thing_content(&$a) { return ''; } - $x = q("delete from obj where obj_obj = '%s' and obj_type = %d and obj_channel = %d", dbesc($thing_hash), intval(TERM_OBJ_THING), @@ -310,6 +300,7 @@ function thing_content(&$a) { dbesc($thing_hash), intval(local_channel()) ); + return $o; } @@ -328,6 +319,4 @@ function thing_content(&$a) { )); return $o; - - } -- cgit v1.2.3 From d3c064cc345ac66a0c3ce2c79d566740b090be8c Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Mar 2015 19:41:42 -0700 Subject: title of preview button incorrect, fix ability to upload to webpages --- mod/editblock.php | 3 ++- mod/editlayout.php | 2 +- mod/editpost.php | 2 +- mod/editwebpage.php | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/editblock.php b/mod/editblock.php index cacb5c27d..73be6a9f3 100644 --- a/mod/editblock.php +++ b/mod/editblock.php @@ -146,6 +146,7 @@ function editblock_content(&$a) { '$underline' => t('Underline'), '$quote' => t('Quote'), '$code' => t('Code'), + '$writefiles' => (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage')), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), @@ -175,7 +176,7 @@ function editblock_content(&$a) { '$acl' => '', '$bang' => '', '$profile_uid' => (intval($channel['channel_id'])), - '$preview' => true, // ((feature_enabled($uid,'preview')) ? t('Preview') : ''), + '$preview' => t('Preview'), '$jotplugins' => $jotplugins, '$sourceapp' => $itm[0]['app'], '$defexpire' => '', diff --git a/mod/editlayout.php b/mod/editlayout.php index 21607de8c..f6d76f6b4 100644 --- a/mod/editlayout.php +++ b/mod/editlayout.php @@ -170,7 +170,7 @@ function editlayout_content(&$a) { '$acl' => '', '$bang' => '', '$profile_uid' => (intval($owner)), - '$preview' => true, // ((feature_enabled($uid,'preview')) ? t('Preview') : ''), + '$preview' => t('Preview'), '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), '$defexpire' => '', diff --git a/mod/editpost.php b/mod/editpost.php index edc5fa1b7..58ebe31cb 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -146,7 +146,7 @@ function editpost_content(&$a) { '$acl' => '', '$bang' => '', '$profile_uid' => local_channel(), - '$preview' => true, // ((feature_enabled(local_channel(),'preview')) ? t('Preview') : ''), + '$preview' => t('Preview'), '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), '$catsenabled' => $catsenabled, diff --git a/mod/editwebpage.php b/mod/editwebpage.php index 3e0bd9ff4..e81cde479 100644 --- a/mod/editwebpage.php +++ b/mod/editwebpage.php @@ -164,11 +164,13 @@ function editwebpage_content(&$a) { $rp = 'webpages/' . $which; +logger('canwrite: ' . (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage'))); $o .= replace_macros($tpl,array( '$return_path' => $rp, '$webpage' => ITEM_WEBPAGE, '$placeholdpagetitle' => t('Page link title'), '$pagetitle' => $page_title, + '$writefiles' => (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage')), '$action' => 'item', '$share' => t('Edit'), @@ -207,7 +209,7 @@ function editwebpage_content(&$a) { 'lockstate' => (((strlen($itm[0]['allow_cid'])) || (strlen($itm[0]['allow_gid'])) || (strlen($itm[0]['deny_cid'])) || (strlen($itm[0]['deny_gid']))) ? 'lock' : 'unlock'), '$bang' => '', '$profile_uid' => (intval($owner)), - '$preview' => true, // ((feature_enabled($uid,'preview')) ? t('Preview') : ''), + '$preview' => t('Preview'), '$jotplugins' => $jotplugins, '$sourceapp' => $a->sourcename, '$defexpire' => '', -- cgit v1.2.3 From cbaa2a9b847bca5b7df4136d961058c7b459be98 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Mar 2015 21:06:41 -0700 Subject: don't included any deleted posts in the self query --- mod/network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index 8db3bfd58..d96c6830d 100644 --- a/mod/network.php +++ b/mod/network.php @@ -324,7 +324,7 @@ function network_content(&$a, $update = 0, $load = false) { } if($conv) { - $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan like '%s' or ( item_flags & %d ) > 0)) ", + $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan like '%s' or ( item_flags & %d ) > 0) and item_restrict = 0 ) ", dbesc(protect_sprintf($channel['channel_hash'])), intval(ITEM_MENTIONSME) ); -- cgit v1.2.3 From 7f6ba91dfadc8f256cd3a707b0ba281d47843c26 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 31 Mar 2015 17:52:03 -0700 Subject: allow webpage for home to use its own layout file --- mod/home.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'mod') diff --git a/mod/home.php b/mod/home.php index f4358da5c..7f28a89fc 100644 --- a/mod/home.php +++ b/mod/home.php @@ -88,6 +88,20 @@ function home_content(&$a, $update = 0, $load = false) { if($r) { xchan_query($r); $r = fetch_post_tags($r,true); + + if($r[0]['layout_mid']) { + $l = q("select body from item where mid = '%s' and uid = %d limit 1", + dbesc($r[0]['layout_mid']), + intval($u[0]['channel_id']) + ); + + if($l) { + require_once('include/comanche.php'); + comanche_parser($a,$l[0]['body']); + $a->pdl = $l[0]['body']; + } + } + $a->profile = array('profile_uid' => $u[0]['channel_id']); $a->profile_uid = $u[0]['channel_id']; $o .= prepare_page($r[0]); -- cgit v1.2.3 From 6f78d7a85d0371dc7fb72acb3a85217005400f91 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 31 Mar 2015 21:06:48 -0700 Subject: fix regdir --- mod/post.php | 6 +++++- mod/regdir.php | 11 +++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'mod') diff --git a/mod/post.php b/mod/post.php index 37002b249..95931a3f0 100644 --- a/mod/post.php +++ b/mod/post.php @@ -622,7 +622,7 @@ function post_post(&$a) { dbesc($data['callback']) ); if($r) { - logger('mod_zot: succesful pickup message received from ' . $data['callback'] . ' ' . count($r) . ' message(s) picked up', LOGGER_DEBUG); + logger('mod_zot: successful pickup message received from ' . $data['callback'] . ' ' . count($r) . ' message(s) picked up', LOGGER_DEBUG); $ret['success'] = true; $ret['pickup'] = array(); @@ -919,6 +919,10 @@ function post_post(&$a) { } if ($msgtype === 'notify') { + + logger('notify received from ' . $hub['hubloc_url']); + + $async = get_config('system','queued_fetch'); if ($async) { diff --git a/mod/regdir.php b/mod/regdir.php index 025be220b..dce50e76a 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -50,7 +50,8 @@ function regdir_init(&$a) { if ($url) { $m = parse_url($url); - if ((! $m) || (! @dns_get_record($m['host'], DNS_A + DNS_CNAME + DNS_PTR)) || (! filter_var($m['host'], FILTER_VALIDATE_IP) )) { + if ((! $m) || ((! @dns_get_record($m['host'], DNS_A + DNS_CNAME + DNS_PTR)) && (! filter_var($m['host'], FILTER_VALIDATE_IP) ))) { + $result['message'] = 'unparseable url'; json_return_and_die($result); } @@ -62,11 +63,13 @@ function regdir_init(&$a) { $x = import_xchan($j); if($x['success']) { $result['success'] = true; - json_return_and_die($result); } } } + if(! $result['success']) + $valid = 0; + q("update site set site_valid = %d where site_url = '%s' limit 1", intval($valid), strtolower($url) @@ -75,11 +78,11 @@ function regdir_init(&$a) { json_return_and_die($result); } else { - // We can put this in the sql without the condition after 31 april 2015 assuming + // We can put this in the sql without the condition after 31 august 2015 assuming // most directory servers will have updated by then // This just makes sure it happens if I forget - $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-04-31')) ? ' and site_valid = 1 ' : '' ); + $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-08-31')) ? ' and site_valid = 1 ' : '' ); if ($dirmode == DIRECTORY_MODE_STANDALONE) { $r = array(array('site_url' => z_root())); } else { -- cgit v1.2.3 From d599ebe742a9fa205da989521388a18655353566 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 1 Apr 2015 15:52:02 -0700 Subject: update resource links --- mod/siteinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/siteinfo.php b/mod/siteinfo.php index ab6891e25..856909a27 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -163,7 +163,7 @@ function siteinfo_content(&$a) { '$web_location' => t('Running at web location') . ' ' . z_root(), '$visit' => t('Please visit redmatrix.me to learn more about the Red Matrix.'), '$bug_text' => t('Bug reports and issues: please visit'), - '$bug_link_url' => 'https://github.com/friendica/red/issues', + '$bug_link_url' => 'https://github.com/redmatrix/redmatrix/issues', '$bug_link_text' => 'redmatrix issues', '$contact' => t('Suggestions, praise, etc. - please email "redmatrix" at librelist - dot com'), '$donate' => $donate, -- cgit v1.2.3 From 649ada7100ef40d605b06088d96cd124fa311863 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 2 Apr 2015 13:22:48 -0700 Subject: provide ability to have randomised homepage content from a set of pages name home-* --- mod/home.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/home.php b/mod/home.php index 7f28a89fc..7bb138d2e 100644 --- a/mod/home.php +++ b/mod/home.php @@ -72,16 +72,20 @@ function home_content(&$a, $update = 0, $load = false) { if($channel_address) { $page_id = 'home'; + $randpage_id = 'home-%'; $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address) ); + $randfunc = db_getfunc('RAND'); + $r = q("select item.* from item left join item_id on item.id = item_id.iid - where item.uid = %d and sid = '%s' and service = 'WEBPAGE' and - item_restrict = %d limit 1", + where item.uid = %d and ( sid = '%s' or sid like '%s' ) and service = 'WEBPAGE' and + item_restrict = %d ORDER BY $randfunc limit 1", intval($u[0]['channel_id']), dbesc($page_id), + dbesc($randpage_id), intval(ITEM_WEBPAGE) ); -- cgit v1.2.3 From f1e73abd21ac99b00038242b8a4e882e7f6dfc12 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 5 Apr 2015 21:32:54 -0700 Subject: issue #226 --- mod/directory.php | 4 ++++ mod/search.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index 274584862..87dadc58f 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -51,6 +51,10 @@ function directory_content(&$a) { $observer = get_observer_hash(); $globaldir = get_globaldir_setting($observer); + // override your personal global search pref if we're doing a navbar search of the directory + if(intval($_REQUEST['navsearch'])) + $globaldir = 1; + $safe_mode = get_safemode_setting($observer); $pubforums = null; diff --git a/mod/search.php b/mod/search.php index 4d66086f8..e235f720a 100644 --- a/mod/search.php +++ b/mod/search.php @@ -57,12 +57,12 @@ function search_content(&$a,$update = 0, $load = false) { } if(strpos($search,'@') === 0) { $search = substr($search,1); - goaway(z_root() . '/directory' . '?f=1&search=' . $search); + goaway(z_root() . '/directory' . '?f=1&navsearch=1&search=' . $search); } // look for a naked webbie if(strpos($search,'@') !== false) { - goaway(z_root() . '/directory' . '?f=1&search=' . $search); + goaway(z_root() . '/directory' . '?f=1&navsearch=1&search=' . $search); } if(! $search) -- cgit v1.2.3 From 754ac2cff72b0d9d5d9b389740cc8946ed1e40b2 Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Mon, 6 Apr 2015 23:51:30 +0200 Subject: Fix Design Tool navigation for sys channel. Fix creating menu for sys channel. --- mod/layouts.php | 6 ++---- mod/menu.php | 27 +++++++++++++++++++-------- mod/webpages.php | 8 +++----- 3 files changed, 24 insertions(+), 17 deletions(-) (limited to 'mod') diff --git a/mod/layouts.php b/mod/layouts.php index 74a713cf1..2616513f8 100644 --- a/mod/layouts.php +++ b/mod/layouts.php @@ -98,7 +98,6 @@ function layouts_content(&$a) { header('Content-disposition: attachment; filename="' . $r[0]['sid'] . '.pdl"'); echo json_encode($r); killme(); - } } @@ -156,7 +155,7 @@ function layouts_content(&$a) { 'title' => $rr['sid'], 'mid' => $rr['mid'] ); - } + } } //Build the base URL for edit links @@ -172,7 +171,6 @@ function layouts_content(&$a) { '$preview' => '1', )); - - return $o; + return $o; } diff --git a/mod/menu.php b/mod/menu.php index 7e9c580a8..4153f1ac0 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -3,11 +3,20 @@ require_once('include/menu.php'); require_once('include/identity.php'); +function menu_init(&$a) { + if (array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { + $sys = get_sys_channel(); + if ($sys && intval($sys['channel_id'])) { + $a->is_sys = true; + } + } +} + function menu_post(&$a) { $uid = local_channel(); - if(array_key_exists('sys',$_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { + if(array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { $sys = get_sys_channel(); $uid = intval($sys['channel_id']); $a->is_sys = true; @@ -17,7 +26,7 @@ function menu_post(&$a) { return; $_REQUEST['menu_channel_id'] = $uid; - + if($_REQUEST['menu_bookmark']) $_REQUEST['menu_flags'] |= MENU_BOOKMARK; if($_REQUEST['menu_system']) @@ -44,7 +53,6 @@ function menu_post(&$a) { notice( t('Unable to create menu.'). EOL); } - } @@ -52,7 +60,7 @@ function menu_content(&$a) { $uid = local_channel(); - if($a->is_sys && is_site_admin()) { + if ($a->is_sys && is_site_admin()) { $sys = get_sys_channel(); $uid = intval($sys['channel_id']); } @@ -82,7 +90,8 @@ function menu_content(&$a) { '$hintnew' => t('Create a new menu'), '$hintdrop' => t('Delete this menu'), '$hintcontent' => t('Edit menu contents'), - '$hintedit' => t('Edit this menu') + '$hintedit' => t('Edit this menu'), + '$sys' => $a->is_sys )); return $o; @@ -91,18 +100,20 @@ function menu_content(&$a) { if(argc() > 1) { - if(argv(1) === 'new') { + if(argv(1) === 'new') { $o = replace_macros(get_markup_template('menuedit.tpl'), array( '$header' => t('New Menu'), '$menu_name' => array('menu_name', t('Menu name'), '', t('Must be unique, only seen by you'), '*'), '$menu_desc' => array('menu_desc', t('Menu title'), '', t('Menu title as seen by others'), ''), '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), 0 , t('Menu may be used to store saved bookmarks'), ''), - '$submit' => t('Create') + '$submit' => t('Create'), + '$sys' => $a->is_sys )); + return $o; } - elseif(intval(argv(1))) { + elseif(intval(argv(1))) { $m = menu_fetch_id(intval(argv(1)),$uid); if(! $m) { notice( t('Menu not found.') . EOL); diff --git a/mod/webpages.php b/mod/webpages.php index 6aff72a5e..a2a0ebf7b 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -71,7 +71,7 @@ function webpages_content(&$a) { if(feature_enabled($owner,'expert')) { $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); if(! $mimetype) - $mimetype = 'choose'; + $mimetype = 'choose'; } else { $mimetype = 'text/bbcode'; @@ -129,7 +129,7 @@ function webpages_content(&$a) { // Get a list of webpages. We can't display all them because endless scroll makes that unusable, // so just list titles and an edit link. - //TODO - this should be replaced with pagelist_widget + /** @TODO - this should be replaced with pagelist_widget */ $r = q("select * from item_id left join item on item_id.iid = item.id where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc", @@ -157,7 +157,7 @@ function webpages_content(&$a) { $url = z_root() . '/editwebpage/' . $which; $o .= replace_macros(get_markup_template('webpagelist.tpl'), array( - '$listtitle' => t('Webpages'), + '$listtitle' => t('Webpages'), '$baseurl' => $url, '$edit' => t('Edit'), '$pages' => $pages, @@ -169,9 +169,7 @@ function webpages_content(&$a) { '$title_txt' => t('Title'), '$created_txt' => t('Created'), '$edited_txt' => t('Edited') - )); return $o; - } -- cgit v1.2.3 From 04959a095f46272ecfee225e1dd85796f4e0676f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 6 Apr 2015 16:14:12 -0700 Subject: make the findpeople widget honour the local/global directory setting --- mod/dirsearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 07621aaef..c741d31a3 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -100,7 +100,7 @@ function dirsearch_content(&$a) { if($name) $sql_extra .= dir_query_build($joiner,'xchan_name',$name); if($hub) - $sql_extra .= " $joiner xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') "; + $sql_extra .= " and xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') "; if($address) $sql_extra .= dir_query_build($joiner,'xchan_addr',$address); if($city) -- cgit v1.2.3 From 3a3563a4b1673cdd86fdba01985ccfea98ab8b0e Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 6 Apr 2015 19:00:13 -0700 Subject: commit 59828593c broke some important poco stuff, looks like the cat might have climbed over the keyboard and deleted something that wasn't intended to be deleted. --- mod/directory.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index 87dadc58f..2a4672039 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -82,12 +82,15 @@ function directory_content(&$a) { $suggest = (local_channel() && x($_REQUEST,'suggest')) ? $_REQUEST['suggest'] : ''; if($suggest) { + $r = suggestion_query(local_channel(),get_observer_hash()); // Remember in which order the suggestions were $addresses = array(); + $common = array(); $index = 0; foreach($r as $rr) { +// $common[$rr['xchan_addr']] = $rr['total']; $addresses[$rr['xchan_addr']] = $index++; } @@ -300,6 +303,8 @@ function directory_content(&$a) { 'keywords' => $out, 'ignlink' => $suggest ? $a->get_baseurl() . '/directory?ignore=' . $rr['hash'] : '', 'ignore_label' => "Don't suggest", + 'common_friends' => (($common[$rr['address']]) ? intval($common[$rr['address']]) : ''), + 'common_txt' => sprintf( t('Common connections: %s'), intval($common[$rr['address']]) ), 'safe' => $safe_mode ); -- cgit v1.2.3 From 5bc7c0e7988765998d44f005a9e7121848888660 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 6 Apr 2015 22:36:46 -0700 Subject: add endless scroll to viewconnections module --- mod/viewconnections.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/viewconnections.php b/mod/viewconnections.php index ee68c2149..ef6681e64 100644 --- a/mod/viewconnections.php +++ b/mod/viewconnections.php @@ -28,6 +28,10 @@ function viewconnections_content(&$a) { return; } + if(! $_REQUEST['aj']) + $_SESSION['return_url'] = $a->query_string; + + $is_owner = ((local_channel() && local_channel() == $a->profile['uid']) ? true : false); $abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF; @@ -54,7 +58,7 @@ function viewconnections_content(&$a) { intval($a->pager['start']) ); - if(! $r) { + if((! $r) && (! $_REQUEST['aj'])) { info( t('No connections.') . EOL ); return $o; } @@ -81,13 +85,30 @@ function viewconnections_content(&$a) { } - $tpl = get_markup_template("viewcontact_template.tpl"); - $o .= replace_macros($tpl, array( - '$title' => t('View Connections'), - '$contacts' => $contacts, - '$paginate' => paginate($a), - )); + if($_REQUEST['aj']) { + if($contacts) { + $o = replace_macros(get_markup_template('viewcontactsajax.tpl'),array( + '$contacts' => $contacts + )); + } + else { + $o = '
      '; + } + echo $o; + killme(); + } + else { + $o .= ""; + $tpl = get_markup_template("viewcontact_template.tpl"); + $o .= replace_macros($tpl, array( + '$title' => t('View Connections'), + '$contacts' => $contacts, +// '$paginate' => paginate($a), + )); + } + if(! $contacts) + $o .= '
      '; return $o; } -- cgit v1.2.3 From 558246257c4cbc91b55884b3d6252e41858b9955 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 7 Apr 2015 13:51:51 -0700 Subject: separate the hub query since it changes the logic default and cannot easily be grouped --- mod/dirsearch.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index c741d31a3..d997020b2 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -91,6 +91,12 @@ function dirsearch_content(&$a) { else $sync = false; + + if($hub) + $hub_query = " and xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') "; + else + $hub_query = ''; + $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : ''); $joiner = ' OR '; @@ -99,8 +105,6 @@ function dirsearch_content(&$a) { if($name) $sql_extra .= dir_query_build($joiner,'xchan_name',$name); - if($hub) - $sql_extra .= " and xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') "; if($address) $sql_extra .= dir_query_build($joiner,'xchan_addr',$address); if($city) @@ -248,13 +252,12 @@ function dirsearch_content(&$a) { } else { - $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql $order $qlimit ", + $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql $order $qlimit ", intval(XCHAN_FLAGS_HIDDEN), intval(XCHAN_FLAGS_ORPHAN), intval(XCHAN_FLAGS_DELETED) ); - $ret['page'] = $page + 1; $ret['records'] = count($r); } -- cgit v1.2.3 From dc2830755dfe14d121e740edaccfc13bade2426a Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 7 Apr 2015 18:13:10 -0700 Subject: add common connection count to suggestions --- mod/directory.php | 2 +- mod/suggest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index 2a4672039..38dd9687a 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -90,7 +90,7 @@ function directory_content(&$a) { $common = array(); $index = 0; foreach($r as $rr) { -// $common[$rr['xchan_addr']] = $rr['total']; + $common[$rr['xchan_addr']] = $rr['total']; $addresses[$rr['xchan_addr']] = $index++; } diff --git a/mod/suggest.php b/mod/suggest.php index fec0e85a4..438d884ca 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -44,6 +44,7 @@ function suggest_content(&$a) { $arr[] = array( 'url' => chanlink_url($rr['xchan_url']), + 'common' => $rr['total'], 'profile' => $rr['xchan_url'], 'name' => $rr['xchan_name'], 'photo' => $rr['xchan_photo_m'], -- cgit v1.2.3 From 37afc8184751556107a23910be094c80990901dd Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 8 Apr 2015 17:54:52 -0700 Subject: update features, allow sys account page deletion --- mod/item.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index fa40aea03..45ac4a6aa 100644 --- a/mod/item.php +++ b/mod/item.php @@ -950,6 +950,10 @@ function item_content(&$a) { if(local_channel() && local_channel() == $i[0]['uid']) $local_delete = true; + $sys = get_sys_channel(); + if(is_site_admin() && $sys['channel_id'] == $i[0]['uid']) + $can_delete = true; + $ob_hash = get_observer_hash(); if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) $can_delete = true; -- cgit v1.2.3 From 7bec4b313a7a553e6df3e24289cf894f3d70a94e Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 8 Apr 2015 23:05:36 -0700 Subject: system channel always has allow_code privileges --- mod/webpages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/webpages.php b/mod/webpages.php index a2a0ebf7b..c5fdda89b 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -68,7 +68,7 @@ function webpages_content(&$a) { return; } - if(feature_enabled($owner,'expert')) { + if(feature_enabled($owner,'expert') || $a->is_sys) { $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); if(! $mimetype) $mimetype = 'choose'; -- cgit v1.2.3 From 2619b60721c328aacbf7bd30d47476a68ce9b203 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 9 Apr 2015 15:45:08 -0700 Subject: make sure we redirect to a sane place after deleting a webpage element --- mod/blocks.php | 2 ++ mod/layouts.php | 2 ++ mod/webpages.php | 2 ++ 3 files changed, 6 insertions(+) (limited to 'mod') diff --git a/mod/blocks.php b/mod/blocks.php index f755f92b0..1b7a3588f 100644 --- a/mod/blocks.php +++ b/mod/blocks.php @@ -33,6 +33,8 @@ function blocks_content(&$a) { $which = argv(1); + $_SESSION['return_url'] = $a->query_string; + $uid = local_channel(); $owner = 0; $channel = null; diff --git a/mod/layouts.php b/mod/layouts.php index 2616513f8..4640c6690 100644 --- a/mod/layouts.php +++ b/mod/layouts.php @@ -33,6 +33,8 @@ function layouts_content(&$a) { $which = argv(1); + $_SESSION['return_url'] = $a->query_string; + $uid = local_channel(); $owner = 0; $channel = null; diff --git a/mod/webpages.php b/mod/webpages.php index c5fdda89b..a9cf61dd1 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -32,6 +32,8 @@ function webpages_content(&$a) { } $which = argv(1); + + $_SESSION['return_url'] = $a->query_string; $uid = local_channel(); $owner = 0; -- cgit v1.2.3 From 3fd2e4b716aaf4626b774ac5d808cc4088e6f3f2 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 9 Apr 2015 19:51:58 -0700 Subject: program the affinity slider labels --- mod/connedit.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'mod') diff --git a/mod/connedit.php b/mod/connedit.php index 2c4c0cef8..70839e373 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -558,16 +558,32 @@ function connedit_content(&$a) { if(feature_enabled(local_channel(),'affinity')) { + $labels = array( + t('Me'), + t('Family'), + t('Friends'), + t('Acquaintances'), + t('All') + ); + call_hooks('affinity_labels',$labels); + $label_str = ''; + + if($labels) { + foreach($labels as $l) { + if($label_str) { + $label_str .= ", '|'"; + $label_str .= ", '" . $l . "'"; + } + else + $label_str .= "'" . $l . "'"; + } + } + $slider_tpl = get_markup_template('contact_slider.tpl'); $slide = replace_macros($slider_tpl,array( - '$me' => t('Me'), '$min' => 1, '$val' => (($contact['abook_closeness']) ? $contact['abook_closeness'] : 99), - '$intimate' => t('Best Friends'), - '$friends' => t('Friends'), - '$oldfriends' => t('Former Friends'), - '$acquaintances' => t('Acquaintances'), - '$world' => t('Unknown') + '$labels' => $label_str, )); } -- cgit v1.2.3 From 7c8b9397ae8fc83ce96d9905992f40e6fde4663a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 12 Apr 2015 13:13:22 +0200 Subject: reverse file activity logic --- mod/filestorage.php | 8 ++++---- mod/photos.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'mod') diff --git a/mod/filestorage.php b/mod/filestorage.php index f2c795379..0421641e2 100644 --- a/mod/filestorage.php +++ b/mod/filestorage.php @@ -21,7 +21,7 @@ function filestorage_post(&$a) { $recurse = ((x($_POST, 'recurse')) ? intval($_POST['recurse']) : 0); $resource = ((x($_POST, 'filehash')) ? notags($_POST['filehash']) : ''); - $no_activity = ((x($_POST, 'no_activity')) ? intval($_POST['no_activity']) : 0); + $notify = ((x($_POST, 'notify')) ? intval($_POST['notify']) : 0); if(! $resource) { notice(t('Item not found.') . EOL); @@ -41,7 +41,7 @@ function filestorage_post(&$a) { attach_change_permissions($channel_id, $resource, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, $recurse); - file_activity($channel_id, $object, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, 'post', $no_activity); + file_activity($channel_id, $object, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, 'post', $notify); goaway($cloudPath); } @@ -148,7 +148,7 @@ function filestorage_content(&$a) { '$aclselect' => $aclselect_e, '$lockstate' => $lockstate, '$permset' => t('Set/edit permissions'), - '$recurse' => t('Include all files and sub folders'), + '$recurse' => array('recurse', t('Include all files and sub folders'), 0, '', array(t('No'), t('Yes'))), '$backlink' => t('Return to file list'), '$isadir' => $is_a_dir, '$cpdesc' => t('Copy/paste this code to attach file to a post'), @@ -156,7 +156,7 @@ function filestorage_content(&$a) { '$submit' => t('Submit'), '$attach_btn_title' => t('Attach this file to a new post'), '$link_btn_title' => t('Show URL to this file'), - '$activity_btn_title' => t('Do not show in shared with me folder of your connections') + '$notify' => array('notify', t('Notify your contacts about this file'), 0, '', array(t('No'), t('Yes'))) )); echo $o; diff --git a/mod/photos.php b/mod/photos.php index 503a113dc..296aab67f 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -553,7 +553,7 @@ function photos_content(&$a) { '$nickname' => $a->data['channel']['channel_address'], '$newalbum_label' => t('Enter a new album name'), '$newalbum_placeholder' => t('or select an existing one (doubleclick)'), - '$visible' => array('visible', t('Create a status post for this upload'),0,''), + '$visible' => array('visible', t('Create a status post for this upload'), 0, '', array(t('No'), t('Yes'))), '$albums' => $albums['albums'], '$selname' => $selname, '$permissions' => t('Permissions'), -- cgit v1.2.3 From 865b602cf8b4eff5e7da00362df95e52e2fe4f77 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 13 Apr 2015 23:38:36 +0200 Subject: webpages appearence --- mod/webpages.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/webpages.php b/mod/webpages.php index a9cf61dd1..b4c4e6e4e 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -127,7 +127,7 @@ function webpages_content(&$a) { if($_REQUEST['pagetitle']) $x['pagetitle'] = $_REQUEST['pagetitle']; - $o .= status_editor($a,$x); + $editor .= status_editor($a,$x); // Get a list of webpages. We can't display all them because endless scroll makes that unusable, // so just list titles and an edit link. @@ -161,14 +161,17 @@ function webpages_content(&$a) { $o .= replace_macros(get_markup_template('webpagelist.tpl'), array( '$listtitle' => t('Webpages'), '$baseurl' => $url, + '$create' => t('Create'), '$edit' => t('Edit'), + '$delete' => t('Delete'), '$pages' => $pages, '$channel' => $which, + '$editor' => $editor, '$view' => t('View'), '$preview' => t('Preview'), '$actions_txt' => t('Actions'), '$pagelink_txt' => t('Page Link'), - '$title_txt' => t('Title'), + '$title_txt' => t('Page Title'), '$created_txt' => t('Created'), '$edited_txt' => t('Edited') )); -- cgit v1.2.3 From d3bc721138433b3d4940f0c8ade7ebd39fff9b6e Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 13 Apr 2015 16:03:09 -0700 Subject: item_check_service_class wasn't returning correct results --- mod/item.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 45ac4a6aa..53064132c 100644 --- a/mod/item.php +++ b/mod/item.php @@ -116,7 +116,7 @@ function item_post(&$a) { * Check service class limits */ if ($uid && !(x($_REQUEST,'parent')) && !(x($_REQUEST,'post_id'))) { - $ret = item_check_service_class($uid,x($_REQUEST,'webpage')); + $ret = item_check_service_class($uid,(($_REQUEST['webpage'] == ITEM_WEBPAGE) ? true : false)); if (!$ret['success']) { notice( t($ret['message']) . EOL) ; if(x($_REQUEST,'return')) @@ -1084,6 +1084,7 @@ function item_check_service_class($channel_id,$iswebpage) { $ret = array('success' => false, $message => ''); if ($iswebpage) { + // note: we aren't counting comanche templates and blocks, only webpages $r = q("select count(id) as total from item where parent = id and ( item_restrict & %d ) > 0 and ( item_restrict & %d ) = 0 and uid = %d ", intval(ITEM_WEBPAGE), @@ -1092,7 +1093,8 @@ function item_check_service_class($channel_id,$iswebpage) { ); } else { - $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and uid = %d ", + $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and (item_flags & %d) > 0 and uid = %d ", + intval(ITEM_WALL), intval($channel_id) ); } @@ -1103,14 +1105,16 @@ function item_check_service_class($channel_id,$iswebpage) { } if (!$iswebpage) { + $max = service_class_fetch($channel_id,'total_items'); if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) { - $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f top level posts.'),$r[0]['total']); + $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f top level posts.'),$max); return $result; } } else { + $max = service_class_fetch($channel_id,'total_pages'); if(! service_class_allows($channel_id,'total_pages',$r[0]['total'])) { - $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f webpages.'),$r[0]['total']); + $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f webpages.'),$max); return $result; } } -- cgit v1.2.3 From 213ca7f8b584c9b75f25aa560b1f3eda1e415f54 Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Mon, 13 Apr 2015 16:18:11 -0700 Subject: unquote binary --- mod/attach.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/attach.php b/mod/attach.php index cf72d09c6..118c67dd5 100644 --- a/mod/attach.php +++ b/mod/attach.php @@ -36,7 +36,8 @@ function attach_init(&$a) { header('Content-disposition: attachment; filename="' . $r['data']['filename'] . '"'); if($r['data']['flags'] & ATTACH_FLAG_OS ) { - $istream = fopen('store/' . $c[0]['channel_address'] . '/' . $r['data']['data'],'rb'); + $fname = dbunescbin($r['data']['data']); + $istream = fopen('store/' . $c[0]['channel_address'] . '/' . $fname,'rb'); $ostream = fopen('php://output','wb'); if($istream && $ostream) { pipe_streams($istream,$ostream); @@ -45,7 +46,7 @@ function attach_init(&$a) { } } else - echo $r['data']['data']; + echo dbunescbin($r['data']['data']); killme(); } -- cgit v1.2.3 From bf2a97147ecef7528e9adbed3cf4a1f3af03ad72 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 14 Apr 2015 11:50:21 +0200 Subject: some more on webpages --- mod/editwebpage.php | 2 +- mod/webpages.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'mod') diff --git a/mod/editwebpage.php b/mod/editwebpage.php index e81cde479..e30a33171 100644 --- a/mod/editwebpage.php +++ b/mod/editwebpage.php @@ -126,7 +126,7 @@ function editwebpage_content(&$a) { $plaintext = true; if(get_config('system','page_mimetype')) - $mimeselect = ''; + $mimeselect = ''; else $mimeselect = mimetype_select($itm[0]['uid'],$mimetype); diff --git a/mod/webpages.php b/mod/webpages.php index b4c4e6e4e..2b284813a 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -70,10 +70,10 @@ function webpages_content(&$a) { return; } - if(feature_enabled($owner,'expert') || $a->is_sys) { - $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); - if(! $mimetype) - $mimetype = 'choose'; + $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); + + if(! $mimetype) { + $mimetype = 'choose'; } else { $mimetype = 'text/bbcode'; -- cgit v1.2.3 From 953819e7da8152f959f04c733ce617cc34cf8c7d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 14 Apr 2015 12:52:31 +0200 Subject: css fixes and remove expert mode for block page content type --- mod/blocks.php | 11 +++-------- mod/webpages.php | 3 --- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'mod') diff --git a/mod/blocks.php b/mod/blocks.php index 1b7a3588f..e0f32f4f1 100644 --- a/mod/blocks.php +++ b/mod/blocks.php @@ -78,16 +78,11 @@ function blocks_content(&$a) { return; } + $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); - if(feature_enabled($owner,'expert')) { - $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); - if(! $mimetype) - $mimetype = 'choose'; + if(! $mimetype) { + $mimetype = 'choose'; } - else { - $mimetype = 'text/bbcode'; - } - $x = array( 'webpage' => ITEM_BUILDBLOCK, diff --git a/mod/webpages.php b/mod/webpages.php index 2b284813a..e2b5eb3a4 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -75,9 +75,6 @@ function webpages_content(&$a) { if(! $mimetype) { $mimetype = 'choose'; } - else { - $mimetype = 'text/bbcode'; - } $layout = (($_REQUEST['layout']) ? $_REQUEST['layout'] : get_pconfig($owner,'system','page_layout')); if(! $layout) -- cgit v1.2.3 From 3a45206b9971ee981ea61de31c8413350ebcdd7b Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 14 Apr 2015 16:22:33 -0700 Subject: default perms not being set in some cases --- mod/connedit.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'mod') diff --git a/mod/connedit.php b/mod/connedit.php index 70839e373..8ae1707ae 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -177,7 +177,17 @@ function connedit_post(&$a) { if(($_REQUEST['pending']) && ($abook_flags & ABOOK_FLAG_PENDING)) { $abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING ); $new_friend = true; + if(! $abook_my_perms) { + $abook_my_perms = get_channel_default_perms(local_channel()); + + $role = get_pconfig(local_channel(),'system','permissions_role'); + if($role) { + $x = get_role_perms($role); + if($x['perms_accept']) + $abook_my_perms = $x['perms_accept']; + } + } } $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d -- cgit v1.2.3 From 2c8394a4b90b5b6dc52d5d886fd8e96134e57406 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 14 Apr 2015 21:48:42 -0700 Subject: funny I should mention comanche preview (yesterday) as clicking the view link on a layout does nothing interesting at all. So I've made it do a crude but useable preview with page content of 'Lorem Ipsum'. --- mod/page.php | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'mod') diff --git a/mod/page.php b/mod/page.php index 05d88aa52..ad1862a7a 100644 --- a/mod/page.php +++ b/mod/page.php @@ -55,11 +55,12 @@ function page_init(&$a) { $sql_options = item_permissions_sql($u[0]['channel_id']); $r = q("select item.* from item left join item_id on item.id = item_id.iid - where item.uid = %d and sid = '%s' and service = 'WEBPAGE' and - item_restrict = %d $sql_options $revision limit 1", + where item.uid = %d and sid = '%s' and (( service = 'WEBPAGE' and + item_restrict = %d ) or ( service = 'PDL' and item_restrict = %d )) $sql_options $revision limit 1", intval($u[0]['channel_id']), dbesc($page_id), - intval(ITEM_WEBPAGE) + intval(ITEM_WEBPAGE), + intval(ITEM_PDL) ); if(! $r) { @@ -83,7 +84,12 @@ function page_init(&$a) { return; } - if($r[0]['layout_mid']) { + if($r[0]['item_restrict'] == ITEM_PDL) { + require_once('include/comanche.php'); + comanche_parser(get_app(),$r[0]['body']); + get_app()->pdl = $r[0]['body']; + } + elseif($r[0]['layout_mid']) { $l = q("select body from item where mid = '%s' and uid = %d limit 1", dbesc($r[0]['layout_mid']), intval($u[0]['channel_id']) @@ -98,8 +104,6 @@ function page_init(&$a) { $a->data['webpage'] = $r; - - } @@ -111,17 +115,11 @@ function page_content(&$a) { 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; - $which = $r[0]['id']; - $o .= writepages_widget($who,$which); + if($r[0]['item_restrict'] == ITEM_PDL) { + $r[0]['body'] = t('Ipsum Lorem'); + $r[0]['mimetype'] = 'text/plain'; + $r[0]['title'] = ''; + } xchan_query($r); -- cgit v1.2.3 From a597c74b977c7cd844ebae642705baa27722f9e1 Mon Sep 17 00:00:00 2001 From: mrjive Date: Wed, 15 Apr 2015 12:26:03 +0200 Subject: Update viewsrc.php Adding the item ID to the item source view --- mod/viewsrc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/viewsrc.php b/mod/viewsrc.php index 983a0e725..3125ae4c0 100644 --- a/mod/viewsrc.php +++ b/mod/viewsrc.php @@ -21,7 +21,7 @@ function viewsrc_content(&$a) { } if(local_channel() && $item_id) { - $r = q("select item_flags, body from item where item_restrict = 0 and uid in (%d , %d) and id = %d limit 1", + $r = q("select item_flags, body, id from item where item_restrict = 0 and uid in (%d , %d) and id = %d limit 1", intval(local_channel()), intval($sys['channel_id']), intval($item_id) @@ -35,6 +35,7 @@ function viewsrc_content(&$a) { } if(is_ajax()) { + print '
      ' . t('Source of Item') . ' ' . $r[0]['id'] . '
      '; echo $o; killme(); } -- cgit v1.2.3 From 86ac9c0d6b56651cb79c60a616f8340524d1573e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 16 Apr 2015 10:43:14 +0200 Subject: move share webpage element from editwebpage to webpages and make it shareable with rpost --- mod/editwebpage.php | 15 --------------- mod/webpages.php | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 18 deletions(-) (limited to 'mod') diff --git a/mod/editwebpage.php b/mod/editwebpage.php index e30a33171..55cd3b4ef 100644 --- a/mod/editwebpage.php +++ b/mod/editwebpage.php @@ -221,21 +221,6 @@ logger('canwrite: ' . (perm_is_allowed($owner, get_observer_hash(), 'post_photos if(($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) $o .= '

      ' . t('Delete Webpage') . '
      '; - - $x = array( - 'type' => 'webpage', - 'title' => $itm[0]['title'], - 'body' => $itm[0]['body'], - 'term' => $itm[0]['term'], - 'created' => $itm[0]['created'], - 'edited' => $itm[0]['edited'], - 'mimetype' => $itm[0]['mimetype'], - 'pagetitle' => $page_title, - 'mid' => $itm[0]['mid'] - ); - - $o .= EOL . EOL . t('Share') . EOL . '' . EOL . EOL; - return $o; } diff --git a/mod/webpages.php b/mod/webpages.php index e2b5eb3a4..75803e908 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -124,7 +124,7 @@ function webpages_content(&$a) { if($_REQUEST['pagetitle']) $x['pagetitle'] = $_REQUEST['pagetitle']; - $editor .= status_editor($a,$x); + $editor = status_editor($a,$x); // Get a list of webpages. We can't display all them because endless scroll makes that unusable, // so just list titles and an edit link. @@ -141,12 +141,24 @@ function webpages_content(&$a) { $pages = array(); foreach($r as $rr) { unobscure($rr); + $element_arr = array( + 'type' => 'webpage', + 'title' => $rr['title'], + 'body' => $rr['body'], + 'term' => $rr['term'], + 'created' => $rr['created'], + 'edited' => $rr['edited'], + 'mimetype' => $rr['mimetype'], + 'pagetitle' => $rr['sid'], + 'mid' => $rr['mid'] + ); $pages[$rr['iid']][] = array( 'url' => $rr['iid'], 'pagetitle' => $rr['sid'], 'title' => $rr['title'], 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']), - 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']) + 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']), + 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]' ); } } @@ -158,8 +170,9 @@ function webpages_content(&$a) { $o .= replace_macros(get_markup_template('webpagelist.tpl'), array( '$listtitle' => t('Webpages'), '$baseurl' => $url, - '$create' => t('Create'), + '$create' => t('Create'), '$edit' => t('Edit'), + '$share' => t('Share'), '$delete' => t('Delete'), '$pages' => $pages, '$channel' => $which, -- cgit v1.2.3 From b42bb09635c6040945bcc65e7b7e6218870b92ea Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 16 Apr 2015 10:46:59 +0200 Subject: whitespace --- mod/webpages.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'mod') diff --git a/mod/webpages.php b/mod/webpages.php index 75803e908..5013d803a 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -142,23 +142,23 @@ function webpages_content(&$a) { foreach($r as $rr) { unobscure($rr); $element_arr = array( - 'type' => 'webpage', - 'title' => $rr['title'], - 'body' => $rr['body'], - 'term' => $rr['term'], - 'created' => $rr['created'], - 'edited' => $rr['edited'], - 'mimetype' => $rr['mimetype'], - 'pagetitle' => $rr['sid'], - 'mid' => $rr['mid'] + 'type' => 'webpage', + 'title' => $rr['title'], + 'body' => $rr['body'], + 'term' => $rr['term'], + 'created' => $rr['created'], + 'edited' => $rr['edited'], + 'mimetype' => $rr['mimetype'], + 'pagetitle' => $rr['sid'], + 'mid' => $rr['mid'] ); $pages[$rr['iid']][] = array( - 'url' => $rr['iid'], - 'pagetitle' => $rr['sid'], - 'title' => $rr['title'], - 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']), - 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']), - 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]' + 'url' => $rr['iid'], + 'pagetitle' => $rr['sid'], + 'title' => $rr['title'], + 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']), + 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']), + 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]' ); } } -- cgit v1.2.3 From 90d3a6c02dd12317c72ad790a1b6810f885f638c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 16 Apr 2015 11:15:04 +0200 Subject: make rpost respect default post permissions --- mod/rpost.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/rpost.php b/mod/rpost.php index 10ae6b8ab..1bde121e4 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -94,6 +94,13 @@ function rpost_content(&$a) { $channel = $a->get_channel(); + $channel_acl = array( + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] + ); + $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit post') )); @@ -111,7 +118,7 @@ function rpost_content(&$a) { 'nickname' => $channel['channel_address'], 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'acl' => populate_acl($channel), + 'acl' => populate_acl($channel_acl), 'bang' => '', 'visitor' => true, 'profile_uid' => local_channel(), -- cgit v1.2.3 From 9addc4581edf594996151eaf514927d271f04da5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 16 Apr 2015 23:26:11 +0200 Subject: provide a separate input field for rpost attachments --- mod/item.php | 2 +- mod/rpost.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 53064132c..d80241f2d 100644 --- a/mod/item.php +++ b/mod/item.php @@ -22,7 +22,6 @@ require_once('include/attach.php'); function item_post(&$a) { - // This will change. Figure out who the observer is and whether or not // they have permission to post here. Else ignore the post. @@ -399,6 +398,7 @@ function item_post(&$a) { $verb = notags(trim($_REQUEST['verb'])); $title = escape_tags(trim($_REQUEST['title'])); $body = trim($_REQUEST['body']); + $body .= trim($_REQUEST['attachment']); $postopts = ''; $private = ( diff --git a/mod/rpost.php b/mod/rpost.php index 1bde121e4..737d705f6 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -124,6 +124,7 @@ function rpost_content(&$a) { 'profile_uid' => local_channel(), 'title' => $_REQUEST['title'], 'body' => $_REQUEST['body'], + 'attachment' => $_REQUEST['attachment'], 'source' => ((x($_REQUEST,'source')) ? strip_tags($_REQUEST['source']) : ''), 'return_path' => 'rpost/return' ); -- cgit v1.2.3 From 10cc643f650b5ff0954ff988fbf768ea5e061571 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 16 Apr 2015 23:46:12 +0200 Subject: wording and css fixes --- mod/filestorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/filestorage.php b/mod/filestorage.php index 0421641e2..8b52c086b 100644 --- a/mod/filestorage.php +++ b/mod/filestorage.php @@ -154,7 +154,7 @@ function filestorage_content(&$a) { '$cpdesc' => t('Copy/paste this code to attach file to a post'), '$cpldesc' => t('Copy/paste this URL to link file from a web page'), '$submit' => t('Submit'), - '$attach_btn_title' => t('Attach this file to a new post'), + '$attach_btn_title' => t('Share this file'), '$link_btn_title' => t('Show URL to this file'), '$notify' => array('notify', t('Notify your contacts about this file'), 0, '', array(t('No'), t('Yes'))) )); -- cgit v1.2.3 From 61e4ee753dd0e823c47a5cf2e485f7f69fb4d125 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 17 Apr 2015 11:20:22 +0200 Subject: allow jot to be displayed expanded, remove deprected datetimepicker js and some random fixes --- mod/editwebpage.php | 19 +++++++++---------- mod/rpost.php | 10 +++++----- mod/webpages.php | 1 + 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'mod') diff --git a/mod/editwebpage.php b/mod/editwebpage.php index 55cd3b4ef..a7564a126 100644 --- a/mod/editwebpage.php +++ b/mod/editwebpage.php @@ -135,12 +135,7 @@ function editwebpage_content(&$a) { $layoutselect = ''; else $layoutselect = layout_select($itm[0]['uid'],$itm[0]['layout_mid']); - - $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( - '$title' => t('Edit Webpage') - )); - $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( '$baseurl' => $a->get_baseurl(), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), @@ -150,7 +145,6 @@ function editwebpage_content(&$a) { '$confirmdelete' => t('Delete webpage?') )); - $tpl = get_markup_template("jot.tpl"); $jotplugins = ''; @@ -164,8 +158,9 @@ function editwebpage_content(&$a) { $rp = 'webpages/' . $which; -logger('canwrite: ' . (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage'))); - $o .= replace_macros($tpl,array( + logger('canwrite: ' . (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage'))); + + $editor = replace_macros($tpl,array( '$return_path' => $rp, '$webpage' => ITEM_WEBPAGE, '$placeholdpagetitle' => t('Page link title'), @@ -218,8 +213,12 @@ logger('canwrite: ' . (perm_is_allowed($owner, get_observer_hash(), 'post_photos )); - if(($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) - $o .= '

      ' . t('Delete Webpage') . '
      '; + $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( + '$title' => t('Edit Webpage'), + '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), + '$editor' => $editor, + '$id' => $itm[0]['id'] + )); return $o; diff --git a/mod/rpost.php b/mod/rpost.php index 737d705f6..0c0916646 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -101,10 +101,6 @@ function rpost_content(&$a) { 'deny_gid' => $channel['channel_deny_gid'] ); - $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( - '$title' => t('Edit post') - )); - if($_REQUEST['url']) { $x = z_fetch_url(z_root() . '/parse_url?f=&url=' . urlencode($_REQUEST['url'])); if($x['success']) @@ -129,8 +125,12 @@ function rpost_content(&$a) { 'return_path' => 'rpost/return' ); + $editor = status_editor($a,$x); - $o .= status_editor($a,$x); + $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( + '$title' => t('Edit post'), + '$editor' => $editor + )); return $o; diff --git a/mod/webpages.php b/mod/webpages.php index 5013d803a..b303b8652 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -115,6 +115,7 @@ function webpages_content(&$a) { 'profile_uid' => intval($owner), 'mimetype' => $mimetype, 'layout' => $layout, + 'expanded' => true ); if($_REQUEST['title']) -- cgit v1.2.3 From 0883512e30af10ea7ed0f461afc8236a828e7d2b Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 18 Apr 2015 17:40:44 -0700 Subject: log this since we may need it to track down failures --- mod/wall_attach.php | 1 + 1 file changed, 1 insertion(+) (limited to 'mod') diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 498389986..021f9f999 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -23,6 +23,7 @@ function wall_attach_post(&$a) { if($_FILES['userfile']['tmp_name']) { $x = @getimagesize($_FILES['userfile']['tmp_name']); + logger('getimagesize: ' . print_r($x,true), LOGGER_DATA); if(($x) && ($x[2] === IMG_GIF || $x[2] === IMG_JPG || $x[2] === IMG_JPEG || $x[2] === IMG_PNG)) { $args = array( 'source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash'])); $ret = photo_upload($channel,$observer,$args); -- cgit v1.2.3 From dadcfd3ff675bfa0d0098ef34fe6a9aece3d096b Mon Sep 17 00:00:00 2001 From: Michael Johnston Date: Sun, 19 Apr 2015 18:06:24 -0400 Subject: switch from IMG_XXX constants to IMAGETYPE_XXX constants --- mod/wall_attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 021f9f999..4b7103802 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -24,7 +24,7 @@ function wall_attach_post(&$a) { if($_FILES['userfile']['tmp_name']) { $x = @getimagesize($_FILES['userfile']['tmp_name']); logger('getimagesize: ' . print_r($x,true), LOGGER_DATA); - if(($x) && ($x[2] === IMG_GIF || $x[2] === IMG_JPG || $x[2] === IMG_JPEG || $x[2] === IMG_PNG)) { + if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) { $args = array( 'source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash'])); $ret = photo_upload($channel,$observer,$args); if($ret['success']) { -- cgit v1.2.3 From 9cc8b44579ad0620d79c675b3449461db8d4e732 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 19 Apr 2015 23:04:14 -0700 Subject: issue #157, provide default directory sort order --- mod/directory.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index 38dd9687a..3e94d6395 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -158,7 +158,11 @@ function directory_content(&$a) { if(! is_null($pubforums)) $query .= '&pubforums=' . intval($pubforums); - $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : 'date'); + $directory_sort_order = get_config('system','directory_sort_order'); + if(! $directory_sort_order) + $directory_sort_order = 'date'; + + $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : $directory_sort_order); if($sort_order) $query .= '&order=' . urlencode($sort_order); -- cgit v1.2.3 From a707e9b9f523fdb6e37c37666651b3b3d4510e94 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 19 Apr 2015 23:16:17 -0700 Subject: issue #178, searching for words such as 'data' would return private items regardless of their unobscured content. --- mod/search.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/search.php b/mod/search.php index e235f720a..6d79f5eee 100644 --- a/mod/search.php +++ b/mod/search.php @@ -153,24 +153,26 @@ function search_content(&$a,$update = 0, $load = false) { } if(local_channel()) { $r = q("SELECT $prefix mid, item.id as item_id, item.* from item - WHERE item_restrict = 0 + WHERE item_restrict = 0 AND ( item_flags & %d ) = 0 AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) OR ( `item`.`uid` = %d )) OR item.owner_xchan = '%s' ) $sql_extra $suffix $pager_sql ", + intval(ITEM_OBSCURED), intval(local_channel()), dbesc($sys['xchan_hash']) ); } if($r === null) { $r = q("SELECT $prefix mid, item.id as item_id, item.* from item - WHERE item_restrict = 0 + WHERE item_restrict = 0 AND ( item_flags & %d ) = 0 AND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) and owner_xchan in ( " . stream_perms_xchans(($observer) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " )) $pub_sql ) OR owner_xchan = '%s') $sql_extra $suffix $pager_sql", + intval(ITEM_OBSCURED), dbesc($sys['xchan_hash']) ); } -- cgit v1.2.3 From 53339d19a391e66635c21199484f1e4afa7b2ec7 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 20 Apr 2015 20:14:07 -0700 Subject: issue #176, sender copy of item not obscured if using private mention --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index d80241f2d..a732a9f81 100644 --- a/mod/item.php +++ b/mod/item.php @@ -602,7 +602,7 @@ function item_post(&$a) { if($results) { // Set permissions based on tag replacements - set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item); + set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item, $private); $post_tags = array(); foreach($results as $result) { -- cgit v1.2.3 From 0bd9fe0b11013423a17ebaabb22482bee38d8f0f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 21 Apr 2015 10:05:26 +0200 Subject: rework and hopefully improve webpage menu creation workflow --- mod/menu.php | 82 +++++++++++++++++---------------- mod/mitem.php | 145 +++++++++++++++++++++++++++++++--------------------------- 2 files changed, 120 insertions(+), 107 deletions(-) (limited to 'mod') diff --git a/mod/menu.php b/mod/menu.php index 4153f1ac0..0dbbfde9c 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -37,7 +37,7 @@ function menu_post(&$a) { $_REQUEST['menu_id'] = intval(argv(1)); $r = menu_edit($_REQUEST); if($r) { - info( t('Menu updated.') . EOL); + //info( t('Menu updated.') . EOL); goaway(z_root() . '/mitem/' . $menu_id . (($a->is_sys) ? '?f=&sys=1' : '')); } else @@ -46,7 +46,7 @@ function menu_post(&$a) { else { $r = menu_create($_REQUEST); if($r) { - info( t('Menu created.') . EOL); + //info( t('Menu created.') . EOL); goaway(z_root() . '/mitem/' . $r . (($a->is_sys) ? '?f=&sys=1' : '')); } else @@ -70,8 +70,10 @@ function menu_content(&$a) { return ''; } - if(argc() == 1) { + + + // list menus $x = menu_list($uid); if($x) { @@ -80,14 +82,26 @@ function menu_content(&$a) { } } + $create = replace_macros(get_markup_template('menuedit.tpl'), array( + '$menu_name' => array('menu_name', t('Menu Name'), '', t('Unique name (not visible on webpage) - required'), '*'), + '$menu_desc' => array('menu_desc', t('Menu Title'), '', t('Visible on webpage - leave empty for no title'), ''), + '$menu_bookmark' => array('menu_bookmark', t('Allow Bookmarks'), 0 , t('Menu may be used to store saved bookmarks'), array(t('No'), t('Yes'))), + '$submit' => t('Submit and proceed'), + '$sys' => $a->is_sys, + '$display' => 'none' + )); + $o = replace_macros(get_markup_template('menulist.tpl'),array( - '$title' => t('Manage Menus'), + '$title' => t('Menus'), + '$create' => $create, '$menus' => $x, + '$nametitle' => t('Menu Name'), + '$desctitle' => t('Menu Title'), '$edit' => t('Edit'), '$drop' => t('Drop'), '$new' => t('New'), '$bmark' => t('Bookmarks allowed'), - '$hintnew' => t('Create a new menu'), + '$hintnew' => t('Create'), '$hintdrop' => t('Delete this menu'), '$hintcontent' => t('Edit menu contents'), '$hintedit' => t('Edit this menu'), @@ -98,50 +112,38 @@ function menu_content(&$a) { } - if(argc() > 1) { - if(argv(1) === 'new') { - $o = replace_macros(get_markup_template('menuedit.tpl'), array( - '$header' => t('New Menu'), - '$menu_name' => array('menu_name', t('Menu name'), '', t('Must be unique, only seen by you'), '*'), - '$menu_desc' => array('menu_desc', t('Menu title'), '', t('Menu title as seen by others'), ''), - '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), 0 , t('Menu may be used to store saved bookmarks'), ''), - '$submit' => t('Create'), - '$sys' => $a->is_sys - )); - - return $o; - } + if(intval(argv(1))) { - elseif(intval(argv(1))) { - $m = menu_fetch_id(intval(argv(1)),$uid); - if(! $m) { - notice( t('Menu not found.') . EOL); - return ''; - } if(argc() == 3 && argv(2) == 'drop') { $r = menu_delete_id(intval(argv(1)),$uid); - if($r) - info( t('Menu deleted.') . EOL); - else + if(!$r) notice( t('Menu could not be deleted.'). EOL); goaway(z_root() . '/menu' . (($a->is_sys) ? '?f=&sys=1' : '')); } - else { - $o = replace_macros(get_markup_template('menuedit.tpl'), array( - '$header' => t('Edit Menu'), - '$menu_id' => intval(argv(1)), - '$hintedit' => t('Add or remove entries to this menu'), - '$editcontents' => t('Edit menu contents'), - '$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'), - '$menu_desc' => array('menu_desc', t('Menu title'), $m['menu_desc'], t('Menu title as seen by others'), ''), - '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), (($m['menu_flags'] & MENU_BOOKMARK) ? 1 : 0), t('Menu may be used to store saved bookmarks'), ''), - '$menu_system' => (($m['menu_flags'] & MENU_SYSTEM) ? 1 : 0), - '$submit' => t('Modify') - )); - return $o; + + $m = menu_fetch_id(intval(argv(1)),$uid); + + if(! $m) { + notice( t('Menu not found.') . EOL); + return ''; } + + $o = replace_macros(get_markup_template('menuedit.tpl'), array( + '$header' => t('Edit Menu'), + '$menu_id' => intval(argv(1)), + '$hintedit' => t('Add or remove entries to this menu'), + '$editcontents' => t('Edit menu contents'), + '$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'), + '$menu_desc' => array('menu_desc', t('Menu title'), $m['menu_desc'], t('Menu title as seen by others'), ''), + '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), (($m['menu_flags'] & MENU_BOOKMARK) ? 1 : 0), t('Menu may be used to store saved bookmarks'), ''), + '$menu_system' => (($m['menu_flags'] & MENU_SYSTEM) ? 1 : 0), + '$submit' => t('Modify') + )); + + return $o; + } else { notice( t('Not found.') . EOL); diff --git a/mod/mitem.php b/mod/mitem.php index b561ec7d6..cce5bcbe3 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -41,14 +41,17 @@ function mitem_post(&$a) { return; } - - if(! $a->data['menu']) return; $channel = $a->get_channel(); + if(!$_REQUEST['mitem_desc'] || !$_REQUEST['mitem_link']) { + notice( t('Unable to create element.') . EOL); + return; + } + $_REQUEST['mitem_channel_id'] = $uid; $_REQUEST['menu_id'] = $a->data['menu']['menu_id']; @@ -64,7 +67,7 @@ function mitem_post(&$a) { $_REQUEST['mitem_id'] = $mitem_id; $r = menu_edit_item($_REQUEST['menu_id'],$uid,$_REQUEST); if($r) { - info( t('Menu element updated.') . EOL); + //info( t('Menu element updated.') . EOL); goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . (($a->is_sys) ? '?f=&sys=1' : '')); } else @@ -74,8 +77,13 @@ function mitem_post(&$a) { else { $r = menu_add_item($_REQUEST['menu_id'],$uid,$_REQUEST); if($r) { - info( t('Menu element added.') . EOL); - goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . (($a->is_sys) ? '?f=&sys=1' : '')); + //info( t('Menu element added.') . EOL); + if($_REQUEST['submit']) { + goaway(z_root() . '/menu' . (($a->is_sys) ? '?f=&sys=1' : '')); + } + if($_REQUEST['submit-more']) { + goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . '?f=&display=block' . (($a->is_sys) ? '&sys=1' : '') ); + } } else notice( t('Unable to add menu element.') . EOL); @@ -84,6 +92,7 @@ function mitem_post(&$a) { + } @@ -115,28 +124,58 @@ function mitem_content(&$a) { $m = menu_fetch($a->data['menu']['menu_name'],$uid,$ob_hash); $a->data['menu_item'] = $m; - if(argc() == 2) { $r = q("select * from menu_item where mitem_menu_id = %d and mitem_channel_id = %d order by mitem_order asc, mitem_desc asc", intval($a->data['menu']['menu_id']), intval($uid) ); + $perm_defaults = array( + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] + ); + + if($_GET['display']) { + $display = $_GET['display']; + } + else { + $display = (($r) ? 'none' : 'block'); + } + + $create = replace_macros(get_markup_template('mitemedit.tpl'), array( + '$menu_id' => $a->data['menu']['menu_id'], + '$permissions' => t('Menu Item Permissions'), + '$permdesc' => t("\x28click to open/close\x29"), + '$aclselect' => populate_acl($perm_defaults,false), + '$mitem_desc' => array('mitem_desc', t('Link Name'), '', 'Visible name of the link','*'), + '$mitem_link' => array('mitem_link', t('Link Target'), '', 'URL of the link', '*'), + '$usezid' => array('usezid', t('Use RedMatrix magic-auth if available'), true, ''), + '$newwin' => array('newwin', t('Open link in new window'), false,''), + '$mitem_order' => array('mitem_order', t('Order in list'),'0',t('Higher numbers will sink to bottom of listing')), + '$submit' => t('Submit and finish'), + '$submit_more' => t('Submit and continue'), + '$display' => $display + )); $o .= replace_macros(get_markup_template('mitemlist.tpl'),array( - '$title' => t('Manage Menu Elements'), - '$menuname' => $a->data['menu']['menu_name'], - '$menudesc' => $a->data['menu']['menu_desc'], - '$edmenu' => t('Edit menu'), - '$menu_id' => $a->data['menu']['menu_id'], - '$mlist' => $r, - '$edit' => t('Edit element'), - '$drop' => t('Drop element'), - '$new' => t('New element'), - '$hintmenu' => t('Edit this menu container'), - '$hintnew' => t('Add menu element'), - '$hintdrop' => t('Delete this menu item'), - '$hintedit' => t('Edit this menu item') + '$title' => t('Menu:'), + '$create' => $create, + '$nametitle' => t('Link Name'), + '$targettitle' => t('Link Target'), + '$menuname' => $a->data['menu']['menu_name'], + '$menudesc' => $a->data['menu']['menu_desc'], + '$edmenu' => t('Edit menu'), + '$menu_id' => $a->data['menu']['menu_id'], + '$mlist' => $r, + '$edit' => t('Edit element'), + '$drop' => t('Drop element'), + '$new' => t('New element'), + '$hintmenu' => t('Edit this menu container'), + '$hintnew' => t('Add menu element'), + '$hintdrop' => t('Delete this menu item'), + '$hintedit' => t('Edit this menu item') )); return $o; @@ -145,38 +184,13 @@ function mitem_content(&$a) { if(argc() > 2) { - if(argv(2) === 'new') { + if(intval(argv(2))) { - $perm_defaults = array( - 'allow_cid' => $channel['channel_allow_cid'], - 'allow_gid' => $channel['channel_allow_gid'], - 'deny_cid' => $channel['channel_deny_cid'], - 'deny_gid' => $channel['channel_deny_gid'] - ); - - $o = replace_macros(get_markup_template('mitemedit.tpl'), array( - '$header' => t('New Menu Element'), - '$menu_id' => $a->data['menu']['menu_id'], - '$permissions' => t('Menu Item Permissions'), - '$permdesc' => t("\x28click to open/close\x29"), - '$aclselect' => populate_acl($perm_defaults,false), - '$mitem_desc' => array('mitem_desc', t('Link text'), '', '','*'), - '$mitem_link' => array('mitem_link', t('URL of link'), '', '', '*'), - '$usezid' => array('usezid', t('Use RedMatrix magic-auth if available'), true, ''), - '$newwin' => array('newwin', t('Open link in new window'), false,''), -// permissions go here - '$mitem_order' => array('mitem_order', t('Order in list'),'0',t('Higher numbers will sink to bottom of listing')), - '$submit' => t('Create') - )); - return $o; - } - - - elseif(intval(argv(2))) { $m = q("select * from menu_item where mitem_id = %d and mitem_channel_id = %d limit 1", intval(argv(2)), intval($uid) ); + if(! $m) { notice( t('Menu item not found.') . EOL); goaway(z_root() . '/menu'. (($a->is_sys) ? '?f=&sys=1' : '')); @@ -193,27 +207,24 @@ function mitem_content(&$a) { goaway(z_root() . '/mitem/' . $mitem['mitem_menu_id'] . (($a->is_sys) ? '?f=&sys=1' : '')); } - else { - - // edit menu item - - $o = replace_macros(get_markup_template('mitemedit.tpl'), array( - '$header' => t('Edit Menu Element'), - '$menu_id' => $a->data['menu']['menu_id'], - '$permissions' => t('Menu Item Permissions'), - '$permdesc' => t("\x28click to open/close\x29"), - '$aclselect' => populate_acl($mitem,false), - '$mitem_id' => intval(argv(2)), - '$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'), - '$mitem_link' => array('mitem_link', t('URL of link'), $mitem['mitem_link'], '', '*'), - '$usezid' => array('usezid', t('Use RedMatrix magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), ''), - '$newwin' => array('newwin', t('Open link in new window'), (($mitem['mitem_flags'] & MENU_ITEM_NEWWIN) ? 1 : 0),''), -// permissions go here - '$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')), - '$submit' => t('Modify') - )); - return $o; - } + + // edit menu item + $o = replace_macros(get_markup_template('mitemedit.tpl'), array( + '$header' => t('Edit Menu Element'), + '$menu_id' => $a->data['menu']['menu_id'], + '$permissions' => t('Menu Item Permissions'), + '$permdesc' => t("\x28click to open/close\x29"), + '$aclselect' => populate_acl($mitem,false), + '$mitem_id' => intval(argv(2)), + '$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'), + '$mitem_link' => array('mitem_link', t('URL of link'), $mitem['mitem_link'], '', '*'), + '$usezid' => array('usezid', t('Use RedMatrix magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), ''), + '$newwin' => array('newwin', t('Open link in new window'), (($mitem['mitem_flags'] & MENU_ITEM_NEWWIN) ? 1 : 0),''), + '$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')), + '$submit' => t('Submit') + )); + + return $o; } } } -- cgit v1.2.3 From 21704ecb93e293f39d0228ae0d9765f37af8d99e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 21 Apr 2015 22:45:54 +0200 Subject: bring lockview to menu items, slightly change the way /lockview is called --- mod/lockview.php | 12 +++++++++--- mod/mitem.php | 28 +++++++++++++++++----------- 2 files changed, 26 insertions(+), 14 deletions(-) (limited to 'mod') diff --git a/mod/lockview.php b/mod/lockview.php index a46fb6d69..84c16f658 100644 --- a/mod/lockview.php +++ b/mod/lockview.php @@ -14,10 +14,13 @@ function lockview_content(&$a) { if(! $item_id) killme(); - if (!in_array($type, array('item','photo','event'))) + if (!in_array($type, array('item','photo','event', 'menu_item'))) killme(); - $r = q("SELECT * FROM %s WHERE id = %d LIMIT 1", + //we have different naming in in menu_item table + $id = (($type == 'menu_item') ? 'mitem_id' : 'id'); + + $r = q("SELECT * FROM %s WHERE $id = %d LIMIT 1", dbesc($type), intval($item_id) ); @@ -27,7 +30,10 @@ function lockview_content(&$a) { $item = $r[0]; - if($item['uid'] != local_channel()) { + //we have different naming in in menu_item table + $uid = (($type == 'menu_item') ? $item['mitem_channel_id'] : $item['uid']); + + if($uid != local_channel()) { echo '
    • ' . t('Remote privacy information not available.') . '
    • '; killme(); } diff --git a/mod/mitem.php b/mod/mitem.php index cce5bcbe3..06c66a323 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -124,19 +124,21 @@ function mitem_content(&$a) { $m = menu_fetch($a->data['menu']['menu_name'],$uid,$ob_hash); $a->data['menu_item'] = $m; + $perm_defaults = array( + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] + ); + + $lockstate = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'); + if(argc() == 2) { $r = q("select * from menu_item where mitem_menu_id = %d and mitem_channel_id = %d order by mitem_order asc, mitem_desc asc", intval($a->data['menu']['menu_id']), intval($uid) ); - $perm_defaults = array( - 'allow_cid' => $channel['channel_allow_cid'], - 'allow_gid' => $channel['channel_allow_gid'], - 'deny_cid' => $channel['channel_deny_cid'], - 'deny_gid' => $channel['channel_deny_gid'] - ); - if($_GET['display']) { $display = $_GET['display']; } @@ -156,7 +158,8 @@ function mitem_content(&$a) { '$mitem_order' => array('mitem_order', t('Order in list'),'0',t('Higher numbers will sink to bottom of listing')), '$submit' => t('Submit and finish'), '$submit_more' => t('Submit and continue'), - '$display' => $display + '$display' => $display, + '$lockstate' => $lockstate )); $o .= replace_macros(get_markup_template('mitemlist.tpl'),array( @@ -175,9 +178,9 @@ function mitem_content(&$a) { '$hintmenu' => t('Edit this menu container'), '$hintnew' => t('Add menu element'), '$hintdrop' => t('Delete this menu item'), - '$hintedit' => t('Edit this menu item') + '$hintedit' => t('Edit this menu item'), )); - + return $o; } @@ -198,6 +201,8 @@ function mitem_content(&$a) { $mitem = $m[0]; + $lockstate = (($mitem['allow_cid'] || $mitem['allow_gid'] || $mitem['deny_cid'] || $mitem['deny_gid']) ? 'lock' : 'unlock'); + if(argc() == 4 && argv(3) == 'drop') { $r = menu_del_item($mitem['mitem_menu_id'], $uid, intval(argv(2))); if($r) @@ -221,7 +226,8 @@ function mitem_content(&$a) { '$usezid' => array('usezid', t('Use RedMatrix magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), ''), '$newwin' => array('newwin', t('Open link in new window'), (($mitem['mitem_flags'] & MENU_ITEM_NEWWIN) ? 1 : 0),''), '$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')), - '$submit' => t('Submit') + '$submit' => t('Submit'), + '$lockstate' => $lockstate )); return $o; -- cgit v1.2.3 From e58e8f3f75ce2119698fb59bda55a5fbea9dda2a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 21 Apr 2015 23:08:54 +0200 Subject: bring lockstate to webpages --- mod/webpages.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/webpages.php b/mod/webpages.php index b303b8652..615969d78 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -142,6 +142,9 @@ function webpages_content(&$a) { $pages = array(); foreach($r as $rr) { unobscure($rr); + + $lockstate = (($rr['allow_cid'] || $rr['allow_gid'] || $rr['deny_cid'] || $rr['deny_gid']) ? 'lock' : 'unlock'); + $element_arr = array( 'type' => 'webpage', 'title' => $rr['title'], @@ -159,7 +162,8 @@ function webpages_content(&$a) { 'title' => $rr['title'], 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']), 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']), - 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]' + 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]', + 'lockstate' => $lockstate ); } } -- cgit v1.2.3 From b4dff3a9ff16811ea0310f5dbf4d7559c97835b0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 22 Apr 2015 10:31:36 +0200 Subject: provide headings for blocks and layouts --- mod/blocks.php | 6 +++++- mod/editlayout.php | 3 +-- mod/layouts.php | 14 +++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'mod') diff --git a/mod/blocks.php b/mod/blocks.php index e0f32f4f1..b74b034e5 100644 --- a/mod/blocks.php +++ b/mod/blocks.php @@ -95,6 +95,7 @@ function blocks_content(&$a) { 'mimetype' => $mimetype, 'ptlabel' => t('Block Name'), 'profile_uid' => intval($owner), + 'expanded' => true, ); if($_REQUEST['title']) @@ -106,7 +107,7 @@ function blocks_content(&$a) { - $o .= status_editor($a,$x); + $editor = status_editor($a,$x); $r = q("select * from item_id where uid = %d and service = 'BUILDBLOCK' order by sid asc", intval($owner) @@ -126,7 +127,10 @@ function blocks_content(&$a) { $o .= replace_macros(get_markup_template('blocklist.tpl'), array( '$baseurl' => $url, + '$title' => t('Blocks'), + '$create' => t('Create'), '$edit' => t('Edit'), + '$editor' => $editor, '$pages' => $pages, '$channel' => $which, '$view' => t('View'), diff --git a/mod/editlayout.php b/mod/editlayout.php index f6d76f6b4..437c164c1 100644 --- a/mod/editlayout.php +++ b/mod/editlayout.php @@ -114,7 +114,7 @@ function editlayout_content(&$a) { '$ispublic' => ' ', // t('Visible to everybody'), '$geotag' => $geotag, '$nickname' => $channel['channel_address'], - '$confirmdelete' => t('Delete layout?') + '$confirmdelete' => t('Delete layout?') )); @@ -170,7 +170,6 @@ function editlayout_content(&$a) { '$acl' => '', '$bang' => '', '$profile_uid' => (intval($owner)), - '$preview' => t('Preview'), '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), '$defexpire' => '', diff --git a/mod/layouts.php b/mod/layouts.php index 4640c6690..04d81f91e 100644 --- a/mod/layouts.php +++ b/mod/layouts.php @@ -112,7 +112,7 @@ function layouts_content(&$a) { 'id' => 'layout-help-tab', )); - $o .= replace_macros(get_markup_template('common_tabs.tpl'),array('$tabs' => $tabs)); + //$o .= replace_macros(get_markup_template('common_tabs.tpl'),array('$tabs' => $tabs)); // Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages @@ -123,13 +123,15 @@ function layouts_content(&$a) { 'webpage' => ITEM_PDL, 'is_owner' => true, 'nickname' => $a->profile['channel_address'], - 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + //do we need that at this place? + //'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), 'bang' => '', 'showacl' => false, 'visitor' => false, 'nopreview' => 1, 'ptlabel' => t('Layout Name'), 'profile_uid' => intval($owner), + 'expanded' => true ); if($_REQUEST['title']) @@ -140,7 +142,7 @@ function layouts_content(&$a) { $x['pagetitle'] = $_REQUEST['pagetitle']; - $o .= status_editor($a,$x); + $editor = status_editor($a,$x); $r = q("select iid, sid, mid from item_id left join item on item.id = item_id.iid where item_id.uid = %d and service = 'PDL' order by sid asc", @@ -164,14 +166,16 @@ function layouts_content(&$a) { $url = z_root() . '/editlayout/' . $which; $o .= replace_macros(get_markup_template('layoutlist.tpl'), array( + '$title' => t('Layouts'), + '$create' => t('Create'), + '$help' => array('text' => t('Help'), 'url' => 'help/Comanche', 'title' => t('Comanche page description language help')), + '$editor' => $editor, '$baseurl' => $url, '$edit' => t('Edit'), '$share' => t('Share'), '$pages' => $pages, '$channel' => $which, '$view' => t('View'), - '$preview' => '1', - )); return $o; -- cgit v1.2.3 From 9e490d022b985f295a0547c8a115c610a77a3a24 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 22 Apr 2015 12:00:15 +0200 Subject: fix webpage perms --- mod/editwebpage.php | 9 ++++++++- mod/webpages.php | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/editwebpage.php b/mod/editwebpage.php index a7564a126..a1918741b 100644 --- a/mod/editwebpage.php +++ b/mod/editwebpage.php @@ -90,11 +90,18 @@ function editwebpage_content(&$a) { // We've already figured out which item we want and whose copy we need, // so we don't need anything fancy here - $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", + $sql_extra = item_permissions_sql($owner); + + $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s $sql_extra LIMIT 1", intval($post_id), intval($owner) ); + if(! $itm) { + notice( t('Permission denied.') . EOL); + return; + } + if($itm[0]['item_flags'] & ITEM_OBSCURED) { $key = get_config('system','prvkey'); if($itm[0]['title']) diff --git a/mod/webpages.php b/mod/webpages.php index 615969d78..44b4ee561 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -131,8 +131,10 @@ function webpages_content(&$a) { // so just list titles and an edit link. /** @TODO - this should be replaced with pagelist_widget */ + $sql_extra = item_permissions_sql($owner); + $r = q("select * from item_id left join item on item_id.iid = item.id - where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc", + where item_id.uid = %d and service = 'WEBPAGE' $sql_extra order by item.created desc", intval($owner) ); -- cgit v1.2.3 From dfc88a41df427bbf6b0b2d41105131aee15b09c5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 22 Apr 2015 12:21:33 +0200 Subject: fix webpages profile_tabs --- mod/webpages.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'mod') diff --git a/mod/webpages.php b/mod/webpages.php index 44b4ee561..e39e6764b 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -80,13 +80,10 @@ function webpages_content(&$a) { if(! $layout) $layout = 'choose'; - // Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages // Nickname is set to the observers xchan, and profile_uid to the owner's. // This lets you post pages at other people's channels. - - if((! $channel) && ($uid) && ($uid == $a->profile_uid)) { $channel = $a->get_channel(); } @@ -101,8 +98,8 @@ function webpages_content(&$a) { else $channel_acl = array(); - - $o = profile_tabs($a,true); + $_is_owner = (local_channel() && (local_channel() == $owner)); + $o = profile_tabs($a,$_is_owner, $a->profile['channel_address']); $x = array( 'webpage' => ITEM_WEBPAGE, -- cgit v1.2.3 From 29061b3ee3bddcc4718e05a421435b875e97c29e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 22 Apr 2015 12:31:30 +0200 Subject: do not show acl button if not owner --- mod/webpages.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/webpages.php b/mod/webpages.php index e39e6764b..121971b12 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -98,8 +98,8 @@ function webpages_content(&$a) { else $channel_acl = array(); - $_is_owner = (local_channel() && (local_channel() == $owner)); - $o = profile_tabs($a,$_is_owner, $a->profile['channel_address']); + $is_owner = ($uid && $uid == $owner); + $o = profile_tabs($a, $is_owner, $a->profile['channel_address']); $x = array( 'webpage' => ITEM_WEBPAGE, @@ -107,7 +107,8 @@ function webpages_content(&$a) { 'nickname' => $a->profile['channel_address'], 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), 'bang' => '', - 'acl' => (($uid && $uid == $owner) ? populate_acl($channel_acl,false) : ''), + 'acl' => (($is_owner) ? populate_acl($channel_acl,false) : ''), + 'showacl' => (($is_owner) ? true : false), 'visitor' => true, 'profile_uid' => intval($owner), 'mimetype' => $mimetype, -- cgit v1.2.3 From c696860cc53bc25558d83de5eda65d9b583da382 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 23 Apr 2015 21:04:01 +0200 Subject: webpages blocks fixes --- mod/blocks.php | 28 +++++++++++++++++++++++----- mod/editblock.php | 31 ++++--------------------------- 2 files changed, 27 insertions(+), 32 deletions(-) (limited to 'mod') diff --git a/mod/blocks.php b/mod/blocks.php index b74b034e5..f609164e0 100644 --- a/mod/blocks.php +++ b/mod/blocks.php @@ -70,7 +70,6 @@ function blocks_content(&$a) { return; } - // Block design features from visitors if((! $uid) || ($uid != $owner)) { @@ -105,11 +104,10 @@ function blocks_content(&$a) { if($_REQUEST['pagetitle']) $x['pagetitle'] = $_REQUEST['pagetitle']; - - $editor = status_editor($a,$x); - $r = q("select * from item_id where uid = %d and service = 'BUILDBLOCK' order by sid asc", + $r = q("select * from item_id left join item on item_id.iid = item.id + where item_id.uid = %d and service = 'BUILDBLOCK' order by item.created desc", intval($owner) ); @@ -118,7 +116,22 @@ function blocks_content(&$a) { if($r) { $pages = array(); foreach($r as $rr) { - $pages[$rr['iid']][] = array('url' => $rr['iid'],'title' => $rr['sid']); + $element_arr = array( + 'type' => 'block', + 'body' => $rr['body'], + 'created' => $rr['created'], + 'edited' => $rr['edited'], + 'mimetype' => $rr['mimetype'], + 'pagetitle' => $rr['sid'], + 'mid' => $rr['mid'] + ); + $pages[$rr['iid']][] = array( + 'url' => $rr['iid'], + 'title' => $rr['sid'], + 'created' => $rr['created'], + 'edited' => $rr['edited'], + 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]' + ); } } @@ -128,8 +141,13 @@ function blocks_content(&$a) { $o .= replace_macros(get_markup_template('blocklist.tpl'), array( '$baseurl' => $url, '$title' => t('Blocks'), + '$name' => t('Block Name'), + '$created' => t('Created'), + '$edited' => t('Edited'), '$create' => t('Create'), '$edit' => t('Edit'), + '$share' => t('Share'), + '$delete' => t('Delete'), '$editor' => $editor, '$pages' => $pages, '$channel' => $which, diff --git a/mod/editblock.php b/mod/editblock.php index 73be6a9f3..a0ece8133 100644 --- a/mod/editblock.php +++ b/mod/editblock.php @@ -70,7 +70,6 @@ function editblock_content(&$a) { $o = ''; - // Figure out which post we're editing $post_id = ((argc() > 2) ? intval(argv(2)) : 0); @@ -96,7 +95,6 @@ function editblock_content(&$a) { return; } - $plaintext = true; $mimeselect = ''; @@ -110,22 +108,21 @@ function editblock_content(&$a) { else $mimeselect = mimetype_select($itm[0]['uid'],$mimetype); - $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( - '$title' => t('Edit Block') + '$title' => t('Edit Block'), + '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), + '$id' => $itm[0]['id'] )); - $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( '$baseurl' => $a->get_baseurl(), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$ispublic' => ' ', // t('Visible to everybody'), '$geotag' => '', '$nickname' => $channel['channel_address'], - '$confirmdelete' => t('Delete block?') + '$confirmdelete' => t('Delete block?') )); - $tpl = get_markup_template("jot.tpl"); $jotplugins = ''; @@ -184,26 +181,6 @@ function editblock_content(&$a) { '$expires' => t('Set expiration date'), )); - - if(($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) - $o .= '

      ' . t('Delete Block') . '
      '; - - - $x = array( - 'type' => 'block', - 'title' => $itm[0]['title'], - 'body' => $itm[0]['body'], - 'term' => $itm[0]['term'], - 'created' => $itm[0]['created'], - 'edited' => $itm[0]['edited'], - 'mimetype' => $itm[0]['mimetype'], - 'pagetitle' => $page_title, - 'mid' => $itm[0]['mid'] - ); - - $o .= EOL . EOL . t('Share') . EOL . '' . EOL . EOL; - - return $o; } -- cgit v1.2.3