aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/_well_known.php40
-rw-r--r--mod/achievements.php2
-rw-r--r--mod/acl.php19
-rw-r--r--mod/admin.php441
-rw-r--r--mod/api.php6
-rw-r--r--mod/appman.php2
-rw-r--r--mod/apps.php2
-rw-r--r--mod/block.php6
-rw-r--r--mod/blocks.php20
-rw-r--r--mod/bookmarks.php15
-rw-r--r--mod/branchtopic.php2
-rwxr-xr-xmod/cal.php351
-rw-r--r--mod/channel.php96
-rw-r--r--mod/chanview.php14
-rw-r--r--mod/chat.php84
-rw-r--r--mod/chatsvc.php43
-rw-r--r--mod/cloud.php20
-rw-r--r--mod/common.php10
-rw-r--r--mod/connect.php34
-rw-r--r--mod/connections.php89
-rw-r--r--mod/connedit.php156
-rw-r--r--mod/cover_photo.php417
-rw-r--r--mod/dav.php22
-rw-r--r--mod/directory.php21
-rw-r--r--mod/dirsearch.php6
-rw-r--r--mod/display.php89
-rw-r--r--mod/dreport.php2
-rw-r--r--mod/editblock.php22
-rw-r--r--mod/editlayout.php23
-rw-r--r--mod/editpost.php22
-rw-r--r--mod/editwebpage.php25
-rwxr-xr-xmod/events.php51
-rw-r--r--mod/fbrowser.php32
-rw-r--r--mod/feed.php2
-rw-r--r--mod/fhublocs.php6
-rw-r--r--mod/filer.php2
-rw-r--r--mod/filerm.php4
-rw-r--r--mod/filestorage.php12
-rw-r--r--mod/follow.php8
-rw-r--r--mod/fsuggest.php8
-rw-r--r--mod/getfile.php97
-rw-r--r--mod/group.php38
-rw-r--r--mod/hcard.php8
-rw-r--r--mod/help.php44
-rw-r--r--mod/home.php8
-rw-r--r--mod/hostxrd.php3
-rw-r--r--mod/id.php10
-rw-r--r--mod/impel.php2
-rw-r--r--mod/import.php51
-rw-r--r--mod/import_items.php8
-rw-r--r--mod/invite.php18
-rw-r--r--mod/item.php113
-rw-r--r--mod/layouts.php19
-rwxr-xr-xmod/like.php31
-rw-r--r--mod/linkinfo.php4
-rw-r--r--mod/lockview.php30
-rw-r--r--mod/locs.php15
-rw-r--r--mod/login.php2
-rw-r--r--mod/lostpass.php12
-rw-r--r--mod/magic.php16
-rw-r--r--mod/mail.php28
-rw-r--r--mod/manage.php20
-rw-r--r--mod/match.php14
-rw-r--r--mod/menu.php20
-rw-r--r--mod/message.php6
-rw-r--r--mod/mitem.php48
-rwxr-xr-xmod/mood.php4
-rw-r--r--mod/msearch.php4
-rw-r--r--mod/network.php43
-rw-r--r--mod/new_channel.php64
-rw-r--r--mod/nojs.php10
-rw-r--r--mod/notes.php12
-rw-r--r--mod/notifications.php8
-rw-r--r--mod/notify.php4
-rw-r--r--mod/oembed.php2
-rw-r--r--mod/oep.php398
-rw-r--r--mod/oexchange.php6
-rw-r--r--mod/openid.php6
-rw-r--r--mod/opensearch.php4
-rw-r--r--mod/page.php21
-rwxr-xr-xmod/pconfig.php2
-rw-r--r--mod/pdledit.php4
-rw-r--r--mod/photo.php4
-rw-r--r--mod/photos.php245
-rw-r--r--mod/ping.php16
-rwxr-xr-xmod/poke.php21
-rw-r--r--mod/post.php4
-rw-r--r--mod/prate.php4
-rw-r--r--mod/probe.php2
-rw-r--r--mod/profile.php17
-rw-r--r--mod/profile_photo.php94
-rw-r--r--mod/profiles.php209
-rw-r--r--mod/profperm.php4
-rw-r--r--mod/public.php12
-rw-r--r--mod/pubsites.php25
-rw-r--r--mod/randprof.php2
-rw-r--r--mod/rate.php36
-rw-r--r--mod/ratings.php14
-rw-r--r--mod/rbmark.php6
-rw-r--r--mod/register.php88
-rw-r--r--mod/regmod.php8
-rw-r--r--mod/regver.php6
-rw-r--r--mod/removeaccount.php4
-rw-r--r--mod/removeme.php4
-rw-r--r--mod/rmagic.php4
-rw-r--r--mod/rpost.php12
-rw-r--r--mod/rsd_xml.php2
-rw-r--r--mod/search.php20
-rw-r--r--mod/search_ac.php2
-rw-r--r--mod/service_limits.php2
-rw-r--r--mod/settings.php149
-rwxr-xr-xmod/setup.php80
-rw-r--r--mod/share.php6
-rw-r--r--mod/sharedwithme.php2
-rw-r--r--mod/siteinfo.php6
-rw-r--r--mod/smilies.php2
-rw-r--r--mod/sources.php2
-rwxr-xr-xmod/subthread.php4
-rw-r--r--mod/suggest.php6
-rw-r--r--mod/tagger.php8
-rw-r--r--mod/tagrm.php20
-rw-r--r--mod/tasks.php2
-rw-r--r--mod/thing.php9
-rw-r--r--mod/toggle_mobile.php2
-rw-r--r--mod/uexport.php2
-rw-r--r--mod/update_display.php2
-rw-r--r--mod/view.php2
-rw-r--r--mod/viewconnections.php18
-rw-r--r--mod/viewsrc.php2
-rw-r--r--mod/wall_attach.php23
-rw-r--r--mod/wall_upload.php2
-rw-r--r--mod/webfinger.php31
-rw-r--r--mod/webpages.php28
-rw-r--r--mod/wfinger.php25
-rw-r--r--mod/xrd.php40
-rw-r--r--mod/zotfeed.php2
-rw-r--r--mod/zping.php2
137 files changed, 3393 insertions, 1434 deletions
diff --git a/mod/_well_known.php b/mod/_well_known.php
index d88bc2391..23d79bb1d 100644
--- a/mod/_well_known.php
+++ b/mod/_well_known.php
@@ -7,32 +7,54 @@ function _well_known_init(&$a){
$arr = array('server' => $_SERVER, 'request' => $_REQUEST);
call_hooks('well_known', $arr);
+
+ if(! check_siteallowed($_SERVER['REMOTE_ADDR'])) {
+ logger('well_known: site not allowed. ' . $_SERVER['REMOTE_ADDR']);
+ killme();
+ }
+
+ // from php.net re: REMOTE_HOST:
+ // Note: Your web server must be configured to create this variable. For example in Apache
+ // you'll need HostnameLookups On inside httpd.conf for it to exist. See also gethostbyaddr().
+
+ if(get_config('system','siteallowed_remote_host') && (! check_siteallowed($_SERVER['REMOTE_HOST']))) {
+ logger('well_known: site not allowed. ' . $_SERVER['REMOTE_HOST']);
+ killme();
+ }
+
+
switch(argv(1)) {
case 'zot-info':
- $a->argc -= 1;
- array_shift($a->argv);
- $a->argv[0] = 'zfinger';
+ App::$argc -= 1;
+ array_shift(App::$argv);
+ App::$argv[0] = 'zfinger';
require_once('mod/zfinger.php');
zfinger_init($a);
break;
case 'webfinger':
- $a->argc -= 1;
- array_shift($a->argv);
- $a->argv[0] = 'wfinger';
+ App::$argc -= 1;
+ array_shift(App::$argv);
+ App::$argv[0] = 'wfinger';
require_once('mod/wfinger.php');
wfinger_init($a);
break;
case 'host-meta':
- $a->argc -= 1;
- array_shift($a->argv);
- $a->argv[0] = 'hostxrd';
+ App::$argc -= 1;
+ array_shift(App::$argv);
+ App::$argv[0] = 'hostxrd';
require_once('mod/hostxrd.php');
hostxrd_init($a);
break;
default:
+ if(file_exists(App::$cmd)) {
+ echo file_get_contents(App::$cmd);
+ killme();
+ }
+ elseif(file_exists(App::$cmd . '.php'))
+ require_once(App::$cmd . '.php');
break;
}
diff --git a/mod/achievements.php b/mod/achievements.php
index 1d0018b08..9d4dad35b 100644
--- a/mod/achievements.php
+++ b/mod/achievements.php
@@ -23,7 +23,7 @@ function achievements_content(&$a) {
$owner = intval($r[0]['channel_id']);
}
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
$perms = get_all_perms($owner,$ob_hash);
if(! $perms['view_profile']) {
diff --git a/mod/acl.php b/mod/acl.php
index aaf056b60..146cb74c8 100644
--- a/mod/acl.php
+++ b/mod/acl.php
@@ -2,6 +2,7 @@
/* ACL selector json backend */
require_once("include/acl_selectors.php");
+require_once("include/group.php");
function acl_init(&$a){
@@ -47,31 +48,29 @@ function acl_init(&$a){
$contacts = array();
if ($type=='' || $type=='g'){
-
- $r = q("SELECT `groups`.`id`, `groups`.`hash`, `groups`.`name`,
- %s as uids
+
+ $r = q("SELECT `groups`.`id`, `groups`.`hash`, `groups`.`name`
FROM `groups`,`group_member`
WHERE `groups`.`deleted` = 0 AND `groups`.`uid` = %d
- AND `group_member`.`gid`=`groups`.`id`
- $sql_extra
+ AND `group_member`.`gid`=`groups`.`id`
+ $sql_extra
GROUP BY `groups`.`id`
ORDER BY `groups`.`name`
LIMIT %d OFFSET %d",
- db_concat('group_member.xchan', ','),
intval(local_channel()),
intval($count),
intval($start)
);
foreach($r as $g){
-// logger('acl: group: ' . $g['name'] . ' members: ' . $g['uids']);
+// logger('acl: group: ' . $g['name'] . ' members: ' . group_get_members_xchan($g['id']));
$groups[] = array(
"type" => "g",
"photo" => "images/twopeople.png",
"name" => $g['name'],
"id" => $g['id'],
"xid" => $g['hash'],
- "uids" => explode(",",$g['uids']),
+ "uids" => group_get_members_xchan($g['id']),
"link" => ''
);
}
@@ -94,7 +93,7 @@ function acl_init(&$a){
$r = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, abook_flags, abook_self
FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE (abook_channel = %d $extra_channels_sql) AND abook_blocked = 0 and abook_pending = 0 and abook_archived = 0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
+ WHERE (abook_channel = %d $extra_channels_sql) AND abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
intval(local_channel())
);
@@ -118,7 +117,7 @@ function acl_init(&$a){
$r2 = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, abook_flags, abook_self
FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel IN ($extra_channels_sql) $known_hashes_sql AND abook_blocked = 0 and abook_pending = 0 and abook_archived = 0 and abook_hidden = 0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc");
+ WHERE abook_channel IN ($extra_channels_sql) $known_hashes_sql AND abook_blocked = 0 and abook_pending = 0 and abook_hidden = 0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc");
if($r2)
$r = array_merge($r,$r2);
diff --git a/mod/admin.php b/mod/admin.php
index 85ab3627c..be703f922 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -7,7 +7,7 @@
*/
require_once('include/queue_fn.php');
-
+require_once('include/account.php');
/**
* @param App &$a
@@ -40,7 +40,7 @@ function admin_post(&$a){
$func($a);
}
}
- goaway($a->get_baseurl(true) . '/admin/plugins/' . argv(2) );
+ goaway(z_root() . '/admin/plugins/' . argv(2) );
break;
case 'themes':
$theme = argv(2);
@@ -54,7 +54,7 @@ function admin_post(&$a){
info(t('Theme settings updated.'));
if(is_ajax()) return;
- goaway($a->get_baseurl(true) . '/admin/themes/' . $theme );
+ goaway(z_root() . '/admin/themes/' . $theme );
break;
case 'logs':
admin_page_logs_post($a);
@@ -62,6 +62,12 @@ function admin_post(&$a){
case 'hubloc':
admin_page_hubloc_post($a);
break;
+ case 'security':
+ admin_page_security_post($a);
+ break;
+ case 'features':
+ admin_page_features_post($a);
+ break;
case 'dbsync':
admin_page_dbsync_post($a);
break;
@@ -71,7 +77,7 @@ function admin_post(&$a){
}
}
- goaway($a->get_baseurl(true) . '/admin' );
+ goaway(z_root() . '/admin' );
}
/**
@@ -113,6 +119,12 @@ function admin_content(&$a) {
// case 'hubloc':
// $o = admin_page_hubloc($a);
// break;
+ case 'security':
+ $o = admin_page_security($a);
+ break;
+ case 'features':
+ $o = admin_page_features($a);
+ break;
case 'logs':
$o = admin_page_logs($a);
break;
@@ -184,7 +196,7 @@ function admin_page_summary(&$a) {
$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;
+ $plugins = (count(App::$plugins) == 0) ? count(App::$plugins) : App::$plugins;
// Could be extended to provide also other alerts to the admin
$alertmsg = '';
@@ -245,7 +257,6 @@ function admin_page_site_post(&$a){
$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')) ? False : True);
$login_on_homepage = ((x($_POST,'login_on_homepage')) ? True : False);
@@ -310,7 +321,6 @@ function admin_page_site_post(&$a){
set_config('system','allowed_sites', $allowed_sites);
set_config('system','allowed_email', $allowed_email);
set_config('system','not_allowed_email', $not_allowed_email);
- 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 == '') {
@@ -327,7 +337,7 @@ function admin_page_site_post(&$a){
set_config('system','curl_timeout', $timeout);
info( t('Site settings updated.') . EOL);
- goaway($a->get_baseurl(true) . '/admin/site' );
+ goaway(z_root() . '/admin/site' );
}
/**
@@ -450,7 +460,7 @@ function admin_page_site(&$a) {
'$corporate' => t('Policies'),
'$advanced' => t('Advanced'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
// 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, ""),
@@ -471,7 +481,6 @@ function admin_page_site(&$a) {
'$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")),
'$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")),
'$not_allowed_email' => array('not_allowed_email', t("Not allowed email domains"), get_config('system','not_allowed_email'), t("Comma separated list of domains which are not allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains, unless allowed domains have been defined.")),
- '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.")),
'$verify_email' => array('verify_email', t("Verify Email Addresses"), get_config('system','verify_email'), t("Check to verify email addresses used in account registration (recommended).")),
'$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('Import Public Streams'), $discover_tab, t('Import and allow access to public content pulled from other sites. Warning: this content is unmoderated.')),
@@ -486,7 +495,7 @@ function admin_page_site(&$a) {
'$delivery_batch_count' => array('delivery_batch_count', t('Deliveries per process'),(x(get_config('system','delivery_batch_count'))?get_config('system','delivery_batch_count'):1), t("Number of deliveries to attempt in a single operating system process. Adjust if necessary to tune system performance. Recommend: 1-5.")),
'$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 (matrix/network) 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 (grid/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"),
));
}
@@ -505,7 +514,7 @@ function admin_page_hubloc_post(&$a){
$hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post';
//perform ping
- $m = zot_build_packet($a->get_channel(),'ping');
+ $m = zot_build_packet(App::get_channel(),'ping');
$r = zot_zot($hublocurl,$m);
//handle results and set the hubloc flags in db to make results visible
$r2 = $r['body'];
@@ -527,15 +536,130 @@ function admin_page_hubloc_post(&$a){
//after repair set hubloc flags to 0
}
- goaway($a->get_baseurl(true) . '/admin/hubloc' );
+ goaway(z_root() . '/admin/hubloc' );
+}
+
+function trim_array_elems($arr) {
+ $narr = array();
+
+ if($arr && is_array($arr)) {
+ for($x = 0; $x < count($arr); $x ++) {
+ $y = trim($arr[$x]);
+ if($y)
+ $narr[] = $y;
+ }
+ }
+ return $narr;
+}
+
+function admin_page_security_post(&$a){
+ check_form_security_token_redirectOnErr('/admin/security', 'admin_security');
+
+logger('post: ' . print_r($_POST,true));
+
+ $block_public = ((x($_POST,'block_public')) ? True : False);
+ set_config('system','block_public',$block_public);
+
+ $ws = trim_array_elems(explode("\n",$_POST['whitelisted_sites']));
+ set_config('system','whitelisted_sites',$ws);
+
+ $bs = trim_array_elems(explode("\n",$_POST['blacklisted_sites']));
+ set_config('system','blacklisted_sites',$bs);
+
+ $wc = trim_array_elems(explode("\n",$_POST['whitelisted_channels']));
+ set_config('system','whitelisted_channels',$wc);
+
+ $bc = trim_array_elems(explode("\n",$_POST['blacklisted_channels']));
+ set_config('system','blacklisted_channels',$bc);
+
+ $embed_coop = ((x($_POST,'embed_coop')) ? True : False);
+ set_config('system','embed_coop',$embed_coop);
+
+ $we = trim_array_elems(explode("\n",$_POST['embed_allow']));
+ set_config('system','embed_allow',$we);
+
+ $be = trim_array_elems(explode("\n",$_POST['embed_deny']));
+ set_config('system','embed_deny',$be);
+
+ goaway(z_root() . '/admin/security');
}
+
+
+
+function admin_page_features_post(&$a) {
+
+ check_form_security_token_redirectOnErr('/admin/features', 'admin_manage_features');
+
+ logger('postvars: ' . print_r($_POST,true));
+
+ $arr = array();
+ $features = get_features(false);
+
+ foreach($features as $fname => $fdata) {
+ foreach(array_slice($fdata,1) as $f) {
+ $feature = $f[0];
+
+ if(array_key_exists('feature_' . $feature,$_POST))
+ $val = intval($_POST['feature_' . $feature]);
+ else
+ $val = 0;
+ set_config('feature',$feature,$val);
+
+ if(array_key_exists('featurelock_' . $feature,$_POST))
+ set_config('feature_lock',$feature,$val);
+ else
+ del_config('feature_lock',$feature);
+ }
+ }
+
+ goaway(z_root() . '/admin/features' );
+
+}
+
+function admin_page_features(&$a) {
+
+ if((argc() > 1) && (argv(1) === 'features')) {
+ $arr = array();
+ $features = get_features(false);
+
+ foreach($features as $fname => $fdata) {
+ $arr[$fname] = array();
+ $arr[$fname][0] = $fdata[0];
+ foreach(array_slice($fdata,1) as $f) {
+
+ $set = get_config('feature',$f[0]);
+ if($set === false)
+ $set = $f[3];
+ $arr[$fname][1][] = array(
+ array('feature_' .$f[0],$f[1],$set,$f[2],array(t('Off'),t('On'))),
+ array('featurelock_' .$f[0],sprintf( t('Lock feature %s'),$f[1]),(($f[4] !== false) ? 1 : 0),'',array(t('Off'),t('On')))
+ );
+ }
+ }
+
+ $tpl = get_markup_template("admin_settings_features.tpl");
+ $o .= replace_macros($tpl, array(
+ '$form_security_token' => get_form_security_token("admin_manage_features"),
+ '$title' => t('Manage Additional Features'),
+ '$features' => $arr,
+ '$submit' => t('Submit'),
+ ));
+
+ return $o;
+ }
+}
+
+
+
+
+
function admin_page_hubloc(&$a) {
$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');
+ goaway(z_root() . '/admin/hubloc');
}
$t = get_markup_template('admin_hubloc.tpl');
@@ -547,11 +671,59 @@ function admin_page_hubloc(&$a) {
'$queues' => $queues,
//'$accounts' => $accounts, /*$accounts is empty here*/
'$pending' => array( t('Pending registrations'), $pending),
- '$plugins' => array( t('Active plugins'), $a->plugins ),
+ '$plugins' => array( t('Active plugins'), App::$plugins ),
'$form_security_token' => get_form_security_token('admin_hubloc')
));
}
+function admin_page_security(&$a) {
+
+ $whitesites = get_config('system','whitelisted_sites');
+ $whitesites_str = ((is_array($whitesites)) ? implode($whitesites,"\n") : '');
+
+ $blacksites = get_config('system','blacklisted_sites');
+ $blacksites_str = ((is_array($blacksites)) ? implode($blacksites,"\n") : '');
+
+
+ $whitechannels = get_config('system','whitelisted_channels');
+ $whitechannels_str = ((is_array($whitechannels)) ? implode($whitechannels,"\n") : '');
+
+ $blackchannels = get_config('system','blacklisted_channels');
+ $blackchannels_str = ((is_array($blackchannels)) ? implode($blackchannels,"\n") : '');
+
+
+ $whiteembeds = get_config('system','embed_allow');
+ $whiteembeds_str = ((is_array($whiteembeds)) ? implode($whiteembeds,"\n") : '');
+
+ $blackembeds = get_config('system','embed_deny');
+ $blackembeds_str = ((is_array($blackembeds)) ? implode($blackembeds,"\n") : '');
+
+ $embed_coop = intval(get_config('system','embed_coop'));
+
+// wait to implement this until we have a co-op in place.
+// if((! $whiteembeds) && (! $blackembeds) && (! $embed_coop))
+// $whiteembeds_str = "youtube.com\nyoutu.be\ntwitter.com\nvimeo.com\nsoundcloud.com\nwikipedia.com";
+
+ $t = get_markup_template('admin_security.tpl');
+ return replace_macros($t, array(
+ '$title' => t('Administration'),
+ '$page' => t('Security'),
+ '$form_security_token' => get_form_security_token('admin_security'),
+ '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently authenticated.")),
+ '$whitelisted_sites' => array('whitelisted_sites', t('Allow communications only from these sites'), $whitesites_str, t('One site per line. Leave empty to allow communication from anywhere by default')),
+ '$blacklisted_sites' => array('blacklisted_sites', t('Block communications from these sites'), $blacksites_str, ''),
+ '$whitelisted_channels' => array('whitelisted_channels', t('Allow communications only from these channels'), $whitechannels_str, t('One channel (hash) per line. Leave empty to allow from any channel by default')),
+ '$blacklisted_channels' => array('blacklisted_channels', t('Block communications from these channels'), $blackchannels_str, ''),
+ '$embed_allow' => array('embed_allow', t('Allow embedded HTML content only from these domains'), $whiteembeds_str, t('One site per line. Leave empty to allow from any site by default')),
+ '$embed_deny' => array('embed_deny', t('Block embedded HTML from these domains'), $blackembeds_str, ''),
+
+ '$embed_coop' => array('embed_coop', t('Cooperative embed security'), $embed_coop, t('Enable to share embed security with other compatible sites/hubs')),
+ '$submit' => t('Submit')
+ ));
+}
+
+
+
function admin_page_dbsync(&$a) {
$o = '';
@@ -561,7 +733,7 @@ function admin_page_dbsync(&$a) {
if(intval(get_config('system','db_version')) <= intval(argv(3)))
set_config('system','db_version',intval(argv(3)) + 1);
info( t('Update has been marked successful') . EOL);
- goaway($a->get_baseurl(true) . '/admin/dbsync');
+ goaway(z_root() . '/admin/dbsync');
}
if(argc() > 2 && intval(argv(2))) {
@@ -599,7 +771,7 @@ function admin_page_dbsync(&$a) {
return '<div class="generic-content-wrapper-styled"><h3>' . t('No failed updates.') . '</h3></div>';
$o = replace_macros(get_markup_template('failed_updates.tpl'),array(
- '$base' => $a->get_baseurl(true),
+ '$base' => z_root(),
'$banner' => t('Failed Updates'),
'$desc' => '',
'$mark' => t('Mark success (if update was manually applied)'),
@@ -689,17 +861,17 @@ function admin_page_users_post($a) {
// registration approved button was submitted
if (x($_POST, 'page_users_approve')) {
foreach ($pending as $hash) {
- user_allow($hash);
+ account_allow($hash);
}
}
// registration deny button was submitted
if (x($_POST, 'page_users_deny')) {
foreach ($pending as $hash) {
- user_deny($hash);
+ account_deny($hash);
}
}
- goaway($a->get_baseurl(true) . '/admin/users' );
+ goaway(z_root() . '/admin/users' );
}
/**
@@ -721,7 +893,7 @@ function admin_page_users(&$a){
if (! $account) {
notice( t('Account not found') . EOL);
- goaway($a->get_baseurl(true) . '/admin/users' );
+ goaway(z_root() . '/admin/users' );
}
check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
@@ -752,7 +924,7 @@ function admin_page_users(&$a){
break;
}
- goaway($a->get_baseurl(true) . '/admin/users' );
+ goaway(z_root() . '/admin/users' );
}
/* get pending */
@@ -764,8 +936,8 @@ function admin_page_users(&$a){
$total = q("SELECT count(*) as total FROM account");
if (count($total)) {
- $a->set_pager_total($total[0]['total']);
- $a->set_pager_itemspage(100);
+ App::set_pager_total($total[0]['total']);
+ App::set_pager_itemspage(100);
}
@@ -786,8 +958,8 @@ function admin_page_users(&$a){
"FROM account as ac where true $serviceclass $order limit %d offset %d ",
intval(ACCOUNT_BLOCKED),
db_concat('ch.channel_address', ' '),
- intval($a->pager['itemspage']),
- intval($a->pager['start'])
+ intval(App::$pager['itemspage']),
+ intval(App::$pager['start'])
);
// function _setup_users($e){
@@ -831,7 +1003,7 @@ function admin_page_users(&$a){
'$form_security_token' => get_form_security_token("admin_users"),
// values //
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$pending' => $pending,
'$users' => $users,
@@ -881,7 +1053,7 @@ function admin_page_channels_post(&$a) {
notice( sprintf( tt("%s channel deleted", "%s channels deleted", count($channels)), count($channels)) );
}
- goaway($a->get_baseurl(true) . '/admin/channels' );
+ goaway(z_root() . '/admin/channels' );
}
/**
@@ -899,7 +1071,7 @@ function admin_page_channels(&$a){
if (! $channel) {
notice( t('Channel not found') . EOL);
- goaway($a->get_baseurl(true) . '/admin/channels' );
+ goaway(z_root() . '/admin/channels' );
}
switch(argv(2)) {
@@ -938,22 +1110,22 @@ function admin_page_channels(&$a){
default:
break;
}
- goaway($a->get_baseurl(true) . '/admin/channels' );
+ goaway(z_root() . '/admin/channels' );
}
/* get channels */
$total = q("SELECT count(*) as total FROM channel where channel_removed = 0 and channel_system = 0");
if($total) {
- $a->set_pager_total($total[0]['total']);
- $a->set_pager_itemspage(100);
+ App::set_pager_total($total[0]['total']);
+ App::set_pager_itemspage(100);
}
$order = " order by channel_name asc ";
$channels = q("SELECT * from channel where channel_removed = 0 and channel_system = 0 $order limit %d offset %d ",
- intval($a->pager['itemspage']),
- intval($a->pager['start'])
+ intval(App::$pager['itemspage']),
+ intval(App::$pager['start'])
);
if($channels) {
@@ -991,7 +1163,7 @@ function admin_page_channels(&$a){
'$form_security_token' => get_form_security_token("admin_channels"),
// values //
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$channels' => $channels,
));
$o .= paginate($a);
@@ -1011,34 +1183,51 @@ function admin_page_plugins(&$a){
/*
* Single plugin
*/
- if ($a->argc == 3){
- $plugin = $a->argv[2];
+ if (App::$argc == 3){
+ $plugin = App::$argv[2];
if (!is_file("addon/$plugin/$plugin.php")){
notice( t("Item not found.") );
return '';
}
+ $enabled = in_array($plugin,App::$plugins);
+ $info = get_plugin_info($plugin);
+ $x = check_plugin_versions($info);
+
+ // disable plugins which are installed but incompatible versions
+
+ if($enabled && ! $x) {
+ $enabled = false;
+ $idz = array_search($plugin, App::$plugins);
+ if ($idz !== false) {
+ unset(App::$plugins[$idz]);
+ uninstall_plugin($plugin);
+ set_config("system","addon", implode(", ",App::$plugins));
+ }
+ }
+ $info['disabled'] = 1-intval($x);
+
if (x($_GET,"a") && $_GET['a']=="t"){
check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't');
// Toggle plugin status
- $idx = array_search($plugin, $a->plugins);
+ $idx = array_search($plugin, App::$plugins);
if ($idx !== false){
- unset($a->plugins[$idx]);
+ unset(App::$plugins[$idx]);
uninstall_plugin($plugin);
info( sprintf( t("Plugin %s disabled."), $plugin ) );
} else {
- $a->plugins[] = $plugin;
+ App::$plugins[] = $plugin;
install_plugin($plugin);
info( sprintf( t("Plugin %s enabled."), $plugin ) );
}
- set_config("system","addon", implode(", ",$a->plugins));
- goaway($a->get_baseurl(true) . '/admin/plugins' );
+ set_config("system","addon", implode(", ",App::$plugins));
+ goaway(z_root() . '/admin/plugins' );
}
// display plugin details
require_once('library/markdown.php');
- if (in_array($plugin, $a->plugins)){
+ if (in_array($plugin, App::$plugins)){
$status = 'on';
$action = t('Disable');
} else {
@@ -1068,20 +1257,26 @@ function admin_page_plugins(&$a){
}
}
+
$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),
+ '$baseurl' => z_root(),
'$plugin' => $plugin,
'$status' => $status,
'$action' => $action,
- '$info' => get_plugin_info($plugin),
+ '$info' => $info,
'$str_author' => t('Author: '),
'$str_maintainer' => t('Maintainer: '),
+ '$str_minversion' => t('Minimum project version: '),
+ '$str_maxversion' => t('Maximum project version: '),
+ '$str_minphpversion' => t('Minimum PHP version: '),
+ '$str_requires' => t('Requires: '),
+ '$disabled' => t('Disabled - version incompatibility'),
'$admin_form' => $admin_form,
'$function' => 'plugins',
@@ -1103,7 +1298,23 @@ function admin_page_plugins(&$a){
if (is_dir($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);
+ $enabled = in_array($id,App::$plugins);
+ $x = check_plugin_versions($info);
+
+ // disable plugins which are installed but incompatible versions
+
+ if($enabled && ! $x) {
+ $enabled = false;
+ $idz = array_search($id, App::$plugins);
+ if ($idz !== false) {
+ unset(App::$plugins[$idz]);
+ uninstall_plugin($id);
+ set_config("system","addon", implode(", ",App::$plugins));
+ }
+ }
+ $info['disabled'] = 1-intval($x);
+
+ $plugins[] = array( $id, (($enabled)?"on":"off") , $info);
}
}
}
@@ -1113,9 +1324,10 @@ function admin_page_plugins(&$a){
'$title' => t('Administration'),
'$page' => t('Plugins'),
'$submit' => t('Submit'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$function' => 'plugins',
'$plugins' => $plugins,
+ '$disabled' => t('Disabled - version incompatibility'),
'$form_security_token' => get_form_security_token('admin_plugins'),
));
}
@@ -1216,8 +1428,8 @@ function admin_page_themes(&$a){
* Single theme
*/
- if ($a->argc == 3){
- $theme = $a->argv[2];
+ if (App::$argc == 3){
+ $theme = App::$argv[2];
if(! is_dir("view/theme/$theme")){
notice( t("Item not found.") );
return '';
@@ -1236,7 +1448,7 @@ function admin_page_themes(&$a){
info( sprintf('Theme %s disabled.', $theme));
set_config('system', 'allowed_themes', $s);
- goaway($a->get_baseurl(true) . '/admin/themes' );
+ goaway(z_root() . '/admin/themes' );
}
// display theme details
@@ -1274,7 +1486,7 @@ function admin_page_themes(&$a){
'$page' => t('Themes'),
'$toggle' => t('Toggle'),
'$settings' => t('Settings'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$plugin' => $theme,
'$status' => $status,
@@ -1307,7 +1519,7 @@ function admin_page_themes(&$a){
'$title' => t('Administration'),
'$page' => t('Themes'),
'$submit' => t('Submit'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$function' => 'themes',
'$plugins' => $xthemes,
'$experimental' => t('[Experimental]'),
@@ -1336,7 +1548,7 @@ function admin_page_logs_post(&$a) {
}
info( t('Log settings updated.') );
- goaway($a->get_baseurl(true) . '/admin/logs' );
+ goaway(z_root() . '/admin/logs' );
}
/**
@@ -1394,7 +1606,7 @@ readable.");
'$submit' => t('Submit'),
'$clear' => t('Clear'),
'$data' => $data,
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$logname' => get_config('system','logfile'),
// name, label, value, help string, extra data...
@@ -1408,26 +1620,47 @@ readable.");
function admin_page_profs_post(&$a) {
- if($_REQUEST['id']) {
- $r = q("update profdef set field_name = '%s', field_type = '%s', field_desc = '%s' field_help = '%s', field_inputs = '%s' where id = %d",
- dbesc($_REQUEST['field_name']),
- dbesc($_REQUEST['field_type']),
- dbesc($_REQUEST['field_desc']),
- dbesc($_REQUEST['field_help']),
- dbesc($_REQUEST['field_inputs']),
- intval($_REQUEST['id'])
- );
+ if(array_key_exists('basic',$_REQUEST)) {
+ $arr = explode(',',$_REQUEST['basic']);
+ for($x = 0; $x < count($arr); $x ++)
+ if(trim($arr[$x]))
+ $arr[$x] = trim($arr[$x]);
+ set_config('system','profile_fields_basic',$arr);
+
+ if(array_key_exists('advanced',$_REQUEST)) {
+ $arr = explode(',',$_REQUEST['advanced']);
+ for($x = 0; $x < count($arr); $x ++)
+ if(trim($arr[$x]))
+ $arr[$x] = trim($arr[$x]);
+ set_config('system','profile_fields_advanced',$arr);
+ }
+ goaway(z_root() . '/admin/profs');
}
- else {
- $r = q("insert into profdef ( field_name, field_type, field_desc, field_help, field_inputs ) values ( '%s' , '%s', '%s', '%s', '%s' )",
- dbesc($_REQUEST['field_name']),
- dbesc($_REQUEST['field_type']),
- dbesc($_REQUEST['field_desc']),
- dbesc($_REQUEST['field_help']),
- dbesc($_REQUEST['field_inputs'])
- );
+
+
+ if(array_key_exists('field_name',$_REQUEST)) {
+ if($_REQUEST['id']) {
+ $r = q("update profdef set field_name = '%s', field_type = '%s', field_desc = '%s' field_help = '%s', field_inputs = '%s' where id = %d",
+ dbesc($_REQUEST['field_name']),
+ dbesc($_REQUEST['field_type']),
+ dbesc($_REQUEST['field_desc']),
+ dbesc($_REQUEST['field_help']),
+ dbesc($_REQUEST['field_inputs']),
+ intval($_REQUEST['id'])
+ );
+ }
+ else {
+ $r = q("insert into profdef ( field_name, field_type, field_desc, field_help, field_inputs ) values ( '%s' , '%s', '%s', '%s', '%s' )",
+ dbesc($_REQUEST['field_name']),
+ dbesc($_REQUEST['field_type']),
+ dbesc($_REQUEST['field_desc']),
+ dbesc($_REQUEST['field_help']),
+ dbesc($_REQUEST['field_inputs'])
+ );
+ }
}
+
// add to chosen array basic or advanced
goaway(z_root() . '/admin/profs');
@@ -1474,4 +1707,70 @@ function admin_page_profs(&$a) {
'$submit' => t('Save')
));
}
+
+ $basic = '';
+ $barr = array();
+ $fields = get_profile_fields_basic();
+ if(! $fields)
+ $fields = get_profile_fields_basic(1);
+ if($fields) {
+ foreach($fields as $k => $v) {
+ if($basic)
+ $basic .= ', ';
+ $basic .= trim($k);
+ $barr[] = trim($k);
+ }
+ }
+
+ $advanced = '';
+ $fields = get_profile_fields_advanced();
+ if(! $fields)
+ $fields = get_profile_fields_advanced(1);
+ if($fields) {
+ foreach($fields as $k => $v) {
+ if(in_array(trim($k),$barr))
+ continue;
+ if($advanced)
+ $advanced .= ', ';
+ $advanced .= trim($k);
+ }
+ }
+
+ $all = '';
+ $fields = get_profile_fields_advanced(1);
+ if($fields) {
+ foreach($fields as $k => $v) {
+ if($all)
+ $all .= ', ';
+ $all .= trim($k);
+ }
+ }
+
+ $r = q("select * from profdef where true");
+ if($r) {
+ foreach($r as $rr) {
+ if($all)
+ $all .= ', ';
+ $all .= $rr['field_name'];
+ }
+ }
+
+
+ $o = replace_macros(get_markup_template('admin_profiles.tpl'),array(
+ '$title' => t('Profile Fields'),
+ '$basic' => array('basic',t('Basic Profile Fields'),$basic,''),
+ '$advanced' => array('advanced',t('Advanced Profile Fields'),$advanced,t('(In addition to basic fields)')),
+ '$all' => $all,
+ '$all_desc' => t('All available fields'),
+ '$cust_field_desc' => t('Custom Fields'),
+ '$cust_fields' => $r,
+ '$edit' => t('Edit'),
+ '$drop' => t('Delete'),
+ '$new' => t('Create Custom Field'),
+ '$submit' => t('Submit')
+ ));
+
+ return $o;
+
+
}
diff --git a/mod/api.php b/mod/api.php
index 232349292..aa95b81dd 100644
--- a/mod/api.php
+++ b/mod/api.php
@@ -27,7 +27,7 @@ function api_post(&$a) {
return;
}
- if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_channel()) {
+ if(count(App::$user) && x(App::$user,'uid') && App::$user['uid'] != local_channel()) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -35,13 +35,13 @@ function api_post(&$a) {
}
function api_content(&$a) {
- if($a->cmd=='api/oauth/authorize'){
+ if(App::$cmd=='api/oauth/authorize'){
/*
* api/oauth/authorize interact with the user. return a standard page
*/
- $a->page['template'] = "minimal";
+ App::$page['template'] = "minimal";
// get consumer/client from request token
try {
diff --git a/mod/appman.php b/mod/appman.php
index e31492f0b..d8d030465 100644
--- a/mod/appman.php
+++ b/mod/appman.php
@@ -67,7 +67,7 @@ function appman_content(&$a) {
return;
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$app = null;
$embed = null;
if($_REQUEST['appid']) {
diff --git a/mod/apps.php b/mod/apps.php
index fcf545421..3539b2bc0 100644
--- a/mod/apps.php
+++ b/mod/apps.php
@@ -9,7 +9,7 @@ function apps_content(&$a) {
else
$mode = 'list';
- $_SESSION['return_url'] = $a->cmd;
+ $_SESSION['return_url'] = App::$cmd;
$apps = array();
diff --git a/mod/block.php b/mod/block.php
index df3909629..301993d03 100644
--- a/mod/block.php
+++ b/mod/block.php
@@ -10,15 +10,15 @@ function block_init(&$a) {
$profile = 0;
profile_load($a,$which,$profile);
- if($a->profile['profile_uid'])
- head_set_icon($a->profile['thumb']);
+ if(App::$profile['profile_uid'])
+ head_set_icon(App::$profile['thumb']);
}
function block_content(&$a) {
- if(! perm_is_allowed($a->profile['profile_uid'],get_observer_hash(),'view_pages')) {
+ if(! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_pages')) {
notice( t('Permission denied.') . EOL);
return;
}
diff --git a/mod/blocks.php b/mod/blocks.php
index 97cc5cd53..3c9274991 100644
--- a/mod/blocks.php
+++ b/mod/blocks.php
@@ -9,7 +9,7 @@ function blocks_init(&$a) {
if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
- $a->is_sys = true;
+ App::$is_sys = true;
}
}
@@ -25,24 +25,24 @@ function blocks_init(&$a) {
function blocks_content(&$a) {
- if(! $a->profile) {
+ if(! App::$profile) {
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
$which = argv(1);
- $_SESSION['return_url'] = $a->query_string;
+ $_SESSION['return_url'] = App::$query_string;
$uid = local_channel();
$owner = 0;
$channel = null;
- $observer = $a->get_observer();
+ $observer = App::get_observer();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- if($a->is_sys && is_site_admin()) {
+ if(App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
$uid = $owner = intval($sys['channel_id']);
@@ -86,7 +86,7 @@ function blocks_content(&$a) {
$x = array(
'webpage' => ITEM_TYPE_BLOCK,
'is_owner' => true,
- 'nickname' => $a->profile['channel_address'],
+ 'nickname' => App::$profile['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'bang' => '',
'showacl' => false,
@@ -95,7 +95,9 @@ function blocks_content(&$a) {
'ptlabel' => t('Block Name'),
'profile_uid' => intval($owner),
'expanded' => true,
- 'novoting' => true
+ 'novoting' => true,
+ 'bbco_autocomplete' => 'bbcode',
+ 'bbcode' => true
);
if($_REQUEST['title'])
diff --git a/mod/bookmarks.php b/mod/bookmarks.php
index c3d25253f..5c48ce5a9 100644
--- a/mod/bookmarks.php
+++ b/mod/bookmarks.php
@@ -4,10 +4,12 @@ function bookmarks_init(&$a) {
if(! local_channel())
return;
$item_id = intval($_REQUEST['item']);
+ $burl = trim($_REQUEST['burl']);
+
if(! $item_id)
return;
- $u = $a->get_channel();
+ $u = App::get_channel();
$item_normal = item_normal();
@@ -36,7 +38,14 @@ function bookmarks_init(&$a) {
killme();
}
foreach($terms as $t) {
- bookmark_add($u,$s[0],$t,$item['item_private']);
+ if($burl) {
+ if($burl == $t['url']) {
+ bookmark_add($u,$s[0],$t,$item['item_private']);
+ }
+ }
+ else
+ bookmark_add($u,$s[0],$t,$item['item_private']);
+
info( t('Bookmark added') . EOL);
}
}
@@ -53,7 +62,7 @@ function bookmarks_content(&$a) {
require_once('include/menu.php');
require_once('include/conversation.php');
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$o = profile_tabs($a,true,$channel['channel_address']);
diff --git a/mod/branchtopic.php b/mod/branchtopic.php
index d49bbaf4c..3702e6d53 100644
--- a/mod/branchtopic.php
+++ b/mod/branchtopic.php
@@ -13,7 +13,7 @@ function branchtopic_init(&$a) {
if(! $item_id)
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if(! $channel)
return;
diff --git a/mod/cal.php b/mod/cal.php
new file mode 100755
index 000000000..56d65d3f2
--- /dev/null
+++ b/mod/cal.php
@@ -0,0 +1,351 @@
+<?php
+
+require_once('include/conversation.php');
+require_once('include/bbcode.php');
+require_once('include/datetime.php');
+require_once('include/event.php');
+require_once('include/items.php');
+require_once('include/Contact.php');
+
+
+function cal_init(&$a) {
+ if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
+ return;
+ }
+
+ $o = '';
+
+ if(argc() > 1) {
+ $nick = argv(1);
+
+ profile_load($a,$nick);
+
+ $channelx = channelx_by_nick($nick);
+
+ if(! $channelx)
+ return;
+
+ App::$data['channel'] = $channelx;
+
+ $observer = App::get_observer();
+ App::$data['observer'] = $observer;
+
+ $observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
+
+ head_set_icon(App::$data['channel']['xchan_photo_s']);
+
+ App::$page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "'; var profile_uid = " . ((App::$data['channel']) ? App::$data['channel']['channel_id'] : 0) . "; </script>" ;
+
+ }
+
+ return;
+}
+
+
+
+function cal_content(&$a) {
+
+ if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
+ return;
+ }
+
+
+ $channel = null;
+
+ if(argc() > 1) {
+ $channel = channelx_by_nick(argv(1));
+ }
+
+
+ if(! $channel) {
+ notice( t('Channel not found.') . EOL);
+ return;
+ }
+
+ // since we don't currently have an event permission - use the stream permission
+
+ if(! perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_stream')) {
+ notice( t('Permissions denied.') . EOL);
+ return;
+ }
+
+ $sql_extra = permissions_sql($channel['channel_id'],get_observer_hash(),'event');
+
+ $first_day = get_pconfig(local_channel(),'system','cal_first_day');
+ $first_day = (($first_day) ? $first_day : 0);
+
+ $htpl = get_markup_template('event_head.tpl');
+ App::$page['htmlhead'] .= replace_macros($htpl,array(
+ '$baseurl' => z_root(),
+ '$module_url' => '/cal/' . $channel['channel_address'],
+ '$modparams' => 2,
+ '$lang' => App::$language,
+ '$first_day' => $first_day
+ ));
+
+ $o = '';
+
+ $tabs = profile_tabs($a, True, $channel['channel_address']);
+
+ $mode = 'view';
+ $y = 0;
+ $m = 0;
+ $ignored = ((x($_REQUEST,'ignored')) ? " and ignored = " . intval($_REQUEST['ignored']) . " " : '');
+
+ // logger('args: ' . print_r(App::$argv,true));
+
+ if(argc() > 3 && intval(argv(2)) && intval(argv(3))) {
+ $mode = 'view';
+ $y = intval(argv(2));
+ $m = intval(argv(3));
+ }
+ if(argc() <= 3) {
+ $mode = 'view';
+ $event_id = argv(2);
+ }
+
+ if($mode == 'view') {
+
+ /* edit/create form */
+ if($event_id) {
+ $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($event_id),
+ intval($channel['channel_id'])
+ );
+ if(count($r))
+ $orig_event = $r[0];
+ }
+
+
+ // Passed parameters overrides anything found in the DB
+ if(!x($orig_event))
+ $orig_event = array();
+
+
+
+ $tz = date_default_timezone_get();
+ if(x($orig_event))
+ $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
+
+ $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
+ $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
+ $sday = datetime_convert('UTC', $tz, $sdt, 'd');
+ $shour = datetime_convert('UTC', $tz, $sdt, 'H');
+ $sminute = datetime_convert('UTC', $tz, $sdt, 'i');
+
+ $stext = datetime_convert('UTC',$tz,$sdt);
+ $stext = substr($stext,0,14) . "00:00";
+
+ $fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
+ $fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
+ $fday = datetime_convert('UTC', $tz, $fdt, 'd');
+ $fhour = datetime_convert('UTC', $tz, $fdt, 'H');
+ $fminute = datetime_convert('UTC', $tz, $fdt, 'i');
+
+ $ftext = datetime_convert('UTC',$tz,$fdt);
+ $ftext = substr($ftext,0,14) . "00:00";
+
+ $type = ((x($orig_event)) ? $orig_event['type'] : 'event');
+
+ $f = get_config('system','event_input_format');
+ if(! $f)
+ $f = 'ymd';
+
+ $catsenabled = feature_enabled($channel['channel_id'],'categories');
+
+
+ $show_bd = perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_contacts');
+ if(! $show_bd) {
+ $sql_extra .= " and event.type != 'birthday' ";
+ }
+
+
+ $category = '';
+
+ $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
+ $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
+ if(! $y)
+ $y = intval($thisyear);
+ if(! $m)
+ $m = intval($thismonth);
+
+ // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
+ // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
+
+ if($y < 1901)
+ $y = 1900;
+ if($y > 2099)
+ $y = 2100;
+
+ $nextyear = $y;
+ $nextmonth = $m + 1;
+ if($nextmonth > 12) {
+ $nextmonth = 1;
+ $nextyear ++;
+ }
+
+ $prevyear = $y;
+ if($m > 1)
+ $prevmonth = $m - 1;
+ else {
+ $prevmonth = 12;
+ $prevyear --;
+ }
+
+ $dim = get_dim($y,$m);
+ $start = sprintf('%d-%d-%d %d:%d:%d',$y,$m,1,0,0,0);
+ $finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59);
+
+
+ if (argv(2) === 'json'){
+ if (x($_GET,'start')) $start = $_GET['start'];
+ if (x($_GET,'end')) $finish = $_GET['end'];
+ }
+
+ $start = datetime_convert('UTC','UTC',$start);
+ $finish = datetime_convert('UTC','UTC',$finish);
+
+ $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
+ $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
+
+ if (x($_GET,'id')){
+ $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan
+ from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d $sql_extra limit 1",
+ intval($channel['channel_id']),
+ intval($_GET['id'])
+ );
+ }
+ else {
+ // fixed an issue with "nofinish" events not showing up in the calendar.
+ // There's still an issue if the finish date crosses the end of month.
+ // Noting this for now - it will need to be fixed here and in Friendica.
+ // Ultimately the finish date shouldn't be involved in the query.
+
+ $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan
+ from event left join item on event_hash = resource_id
+ where resource_type = 'event' and event.uid = %d $ignored
+ AND (( adjust = 0 AND ( finish >= '%s' or nofinish = 1 ) AND start <= '%s' )
+ OR ( adjust = 1 AND ( finish >= '%s' or nofinish = 1 ) AND start <= '%s' )) $sql_extra ",
+ intval($channel['channel_id']),
+ dbesc($start),
+ dbesc($finish),
+ dbesc($adjust_start),
+ dbesc($adjust_finish)
+ );
+
+ }
+
+ $links = array();
+
+ if($r) {
+ xchan_query($r);
+ $r = fetch_post_tags($r,true);
+
+ $r = sort_by_date($r);
+ }
+
+ if($r) {
+ foreach($r as $rr) {
+ $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
+ if(! x($links,$j))
+ $links[$j] = z_root() . '/' . App::$cmd . '#link-' . $j;
+ }
+ }
+
+ $events=array();
+
+ $last_date = '';
+ $fmt = t('l, F j');
+
+ if($r) {
+
+ foreach($r as $rr) {
+
+ $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
+ $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt));
+ $d = day_translate($d);
+
+ $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c'));
+ if ($rr['nofinish']){
+ $end = null;
+ } else {
+ $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c'));
+ }
+
+
+ $is_first = ($d !== $last_date);
+
+ $last_date = $d;
+
+ $edit = false;
+
+ $drop = false;
+
+ $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
+ if(! $title) {
+ list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);
+ $title = strip_tags(html_entity_decode($title,ENT_QUOTES,'UTF-8'));
+ }
+ $html = format_event_html($rr);
+ $rr['desc'] = bbcode($rr['desc']);
+ $rr['location'] = bbcode($rr['location']);
+ $events[] = array(
+ 'id'=>$rr['id'],
+ 'hash' => $rr['event_hash'],
+ 'start'=> $start,
+ 'end' => $end,
+ 'drop' => $drop,
+ 'allDay' => false,
+ 'title' => $title,
+
+ 'j' => $j,
+ 'd' => $d,
+ 'edit' => $edit,
+ 'is_first'=>$is_first,
+ 'item'=>$rr,
+ 'html'=>$html,
+ 'plink' => array($rr['plink'],t('Link to Source'),'',''),
+ );
+
+
+ }
+ }
+
+ if (argv(2) === 'json'){
+ echo json_encode($events); killme();
+ }
+
+ // links: array('href', 'text', 'extra css classes', 'title')
+ if (x($_GET,'id')){
+ $tpl = get_markup_template("event_cal.tpl");
+ }
+ else {
+ $tpl = get_markup_template("events_cal-js.tpl");
+ }
+
+ $nick = $channel['channel_address'];
+
+ $o = replace_macros($tpl, array(
+ '$baseurl' => z_root(),
+ '$new_event' => array(z_root().'/cal',(($event_id) ? t('Edit Event') : t('Create Event')),'',''),
+ '$previus' => array(z_root()."/cal/$nick/$prevyear/$prevmonth",t('Previous'),'',''),
+ '$next' => array(z_root()."/cal/$nick/$nextyear/$nextmonth",t('Next'),'',''),
+ '$export' => array(z_root()."/cal/$nick/$y/$m/export",t('Export'),'',''),
+ '$calendar' => cal($y,$m,$links, ' eventcal'),
+ '$events' => $events,
+ '$upload' => t('Import'),
+ '$submit' => t('Submit'),
+ '$prev' => t('Previous'),
+ '$next' => t('Next'),
+ '$today' => t('Today'),
+ '$form' => $form,
+ '$expandform' => ((x($_GET,'expandform')) ? true : false),
+ '$tabs' => $tabs
+ ));
+
+ if (x($_GET,'id')){ echo $o; killme(); }
+
+ return $o;
+ }
+
+}
diff --git a/mod/channel.php b/mod/channel.php
index 2b9d0ed89..9bc7332dc 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -16,7 +16,7 @@ function channel_init(&$a) {
$which = argv(1);
if(! $which) {
if(local_channel()) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if($channel && $channel['channel_address'])
$which = $channel['channel_address'];
}
@@ -27,19 +27,19 @@ function channel_init(&$a) {
}
$profile = 0;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) {
$which = $channel['channel_address'];
$profile = argv(1);
}
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which .'" />' . "\r\n" ;
-
+ App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" title="' . t('Posts and comments') . '" href="' . z_root() . '/feed/' . $which . '" />' . "\r\n" ;
+ App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" title="' . t('Only posts') . '" href="' . z_root() . '/feed/' . $which . '?top=1" />' . "\r\n" ;
// Not yet ready for prime time
-// $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->get_baseurl() . '/id/' . $which .'?f=" />' . "\r\n" ;
-// $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $a->get_baseurl() . '/channel/' . $which .'" />' . "\r\n" ;
+// App::$page['htmlhead'] .= '<link rel="openid.server" href="' . z_root() . '/id/' . $which .'?f=" />' . "\r\n" ;
+// App::$page['htmlhead'] .= '<link rel="openid.delegate" href="' . z_root() . '/channel/' . $which .'" />' . "\r\n" ;
// Run profile_load() here to make sure the theme is set before
// we start loading content
@@ -54,6 +54,7 @@ function channel_content(&$a, $update = 0, $load = false) {
if($load)
$_SESSION['loadtime'] = datetime_convert();
+ $checkjs = new Zotlabs\Web\CheckJS();
$category = $datequery = $datequery2 = '';
@@ -75,27 +76,27 @@ function channel_content(&$a, $update = 0, $load = false) {
if($update) {
// Ensure we've got a profile owner if updating.
- $a->profile['profile_uid'] = $a->profile_uid = $update;
+ App::$profile['profile_uid'] = App::$profile_uid = $update;
}
else {
- if($a->profile['profile_uid'] == local_channel()) {
+ if(App::$profile['profile_uid'] == local_channel()) {
nav_set_selected('home');
}
}
- $is_owner = (((local_channel()) && ($a->profile['profile_uid'] == local_channel())) ? true : false);
+ $is_owner = (((local_channel()) && (App::$profile['profile_uid'] == local_channel())) ? true : false);
- $channel = $a->get_channel();
- $observer = $a->get_observer();
+ $channel = App::get_channel();
+ $observer = App::get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
- $perms = get_all_perms($a->profile['profile_uid'],$ob_hash);
+ $perms = get_all_perms(App::$profile['profile_uid'],$ob_hash);
if(! $perms['view_stream']) {
// We may want to make the target of this redirect configurable
if($perms['view_profile']) {
notice( t('Insufficient permissions. Request redirected to profile page.') . EOL);
- goaway (z_root() . "/profile/" . $a->profile['channel_address']);
+ goaway (z_root() . "/profile/" . App::$profile['channel_address']);
}
notice( t('Permission denied.') . EOL);
return;
@@ -104,9 +105,9 @@ function channel_content(&$a, $update = 0, $load = false) {
if(! $update) {
- $o .= profile_tabs($a, $is_owner, $a->profile['channel_address']);
+ $o .= profile_tabs($a, $is_owner, App::$profile['channel_address']);
- $o .= common_friends_visitor_widget($a->profile['profile_uid']);
+ $o .= common_friends_visitor_widget(App::$profile['profile_uid']);
if($channel && $is_owner) {
$channel_acl = array(
@@ -124,15 +125,18 @@ function channel_content(&$a, $update = 0, $load = false) {
$x = array(
'is_owner' => $is_owner,
- 'allow_location' => ((($is_owner || $observer) && (intval(get_pconfig($a->profile['profile_uid'],'system','use_browser_location')))) ? true : false),
- 'default_location' => (($is_owner) ? $a->profile['channel_location'] : ''),
- 'nickname' => $a->profile['channel_address'],
- 'lockstate' => (((strlen($a->profile['channel_allow_cid'])) || (strlen($a->profile['channel_allow_gid'])) || (strlen($a->profile['channel_deny_cid'])) || (strlen($a->profile['channel_deny_gid']))) ? 'lock' : 'unlock'),
- 'acl' => (($is_owner) ? populate_acl($channel_acl) : ''),
+ 'allow_location' => ((($is_owner || $observer) && (intval(get_pconfig(App::$profile['profile_uid'],'system','use_browser_location')))) ? true : false),
+ 'default_location' => (($is_owner) ? App::$profile['channel_location'] : ''),
+ 'nickname' => App::$profile['channel_address'],
+ 'lockstate' => (((strlen(App::$profile['channel_allow_cid'])) || (strlen(App::$profile['channel_allow_gid'])) || (strlen(App::$profile['channel_deny_cid'])) || (strlen(App::$profile['channel_deny_gid']))) ? 'lock' : 'unlock'),
+ 'acl' => (($is_owner) ? populate_acl($channel_acl,true,((App::$profile['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : '')) : ''),
'showacl' => (($is_owner) ? 'yes' : ''),
- 'bang' => '',
+ 'bang' => '',
'visitor' => (($is_owner || $observer) ? true : false),
- 'profile_uid' => $a->profile['profile_uid']
+ 'profile_uid' => App::$profile['profile_uid'],
+ 'editor_autocomplete' => true,
+ 'bbco_autocomplete' => 'bbcode',
+ 'bbcode' => true
);
$o .= status_editor($a,$x);
@@ -146,16 +150,18 @@ function channel_content(&$a, $update = 0, $load = false) {
*/
$item_normal = item_normal();
- $sql_extra = item_permissions_sql($a->profile['profile_uid']);
+ $sql_extra = item_permissions_sql(App::$profile['profile_uid']);
- if(get_pconfig($a->profile['profile_uid'],'system','channel_list_mode') && (! $mid))
+ if(get_pconfig(App::$profile['profile_uid'],'system','channel_list_mode') && (! $mid))
$page_mode = 'list';
else
$page_mode = 'client';
- $abook_uids = " and abook.abook_channel = " . intval($a->profile['profile_uid']) . " ";
+ $abook_uids = " and abook.abook_channel = " . intval(App::$profile['profile_uid']) . " ";
$simple_update = (($update) ? " AND item_unseen = 1 " : '');
+
+ App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$query_string) . '" title="oembed" />' . "\r\n";
if($update && $_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']) . "' ) ";
@@ -163,11 +169,12 @@ function channel_content(&$a, $update = 0, $load = false) {
$simple_update = '';
if(($update) && (! $load)) {
+
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d $item_normal
AND item_wall = 1 AND item_unseen = 1 $sql_extra limit 1",
dbesc($mid . '%'),
- intval($a->profile['profile_uid'])
+ intval(App::$profile['profile_uid'])
);
} else {
$r = q("SELECT distinct parent AS `item_id`, created from item
@@ -177,7 +184,7 @@ function channel_content(&$a, $update = 0, $load = false) {
AND (abook.abook_blocked = 0 or abook.abook_flags is null)
$sql_extra
ORDER BY created DESC",
- intval($a->profile['profile_uid'])
+ intval(App::$profile['profile_uid'])
);
$_SESSION['loadtime'] = datetime_convert();
}
@@ -200,15 +207,15 @@ function channel_content(&$a, $update = 0, $load = false) {
}
$itemspage = get_pconfig(local_channel(),'system','itemspage');
- $a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
- $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
+ App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
- if($load || ($_COOKIE['jsAvailable'] != 1)) {
+ if($load || ($checkjs->disabled())) {
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal
AND item_wall = 1 $sql_extra limit 1",
dbesc($mid),
- intval($a->profile['profile_uid'])
+ intval(App::$profile['profile_uid'])
);
if (! $r) {
notice( t('Permission denied.') . EOL);
@@ -222,7 +229,7 @@ function channel_content(&$a, $update = 0, $load = false) {
AND (abook_blocked = 0 or abook.abook_flags is null)
$sql_extra $sql_extra2
ORDER BY created DESC $pager_sql ",
- intval($a->profile['profile_uid'])
+ intval(App::$profile['profile_uid'])
);
}
}
@@ -240,7 +247,7 @@ function channel_content(&$a, $update = 0, $load = false) {
WHERE `item`.`uid` = %d $item_normal
AND `item`.`parent` IN ( %s )
$sql_extra ",
- intval($a->profile['profile_uid']),
+ intval(App::$profile['profile_uid']),
dbesc($parents_str)
);
@@ -258,25 +265,24 @@ function channel_content(&$a, $update = 0, $load = false) {
$items = array();
}
-
if((! $update) && (! $load)) {
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
// because browser prefetching might change it on us. We have to deliver it with the page.
- $maxheight = get_pconfig($a->profile['profile_uid'],'system','channel_divmore_height');
+ $maxheight = get_pconfig(App::$profile['profile_uid'],'system','channel_divmore_height');
if(! $maxheight)
$maxheight = 400;
$o .= '<div id="live-channel"></div>' . "\r\n";
- $o .= "<script> var profile_uid = " . $a->profile['profile_uid']
- . "; var netargs = '?f='; var profile_page = " . $a->pager['page']
+ $o .= "<script> var profile_uid = " . App::$profile['profile_uid']
+ . "; var netargs = '?f='; var profile_page = " . App::$pager['page']
. "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
- $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
+ App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
'$baseurl' => z_root(),
'$pgtype' => 'channel',
- '$uid' => (($a->profile['profile_uid']) ? $a->profile['profile_uid'] : '0'),
+ '$uid' => ((App::$profile['profile_uid']) ? App::$profile['profile_uid'] : '0'),
'$gid' => '0',
'$cid' => '0',
'$cmin' => '0',
@@ -288,7 +294,7 @@ function channel_content(&$a, $update = 0, $load = false) {
'$nouveau' => '0',
'$wall' => '1',
'$fh' => '0',
- '$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1),
+ '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
'$search' => '',
'$order' => '',
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
@@ -333,16 +339,16 @@ function channel_content(&$a, $update = 0, $load = false) {
}
- if($_COOKIE['jsAvailable'] == 1) {
- $o .= conversation($a,$items,'channel',$update,$page_mode);
- } else {
+ if($checkjs->disabled()) {
$o .= conversation($a,$items,'channel',$update,'traditional');
+ } else {
+ $o .= conversation($a,$items,'channel',$update,$page_mode);
}
- if((! $update) || ($_COOKIE['jsAvailable'] != 1)) {
+ if((! $update) || ($checkjs->disabled())) {
$o .= alt_pager($a,count($items));
if ($mid && $items[0]['title'])
- $a->page['title'] = $items[0]['title'] . " - " . $a->page['title'];
+ App::$page['title'] = $items[0]['title'] . " - " . App::$page['title'];
}
if($mid)
diff --git a/mod/chanview.php b/mod/chanview.php
index 0cbcb2e57..705fb5a7d 100644
--- a/mod/chanview.php
+++ b/mod/chanview.php
@@ -5,7 +5,7 @@ require_once('include/zot.php');
function chanview_content(&$a) {
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$xchan = null;
$r = null;
@@ -38,7 +38,7 @@ function chanview_content(&$a) {
);
}
if($r) {
- $a->poi = $r[0];
+ App::$poi = $r[0];
}
@@ -47,7 +47,7 @@ function chanview_content(&$a) {
// address, we can and should try to import it. If it's just a hash, we can't continue, but we
// probably wouldn't have a hash if we don't already have an xchan for this channel.
- if(! $a->poi) {
+ if(! App::$poi) {
logger('mod_chanview: fallback');
// This is hackish - construct a zot address from the url
if($_REQUEST['url']) {
@@ -67,13 +67,13 @@ function chanview_content(&$a) {
dbesc($_REQUEST['address'])
);
if($r)
- $a->poi = $r[0];
+ App::$poi = $r[0];
}
}
}
- if(! $a->poi) {
+ if(! App::$poi) {
// We don't know who this is, and we can't figure it out from the URL
// On the plus side, there's a good chance we know somebody else at that
// hub so sending them there with a Zid will probably work anyway.
@@ -82,8 +82,8 @@ function chanview_content(&$a) {
$url = zid($url);
}
- if ($a->poi) {
- $url = $a->poi['xchan_url'];
+ if (App::$poi) {
+ $url = App::$poi['xchan_url'];
if($observer)
$url = zid($url);
}
diff --git a/mod/chat.php b/mod/chat.php
index 79a5c050b..375d069be 100644
--- a/mod/chat.php
+++ b/mod/chat.php
@@ -10,7 +10,7 @@ function chat_init(&$a) {
$which = argv(1);
if(! $which) {
if(local_channel()) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if($channel && $channel['channel_address'])
$which = $channel['channel_address'];
}
@@ -21,14 +21,14 @@ function chat_init(&$a) {
}
$profile = 0;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) {
$which = $channel['channel_address'];
$profile = argv(1);
}
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which .'" />' . "\r\n" ;
+ App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . z_root() . '/feed/' . $which .'" />' . "\r\n" ;
// Run profile_load() here to make sure the theme is set before
// we start loading content
@@ -45,7 +45,7 @@ function chat_post(&$a) {
if((! $room) || (! local_channel()))
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if($_POST['action'] === 'drop') {
@@ -54,7 +54,7 @@ function chat_post(&$a) {
goaway(z_root() . '/chat/' . $channel['channel_address']);
}
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$acl->set_from_array($_REQUEST);
$arr = $acl->get();
@@ -86,16 +86,16 @@ function chat_post(&$a) {
function chat_content(&$a) {
if(local_channel())
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- $ob = $a->get_observer();
+ $ob = App::get_observer();
$observer = get_observer_hash();
if(! $observer) {
notice( t('Permission denied.') . EOL);
return;
}
- if(! perm_is_allowed($a->profile['profile_uid'],$observer,'chat')) {
+ if(! perm_is_allowed(App::$profile['profile_uid'],$observer,'chat')) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -159,10 +159,11 @@ function chat_content(&$a) {
return;
$x = q("select * from chatroom where cr_id = %d and cr_uid = %d $sql_extra limit 1",
intval($room_id),
- intval($a->profile['profile_uid'])
+ intval(App::$profile['profile_uid'])
);
+
if($x) {
- $acl = new AccessList(false);
+ $acl = new Zotlabs\Access\AccessList(false);
$acl->set($x[0]);
$private = $acl->is_private();
@@ -175,6 +176,11 @@ function chat_content(&$a) {
return;
}
+ $cipher = get_pconfig(local_channel(),'system','default_cipher');
+ if(! $cipher)
+ $cipher = 'aes256';
+
+
$o = replace_macros(get_markup_template('chat.tpl'),array(
'$is_owner' => ((local_channel() && local_channel() == $x[0]['cr_uid']) ? true : false),
'$room_name' => $room_name,
@@ -183,53 +189,65 @@ function chat_content(&$a) {
'$nickname' => argv(1),
'$submit' => t('Submit'),
'$leave' => t('Leave Room'),
- '$drop' => t('Delete This Room'),
+ '$drop' => t('Delete Room'),
'$away' => t('I am away right now'),
'$online' => t('I am online'),
'$bookmark_link' => $bookmark_link,
- '$bookmark' => t('Bookmark this room')
-
+ '$bookmark' => t('Bookmark this room'),
+ '$feature_encrypt' => ((feature_enabled(local_channel(),'content_encrypt')) ? true : false),
+ '$cipher' => $cipher,
+ '$linkurl' => t('Please enter a link URL:'),
+ '$encrypt' => t('Encrypt text'),
+ '$insert' => t('Insert web link')
));
return $o;
}
+ require_once('include/conversation.php');
+ $o = profile_tabs($a,((local_channel() && local_channel() == App::$profile['profile_uid']) ? true : false),App::$profile['channel_address']);
+ if(! feature_enabled(App::$profile['profile_uid'],'ajaxchat')) {
+ notice( t('Feature disabled.') . EOL);
+ return $o;
+ }
- if(local_channel() && argc() > 2 && argv(2) === 'new') {
-
- $acl = new AccessList($channel);
- $channel_acl = $acl->get();
- require_once('include/acl_selectors.php');
+ $acl = new Zotlabs\Access\AccessList($channel);
+ $channel_acl = $acl->get();
- $o = replace_macros(get_markup_template('chatroom_new.tpl'),array(
+ $lockstate = (($channel_acl['allow_cid'] || $channel_acl['allow_gid'] || $channel_acl['deny_cid'] || $channel_acl['deny_gid']) ? 'lock' : 'unlock');
+ require_once('include/acl_selectors.php');
+
+ $chatroom_new = '';
+ if(local_channel()) {
+ $chatroom_new = replace_macros(get_markup_template('chatroom_new.tpl'),array(
'$header' => t('New Chatroom'),
- '$name' => array('room_name',t('Chatroom Name'),'', ''),
+ '$name' => array('room_name',t('Chatroom name'),'', ''),
'$chat_expire' => array('chat_expire',t('Expiration of chats (minutes)'),120,''),
'$permissions' => t('Permissions'),
'$acl' => populate_acl($channel_acl,false),
+ '$lockstate' => $lockstate,
'$submit' => t('Submit')
+
));
- return $o;
}
-
-
- require_once('include/conversation.php');
-
- $o = profile_tabs($a,((local_channel() && local_channel() == $a->profile['profile_uid']) ? true : false),$a->profile['channel_address']);
-
- require_once('include/widgets.php');
+ $rooms = chatroom_list(App::$profile['profile_uid']);
$o .= replace_macros(get_markup_template('chatrooms.tpl'), array(
- '$header' => sprintf( t('%1$s\'s Chatrooms'), $a->profile['name']),
+ '$header' => sprintf( t('%1$s\'s Chatrooms'), App::$profile['name']),
+ '$name' => t('Name'),
'$baseurl' => z_root(),
- '$nickname' => $channel['channel_address'],
- '$rooms' => widget_chatroom_list(array()),
- '$newroom' => t('New Chatroom'),
- '$is_owner' => ((local_channel() && local_channel() == $a->profile['profile_uid']) ? 1 : 0)
+ '$nickname' => App::$profile['channel_address'],
+ '$rooms' => $rooms,
+ '$norooms' => t('No chatrooms available'),
+ '$newroom' => t('Create New'),
+ '$is_owner' => ((local_channel() && local_channel() == App::$profile['profile_uid']) ? 1 : 0),
+ '$chatroom_new' => $chatroom_new,
+ '$expire' => t('Expiration'),
+ '$expire_unit' => t('min') //minutes
));
return $o;
diff --git a/mod/chatsvc.php b/mod/chatsvc.php
index 44225e6dd..4fa38e819 100644
--- a/mod/chatsvc.php
+++ b/mod/chatsvc.php
@@ -8,16 +8,16 @@ function chatsvc_init(&$a) {
$ret = array('success' => false);
- $a->data['chat']['room_id'] = intval($_REQUEST['room_id']);
+ App::$data['chat']['room_id'] = intval($_REQUEST['room_id']);
$x = q("select cr_uid from chatroom where cr_id = %d and cr_id != 0 limit 1",
- intval($a->data['chat']['room_id'])
+ intval(App::$data['chat']['room_id'])
);
if(! $x)
json_return_and_die($ret);
- $a->data['chat']['uid'] = $x[0]['cr_uid'];
+ App::$data['chat']['uid'] = $x[0]['cr_uid'];
- if(! perm_is_allowed($a->data['chat']['uid'],get_observer_hash(),'chat')) {
+ if(! perm_is_allowed(App::$data['chat']['uid'],get_observer_hash(),'chat')) {
json_return_and_die($ret);
}
@@ -27,22 +27,22 @@ function chatsvc_post(&$a) {
$ret = array('success' => false);
- $room_id = $a->data['chat']['room_id'];
+ $room_id = App::$data['chat']['room_id'];
$text = escape_tags($_REQUEST['chat_text']);
if(! $text)
return;
- $sql_extra = permissions_sql($a->data['chat']['uid']);
+ $sql_extra = permissions_sql(App::$data['chat']['uid']);
$r = q("select * from chatroom where cr_uid = %d and cr_id = %d $sql_extra",
- intval($a->data['chat']['uid']),
- intval($a->data['chat']['room_id'])
+ intval(App::$data['chat']['uid']),
+ intval(App::$data['chat']['room_id'])
);
if(! $r)
json_return_and_die($ret);
$arr = array(
- 'chat_room' => $a->data['chat']['room_id'],
+ 'chat_room' => App::$data['chat']['room_id'],
'chat_xchan' => get_observer_hash(),
'chat_text' => $text
);
@@ -51,7 +51,7 @@ function chatsvc_post(&$a) {
$x = q("insert into chat ( chat_room, chat_xchan, created, chat_text )
values( %d, '%s', '%s', '%s' )",
- intval($a->data['chat']['room_id']),
+ intval(App::$data['chat']['room_id']),
dbesc(get_observer_hash()),
dbesc(datetime_convert()),
dbesc($arr['chat_text'])
@@ -64,13 +64,13 @@ function chatsvc_post(&$a) {
function chatsvc_content(&$a) {
$status = strip_tags($_REQUEST['status']);
- $room_id = intval($a->data['chat']['room_id']);
+ $room_id = intval(App::$data['chat']['room_id']);
$stopped = ((x($_REQUEST,'stopped') && intval($_REQUEST['stopped'])) ? true : false);
if($status && $room_id) {
$x = q("select channel_address from channel where channel_id = %d limit 1",
- intval($a->data['chat']['uid'])
+ intval(App::$data['chat']['uid'])
);
$r = q("update chatpresence set cp_status = '%s', cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s'",
@@ -90,11 +90,11 @@ function chatsvc_content(&$a) {
$ret = array('success' => false);
- $sql_extra = permissions_sql($a->data['chat']['uid']);
+ $sql_extra = permissions_sql(App::$data['chat']['uid']);
$r = q("select * from chatroom where cr_uid = %d and cr_id = %d $sql_extra",
- intval($a->data['chat']['uid']),
- intval($a->data['chat']['room_id'])
+ intval(App::$data['chat']['uid']),
+ intval(App::$data['chat']['room_id'])
);
if(! $r)
json_return_and_die($ret);
@@ -102,28 +102,30 @@ function chatsvc_content(&$a) {
$inroom = array();
$r = q("select * from chatpresence left join xchan on xchan_hash = cp_xchan where cp_room = %d order by xchan_name",
- intval($a->data['chat']['room_id'])
+ intval(App::$data['chat']['room_id'])
);
if($r) {
foreach($r as $rr) {
switch($rr['cp_status']) {
case 'away':
$status = t('Away');
+ $status_class = 'away';
break;
case 'online':
default:
$status = t('Online');
+ $status_class = 'online';
break;
}
- $inroom[] = array('img' => zid($rr['xchan_photo_m']), 'img_type' => $rr['xchan_photo_mimetype'],'name' => $rr['xchan_name'], status => $status);
+ $inroom[] = array('img' => zid($rr['xchan_photo_m']), 'img_type' => $rr['xchan_photo_mimetype'],'name' => $rr['xchan_name'], 'status' => $status, 'status_class' => $status_class);
}
}
$chats = array();
$r = q("select * from chat left join xchan on chat_xchan = xchan_hash where chat_room = %d and chat_id > %d order by created",
- intval($a->data['chat']['room_id']),
+ intval(App::$data['chat']['room_id']),
intval($lastseen)
);
if($r) {
@@ -135,7 +137,8 @@ function chatsvc_content(&$a) {
'name' => $rr['xchan_name'],
'isotime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'c'),
'localtime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'r'),
- 'text' => smilies(bbcode($rr['chat_text']))
+ 'text' => smilies(bbcode($rr['chat_text'])),
+ 'self' => ((get_observer_hash() == $rr['chat_xchan']) ? 'self' : '')
);
}
}
@@ -143,7 +146,7 @@ function chatsvc_content(&$a) {
$r = q("update chatpresence set cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s'",
dbesc(datetime_convert()),
- intval($a->data['chat']['room_id']),
+ intval(App::$data['chat']['room_id']),
dbesc(get_observer_hash()),
dbesc($_SERVER['REMOTE_ADDR'])
);
diff --git a/mod/cloud.php b/mod/cloud.php
index 67fc199bf..eed941ff7 100644
--- a/mod/cloud.php
+++ b/mod/cloud.php
@@ -7,7 +7,7 @@
*/
use Sabre\DAV;
-use RedMatrix\RedDAV;
+use Zotlabs\Storage;
// composer autoloader for SabreDAV
require_once('vendor/autoload.php');
@@ -30,18 +30,18 @@ function cloud_init(&$a) {
$profile = 0;
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which . '" />' . "\r\n";
+ App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . z_root() . '/feed/' . $which . '" />' . "\r\n";
if ($which)
profile_load($a, $which, $profile);
- $auth = new RedDAV\RedBasicAuth();
+ $auth = new Zotlabs\Storage\BasicAuth();
$ob_hash = get_observer_hash();
if ($ob_hash) {
if (local_channel()) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$auth->setCurrentUser($channel['channel_address']);
$auth->channel_id = $channel['channel_id'];
$auth->channel_hash = $channel['channel_hash'];
@@ -63,7 +63,7 @@ function cloud_init(&$a) {
$_SERVER['REQUEST_URI'] = strip_zids($_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = preg_replace('/[\?&]davguest=(.*?)([\?&]|$)/ism', '', $_SERVER['REQUEST_URI']);
- $rootDirectory = new RedDAV\RedDirectory('/', $auth);
+ $rootDirectory = new Zotlabs\Storage\Directory('/', $auth);
// A SabreDAV server-object
$server = new DAV\Server($rootDirectory);
@@ -77,7 +77,7 @@ function cloud_init(&$a) {
if($_SERVER['REQUEST_METHOD'] === 'GET') {
try {
- $x = RedFileData('/' . $a->cmd, $auth);
+ $x = RedFileData('/' . App::$cmd, $auth);
}
catch(\Exception $e) {
if($e instanceof Sabre\DAV\Exception\Forbidden) {
@@ -86,16 +86,16 @@ function cloud_init(&$a) {
}
}
- require_once('include/RedDAV/RedBrowser.php');
+// require_once('Zotlabs/Storage/Browser.php');
// provide a directory view for the cloud in Hubzilla
- $browser = new RedDAV\RedBrowser($auth);
+ $browser = new Zotlabs\Storage\Browser($auth);
$auth->setBrowserPlugin($browser);
$server->addPlugin($browser);
// Experimental QuotaPlugin
-// require_once('include/RedDAV/QuotaPlugin.php');
-// $server->addPlugin(new RedDAV\QuotaPlugin($auth));
+// require_once('Zotlabs\Storage/QuotaPlugin.php');
+// $server->addPlugin(new Zotlabs\Storage\\QuotaPlugin($auth));
// All we need to do now, is to fire up the server
$server->exec();
diff --git a/mod/common.php b/mod/common.php
index e19a9d3a9..3390bd997 100644
--- a/mod/common.php
+++ b/mod/common.php
@@ -8,7 +8,7 @@ function common_init(&$a) {
$channel_id = intval(argv(1));
else {
notice( t('No channel.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
@@ -25,27 +25,27 @@ function common_content(&$a) {
$o = '';
- if(! $a->profile['profile_uid'])
+ if(! App::$profile['profile_uid'])
return;
$observer_hash = get_observer_hash();
- if(! perm_is_allowed($a->profile['profile_uid'],$observer_hash,'view_contacts')) {
+ if(! perm_is_allowed(App::$profile['profile_uid'],$observer_hash,'view_contacts')) {
notice( t('Permission denied.') . EOL);
return;
}
$o .= '<h2>' . t('Common connections') . '</h2>';
- $t = count_common_friends($a->profile['profile_uid'],$observer_hash);
+ $t = count_common_friends(App::$profile['profile_uid'],$observer_hash);
if(! $t) {
notice( t('No connections in common.') . EOL);
return $o;
}
- $r = common_friends($a->profile['profile_uid'],$observer_hash);
+ $r = common_friends(App::$profile['profile_uid'],$observer_hash);
if($r) {
diff --git a/mod/connect.php b/mod/connect.php
index c36aef433..84c67e4d2 100644
--- a/mod/connect.php
+++ b/mod/connect.php
@@ -11,7 +11,7 @@ function connect_init(&$a) {
$which = argv(1);
else {
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
@@ -20,20 +20,20 @@ function connect_init(&$a) {
);
if($r)
- $a->data['channel'] = $r[0];
+ App::$data['channel'] = $r[0];
profile_load($a,$which,'');
}
function connect_post(&$a) {
- if(! array_key_exists('channel', $a->data))
+ if(! array_key_exists('channel', App::$data))
return;
- $edit = ((local_channel() && (local_channel() == $a->data['channel']['channel_id'])) ? true : false);
+ $edit = ((local_channel() && (local_channel() == App::$data['channel']['channel_id'])) ? true : false);
if($edit) {
- $has_premium = (($a->data['channel']['channel_pageflags'] & PAGE_PREMIUM) ? 1 : 0);
+ $has_premium = ((App::$data['channel']['channel_pageflags'] & PAGE_PREMIUM) ? 1 : 0);
$premium = (($_POST['premium']) ? intval($_POST['premium']) : 0);
$text = escape_tags($_POST['text']);
@@ -43,25 +43,25 @@ function connect_post(&$a) {
intval(PAGE_PREMIUM),
intval(local_channel())
);
- proc_run('php','include/notifier.php','refresh_all',$a->data['channel']['channel_id']);
+ proc_run('php','include/notifier.php','refresh_all',App::$data['channel']['channel_id']);
}
- set_pconfig($a->data['channel']['channel_id'],'system','selltext',$text);
+ set_pconfig(App::$data['channel']['channel_id'],'system','selltext',$text);
// reload the page completely to get fresh data
- goaway(z_root() . '/' . $a->query_string);
+ goaway(z_root() . '/' . App::$query_string);
}
$url = '';
- $observer = $a->get_observer();
+ $observer = App::get_observer();
if(($observer) && ($_POST['submit'] === t('Continue'))) {
if($observer['xchan_follow'])
- $url = sprintf($observer['xchan_follow'],urlencode($a->data['channel']['channel_address'] . '@' . $a->get_hostname()));
+ $url = sprintf($observer['xchan_follow'],urlencode(App::$data['channel']['channel_address'] . '@' . App::get_hostname()));
if(! $url) {
$r = q("select * from hubloc where hubloc_hash = '%s' order by hubloc_id desc limit 1",
dbesc($observer['xchan_hash'])
);
if($r)
- $url = $r[0]['hubloc_url'] . '/follow?f=&url=' . urlencode($a->data['channel']['channel_address'] . '@' . $a->get_hostname());
+ $url = $r[0]['hubloc_url'] . '/follow?f=&url=' . urlencode(App::$data['channel']['channel_address'] . '@' . App::get_hostname());
}
}
if($url)
@@ -75,16 +75,16 @@ function connect_post(&$a) {
function connect_content(&$a) {
- $edit = ((local_channel() && (local_channel() == $a->data['channel']['channel_id'])) ? true : false);
+ $edit = ((local_channel() && (local_channel() == App::$data['channel']['channel_id'])) ? true : false);
- $text = get_pconfig($a->data['channel']['channel_id'],'system','selltext');
+ $text = get_pconfig(App::$data['channel']['channel_id'],'system','selltext');
if($edit) {
$o = replace_macros(get_markup_template('sellpage_edit.tpl'),array(
'$header' => t('Premium Channel Setup'),
- '$address' => $a->data['channel']['channel_address'],
- '$premium' => array('premium', t('Enable premium channel connection restrictions'),(($a->data['channel']['channel_pageflags'] & PAGE_PREMIUM) ? '1' : ''),''),
+ '$address' => App::$data['channel']['channel_address'],
+ '$premium' => array('premium', t('Enable premium channel connection restrictions'),((App::$data['channel']['channel_pageflags'] & PAGE_PREMIUM) ? '1' : ''),''),
'$lbl_about' => t('Please enter your restrictions or conditions, such as paypal receipt, usage guidelines, etc.'),
'$text' => $text,
'$desc' => t('This channel may require additional steps or acknowledgement of the following conditions prior to connecting:'),
@@ -102,7 +102,7 @@ function connect_content(&$a) {
$submit = replace_macros(get_markup_template('sellpage_submit.tpl'), array(
'$continue' => t('Continue'),
- '$address' => $a->data['channel']['channel_address']
+ '$address' => App::$data['channel']['channel_address']
));
$o = replace_macros(get_markup_template('sellpage_view.tpl'),array(
@@ -115,7 +115,7 @@ function connect_content(&$a) {
));
- $arr = array('channel' => $a->data['channel'],'observer' => $a->get_observer(), 'sellpage' => $o, 'submit' => $submit);
+ $arr = array('channel' => App::$data['channel'],'observer' => App::get_observer(), 'sellpage' => $o, 'submit' => $submit);
call_hooks('connect_premium', $arr);
$o = $arr['sellpage'];
diff --git a/mod/connections.php b/mod/connections.php
index 2060ca85e..992d485bd 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -13,7 +13,7 @@ function connections_init(&$a) {
if(! local_channel())
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if($channel)
head_set_icon($channel['xchan_photo_s']);
@@ -40,7 +40,7 @@ function connections_content(&$a) {
$all = false;
if(! $_REQUEST['aj'])
- $_SESSION['return_url'] = $a->query_string;
+ $_SESSION['return_url'] = App::$query_string;
$search_flags = '';
$head = '';
@@ -82,14 +82,14 @@ function connections_content(&$a) {
$head = t('New');
$pending = true;
nav_set_selected('intros');
- $a->argv[1] = 'pending';
+ App::$argv[1] = 'pending';
}
else {
$head = t('All');
$search_flags = '';
$all = true;
- $a->argc = 1;
- unset($a->argv[1]);
+ App::$argc = 1;
+ unset(App::$argv[1]);
}
nav_set_selected('intros');
break;
@@ -121,53 +121,60 @@ function connections_content(&$a) {
$search = ((x($_REQUEST,'search')) ? notags(trim($_REQUEST['search'])) : '');
$tabs = array(
+ /*
array(
'label' => t('Suggestions'),
'url' => z_root() . '/suggest',
'sel' => '',
'title' => t('Suggest new connections'),
),
- array(
+ */
+
+ 'pending' => array(
'label' => t('New Connections'),
'url' => z_root() . '/connections/pending',
'sel' => ($pending) ? 'active' : '',
'title' => t('Show pending (new) connections'),
),
- array(
+
+ 'all' => array(
'label' => t('All Connections'),
'url' => z_root() . '/connections/all',
'sel' => ($all) ? 'active' : '',
'title' => t('Show all connections'),
),
+
+ /*
array(
'label' => t('Unblocked'),
'url' => z_root() . '/connections',
'sel' => (($unblocked) && (! $search) && (! $nets)) ? 'active' : '',
'title' => t('Only show unblocked connections'),
),
+ */
- array(
+ 'blocked' => array(
'label' => t('Blocked'),
'url' => z_root() . '/connections/blocked',
'sel' => ($blocked) ? 'active' : '',
'title' => t('Only show blocked connections'),
),
- array(
+ 'ignored' => array(
'label' => t('Ignored'),
'url' => z_root() . '/connections/ignored',
'sel' => ($ignored) ? 'active' : '',
'title' => t('Only show ignored connections'),
),
- array(
+ 'archived' => array(
'label' => t('Archived'),
'url' => z_root() . '/connections/archived',
'sel' => ($archived) ? 'active' : '',
'title' => t('Only show archived connections'),
),
- array(
+ 'hidden' => array(
'label' => t('Hidden'),
'url' => z_root() . '/connections/hidden',
'sel' => ($hidden) ? 'active' : '',
@@ -184,8 +191,8 @@ function connections_content(&$a) {
);
- $tab_tpl = get_markup_template('common_tabs.tpl');
- $t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
+ //$tab_tpl = get_markup_template('common_tabs.tpl');
+ //$t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
$searching = false;
if($search) {
@@ -204,15 +211,15 @@ function connections_content(&$a) {
intval(local_channel())
);
if($r) {
- $a->set_pager_total($r[0]['total']);
+ App::set_pager_total($r[0]['total']);
$total = $r[0]['total'];
}
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
WHERE abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d OFFSET %d ",
intval(local_channel()),
- intval($a->pager['itemspage']),
- intval($a->pager['start'])
+ intval(App::$pager['itemspage']),
+ intval(App::$pager['start'])
);
$contacts = array();
@@ -221,20 +228,51 @@ function connections_content(&$a) {
foreach($r as $rr) {
if($rr['xchan_url']) {
+
+ $status_str = '';
+ $status = array(
+ ((intval($rr['abook_pending'])) ? t('Pending approval') : ''),
+ ((intval($rr['abook_archived'])) ? t('Archived') : ''),
+ ((intval($rr['abook_hidden'])) ? t('Hidden') : ''),
+ ((intval($rr['abook_ignored'])) ? t('Ignored') : ''),
+ ((intval($rr['abook_blocked'])) ? t('Blocked') : '')
+ );
+
+ foreach($status as $str) {
+ if(!$str)
+ continue;
+ $status_str .= $str;
+ $status_str .= ', ';
+ }
+ $status_str = rtrim($status_str, ', ');
+
$contacts[] = array(
'img_hover' => sprintf( t('%1$s [%2$s]'),$rr['xchan_name'],$rr['xchan_url']),
'edit_hover' => t('Edit connection'),
+ 'delete_hover' => t('Delete connection'),
'id' => $rr['abook_id'],
- 'alt_text' => $alt_text,
- 'dir_icon' => $dir_icon,
'thumb' => $rr['xchan_photo_m'],
'name' => $rr['xchan_name'],
- 'username' => $rr['xchan_name'],
'classes' => (intval($rr['abook_archived']) ? 'archived' : ''),
'link' => z_root() . '/connedit/' . $rr['abook_id'],
- 'edit' => t('Edit'),
+ 'deletelink' => z_root() . '/connedit/' . intval($rr['abook_id']) . '/drop',
+ 'delete' => t('Delete'),
'url' => chanlink_url($rr['xchan_url']),
- 'network' => network_to_name($rr['network']),
+ 'webbie_label' => t('Channel address'),
+ 'webbie' => $rr['xchan_addr'],
+ 'network_label' => t('Network'),
+ 'network' => network_to_name($rr['xchan_network']),
+ 'public_forum' => ((intval($rr['xchan_pubforum'])) ? true : false),
+ 'status_label' => t('Status'),
+ 'status' => $status_str,
+ 'connected_label' => t('Connected'),
+ 'connected' => datetime_convert('UTC',date_default_timezone_get(),$rr['abook_created'], 'c'),
+ 'approve_hover' => t('Approve connection'),
+ 'approve' => (($rr['abook_pending']) ? t('Approve') : false),
+ 'ignore_hover' => t('Ignore connection'),
+ 'ignore' => ((! $rr['abook_ignored']) ? t('Ignore') : false),
+ 'recent_label' => t('Recent activity'),
+ 'recentlink' => z_root() . '/network/?f=&cid=' . intval($rr['abook_id'])
);
}
}
@@ -257,15 +295,16 @@ function connections_content(&$a) {
else {
$o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
$o .= replace_macros(get_markup_template('connections.tpl'),array(
- '$header' => t('Connections') . (($head) ? ' - ' . $head : ''),
- '$tabs' => $t,
+ '$header' => t('Connections') . (($head) ? ': ' . $head : ''),
+ '$tabs' => $tabs,
'$total' => $total,
'$search' => $search_hdr,
+ '$label' => t('Search'),
'$desc' => t('Search your connections'),
- '$finding' => (($searching) ? t('Finding: ') . "'" . $search . "'" : ""),
+ '$finding' => (($searching) ? t('Connections search') . ": '" . $search . "'" : ""),
'$submit' => t('Find'),
'$edit' => t('Edit'),
- '$cmd' => $a->cmd,
+ '$cmd' => App::$cmd,
'$contacts' => $contacts,
'$paginate' => paginate($a),
diff --git a/mod/connedit.php b/mod/connedit.php
index 9c46fa999..f57fdefc6 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -25,18 +25,18 @@ function connedit_init(&$a) {
return;
if((argc() >= 2) && intval(argv(1))) {
- $r = q("SELECT abook.*, xchan.*
+ $r = q("SELECT abook.*, xchan.*
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d and abook_id = %d LIMIT 1",
intval(local_channel()),
intval(argv(1))
);
if($r) {
- $a->poi = $r[0];
+ App::$poi = $r[0];
}
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if($channel)
head_set_icon($channel['xchan_photo_s']);
@@ -55,17 +55,17 @@ function connedit_post(&$a) {
if(! $contact_id)
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
// TODO if configured for hassle-free permissions, we'll post the form with ajax as soon as the
- // connection enable is toggled to a special autopost url and set permissions immediately, leaving
- // the other form elements alone pending a manual submit of the form. The downside is that there
+ // connection enable is toggled to a special autopost url and set permissions immediately, leaving
+ // the other form elements alone pending a manual submit of the form. The downside is that there
// will be a window of opportunity when the permissions have been set but before you've had a chance
// to review and possibly restrict them. The upside is we won't have to warn you that your connection
- // can't do anything until you save the bloody form.
+ // can't do anything until you save the bloody form.
$autopost = (((argc() > 2) && (argv(2) === 'auto')) ? true : false);
-
+
$orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1",
intval($contact_id),
intval(local_channel())
@@ -73,7 +73,7 @@ function connedit_post(&$a) {
if(! $orig_record) {
notice( t('Could not access contact record.') . EOL);
- goaway($a->get_baseurl(true) . '/connections');
+ goaway(z_root() . '/connections');
return; // NOTREACHED
}
@@ -145,7 +145,7 @@ function connedit_post(&$a) {
if($z) {
$record = $z[0]['xlink_id'];
- $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s'
+ $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s'
where xlink_id = %d",
intval($rating),
dbesc($rating_text),
@@ -172,7 +172,7 @@ function connedit_post(&$a) {
}
if($record) {
proc_run('php','include/ratenotif.php','rating',$record);
- }
+ }
}
if(($_REQUEST['pending']) && intval($orig_record[0]['abook_pending'])) {
@@ -181,7 +181,7 @@ function connedit_post(&$a) {
// @fixme it won't be common, but when you accept a new connection request
// the permissions will now be that of your permissions role and ignore
// any you may have set manually on the form. We'll probably see a bug if somebody
- // tries to set the permissions *and* approve the connection in the same
+ // tries to set the permissions *and* approve the connection in the same
// request. The workaround is to approve the connection, then go back and
// adjust permissions as desired.
@@ -210,7 +210,7 @@ function connedit_post(&$a) {
intval(local_channel())
);
- if($orig_record[0]['abook_profile'] != $profile_id) {
+ if($orig_record[0]['abook_profile'] != $profile_id) {
//Update profile photo permissions
logger('A new profile was assigned - updating profile photos');
@@ -224,8 +224,8 @@ function connedit_post(&$a) {
else
notice( t('Failed to update connection record.') . EOL);
- if($a->poi && $a->poi['abook_my_perms'] != $abook_my_perms
- && (! intval($a->poi['abook_self']))) {
+ if(App::$poi && App::$poi['abook_my_perms'] != $abook_my_perms
+ && (! intval(App::$poi['abook_self']))) {
proc_run('php', 'include/notifier.php', (($new_friend) ? 'permission_create' : 'permission_update'), $contact_id);
}
@@ -235,11 +235,11 @@ function connedit_post(&$a) {
require_once('include/group.php');
$g = group_rec_byhash(local_channel(),$default_group);
if($g)
- group_add_member(local_channel(),'',$a->poi['abook_xchan'],$g['id']);
+ group_add_member(local_channel(),'',App::$poi['abook_xchan'],$g['id']);
}
- // Check if settings permit ("post new friend activity" is allowed, and
- // friends in general or this friend in particular aren't hidden)
+ // Check if settings permit ("post new friend activity" is allowed, and
+ // friends in general or this friend in particular aren't hidden)
// and send out a new friend activity
$pr = q("select * from profile where uid = %d and is_default = 1 and hide_friends = 0",
@@ -259,19 +259,19 @@ function connedit_post(&$a) {
$xarr['item_private'] = (($xarr['allow_cid']||$xarr['allow_gid']||$xarr['deny_cid']||$xarr['deny_gid']) ? 1 : 0);
$obj = array(
'type' => ACTIVITY_OBJ_PERSON,
- 'title' => $a->poi['xchan_name'],
- 'id' => $a->poi['xchan_hash'],
+ 'title' => App::$poi['xchan_name'],
+ 'id' => App::$poi['xchan_hash'],
'link' => array(
- array('rel' => 'alternate', 'type' => 'text/html', 'href' => $a->poi['xchan_url']),
- array('rel' => 'photo', 'type' => $a->poi['xchan_photo_mimetype'], 'href' => $a->poi['xchan_photo_l'])
+ array('rel' => 'alternate', 'type' => 'text/html', 'href' => App::$poi['xchan_url']),
+ array('rel' => 'photo', 'type' => App::$poi['xchan_photo_mimetype'], 'href' => App::$poi['xchan_photo_l'])
),
);
$xarr['object'] = json_encode($obj);
$xarr['obj_type'] = ACTIVITY_OBJ_PERSON;
- $xarr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t('is now connected to') . ' ' . '[zrl=' . $a->poi['xchan_url'] . ']' . $a->poi['xchan_name'] . '[/zrl]';
+ $xarr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t('is now connected to') . ' ' . '[zrl=' . App::$poi['xchan_url'] . ']' . App::$poi['xchan_name'] . '[/zrl]';
- $xarr['body'] .= "\n\n\n" . '[zrl=' . $a->poi['xchan_url'] . '][zmg=80x80]' . $a->poi['xchan_photo_m'] . '[/zmg][/zrl]';
+ $xarr['body'] .= "\n\n\n" . '[zrl=' . App::$poi['xchan_url'] . '][zmg=80x80]' . App::$poi['xchan_photo_m'] . '[/zmg][/zrl]';
post_activity_item($xarr);
@@ -285,26 +285,29 @@ function connedit_post(&$a) {
// Refresh the structure in memory with the new data
- $r = q("SELECT abook.*, xchan.*
+ $r = q("SELECT abook.*, xchan.*
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d and abook_id = %d LIMIT 1",
intval(local_channel()),
intval($contact_id)
);
if($r) {
- $a->poi = $r[0];
+ App::$poi = $r[0];
}
if($new_friend) {
- $arr = array('channel_id' => local_channel(), 'abook' => $a->poi);
+ $arr = array('channel_id' => local_channel(), 'abook' => App::$poi);
call_hooks('accept_follow', $arr);
}
- if(! is_null($autoperms))
+ if(! is_null($autoperms))
set_pconfig(local_channel(),'system','autoperms',(($autoperms) ? $abook_my_perms : 0));
connedit_clone($a);
+ if(($_REQUEST['pending']) && (!$_REQUEST['done']))
+ goaway(z_root() . '/connections/ifpending');
+
return;
}
@@ -316,25 +319,32 @@ function connedit_post(&$a) {
function connedit_clone(&$a) {
- if(! $a->poi)
+ if(! App::$poi)
return;
- $r = q("SELECT abook.*, xchan.*
+
+ $channel = App::get_channel();
+
+ $r = q("SELECT abook.*, xchan.*
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d and abook_id = %d LIMIT 1",
intval(local_channel()),
- intval($a->poi['abook_id'])
+ intval(App::$poi['abook_id'])
);
if($r) {
- $a->poi = $r[0];
+ App::$poi = $r[0];
}
- $clone = $a->poi;
+ $clone = App::$poi;
unset($clone['abook_id']);
unset($clone['abook_account']);
unset($clone['abook_channel']);
+ $abconfig = load_abconfig($channel['channel_hash'],$clone['abook_xchan']);
+ if($abconfig)
+ $clone['abconfig'] = $abconfig;
+
build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
}
@@ -353,7 +363,7 @@ function connedit_content(&$a) {
return login();
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$my_perms = get_channel_default_perms(local_channel());
$role = get_pconfig(local_channel(),'system','permissions_role');
if($role) {
@@ -362,6 +372,8 @@ function connedit_content(&$a) {
$my_perms = $x['perms_accept'];
}
+ $yes_no = array(t('No'),t('Yes'));
+
if($my_perms) {
$o .= "<script>function connectDefaultShare() {
\$('.abook-edit-me').each(function() {
@@ -393,21 +405,27 @@ function connedit_content(&$a) {
if(! count($orig_record)) {
notice( t('Could not access address book record.') . EOL);
- goaway($a->get_baseurl(true) . '/connections');
+ goaway(z_root() . '/connections');
}
-
- if($cmd === 'update') {
+ if($cmd === 'update') {
// pull feed and consume it, which should subscribe to the hub.
proc_run('php',"include/poller.php","$contact_id");
- goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ goaway(z_root() . '/connedit/' . $contact_id);
}
if($cmd === 'refresh') {
- if(! zot_refresh($orig_record[0],get_app()->get_channel()))
- notice( t('Refresh failed - channel is currently unavailable.') );
- goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ if($orig_record[0]['xchan_network'] === 'zot') {
+ if(! zot_refresh($orig_record[0],App::get_channel()))
+ notice( t('Refresh failed - channel is currently unavailable.') );
+ }
+ else {
+
+ // if you are on a different network we'll force a refresh of the connection basic info
+ proc_run('php','include/notifier.php','permission_update',$contact_id);
+ }
+ goaway(z_root() . '/connedit/' . $contact_id);
}
if($cmd === 'block') {
@@ -416,7 +434,7 @@ function connedit_content(&$a) {
}
else
notice(t('Unable to set address book parameters.') . EOL);
- goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ goaway(z_root() . '/connedit/' . $contact_id);
}
if($cmd === 'ignore') {
@@ -425,7 +443,7 @@ function connedit_content(&$a) {
}
else
notice(t('Unable to set address book parameters.') . EOL);
- goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ goaway(z_root() . '/connedit/' . $contact_id);
}
if($cmd === 'archive') {
@@ -434,7 +452,7 @@ function connedit_content(&$a) {
}
else
notice(t('Unable to set address book parameters.') . EOL);
- goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ goaway(z_root() . '/connedit/' . $contact_id);
}
if($cmd === 'hide') {
@@ -443,7 +461,7 @@ function connedit_content(&$a) {
}
else
notice(t('Unable to set address book parameters.') . EOL);
- goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ goaway(z_root() . '/connedit/' . $contact_id);
}
// We'll prevent somebody from unapproving an already approved contact.
@@ -457,7 +475,7 @@ function connedit_content(&$a) {
else
notice(t('Unable to set address book parameters.') . EOL);
}
- goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ goaway(z_root() . '/connedit/' . $contact_id);
}
@@ -466,13 +484,13 @@ function connedit_content(&$a) {
require_once('include/Contact.php');
// FIXME
-// We need to send either a purge or a refresh packet to the other side (the channel being unfriended).
+// We need to send either a purge or a refresh packet to the other side (the channel being unfriended).
// The issue is that the abook DB record _may_ get destroyed when we call contact_remove. As the notifier runs
// in the background there could be a race condition preventing this packet from being sent in all cases.
// PLACEHOLDER
contact_remove(local_channel(), $orig_record[0]['abook_id']);
- build_sync_packet(0 /* use the current local_channel */,
+ build_sync_packet(0 /* use the current local_channel */,
array('abook' => array(array(
'abook_xchan' => $orig_record[0]['abook_xchan'],
'entry_deleted' => true))
@@ -481,43 +499,43 @@ function connedit_content(&$a) {
info( t('Connection has been removed.') . EOL );
if(x($_SESSION,'return_url'))
- goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
- goaway($a->get_baseurl(true) . '/contacts');
+ goaway(z_root() . '/' . $_SESSION['return_url']);
+ goaway(z_root() . '/contacts');
}
}
- if($a->poi) {
+ if(App::$poi) {
- $contact_id = $a->poi['abook_id'];
- $contact = $a->poi;
+ $contact_id = App::$poi['abook_id'];
+ $contact = App::$poi;
$buttons = array(
'view' => array(
'label' => t('View Profile'),
- 'url' => chanlink_cid($contact['abook_id']),
+ 'url' => chanlink_cid($contact['abook_id']),
'sel' => '',
'title' => sprintf( t('View %s\'s profile'), $contact['xchan_name']),
),
'refresh' => array(
'label' => t('Refresh Permissions'),
- 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/refresh',
+ 'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/refresh',
'sel' => '',
'title' => t('Fetch updated permissions'),
),
'recent' => array(
'label' => t('Recent Activity'),
- 'url' => $a->get_baseurl(true) . '/network/?f=&cid=' . $contact['abook_id'],
+ 'url' => z_root() . '/network/?f=&cid=' . $contact['abook_id'],
'sel' => '',
'title' => t('View recent posts and comments'),
),
'block' => array(
'label' => (intval($contact['abook_blocked']) ? t('Unblock') : t('Block')),
- 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/block',
+ 'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/block',
'sel' => (intval($contact['abook_blocked']) ? 'active' : ''),
'title' => t('Block (or Unblock) all communications with this connection'),
'info' => (intval($contact['abook_blocked']) ? t('This connection is blocked!') : ''),
@@ -525,7 +543,7 @@ function connedit_content(&$a) {
'ignore' => array(
'label' => (intval($contact['abook_ignored']) ? t('Unignore') : t('Ignore')),
- 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/ignore',
+ 'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/ignore',
'sel' => (intval($contact['abook_ignored']) ? 'active' : ''),
'title' => t('Ignore (or Unignore) all inbound communications from this connection'),
'info' => (intval($contact['abook_ignored']) ? t('This connection is ignored!') : ''),
@@ -533,7 +551,7 @@ function connedit_content(&$a) {
'archive' => array(
'label' => (intval($contact['abook_archived']) ? t('Unarchive') : t('Archive')),
- 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/archive',
+ 'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/archive',
'sel' => (intval($contact['abook_archived']) ? 'active' : ''),
'title' => t('Archive (or Unarchive) this connection - mark channel dead but keep content'),
'info' => (intval($contact['abook_archived']) ? t('This connection is archived!') : ''),
@@ -541,7 +559,7 @@ function connedit_content(&$a) {
'hide' => array(
'label' => (intval($contact['abook_hidden']) ? t('Unhide') : t('Hide')),
- 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/hide',
+ 'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/hide',
'sel' => (intval($contact['abook_hidden']) ? 'active' : ''),
'title' => t('Hide or Unhide this connection from your other connections'),
'info' => (intval($contact['abook_hidden']) ? t('This connection is hidden!') : ''),
@@ -549,7 +567,7 @@ function connedit_content(&$a) {
'delete' => array(
'label' => t('Delete'),
- 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/drop',
+ 'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/drop',
'sel' => '',
'title' => t('Delete this connection'),
),
@@ -627,10 +645,10 @@ function connedit_content(&$a) {
$perms = array();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$global_perms = get_perms();
- $existing = get_all_perms(local_channel(),$contact['abook_xchan']);
+ $existing = get_all_perms(local_channel(),$contact['abook_xchan']);
$unapproved = array('pending', t('Approve this connection'), '', t('Accept connection to allow communication'), array(t('No'),('Yes')));
@@ -659,7 +677,7 @@ function connedit_content(&$a) {
$locstr = '';
- $locs = q("select hubloc_addr as location from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s'
+ $locs = q("select hubloc_addr as location from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s'
and hubloc_deleted = 0 and site_dead = 0",
dbesc($contact['xchan_hash'])
);
@@ -681,7 +699,7 @@ function connedit_content(&$a) {
$o .= replace_macros($tpl,array(
'$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])),
- '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), 'Connection requests will be approved without your interaction', array(t('No'),('Yes'))),
+ '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('Connection requests will be approved without your interaction'), $yes_no),
'$addr' => $contact['xchan_addr'],
'$addr_text' => t('This connection\'s primary address is'),
'$loc_text' => t('Available locations:'),
@@ -696,8 +714,8 @@ function connedit_content(&$a) {
'$lbl_rating_txt' => t('Optionally explain your rating'),
'$connfilter' => feature_enabled(local_channel(),'connfilter'),
'$connfilter_label' => t('Custom Filter'),
- '$incl' => array('abook_incl',t('Only import posts with this text'), $contact['abook_incl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')),
- '$excl' => array('abook_excl',t('Do not import posts with this text'), $contact['abook_excl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')),
+ '$incl' => array('abook_incl',t('Only import posts with this text'), $contact['abook_incl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')),
+ '$excl' => array('abook_excl',t('Do not import posts with this text'), $contact['abook_excl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')),
'$rating_text' => array('rating_text', t('Optionally explain your rating'),$rating_text,''),
'$rating_info' => t('This information is public!'),
'$rating' => $rating,
@@ -705,10 +723,6 @@ function connedit_content(&$a) {
'$slide' => $slide,
'$affinity' => $affinity,
'$pending_label' => t('Connection Pending Approval'),
- '$pending_modal_title' => t('Connection Request'),
- '$pending_modal_body' => sprintf(t('(%s) would like to connect with you. Please approve this connection to allow communication.'), $contact['xchan_addr']),
- '$pending_modal_approve' => t('Approve'),
- '$pending_modal_dismiss' => t('Approve Later'),
'$is_pending' => (intval($contact['abook_pending']) ? 1 : ''),
'$unapproved' => $unapproved,
'$inherited' => t('inherited'),
diff --git a/mod/cover_photo.php b/mod/cover_photo.php
new file mode 100644
index 000000000..c99fdf7de
--- /dev/null
+++ b/mod/cover_photo.php
@@ -0,0 +1,417 @@
+<?php
+
+/*
+ @file cover_photo.php
+ @brief Module-file with functions for handling of cover-photos
+
+*/
+
+require_once('include/photo/photo_driver.php');
+require_once('include/identity.php');
+
+
+
+/* @brief Initalize the cover-photo edit view
+ *
+ * @param $a Current application
+ * @return void
+ *
+ */
+
+function cover_photo_init(&$a) {
+
+ if(! local_channel()) {
+ return;
+ }
+
+ $channel = App::get_channel();
+ profile_load($a,$channel['channel_address']);
+
+}
+
+/* @brief Evaluate posted values
+ *
+ * @param $a Current application
+ * @return void
+ *
+ */
+
+function cover_photo_post(&$a) {
+
+ if(! local_channel()) {
+ return;
+ }
+
+ $channel = App::get_channel();
+
+ check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo');
+
+ if((x($_POST,'cropfinal')) && ($_POST['cropfinal'] == 1)) {
+
+ // phase 2 - we have finished cropping
+
+ if(argc() != 2) {
+ notice( t('Image uploaded but image cropping failed.') . EOL );
+ return;
+ }
+
+ $image_id = argv(1);
+
+ if(substr($image_id,-2,1) == '-') {
+ $scale = substr($image_id,-1,1);
+ $image_id = substr($image_id,0,-2);
+ }
+
+
+ $srcX = $_POST['xstart'];
+ $srcY = $_POST['ystart'];
+ $srcW = $_POST['xfinal'] - $srcX;
+ $srcH = $_POST['yfinal'] - $srcY;
+
+
+ $r = q("select gender from profile where uid = %d and is_default = 1 limit 1",
+ intval(local_channel())
+ );
+ if($r) {
+ $profile = $r[0];
+ }
+
+ $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND uid = %d AND scale = 0 LIMIT 1",
+ dbesc($image_id),
+ intval(local_channel())
+ );
+
+ if($r) {
+
+ $base_image = $r[0];
+ $base_image['data'] = (($r[0]['os_storage']) ? @file_get_contents($base_image['data']) : dbunescbin($base_image['data']));
+
+ $im = photo_factory($base_image['data'], $base_image['type']);
+ if($im->is_valid()) {
+
+ // We are scaling and cropping the relative pixel locations to the original photo instead of the
+ // scaled photo we operated on.
+
+ // First load the scaled photo to check its size. (Should probably pass this in the post form and save
+ // a query.)
+
+ $g = q("select width, height from photo where resource_id = '%s' and uid = %d and scale = 3",
+ dbesc($image_id),
+ intval(local_channel())
+ );
+
+
+ $scaled_width = $g[0]['width'];
+ $scaled_height = $g[0]['height'];
+
+ if((! $scaled_width) || (! $scaled_height)) {
+ logger('potential divide by zero scaling cover photo');
+ return;
+ }
+
+ // unset all other cover photos
+
+ q("update photo set photo_usage = %d where photo_usage = %d and uid = %d",
+ intval(PHOTO_NORMAL),
+ intval(PHOTO_COVER),
+ intval(local_channel())
+ );
+
+ $orig_srcx = ( $r[0]['width'] / $scaled_width ) * $srcX;
+ $orig_srcy = ( $r[0]['height'] / $scaled_height ) * $srcY;
+ $orig_srcw = ( $srcW / $scaled_width ) * $r[0]['width'];
+ $orig_srch = ( $srcH / $scaled_height ) * $r[0]['height'];
+
+ $im->cropImageRect(1200,435,$orig_srcx, $orig_srcy, $orig_srcw, $orig_srch);
+
+ $aid = get_account_id();
+
+ $p = array('aid' => $aid, 'uid' => local_channel(), 'resource_id' => $base_image['resource_id'],
+ 'filename' => $base_image['filename'], 'album' => t('Cover Photos'));
+
+ $p['scale'] = 7;
+ $p['photo_usage'] = PHOTO_COVER;
+
+ $r1 = $im->save($p);
+
+ $im->doScaleImage(850,310);
+ $p['scale'] = 8;
+
+ $r2 = $im->save($p);
+
+
+ $im->doScaleImage(425,160);
+ $p['scale'] = 9;
+
+ $r3 = $im->save($p);
+
+ if($r1 === false || $r2 === false || $r3 === false) {
+ // if one failed, delete them all so we can start over.
+ notice( t('Image resize failed.') . EOL );
+ $x = q("delete from photo where resource_id = '%s' and uid = %d and scale >= 7 ",
+ dbesc($base_image['resource_id']),
+ local_channel()
+ );
+ return;
+ }
+
+ $channel = App::get_channel();
+ send_cover_photo_activity($channel,$base_image,$profile);
+
+
+ }
+ else
+ notice( t('Unable to process image') . EOL);
+ }
+
+ goaway(z_root() . '/channel/' . $channel['channel_address']);
+
+ }
+
+
+ $hash = photo_new_resource();
+ $smallest = 0;
+
+ require_once('include/attach.php');
+
+ $res = attach_store(App::get_channel(), get_observer_hash(), '', array('album' => t('Cover Photos'), 'hash' => $hash));
+
+ logger('attach_store: ' . print_r($res,true));
+
+ if($res && intval($res['data']['is_photo'])) {
+ $i = q("select * from photo where resource_id = '%s' and uid = %d and scale = 0",
+ dbesc($hash),
+ intval(local_channel())
+ );
+
+ if(! $i) {
+ notice( t('Image upload failed.') . EOL );
+ return;
+ }
+ $os_storage = false;
+
+ foreach($i as $ii) {
+ $smallest = intval($ii['scale']);
+ $os_storage = intval($ii['os_storage']);
+ $imagedata = $ii['data'];
+ $filetype = $ii['type'];
+
+ }
+ }
+
+ $imagedata = (($os_storage) ? @file_get_contents($imagedata) : $imagedata);
+ $ph = photo_factory($imagedata, $filetype);
+
+ if(! $ph->is_valid()) {
+ notice( t('Unable to process image.') . EOL );
+ return;
+ }
+
+ return cover_photo_crop_ui_head($a, $ph, $hash, $smallest);
+
+}
+
+function send_cover_photo_activity($channel,$photo,$profile) {
+
+ $arr = array();
+ $arr['item_thread_top'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = 1;
+ $arr['obj_type'] = ACTIVITY_OBJ_PHOTO;
+ $arr['verb'] = ACTIVITY_UPDATE;
+
+ $arr['object'] = json_encode(array(
+ 'type' => $arr['obj_type'],
+ 'id' => z_root() . '/photo/' . $photo['resource_id'] . '-7',
+ 'link' => array('rel' => 'photo', 'type' => $photo['type'], 'href' => z_root() . '/photo/' . $photo['resource_id'] . '-7')
+ ));
+
+ if($profile && stripos($profile['gender'],t('female')) !== false)
+ $t = t('%1$s updated her %2$s');
+ elseif($profile && stripos($profile['gender'],t('male')) !== false)
+ $t = t('%1$s updated his %2$s');
+ else
+ $t = t('%1$s updated their %2$s');
+
+ $ptext = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . t('cover photo') . '[/zrl]';
+
+ $ltext = '[zrl=' . z_root() . '/profile/' . $channel['channel_address'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-8[/zmg][/zrl]';
+
+ $arr['body'] = sprintf($t,$channel['channel_name'],$ptext) . "\n\n" . $ltext;
+
+ $acl = new Zotlabs\Access\AccessList($channel);
+ $x = $acl->get();
+ $arr['allow_cid'] = $x['allow_cid'];
+
+ $arr['allow_gid'] = $x['allow_gid'];
+ $arr['deny_cid'] = $x['deny_cid'];
+ $arr['deny_gid'] = $x['deny_gid'];
+
+ $arr['uid'] = $channel['channel_id'];
+ $arr['aid'] = $channel['channel_account_id'];
+
+ $arr['owner_xchan'] = $channel['channel_hash'];
+ $arr['author_xchan'] = $channel['channel_hash'];
+
+ post_activity_item($arr);
+
+
+}
+
+
+/* @brief Generate content of profile-photo view
+ *
+ * @param $a Current application
+ * @return void
+ *
+ */
+
+
+function cover_photo_content(&$a) {
+
+ if(! local_channel()) {
+ notice( t('Permission denied.') . EOL );
+ return;
+ }
+
+ $channel = App::get_channel();
+
+ $newuser = false;
+
+ if(argc() == 2 && argv(1) === 'new')
+ $newuser = true;
+
+ if(argv(1) === 'use') {
+ if (argc() < 3) {
+ notice( t('Permission denied.') . EOL );
+ return;
+ };
+
+// check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo');
+
+ $resource_id = argv(2);
+
+ $r = q("SELECT id, album, scale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY scale ASC",
+ intval(local_channel()),
+ dbesc($resource_id)
+ );
+ if(! $r) {
+ notice( t('Photo not available.') . EOL );
+ return;
+ }
+ $havescale = false;
+ foreach($r as $rr) {
+ if($rr['scale'] == 7)
+ $havescale = true;
+ }
+
+ $r = q("SELECT `data`, `type`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1",
+ intval($r[0]['id']),
+ intval(local_channel())
+
+ );
+ if(! $r) {
+ notice( t('Photo not available.') . EOL );
+ return;
+ }
+
+ if(intval($r[0]['os_storage']))
+ $data = @file_get_contents($r[0]['data']);
+ else
+ $data = dbunescbin($r[0]['data']);
+
+ $ph = photo_factory($data, $r[0]['type']);
+ $smallest = 0;
+ if($ph->is_valid()) {
+ // go ahead as if we have just uploaded a new photo to crop
+ $i = q("select resource_id, scale from photo where resource_id = '%s' and uid = %d and scale = 0",
+ dbesc($r[0]['resource_id']),
+ intval(local_channel())
+ );
+
+ if($i) {
+ $hash = $i[0]['resource_id'];
+ foreach($i as $ii) {
+ $smallest = intval($ii['scale']);
+ }
+ }
+ }
+
+ cover_photo_crop_ui_head($a, $ph, $hash, $smallest);
+ }
+
+
+ if(! x(App::$data,'imagecrop')) {
+
+ $tpl = get_markup_template('cover_photo.tpl');
+
+ $o .= replace_macros($tpl,array(
+ '$user' => App::$channel['channel_address'],
+ '$lbl_upfile' => t('Upload File:'),
+ '$lbl_profiles' => t('Select a profile:'),
+ '$title' => t('Upload Cover Photo'),
+ '$submit' => t('Upload'),
+ '$profiles' => $profiles,
+ '$form_security_token' => get_form_security_token("cover_photo"),
+// FIXME - yuk
+ '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . z_root() . '">' . t('skip this step') . '</a>' : '<a href="'. z_root() . '/photos/' . App::$channel['channel_address'] . '">' . t('select a photo from your photo albums') . '</a>')
+ ));
+
+ call_hooks('cover_photo_content_end', $o);
+
+ return $o;
+ }
+ else {
+ $filename = App::$data['imagecrop'] . '-3';
+ $resolution = 3;
+ $tpl = get_markup_template("cropcover.tpl");
+ $o .= replace_macros($tpl,array(
+ '$filename' => $filename,
+ '$profile' => intval($_REQUEST['profile']),
+ '$resource' => App::$data['imagecrop'] . '-3',
+ '$image_url' => z_root() . '/photo/' . $filename,
+ '$title' => t('Crop Image'),
+ '$desc' => t('Please adjust the image cropping for optimum viewing.'),
+ '$form_security_token' => get_form_security_token("cover_photo"),
+ '$done' => t('Done Editing')
+ ));
+ return $o;
+ }
+
+ return; // NOTREACHED
+}
+
+/* @brief Generate the UI for photo-cropping
+ *
+ * @param $a Current application
+ * @param $ph Photo-Factory
+ * @return void
+ *
+ */
+
+
+
+function cover_photo_crop_ui_head(&$a, $ph, $hash, $smallest){
+
+ $max_length = get_config('system','max_image_length');
+ if(! $max_length)
+ $max_length = MAX_IMAGE_LENGTH;
+ if($max_length > 0)
+ $ph->scaleImage($max_length);
+
+ $width = $ph->getWidth();
+ $height = $ph->getHeight();
+
+ if($width < 300 || $height < 300) {
+ $ph->scaleImageUp(240);
+ $width = $ph->getWidth();
+ $height = $ph->getHeight();
+ }
+
+
+ App::$data['imagecrop'] = $hash;
+ App::$data['imagecrop_resolution'] = $smallest;
+ App::$page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), array());
+ return;
+}
+
diff --git a/mod/dav.php b/mod/dav.php
index d4695a544..e2a857dca 100644
--- a/mod/dav.php
+++ b/mod/dav.php
@@ -7,7 +7,7 @@
*/
use Sabre\DAV;
-use RedMatrix\RedDAV;
+use Zotlabs\Storage;
// composer autoloader for SabreDAV
require_once('vendor/autoload.php');
@@ -49,18 +49,18 @@ function dav_init(&$a) {
$profile = 0;
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which . '" />' . "\r\n";
+ App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . z_root() . '/feed/' . $which . '" />' . "\r\n";
if ($which)
profile_load($a, $which, $profile);
- $auth = new RedDAV\RedBasicAuth();
+ $auth = new Zotlabs\Storage\BasicAuth();
$ob_hash = get_observer_hash();
if ($ob_hash) {
if (local_channel()) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$auth->setCurrentUser($channel['channel_address']);
$auth->channel_id = $channel['channel_id'];
$auth->channel_hash = $channel['channel_hash'];
@@ -82,7 +82,7 @@ function dav_init(&$a) {
$_SERVER['REQUEST_URI'] = strip_zids($_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = preg_replace('/[\?&]davguest=(.*?)([\?&]|$)/ism', '', $_SERVER['REQUEST_URI']);
- $rootDirectory = new RedDAV\RedDirectory('/', $auth);
+ $rootDirectory = new Zotlabs\Storage\Directory('/', $auth);
// A SabreDAV server-object
$server = new DAV\Server($rootDirectory);
@@ -107,8 +107,8 @@ function dav_init(&$a) {
if ((! $auth->observer) && ($_SERVER['REQUEST_METHOD'] === 'GET')) {
try {
- $x = RedFileData('/' . $a->cmd, $auth);
- if($x instanceof RedDAV\RedFile)
+ $x = RedFileData('/' . App::$cmd, $auth);
+ if($x instanceof Zotlabs\Storage\File)
$isapublic_file = true;
}
catch (Exception $e) {
@@ -126,14 +126,14 @@ function dav_init(&$a) {
}
}
- require_once('include/RedDAV/RedBrowser.php');
+// require_once('Zotlabs/Storage/Browser.php');
// provide a directory view for the cloud in Hubzilla
- $browser = new RedDAV\RedBrowser($auth);
+ $browser = new Zotlabs\Storage\Browser($auth);
$auth->setBrowserPlugin($browser);
// Experimental QuotaPlugin
-// require_once('include/RedDAV/QuotaPlugin.php');
-// $server->addPlugin(new RedDAV\QuotaPlugin($auth));
+// require_once('Zotlabs/Storage/QuotaPlugin.php');
+// $server->addPlugin(new Zotlabs\Storage\QuotaPlugin($auth));
// All we need to do now, is to fire up the server
$server->exec();
diff --git a/mod/directory.php b/mod/directory.php
index 4ab118b17..79c03777e 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -6,7 +6,7 @@ require_once('include/widgets.php');
require_once('include/bbcode.php');
function directory_init(&$a) {
- $a->set_pager_itemspage(60);
+ App::set_pager_itemspage(60);
if(x($_GET,'ignore')) {
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
@@ -144,18 +144,21 @@ function directory_content(&$a) {
}
if($url) {
- // We might want to make the tagadelic count (&kw=) configurable or turn it off completely.
$numtags = get_config('system','directorytags');
- $kw = ((intval($numtags)) ? $numtags : 50);
+ $kw = ((intval($numtags) > 0) ? intval($numtags) : 50);
+
+ if(get_config('system','disable_directory_keywords'))
+ $kw = 0;
+
$query = $url . '?f=&kw=' . $kw . (($safe_mode != 1) ? '&safe=' . $safe_mode : '');
if($token)
$query .= '&t=' . $token;
if(! $globaldir)
- $query .= '&hub=' . get_app()->get_hostname();
+ $query .= '&hub=' . App::get_hostname();
if($search)
$query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
@@ -177,8 +180,8 @@ function directory_content(&$a) {
if($sort_order)
$query .= '&order=' . urlencode($sort_order);
- if($a->pager['page'] != 1)
- $query .= '&p=' . $a->pager['page'];
+ if(App::$pager['page'] != 1)
+ $query .= '&p=' . App::$pager['page'];
logger('mod_directory: query: ' . $query);
@@ -321,7 +324,7 @@ function directory_content(&$a) {
'online' => $online,
'kw' => (($out) ? t('Keywords: ') : ''),
'keywords' => $out,
- 'ignlink' => $suggest ? $a->get_baseurl() . '/directory?ignore=' . $rr['hash'] : '',
+ 'ignlink' => $suggest ? z_root() . '/directory?ignore=' . $rr['hash'] : '',
'ignore_label' => t('Don\'t suggest'),
'common_friends' => (($common[$rr['address']]) ? intval($common[$rr['address']]) : ''),
'common_label' => t('Common connections:'),
@@ -352,7 +355,7 @@ function directory_content(&$a) {
ksort($entries); // Sort array by key so that foreach-constructs work as expected
if($j['keywords']) {
- $a->data['directory_keywords'] = $j['keywords'];
+ App::$data['directory_keywords'] = $j['keywords'];
}
logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA);
@@ -403,7 +406,7 @@ function directory_content(&$a) {
echo $o;
killme();
}
- if($a->pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) {
+ if(App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) {
goaway(z_root() . '/chanview/?f=&address=' . $search);
}
info( t("No entries (some entries may be hidden).") . EOL);
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index 388e5f3ac..1273c5ccd 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -4,7 +4,7 @@ require_once('include/dir_fns.php');
function dirsearch_init(&$a) {
- $a->set_pager_itemspage(60);
+ App::set_pager_itemspage(60);
}
@@ -75,6 +75,8 @@ function dirsearch_content(&$a) {
$kw = ((x($_REQUEST,'kw')) ? intval($_REQUEST['kw']) : 0 );
$forums = ((array_key_exists('pubforums',$_REQUEST)) ? intval($_REQUEST['pubforums']) : 0);
+ if(get_config('system','disable_directory_keywords'))
+ $kw = 0;
// by default use a safe search
@@ -164,7 +166,7 @@ function dirsearch_content(&$a) {
$logic = 'true';
if($dirmode == DIRECTORY_MODE_STANDALONE) {
- $sql_extra .= " and xchan_addr like '%%" . get_app()->get_hostname() . "' ";
+ $sql_extra .= " and xchan_addr like '%%" . App::get_hostname() . "' ";
}
$safesql = (($safe > 0) ? " and xchan_censored = 0 and xchan_selfcensored = 0 " : '');
diff --git a/mod/display.php b/mod/display.php
index b2d9ba34b..2844a1205 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");
+
+ $checkjs = new Zotlabs\Web\CheckJS();
+
+
if($load)
$_SESSION['loadtime'] = datetime_convert();
@@ -21,7 +25,7 @@ function display_content(&$a, $update = 0, $load = false) {
require_once('include/items.php');
- $a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array());
+ App::$page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array());
if(argc() > 1 && argv(1) !== 'load')
$item_hash = argv(1);
@@ -32,7 +36,7 @@ function display_content(&$a, $update = 0, $load = false) {
if(! $item_hash) {
- $a->error = 404;
+ App::$error = 404;
notice( t('Item not found.') . EOL);
return;
}
@@ -42,7 +46,7 @@ function display_content(&$a, $update = 0, $load = false) {
if(local_channel() && (! $update)) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$channel_acl = array(
@@ -65,7 +69,10 @@ function display_content(&$a, $update = 0, $load = false) {
'visitor' => true,
'profile_uid' => local_channel(),
'return_path' => 'channel/' . $channel['channel_address'],
- 'expanded' => true
+ 'expanded' => true,
+ 'editor_autocomplete' => true,
+ 'bbco_autocomplete' => 'bbcode',
+ 'bbcode' => true
);
$o = '<div id="jot-popup">';
@@ -116,7 +123,7 @@ 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']) . "' ";
+ $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 = '';
@@ -127,9 +134,9 @@ function display_content(&$a, $update = 0, $load = false) {
$o .= '<div id="live-display"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . ((intval(local_channel())) ? local_channel() : (-1))
- . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
+ . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . "; </script>\r\n";
- $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
+ App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
'$baseurl' => z_root(),
'$pgtype' => 'display',
'$uid' => '0',
@@ -144,7 +151,7 @@ function display_content(&$a, $update = 0, $load = false) {
'$fh' => '0',
'$nouveau' => '0',
'$wall' => '0',
- '$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1),
+ '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
'$search' => '',
'$order' => '',
@@ -165,13 +172,13 @@ function display_content(&$a, $update = 0, $load = false) {
$sql_extra = public_permissions_sql($observer_hash);
- if(($update && $load) || ($_COOKIE['jsAvailable'] != 1)) {
+ if(($update && $load) || ($checkjs->disabled())) {
$updateable = false;
- $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']),intval($a->pager['start']));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']),intval(App::$pager['start']));
- if($load || ($_COOKIE['jsAvailable'] != 1)) {
+ if($load || ($checkjs->disabled())) {
$r = null;
require_once('include/identity.php');
@@ -217,9 +224,54 @@ function display_content(&$a, $update = 0, $load = false) {
}
}
- else {
- $r = array();
+ }
+
+ elseif($update && !$load) {
+ $r = null;
+
+ require_once('include/identity.php');
+ $sys = get_sys_channel();
+ $sysid = $sys['channel_id'];
+
+ if(local_channel()) {
+ $r = q("SELECT * from item
+ WHERE uid = %d
+ and mid = '%s'
+ $item_normal
+ $simple_update
+ limit 1",
+ intval(local_channel()),
+ dbesc($target_item['parent_mid'])
+ );
+ if($r) {
+ $updateable = true;
+ }
+ }
+ if($r === null) {
+ // in case somebody turned off public access to sys channel content using permissions
+ // make that content unsearchable by ensuring the owner_xchan can't match
+ if(! perm_is_allowed($sysid,$observer_hash,'view_stream'))
+ $sysid = 0;
+
+ $r = q("SELECT * from item
+ WHERE mid = '%s'
+ 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_hash) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " ))
+ OR uid = %d )
+ $sql_extra )
+ $item_normal
+ $simple_update
+ limit 1",
+ dbesc($target_item['parent_mid']),
+ intval($sysid)
+ );
}
+ $_SESSION['loadtime'] = datetime_convert();
+ }
+
+ else {
+ $r = array();
}
if($r) {
@@ -242,13 +294,13 @@ function display_content(&$a, $update = 0, $load = false) {
}
- if ($_COOKIE['jsAvailable'] == 1) {
- $o .= conversation($a, $items, 'display', $update, 'client');
- } else {
+ if ($checkjs->disabled()) {
$o .= conversation($a, $items, 'display', $update, 'traditional');
if ($items[0]['title'])
- $a->page['title'] = $items[0]['title'] . " - " . $a->page['title'];
-
+ App::$page['title'] = $items[0]['title'] . " - " . App::$page['title'];
+ }
+ else {
+ $o .= conversation($a, $items, 'display', $update, 'client');
}
if($updateable) {
@@ -284,6 +336,5 @@ function display_content(&$a, $update = 0, $load = false) {
}
*/
- return $o;
}
diff --git a/mod/dreport.php b/mod/dreport.php
index 1ad1eca7c..4edec2e2b 100644
--- a/mod/dreport.php
+++ b/mod/dreport.php
@@ -9,7 +9,7 @@ function dreport_content(&$a) {
$table = 'item';
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$mid = ((argc() > 1) ? argv(1) : '');
diff --git a/mod/editblock.php b/mod/editblock.php
index 9269676b1..214c495dd 100644
--- a/mod/editblock.php
+++ b/mod/editblock.php
@@ -8,7 +8,7 @@ function editblock_init(&$a) {
if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
- $a->is_sys = true;
+ App::$is_sys = true;
}
}
@@ -25,9 +25,9 @@ function editblock_init(&$a) {
function editblock_content(&$a) {
- if(! $a->profile) {
+ if(! App::$profile) {
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
@@ -36,11 +36,11 @@ function editblock_content(&$a) {
$uid = local_channel();
$owner = 0;
$channel = null;
- $observer = $a->get_observer();
+ $observer = App::get_observer();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- if($a->is_sys && is_site_admin()) {
+ if(App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
$uid = $owner = intval($sys['channel_id']);
@@ -108,14 +108,15 @@ function editblock_content(&$a) {
else
$mimeselect = mimetype_select($itm[0]['uid'],$mimetype);
- $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
- '$baseurl' => $a->get_baseurl(),
+ App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
+ '$baseurl' => z_root(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$pretext' => '',
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => '',
'$nickname' => $channel['channel_address'],
- '$confirmdelete' => t('Delete block?')
+ '$confirmdelete' => t('Delete block?'),
+ '$bbco_autocomplete'=> (($mimetype == 'text/bbcode') ? 'bbcode' : 'comanche-block')
));
$tpl = get_markup_template("jot.tpl");
@@ -153,7 +154,7 @@ function editblock_content(&$a) {
'$mimeselect' => $mimeselect,
'$content' => undo_post_tagging($itm[0]['body']),
'$post_id' => $post_id,
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => z_root(),
'$defloc' => $channel['channel_location'],
'$visitor' => false,
'$public' => t('Public post'),
@@ -174,6 +175,7 @@ function editblock_content(&$a) {
'$defexpire' => '',
'$feature_expire' => false,
'$expires' => t('Set expiration date'),
+ '$bbcode' => (($mimetype == 'text/bbcode') ? true : false)
));
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
diff --git a/mod/editlayout.php b/mod/editlayout.php
index fc68cfe3c..0b58fe5fe 100644
--- a/mod/editlayout.php
+++ b/mod/editlayout.php
@@ -8,7 +8,7 @@ function editlayout_init(&$a) {
if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
- $a->is_sys = true;
+ App::$is_sys = true;
}
}
@@ -23,9 +23,9 @@ function editlayout_init(&$a) {
function editlayout_content(&$a) {
- if(! $a->profile) {
+ if(! App::$profile) {
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
@@ -34,11 +34,11 @@ function editlayout_content(&$a) {
$uid = local_channel();
$owner = 0;
$channel = null;
- $observer = $a->get_observer();
+ $observer = App::get_observer();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- if($a->is_sys && is_site_admin()) {
+ if(App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
$uid = $owner = intval($sys['channel_id']);
@@ -102,14 +102,15 @@ function editlayout_content(&$a) {
$plaintext = true;
- $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
- '$baseurl' => $a->get_baseurl(),
+ App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
+ '$baseurl' => z_root(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$pretext' => '',
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag,
'$nickname' => $channel['channel_address'],
- '$confirmdelete' => t('Delete layout?')
+ '$confirmdelete' => t('Delete layout?'),
+ '$bbco_autocomplete'=> 'comanche'
));
@@ -150,7 +151,7 @@ function editlayout_content(&$a) {
'$ptyp' => $itm[0]['type'],
'$content' => undo_post_tagging($itm[0]['body']),
'$post_id' => $post_id,
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => z_root(),
'$defloc' => $channel['channel_location'],
'$visitor' => false,
'$public' => t('Public post'),
@@ -167,7 +168,7 @@ function editlayout_content(&$a) {
'$bang' => '',
'$profile_uid' => (intval($owner)),
'$jotplugins' => $jotplugins,
- '$sourceapp' => t($a->sourcename),
+ '$sourceapp' => t(App::$sourcename),
'$defexpire' => '',
'$feature_expire' => false,
'$expires' => t('Set expiration date'),
diff --git a/mod/editpost.php b/mod/editpost.php
index 030d8d671..397254a48 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -1,6 +1,6 @@
<?php /** @file */
-require_once('acl_selectors.php');
+require_once('include/acl_selectors.php');
require_once('include/crypto.php');
require_once('include/items.php');
require_once('include/taxonomy.php');
@@ -44,17 +44,19 @@ function editpost_content(&$a) {
// if(feature_enabled(local_channel(),'richtext'))
// $plaintext = false;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
- '$baseurl' => $a->get_baseurl(),
+ App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
+ '$baseurl' => z_root(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$pretext' => '',
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag,
'$nickname' => $channel['channel_address'],
'$expireswhen' => t('Expires YYYY-MM-DD HH:MM'),
- '$confirmdelete' => t('Delete item?'),
+ '$confirmdelete' => t('Delete item?'),
+ '$editor_autocomplete'=> true,
+ '$bbco_autocomplete'=> 'bbcode'
));
if(intval($itm[0]['item_obscured'])) {
@@ -101,7 +103,7 @@ function editpost_content(&$a) {
}
}
- $cipher = get_pconfig(get_app()->profile['profile_uid'],'system','default_cipher');
+ $cipher = get_pconfig(App::$profile['profile_uid'],'system','default_cipher');
if(! $cipher)
$cipher = 'aes256';
@@ -132,7 +134,7 @@ function editpost_content(&$a) {
'$content' => undo_post_tagging($itm[0]['body']),
'$post_id' => $post_id,
'$parent' => (($itm[0]['parent'] != $itm[0]['id']) ? $itm[0]['parent'] : ''),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => z_root(),
'$defloc' => $channel['channel_location'],
'$visitor' => false,
'$public' => t('Public post'),
@@ -148,12 +150,12 @@ function editpost_content(&$a) {
'$profile_uid' => $owner_uid,
'$preview' => t('Preview'),
'$jotplugins' => $jotplugins,
- '$sourceapp' => t($a->sourcename),
+ '$sourceapp' => t(App::$sourcename),
'$catsenabled' => $catsenabled,
'$defexpire' => datetime_convert('UTC', date_default_timezone_get(),$itm[0]['expires']),
- '$feature_expire' => ((feature_enabled(get_app()->profile['profile_uid'],'content_expire') && (! $webpage)) ? true : false),
+ '$feature_expire' => ((feature_enabled(App::$profile['profile_uid'],'content_expire') && (! $webpage)) ? true : false),
'$expires' => t('Set expiration date'),
- '$feature_encrypt' => ((feature_enabled(get_app()->profile['profile_uid'],'content_encrypt') && (! $webpage)) ? true : false),
+ '$feature_encrypt' => ((feature_enabled(App::$profile['profile_uid'],'content_encrypt') && (! $webpage)) ? true : false),
'$encrypt' => t('Encrypt text'),
'$cipher' => $cipher,
'$expiryModalOK' => t('OK'),
diff --git a/mod/editwebpage.php b/mod/editwebpage.php
index 0192fd9c0..7cf738989 100644
--- a/mod/editwebpage.php
+++ b/mod/editwebpage.php
@@ -8,7 +8,7 @@ function editwebpage_init(&$a) {
if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
- $a->is_sys = true;
+ App::$is_sys = true;
}
}
@@ -24,9 +24,9 @@ function editwebpage_init(&$a) {
function editwebpage_content(&$a) {
- if(! $a->profile) {
+ if(! App::$profile) {
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
@@ -35,11 +35,11 @@ function editwebpage_content(&$a) {
$uid = local_channel();
$owner = 0;
$channel = null;
- $observer = $a->get_observer();
+ $observer = App::get_observer();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- if($a->is_sys && is_site_admin()) {
+ if(App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
$uid = $owner = intval($sys['channel_id']);
@@ -143,14 +143,15 @@ function editwebpage_content(&$a) {
else
$layoutselect = layout_select($itm[0]['uid'],$itm[0]['layout_mid']);
- $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
- '$baseurl' => $a->get_baseurl(),
+ App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
+ '$baseurl' => z_root(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$pretext' => '',
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag,
'$nickname' => $channel['channel_address'],
- '$confirmdelete' => t('Delete webpage?')
+ '$confirmdelete' => t('Delete webpage?'),
+ '$bbco_autocomplete'=> (($mimetype == 'text/bbcode') ? 'bbcode' : '')
));
$tpl = get_markup_template("jot.tpl");
@@ -192,7 +193,7 @@ function editwebpage_content(&$a) {
'$ptyp' => $itm[0]['type'],
'$content' => undo_post_tagging($itm[0]['body']),
'$post_id' => $post_id,
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => z_root(),
'$defloc' => $itm[0]['location'],
'$visitor' => ($is_owner) ? true : false,
'$acl' => populate_acl($itm[0],false),
@@ -211,11 +212,11 @@ function editwebpage_content(&$a) {
'$profile_uid' => (intval($owner)),
'$preview' => t('Preview'),
'$jotplugins' => $jotplugins,
- '$sourceapp' => $a->sourcename,
+ '$sourceapp' => App::$sourcename,
'$defexpire' => '',
'$feature_expire' => false,
'$expires' => t('Set expiration date'),
-
+ '$bbcode' => (($mimetype == 'text/bbcode') ? true : false)
));
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
diff --git a/mod/events.php b/mod/events.php
index 74b44906c..30cf5f303 100755
--- a/mod/events.php
+++ b/mod/events.php
@@ -93,8 +93,8 @@ function events_post(&$a) {
//$action = ($event_hash == '') ? 'new' : "event/" . $event_hash;
//fixme: this url gives a wsod if there is a linebreak detected in one of the variables ($desc or $location)
- //$onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish&type=$type";
- $onerror_url = $a->get_baseurl() . "/events";
+ //$onerror_url = z_root() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish&type=$type";
+ $onerror_url = z_root() . "/events";
if(strcmp($finish,$start) < 0 && !$nofinish) {
notice( t('Event can not end before it has started.') . EOL);
@@ -116,9 +116,9 @@ function events_post(&$a) {
$share = ((intval($_POST['share'])) ? intval($_POST['share']) : 0);
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- $acl = new AccessList(false);
+ $acl = new Zotlabs\Access\AccessList(false);
if($event_id) {
$x = q("select * from event where id = %d and uid = %d limit 1",
@@ -158,7 +158,7 @@ function events_post(&$a) {
}
$post_tags = array();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$ac = $acl->get();
if(strlen($categories)) {
@@ -281,21 +281,28 @@ function events_content(&$a) {
$first_day = (($first_day) ? $first_day : 0);
$htpl = get_markup_template('event_head.tpl');
- $a->page['htmlhead'] .= replace_macros($htpl,array(
- '$baseurl' => $a->get_baseurl(),
- '$lang' => $a->language,
+ App::$page['htmlhead'] .= replace_macros($htpl,array(
+ '$baseurl' => z_root(),
+ '$module_url' => '/events',
+ '$modparams' => 1,
+ '$lang' => App::$language,
'$first_day' => $first_day
));
$o = '';
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$mode = 'view';
$y = 0;
$m = 0;
$ignored = ((x($_REQUEST,'ignored')) ? " and ignored = " . intval($_REQUEST['ignored']) . " " : '');
+
+ // logger('args: ' . print_r(App::$argv,true));
+
+
+
if(argc() > 1) {
if(argc() > 2 && argv(1) === 'add') {
$mode = 'add';
@@ -333,7 +340,7 @@ function events_content(&$a) {
$orig_event = $r[0];
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
// Passed parameters overrides anything found in the DB
if(!x($orig_event))
@@ -422,19 +429,19 @@ function events_content(&$a) {
require_once('include/acl_selectors.php');
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$perm_defaults = $acl->get();
$tpl = get_markup_template('event_form.tpl');
$form = replace_macros($tpl,array(
- '$post' => $a->get_baseurl() . '/events',
+ '$post' => z_root() . '/events',
'$eid' => $eid,
'$type' => $type,
'$xchan' => $event_xchan,
'$mid' => $mid,
'$event_hash' => $event_id,
- '$summary' => array('summary', (($event_id) ? t('Edit event titel') : t('Event titel')), $t_orig, t('Required'), '*'),
+ '$summary' => array('summary', (($event_id) ? t('Edit event title') : t('Event title')), $t_orig, t('Required'), '*'),
'$catsenabled' => $catsenabled,
'$placeholdercategory' => t('Categories (comma-separated list)'),
'$c_text' => (($event_id) ? t('Edit Category') : t('Category')),
@@ -564,7 +571,7 @@ function events_content(&$a) {
foreach($r as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
if(! x($links,$j))
- $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+ $links[$j] = z_root() . '/' . App::$cmd . '#link-' . $j;
}
}
@@ -593,9 +600,9 @@ function events_content(&$a) {
$last_date = $d;
- $edit = ((local_channel() && $rr['author_xchan'] == get_observer_hash()) ? array($a->get_baseurl().'/events/'.$rr['event_hash'].'?expandform=1',t('Edit event'),'','') : false);
+ $edit = ((local_channel() && $rr['author_xchan'] == get_observer_hash()) ? array(z_root().'/events/'.$rr['event_hash'].'?expandform=1',t('Edit event'),'','') : false);
- $drop = array($a->get_baseurl().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');
+ $drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
if(! $title) {
@@ -634,7 +641,7 @@ function events_content(&$a) {
killme();
}
- if ($a->argv[1] === 'json'){
+ if (App::$argv[1] === 'json'){
echo json_encode($events); killme();
}
@@ -647,11 +654,11 @@ function events_content(&$a) {
}
$o = replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
- '$new_event' => array($a->get_baseurl().'/events',(($event_id) ? t('Edit Event') : t('Create Event')),'',''),
- '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
- '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
- '$export' => array($a->get_baseurl()."/events/$y/$m/export",t('Export'),'',''),
+ '$baseurl' => z_root(),
+ '$new_event' => array(z_root().'/events',(($event_id) ? t('Edit Event') : t('Create Event')),'',''),
+ '$previus' => array(z_root()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
+ '$next' => array(z_root()."/events/$nextyear/$nextmonth",t('Next'),'',''),
+ '$export' => array(z_root()."/events/$y/$m/export",t('Export'),'',''),
'$calendar' => cal($y,$m,$links, ' eventcal'),
'$events' => $events,
'$upload' => t('Import'),
diff --git a/mod/fbrowser.php b/mod/fbrowser.php
index 13abbfd8a..96e0fe953 100644
--- a/mod/fbrowser.php
+++ b/mod/fbrowser.php
@@ -15,19 +15,19 @@ function fbrowser_content($a){
if (!local_channel())
killme();
- if ($a->argc==1)
+ if (App::$argc==1)
killme();
- //echo "<pre>"; var_dump($a->argv); killme();
+ //echo "<pre>"; var_dump(App::$argv); killme();
- switch($a->argv[1]){
+ switch(App::$argv[1]){
case "image":
- $path = array( array($a->get_baseurl()."/fbrowser/image/", t("Photos")));
+ $path = array( array(z_root()."/fbrowser/image/", t("Photos")));
$albums = false;
$sql_extra = "";
$sql_extra2 = " ORDER BY created DESC LIMIT 0, 10";
- if ($a->argc==2){
+ if (App::$argc==2){
$albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d ",
intval(local_channel())
);
@@ -38,11 +38,11 @@ function fbrowser_content($a){
}
$album = "";
- if ($a->argc==3){
- $album = hex2bin($a->argv[2]);
+ if (App::$argc==3){
+ $album = hex2bin(App::$argv[2]);
$sql_extra = sprintf("AND `album` = '%s' ",dbesc($album));
$sql_extra2 = "";
- $path[]=array($a->get_baseurl()."/fbrowser/image/".$a->argv[2]."/", $album);
+ $path[]=array(z_root()."/fbrowser/image/".App::$argv[2]."/", $album);
}
$r = q("SELECT `resource_id`, `id`, `filename`, type, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `description`
@@ -60,9 +60,9 @@ function fbrowser_content($a){
$filename_e = $rr['filename'];
return array(
- $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . $rr['hiq'] . '.' .$ext,
+ z_root() . '/photo/' . $rr['resource_id'] . '-' . $rr['hiq'] . '.' .$ext,
$filename_e,
- $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . $rr['loq'] . '.'. $ext
+ z_root() . '/photo/' . $rr['resource_id'] . '-' . $rr['loq'] . '.'. $ext
);
}
$files = array_map("files1", $r);
@@ -70,7 +70,7 @@ function fbrowser_content($a){
$tpl = get_markup_template("filebrowser.tpl");
echo replace_macros($tpl, array(
'$type' => 'image',
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => z_root(),
'$path' => $path,
'$folders' => $albums,
'$files' =>$files,
@@ -80,7 +80,7 @@ function fbrowser_content($a){
break;
case "file":
- if ($a->argc==2){
+ if (App::$argc==2){
$files = q("SELECT id, filename, filetype FROM `attach` WHERE `uid` = %d ",
intval(local_channel())
);
@@ -89,14 +89,14 @@ function fbrowser_content($a){
list($m1,$m2) = explode("/",$rr['filetype']);
$filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
- if($a->get_template_engine() === 'internal') {
+ if(App::get_template_engine() === 'internal') {
$filename_e = template_escape($rr['filename']);
}
else {
$filename_e = $rr['filename'];
}
- return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
+ return array( z_root() . '/attach/' . $rr['id'], $filename_e, z_root() . '/images/icons/16/' . $filetype . '.png');
}
$files = array_map("files2", $files);
//echo "<pre>"; var_dump($files); killme();
@@ -105,8 +105,8 @@ function fbrowser_content($a){
$tpl = get_markup_template("filebrowser.tpl");
echo replace_macros($tpl, array(
'$type' => 'file',
- '$baseurl' => $a->get_baseurl(),
- '$path' => array( array($a->get_baseurl()."/fbrowser/image/", t("Files")) ),
+ '$baseurl' => z_root(),
+ '$path' => array( array(z_root()."/fbrowser/image/", t("Files")) ),
'$folders' => false,
'$files' =>$files,
'$cancel' => t('Cancel'),
diff --git a/mod/feed.php b/mod/feed.php
index eb72af9cf..087d3f827 100644
--- a/mod/feed.php
+++ b/mod/feed.php
@@ -31,7 +31,9 @@ function feed_init(&$a) {
killme();
logger('mod_feed: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']);
+
echo get_public_feed($channel,$params);
+
killme();
}
diff --git a/mod/fhublocs.php b/mod/fhublocs.php
index dce00e383..7eab2b811 100644
--- a/mod/fhublocs.php
+++ b/mod/fhublocs.php
@@ -38,7 +38,7 @@ function fhublocs_content(&$a) {
if($y)
$primary_address = $y[0]['xchan_addr'];
- $hub_address = $rr['channel']['channel_address'] . '@' . get_app()->get_hostname();
+ $hub_address = $rr['channel']['channel_address'] . '@' . App::get_hostname();
$primary = (($hub_address === $primary_address) ? 1 : 0);
@@ -57,11 +57,11 @@ function fhublocs_content(&$a) {
dbesc($rr['channel_guid']),
dbesc($rr['channel_guid_sig']),
dbesc($rr['channel_hash']),
- dbesc($rr['channel_address'] . '@' . get_app()->get_hostname()),
+ dbesc($rr['channel_address'] . '@' . App::get_hostname()),
intval($primary),
dbesc(z_root()),
dbesc(base64url_encode(rsa_sign(z_root(),$rr['channel_prvkey']))),
- dbesc(get_app()->get_hostname()),
+ dbesc(App::get_hostname()),
dbesc(z_root() . '/post'),
dbesc($sitekey),
dbesc('zot')
diff --git a/mod/filer.php b/mod/filer.php
index 8d69503b2..b09c73f0a 100644
--- a/mod/filer.php
+++ b/mod/filer.php
@@ -12,7 +12,7 @@ function filer_content(&$a) {
}
$term = unxmlify(trim($_GET['term']));
- $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
+ $item_id = ((App::$argc > 1) ? intval(App::$argv[1]) : 0);
logger('filer: tag ' . $term . ' item ' . $item_id);
diff --git a/mod/filerm.php b/mod/filerm.php
index bd8ce7cfc..82eed83f8 100644
--- a/mod/filerm.php
+++ b/mod/filerm.php
@@ -13,7 +13,7 @@ function filerm_content(&$a) {
if($category)
$term = $cat;
- $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
+ $item_id = ((App::$argc > 1) ? intval(App::$argv[1]) : 0);
logger('filerm: tag ' . $term . ' item ' . $item_id);
@@ -27,7 +27,7 @@ function filerm_content(&$a) {
}
if(x($_SESSION,'return_url'))
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ goaway(z_root() . '/' . $_SESSION['return_url']);
killme();
}
diff --git a/mod/filestorage.php b/mod/filestorage.php
index 7ba8c1801..1feffa9ee 100644
--- a/mod/filestorage.php
+++ b/mod/filestorage.php
@@ -28,9 +28,9 @@ function filestorage_post(&$a) {
return;
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$acl->set_from_array($_REQUEST);
$x = $acl->get();
@@ -52,7 +52,7 @@ function filestorage_content(&$a) {
$which = argv(1);
else {
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
@@ -64,7 +64,7 @@ function filestorage_content(&$a) {
$owner = intval($r[0]['channel_id']);
}
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
$perms = get_all_perms($owner, $ob_hash);
@@ -100,7 +100,7 @@ function filestorage_content(&$a) {
}
$f = $r[0];
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$parentpath = get_parent_cloudpath($channel['channel_id'], $channel['channel_address'], $f['hash']);
@@ -123,7 +123,7 @@ function filestorage_content(&$a) {
);
$f = $r[0];
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$cloudpath = get_cloudpath($f) . (intval($f['is_dir']) ? '?f=&davguest=1' : '');
$parentpath = get_parent_cloudpath($channel['channel_id'], $channel['channel_address'], $f['hash']);
diff --git a/mod/follow.php b/mod/follow.php
index 3ad2cb3bb..207a99dd7 100644
--- a/mod/follow.php
+++ b/mod/follow.php
@@ -14,7 +14,9 @@ function follow_init(&$a) {
$return_url = $_SESSION['return_url'];
$confirm = intval($_REQUEST['confirm']);
- $result = new_contact($uid,$url,$a->get_channel(),true,$confirm);
+ $channel = App::get_channel();
+
+ $result = new_contact($uid,$url,$channel,true,$confirm);
if($result['success'] == false) {
if($result['message'])
@@ -34,6 +36,10 @@ function follow_init(&$a) {
unset($clone['abook_account']);
unset($clone['abook_channel']);
+ $abconfig = load_abconfig($channel['channel_hash'],$clone['abook_xchan']);
+ if($abconfig)
+ $clone['abconfig'] = $abconfig;
+
build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
diff --git a/mod/fsuggest.php b/mod/fsuggest.php
index ec87af6ae..261679e6b 100644
--- a/mod/fsuggest.php
+++ b/mod/fsuggest.php
@@ -7,10 +7,10 @@ function fsuggest_post(&$a) {
return;
}
- if($a->argc != 2)
+ if(App::$argc != 2)
return;
- $contact_id = intval($a->argv[1]);
+ $contact_id = intval(App::$argv[1]);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
@@ -79,10 +79,10 @@ function fsuggest_content(&$a) {
return;
}
- if($a->argc != 2)
+ if(App::$argc != 2)
return;
- $contact_id = intval($a->argv[1]);
+ $contact_id = intval(App::$argv[1]);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
diff --git a/mod/getfile.php b/mod/getfile.php
new file mode 100644
index 000000000..c0916de79
--- /dev/null
+++ b/mod/getfile.php
@@ -0,0 +1,97 @@
+<?php
+
+/**
+ * module: getfile
+ *
+ * used for synchronising files and photos across clones
+ *
+ * The site initiating the file operation will send a sync packet to known clones.
+ * They will respond by building the DB structures they require, then will provide a
+ * post request to this site to grab the file data. This is sent as a stream direct to
+ * disk at the other end, avoiding memory issues.
+ *
+ * Since magic-auth cannot easily be used by the CURL process at the other end,
+ * we will require a signed request which includes a timestamp. This should not be
+ * used without SSL and is potentially vulnerable to replay if an attacker decrypts
+ * the SSL traffic fast enough. The amount of time slop is configurable but defaults
+ * to 3 minutes.
+ *
+ */
+
+
+
+require_once('include/Contact.php');
+require_once('include/attach.php');
+
+function getfile_post(&$a) {
+
+ $hash = $_POST['hash'];
+ $time = $_POST['time'];
+ $sig = $_POST['signature'];
+ $resource = $_POST['resource'];
+ $revision = intval($_POST['revision']);
+
+ if(! $hash)
+ killme();
+
+ $channel = channelx_by_hash($hash);
+
+ if((! $channel) || (! $time) || (! $sig))
+ killme();
+
+ $slop = intval(get_pconfig($channel['channel_id'],'system','getfile_time_slop'));
+ if($slop < 1)
+ $slop = 3;
+
+ $d1 = datetime_convert('UTC','UTC',"now + $slop minutes");
+ $d2 = datetime_convert('UTC','UTC',"now - $slop minutes");
+
+ if(($time > $d1) || ($time < $d2)) {
+ logger('time outside allowable range');
+ killme();
+ }
+
+ if(! rsa_verify($hash . '.' . $time,base64url_decode($sig),$channel['channel_pubkey'])) {
+ logger('verify failed.');
+ killme();
+ }
+
+
+ $r = attach_by_hash($resource,$revision);
+
+ if(! $r['success']) {
+ notice( $r['message'] . EOL);
+ return;
+ }
+
+
+ $unsafe_types = array('text/html','text/css','application/javascript');
+
+ if(in_array($r['data']['filetype'],$unsafe_types)) {
+ header('Content-type: text/plain');
+ }
+ else {
+ header('Content-type: ' . $r['data']['filetype']);
+ }
+
+ header('Content-disposition: attachment; filename="' . $r['data']['filename'] . '"');
+ if(intval($r['data']['os_storage'])) {
+ $fname = dbunescbin($r['data']['data']);
+ if(strpos($fname,'store') !== false)
+ $istream = fopen($fname,'rb');
+ else
+ $istream = fopen('store/' . $channel['channel_address'] . '/' . $fname,'rb');
+ $ostream = fopen('php://output','wb');
+ if($istream && $ostream) {
+ pipe_streams($istream,$ostream);
+ fclose($istream);
+ fclose($ostream);
+ }
+ }
+ else
+ echo dbunescbin($r['data']['data']);
+ killme();
+
+
+
+} \ No newline at end of file
diff --git a/mod/group.php b/mod/group.php
index ce9633669..d5f2129bd 100644
--- a/mod/group.php
+++ b/mod/group.php
@@ -17,14 +17,14 @@ function group_post(&$a) {
$public = intval($_POST['public']);
$r = group_add(local_channel(),$name,$public);
if($r) {
- info( t('Collection created.') . EOL );
+ info( t('Privacy group created.') . EOL );
$r = group_byname(local_channel(),$name);
if($r)
- goaway($a->get_baseurl() . '/group/' . $r);
+ goaway(z_root() . '/group/' . $r);
}
else
- notice( t('Could not create collection.') . EOL );
- goaway($a->get_baseurl() . '/group');
+ notice( t('Could not create privacy group.') . EOL );
+ goaway(z_root() . '/group');
}
if((argc() == 2) && (intval(argv(1)))) {
@@ -35,8 +35,8 @@ function group_post(&$a) {
intval(local_channel())
);
if(! $r) {
- notice( t('Collection not found.') . EOL );
- goaway($a->get_baseurl() . '/connections');
+ notice( t('Privacy group not found.') . EOL );
+ goaway(z_root() . '/connections');
}
$group = $r[0];
@@ -51,7 +51,7 @@ function group_post(&$a) {
intval($group['id'])
);
if($r)
- info( t('Collection updated.') . EOL );
+ info( t('Privacy group updated.') . EOL );
}
goaway(z_root() . '/group/' . argv(1) . '/' . argv(2));
@@ -62,7 +62,7 @@ function group_post(&$a) {
function group_content(&$a) {
$change = false;
- logger('mod_group: ' . $a->cmd,LOGGER_DEBUG);
+ logger('mod_group: ' . App::$cmd,LOGGER_DEBUG);
if(! local_channel()) {
notice( t('Permission denied') . EOL);
@@ -83,8 +83,8 @@ function group_content(&$a) {
if((argc() == 2) && (argv(1) === 'new')) {
return replace_macros($tpl, $context + array(
- '$title' => t('Create a collection of channels.'),
- '$gname' => array('groupname',t('Collection Name: '), '', ''),
+ '$title' => t('Create a group of channels.'),
+ '$gname' => array('groupname',t('Privacy group name: '), '', ''),
'$gid' => 'new',
'$public' => array('public',t('Members are visible to other channels'), false, ''),
'$form_security_token' => get_form_security_token("group_edit"),
@@ -104,11 +104,11 @@ function group_content(&$a) {
if($r)
$result = group_rmv(local_channel(),$r[0]['name']);
if($result)
- info( t('Collection removed.') . EOL);
+ info( t('Privacy group removed.') . EOL);
else
- notice( t('Unable to remove collection.') . EOL);
+ notice( t('Unable to remove privacy group.') . EOL);
}
- goaway($a->get_baseurl() . '/group');
+ goaway(z_root() . '/group');
// NOTREACHED
}
@@ -117,7 +117,7 @@ function group_content(&$a) {
check_form_security_token_ForbiddenOnErr('group_member_change', 't');
- $r = q("SELECT abook_xchan from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d and xchan_deleted = 0 and abook_blocked = 0 and abook_pending = 0 limit 1",
+ $r = q("SELECT abook_xchan from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 limit 1",
dbesc(base64url_decode(argv(2))),
intval(local_channel())
);
@@ -134,8 +134,8 @@ function group_content(&$a) {
intval(local_channel())
);
if(! $r) {
- notice( t('Collection not found.') . EOL );
- goaway($a->get_baseurl() . '/connections');
+ notice( t('Privacy group not found.') . EOL );
+ goaway(z_root() . '/connections');
}
$group = $r[0];
@@ -176,8 +176,8 @@ function group_content(&$a) {
$context = $context + array(
- '$title' => t('Collection Editor'),
- '$gname' => array('groupname',t('Collection Name: '),$group['name'], ''),
+ '$title' => t('Privacy group editor'),
+ '$gname' => array('groupname',t('Privacy group name: '),$group['name'], ''),
'$gid' => $group['id'],
'$drop' => $drop_txt,
'$public' => array('public',t('Members are visible to other channels'), $group['visible'], ''),
@@ -208,7 +208,7 @@ function group_content(&$a) {
group_rmv_member(local_channel(),$group['name'],$member['xchan_hash']);
}
- $r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc",
+ $r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND abook_self = 0 and abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc",
intval(local_channel())
);
diff --git a/mod/hcard.php b/mod/hcard.php
index 014a63b35..9954e0838 100644
--- a/mod/hcard.php
+++ b/mod/hcard.php
@@ -6,12 +6,12 @@ function hcard_init(&$a) {
$which = argv(1);
else {
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
$profile = '';
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) {
$which = $channel['channel_address'];
@@ -25,14 +25,14 @@ function hcard_init(&$a) {
$profile = $r[0]['profile_guid'];
}
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which .'" />' . "\r\n" ;
+ App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . z_root() . '/feed/' . $which .'" />' . "\r\n" ;
if(! $profile) {
$x = q("select channel_id as profile_uid from channel where channel_address = '%s' limit 1",
dbesc(argv(1))
);
if($x) {
- $a->profile = $x[0];
+ App::$profile = $x[0];
}
}
diff --git a/mod/help.php b/mod/help.php
index c4549a2bd..fb0339cd9 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -13,7 +13,7 @@
function load_doc_file($s) {
- $lang = get_app()->language;
+ $lang = App::$language;
if(! isset($lang))
$lang = 'en';
$b = basename($s);
@@ -39,8 +39,8 @@ function search_doc_files($s) {
$a = get_app();
$itemspage = get_pconfig(local_channel(),'system','itemspage');
- $a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
- $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
+ App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
$regexop = db_getfunc('REGEXP');
@@ -68,7 +68,7 @@ function search_doc_files($s) {
$r[$x]['rank'] ++;
$r[$x]['rank'] += substr_count(strtolower($r[$x]['text']),strtolower($s));
// bias the results to the observer's native language
- if($r[$x]['lang'] === $a->language)
+ if($r[$x]['lang'] === App::$language)
$r[$x]['rank'] = $r[$x]['rank'] + 10;
}
@@ -84,7 +84,21 @@ function doc_rank_sort($s1,$s2) {
}
+function load_context_help() {
+
+ $path = App::$cmd;
+ $args = App::$argv;
+
+ while($path) {
+ $context_help = load_doc_file('doc/context/' . $path . '/help.html');
+ if($context_help)
+ break;
+ array_pop($args);
+ $path = implode($args,'/');
+ }
+ return $context_help;
+}
function store_doc_file($s) {
@@ -145,7 +159,10 @@ function help_content(&$a) {
if($_REQUEST['search']) {
$o .= '<div id="help-content" class="generic-content-wrapper">';
+ $o .= '<div class="section-title-wrapper">';
$o .= '<h2>' . t('Documentation Search') . ' - ' . htmlspecialchars($_REQUEST['search']) . '</h2>';
+ $o .= '</div>';
+ $o .= '<div class="section-content-wrapper">';
$r = search_doc_files($_REQUEST['search']);
if($r) {
@@ -157,11 +174,12 @@ function help_content(&$a) {
$path = trim(substr($dirname,4),'/');
$o .= '<li><a href="help/' . (($path) ? $path . '/' : '') . $fname . '" >' . ucwords(str_replace('_',' ',notags($fname))) . '</a><br />' .
- str_replace('$Projectname',PLATFORM_NAME,substr($rr['text'],0,200)) . '...<br /><br /></li>';
+ str_replace('$Projectname',Zotlabs\Project\System::get_platform_name(),substr($rr['text'],0,200)) . '...<br /><br /></li>';
}
$o .= '</ul>';
$o .= '</div>';
+ $o .= '</div>';
}
return $o;
}
@@ -183,30 +201,30 @@ function help_content(&$a) {
$title = basename($path);
$text = load_doc_file('doc/' . $path . '.md');
- $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags($title)));
+ App::$page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags($title)));
if(! $text) {
$text = load_doc_file('doc/' . $path . '.bb');
if($text)
$doctype = 'bbcode';
- $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('_',' ',notags($title)));
+ App::$page['title'] = t('Help:') . ' ' . ucwords(str_replace('_',' ',notags($title)));
}
if(! $text) {
$text = load_doc_file('doc/' . $path . '.html');
if($text)
$doctype = 'html';
- $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags($title)));
+ App::$page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags($title)));
}
}
if(! $text) {
$text = load_doc_file('doc/Site.md');
- $a->page['title'] = t('Help');
+ App::$page['title'] = t('Help');
}
if(! $text) {
$doctype = 'bbcode';
$text = load_doc_file('doc/main.bb');
- $a->page['title'] = t('Help');
+ App::$page['title'] = t('Help');
}
if(! strlen($text)) {
@@ -229,6 +247,8 @@ function help_content(&$a) {
if($doctype === 'bbcode') {
require_once('include/bbcode.php');
$content = bbcode($text);
+ // bbcode retargets external content to new windows. This content is internal.
+ $content = str_replace(' target="_blank"','',$content);
}
$content = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $content);
@@ -248,7 +268,9 @@ function preg_callback_help_include($matches) {
if(preg_match('/\.bb$/', $matches[1]) || preg_match('/\.txt$/', $matches[1])) {
require_once('include/bbcode.php');
$include = bbcode($include);
- } elseif(preg_match('/\.md$/', $matches[1])) {
+ $include = str_replace(' target="_blank"','',$include);
+ }
+ elseif(preg_match('/\.md$/', $matches[1])) {
require_once('library/markdown.php');
$include = Markdown($include);
}
diff --git a/mod/home.php b/mod/home.php
index bfac17eab..478c764ea 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -12,7 +12,7 @@ function home_init(&$a) {
$splash = ((argc() > 1 && argv(1) === 'splash') ? true : false);
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if(local_channel() && $channel && $channel['xchan_url'] && ! $splash) {
$dest = $channel['channel_startpage'];
if(! $dest)
@@ -53,8 +53,8 @@ function home_content(&$a, $update = 0, $load = false) {
if(strpos($frontpage,'include:') !== false) {
$file = trim(str_replace('include:' , '', $frontpage));
if(file_exists($file)) {
- $a->page['template'] = 'full';
- $a->page['title'] = t('$Projectname');
+ App::$page['template'] = 'full';
+ App::$page['title'] = t('$Projectname');
$o .= file_get_contents($file);
return $o;
}
@@ -76,7 +76,7 @@ function home_content(&$a, $update = 0, $load = false) {
$loginbox = get_config('system','login_on_homepage');
if(intval($loginbox) || $loginbox === false)
- $o .= login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
+ $o .= login((App::$config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
return $o;
diff --git a/mod/hostxrd.php b/mod/hostxrd.php
index 0e18c133b..0e19d8af6 100644
--- a/mod/hostxrd.php
+++ b/mod/hostxrd.php
@@ -7,11 +7,12 @@ function hostxrd_init(&$a) {
$tpl = get_markup_template('xrd_host.tpl');
$x = replace_macros(get_markup_template('xrd_host.tpl'), array(
- '$zhost' => $a->get_hostname(),
+ '$zhost' => App::get_hostname(),
'$zroot' => z_root()
));
$arr = array('xrd' => $x);
call_hooks('hostxrd',$arr);
+
echo $arr['xrd'];
killme();
}
diff --git a/mod/id.php b/mod/id.php
index bd4c1fa89..382df45d8 100644
--- a/mod/id.php
+++ b/mod/id.php
@@ -46,12 +46,12 @@ function id_init(&$a) {
if(argc() > 1) {
$which = argv(1);
} else {
- $a->error = 404;
+ App::$error = 404;
return;
}
$profile = '';
- $channel = $a->get_channel();
+ $channel = App::get_channel();
profile_load($a,$which,$profile);
$op = new MysqlProvider;
@@ -69,7 +69,7 @@ function id_init(&$a) {
function getUserData($handle = null) {
if (! local_channel()) {
notice( t('Permission denied.') . EOL);
- get_app()->page['content'] = login();
+ App::$page['content'] = login();
return false;
}
@@ -235,7 +235,7 @@ class MysqlProvider extends LightOpenIDProvider {
. '<button name="cancel">cancel</button> '
. '</form>';
- get_app()->page['content'] .= $o;
+ App::$page['content'] .= $o;
}
function checkid($realm, &$attributes) {
@@ -279,7 +279,7 @@ class MysqlProvider extends LightOpenIDProvider {
function assoc_handle() {
logger('assoc_handle');
- $channel = get_app()->get_channel();
+ $channel = App::get_channel();
return z_root() . '/channel/' . $channel['channel_address'];
}
diff --git a/mod/impel.php b/mod/impel.php
index da7138438..a0cb1d949 100644
--- a/mod/impel.php
+++ b/mod/impel.php
@@ -22,7 +22,7 @@ function impel_init(&$a) {
if(! $j)
json_return_and_die($ret);
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$arr = array();
$is_menu = false;
diff --git a/mod/import.php b/mod/import.php
index 02e71233a..b14b97777 100644
--- a/mod/import.php
+++ b/mod/import.php
@@ -108,7 +108,9 @@ function import_account(&$a, $account_id) {
import_diaspora($data);
return;
}
-
+
+ $moving = false;
+
if(array_key_exists('compatibility',$data) && array_key_exists('database',$data['compatibility'])) {
$v1 = substr($data['compatibility']['database'],-4);
$v2 = substr(DB_UPDATE_VERSION,-4);
@@ -116,14 +118,19 @@ function import_account(&$a, $account_id) {
$t = sprintf( t('Warning: Database versions differ by %1$d updates.'), $v2 - $v1 );
notice($t);
}
+ if(array_key_exists('server_role',$data['compatibility']) && $data['compatibility']['server_role'] == 'basic')
+ $moving = true;
}
+ if($moving)
+ $seize = 1;
+
// import channel
if(array_key_exists('channel',$data)) {
if($completed < 1) {
- $channel = import_channel($data['channel'], $account_id);
+ $channel = import_channel($data['channel'], $account_id, $seize);
}
else {
@@ -142,7 +149,7 @@ function import_account(&$a, $account_id) {
}
if(! $channel)
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if(! $channel) {
logger('mod_import: channel not found. ', print_r($channel,true));
@@ -158,7 +165,6 @@ function import_account(&$a, $account_id) {
logger('import step 2');
$_SESSION['import_step'] = 2;
- ref_session_write(session_id(), serialize($_SESSION));
}
@@ -174,19 +180,17 @@ function import_account(&$a, $account_id) {
logger('import step 3');
$_SESSION['import_step'] = 3;
- ref_session_write(session_id(), serialize($_SESSION));
}
if($completed < 4) {
- if(is_array($data['hubloc'])) {
+ if(is_array($data['hubloc']) && (! $moving)) {
import_hublocs($channel,$data['hubloc'],$seize);
}
logger('import step 4');
$_SESSION['import_step'] = 4;
- ref_session_write(session_id(), serialize($_SESSION));
}
if($completed < 5) {
@@ -198,12 +202,12 @@ function import_account(&$a, $account_id) {
dbesc($channel['channel_guid']),
dbesc($channel['channel_guid_sig']),
dbesc($channel['channel_hash']),
- dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()),
+ dbesc($channel['channel_address'] . '@' . App::get_hostname()),
dbesc('zot'),
intval(($seize) ? 1 : 0),
dbesc(z_root()),
dbesc(base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))),
- dbesc(get_app()->get_hostname()),
+ dbesc(App::get_hostname()),
dbesc(z_root() . '/post'),
dbesc(get_config('system','pubkey'))
);
@@ -218,7 +222,6 @@ function import_account(&$a, $account_id) {
}
logger('import step 5');
$_SESSION['import_step'] = 5;
- ref_session_write(session_id(), serialize($_SESSION));
}
@@ -239,10 +242,10 @@ function import_account(&$a, $account_id) {
dbesc($channel['channel_guid']),
dbesc($channel['channel_guid_sig']),
dbesc($channel['channel_pubkey']),
- dbesc($a->get_baseurl() . "/photo/profile/l/" . $channel['channel_id']),
- dbesc($a->get_baseurl() . "/photo/profile/m/" . $channel['channel_id']),
- dbesc($a->get_baseurl() . "/photo/profile/s/" . $channel['channel_id']),
- dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()),
+ dbesc(z_root() . "/photo/profile/l/" . $channel['channel_id']),
+ dbesc(z_root() . "/photo/profile/m/" . $channel['channel_id']),
+ dbesc(z_root() . "/photo/profile/s/" . $channel['channel_id']),
+ dbesc($channel['channel_address'] . '@' . App::get_hostname()),
dbesc(z_root() . '/channel/' . $channel['channel_address']),
dbesc(z_root() . '/follow?f=&url=%s'),
dbesc(z_root() . '/poco/' . $channel['channel_address']),
@@ -255,7 +258,6 @@ function import_account(&$a, $account_id) {
}
logger('import step 6');
$_SESSION['import_step'] = 6;
- ref_session_write(session_id(), serialize($_SESSION));
}
if($completed < 7) {
@@ -316,7 +318,7 @@ function import_account(&$a, $account_id) {
}
logger('import step 7');
$_SESSION['import_step'] = 7;
- ref_session_write(session_id(), serialize($_SESSION));
+
}
@@ -332,6 +334,10 @@ function import_account(&$a, $account_id) {
if($abooks) {
foreach($abooks as $abook) {
+ $abconfig = null;
+ if(array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && count($abook['abconfig']))
+ $abconfig = $abook['abconfig'];
+
unset($abook['abook_id']);
unset($abook['abook_rating']);
unset($abook['abook_rating_text']);
@@ -373,11 +379,21 @@ function import_account(&$a, $account_id) {
$friends ++;
if(intval($abook['abook_feed']))
$feeds ++;
+
+ if($abconfig) {
+ // @fixme does not handle sync of del_abconfig
+ foreach($abconfig as $abc) {
+ if($abc['chan'] === $channel['channel_hash'])
+ set_abconfig($abc['chan'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
+ }
+ }
+
+
+
}
}
logger('import step 8');
$_SESSION['import_step'] = 8;
- ref_session_write(session_id(), serialize($_SESSION));
}
@@ -427,7 +443,6 @@ function import_account(&$a, $account_id) {
}
logger('import step 9');
$_SESSION['import_step'] = 9;
- ref_session_write(session_id(), serialize($_SESSION));
}
if(is_array($data['obj']))
diff --git a/mod/import_items.php b/mod/import_items.php
index 6b97939c9..df3afb3ea 100644
--- a/mod/import_items.php
+++ b/mod/import_items.php
@@ -84,16 +84,13 @@ function import_items_post(&$a) {
}
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- $saved_notification_flags = notifications_off($channel['channel_id']);
if(array_key_exists('item',$data) && $data['item']) {
import_items($channel,$data['item']);
}
- notifications_on($channel['channel_id'],$saved_notification_flags);
-
if(array_key_exists('item_id',$data) && $data['item_id']) {
import_item_ids($channel,$data['item_id']);
}
@@ -107,9 +104,6 @@ function import_items_post(&$a) {
function import_items_content(&$a) {
-
-
-
if(! local_channel()) {
notice( t('Permission denied') . EOL);
return login();
diff --git a/mod/invite.php b/mod/invite.php
index e8bb74ee2..2adad8257 100644
--- a/mod/invite.php
+++ b/mod/invite.php
@@ -49,15 +49,15 @@ function invite_post(&$a) {
notice( sprintf( t('%s : Not a valid email address.'), $recip) . EOL);
continue;
}
-
+
else
$nmessage = $message;
- $account = $a->get_account();
+ $account = App::get_account();
- $res = mail($recip, sprintf( t('Please join us on $Projectname'), $a->config['sitename']),
- $nmessage,
+ $res = mail($recip, sprintf( t('Please join us on $Projectname'), App::$config['sitename']),
+ $nmessage,
"From: " . $account['account_email'] . "\n"
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit' );
@@ -98,7 +98,7 @@ function invite_content(&$a) {
notice( t('You have no more invitations available') . EOL);
return '';
}
- }
+ }
if($invonly && ($x || is_site_admin())) {
$invite_code = autoname(8) . rand(1000,9999);
@@ -118,11 +118,11 @@ function invite_content(&$a) {
}
}
- $ob = $a->get_observer();
+ $ob = App::get_observer();
if(! $ob)
return $o;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$o = replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("send_invite"),
@@ -131,11 +131,11 @@ function invite_content(&$a) {
'$msg_text' => t('Your message:'),
'$default_message' => t('Please join my community on $Projectname.') . "\r\n" . "\r\n"
. $linktxt
- . (($invonly) ? "\r\n" . "\r\n" . t('You will need to supply this invitation code: ') . $invite_code . "\r\n" . "\r\n" : '')
+ . (($invonly) ? "\r\n" . "\r\n" . t('You will need to supply this invitation code:') . " " . $invite_code . "\r\n" . "\r\n" : '')
. t('1. Register at any $Projectname location (they are all inter-connected)')
. "\r\n" . "\r\n" . z_root() . '/register'
. "\r\n" . "\r\n" . t('2. Enter my $Projectname network address into the site searchbar.')
- . "\r\n" . "\r\n" . $ob['xchan_addr'] . ' (' . t('or visit ') . z_root() . '/channel/' . $channel['channel_address'] . ')'
+ . "\r\n" . "\r\n" . $ob['xchan_addr'] . ' (' . t('or visit') . " " . z_root() . '/channel/' . $channel['channel_address'] . ')'
. "\r\n" . "\r\n"
. t('3. Click [Connect]')
. "\r\n" . "\r\n" ,
diff --git a/mod/item.php b/mod/item.php
index b3ef57529..6e7c77a4d 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -119,7 +119,7 @@ function item_post(&$a) {
if (!$ret['success']) {
notice( t($ret['message']) . EOL) ;
if(x($_REQUEST,'return'))
- goaway($a->get_baseurl() . "/" . $return_path );
+ goaway(z_root() . "/" . $return_path );
killme();
}
}
@@ -173,7 +173,7 @@ function item_post(&$a) {
if(($r === false) || (! count($r))) {
notice( t('Unable to locate original post.') . EOL);
if(x($_REQUEST,'return'))
- goaway($a->get_baseurl() . "/" . $return_path );
+ goaway(z_root() . "/" . $return_path );
killme();
}
@@ -192,7 +192,7 @@ function item_post(&$a) {
}
if(! $observer)
- $observer = $a->get_observer();
+ $observer = App::get_observer();
if($parent) {
logger('mod_item: item_post parent=' . $parent);
@@ -205,15 +205,15 @@ function item_post(&$a) {
if(! $can_comment) {
notice( t('Permission denied.') . EOL) ;
if(x($_REQUEST,'return'))
- goaway($a->get_baseurl() . "/" . $return_path );
+ goaway(z_root() . "/" . $return_path );
killme();
}
}
else {
- if(! perm_is_allowed($profile_uid,$observer['xchan_hash'],'post_wall')) {
+ if(! perm_is_allowed($profile_uid,$observer['xchan_hash'],($webpage) ? 'write_pages' : 'post_wall')) {
notice( t('Permission denied.') . EOL) ;
if(x($_REQUEST,'return'))
- goaway($a->get_baseurl() . "/" . $return_path );
+ goaway(z_root() . "/" . $return_path );
killme();
}
}
@@ -233,6 +233,8 @@ function item_post(&$a) {
$post_id = $i[0]['iid'];
}
+ $iconfig = null;
+
if($post_id) {
$i = q("SELECT * FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($profile_uid),
@@ -241,12 +243,15 @@ function item_post(&$a) {
if(! count($i))
killme();
$orig_post = $i[0];
+ $iconfig = q("select * from iconfig where iid = %d",
+ intval($post_id)
+ );
}
if(! $channel) {
if($uid && $uid == $profile_uid) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
}
else {
// posting as yourself but not necessarily to a channel you control
@@ -262,7 +267,7 @@ function item_post(&$a) {
if(! $channel) {
logger("mod_item: no channel.");
if(x($_REQUEST,'return'))
- goaway($a->get_baseurl() . "/" . $return_path );
+ goaway(z_root() . "/" . $return_path );
killme();
}
@@ -277,7 +282,7 @@ function item_post(&$a) {
else {
logger("mod_item: no owner.");
if(x($_REQUEST,'return'))
- goaway($a->get_baseurl() . "/" . $return_path );
+ goaway(z_root() . "/" . $return_path );
killme();
}
@@ -305,7 +310,7 @@ function item_post(&$a) {
}
}
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$public_policy = ((x($_REQUEST,'public_policy')) ? escape_tags($_REQUEST['public_policy']) : map_scope($channel['channel_r_stream'],true));
@@ -417,7 +422,7 @@ function item_post(&$a) {
killme();
info( t('Empty post discarded.') . EOL );
if(x($_REQUEST,'return'))
- goaway($a->get_baseurl() . "/" . $return_path );
+ goaway(z_root() . "/" . $return_path );
killme();
}
}
@@ -446,7 +451,7 @@ function item_post(&$a) {
$execflag = false;
- if($mimetype === 'application/x-php') {
+ if($mimetype !== 'text/bbcode') {
$z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1",
intval($profile_uid)
);
@@ -457,7 +462,7 @@ function item_post(&$a) {
else {
notice( t('Executable content type not permitted to this channel.') . EOL);
if(x($_REQUEST,'return'))
- goaway($a->get_baseurl() . "/" . $return_path );
+ goaway(z_root() . "/" . $return_path );
killme();
}
}
@@ -472,15 +477,28 @@ function item_post(&$a) {
if($mimetype === 'text/bbcode') {
require_once('include/text.php');
- if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) {
- require_once('include/bb2diaspora.php');
- $body = escape_tags(trim($body));
- $body = str_replace("\n",'<br />', $body);
-
- $body = preg_replace_callback('/\[share(.*?)\]/ism','share_shield',$body);
- $body = diaspora2bb($body,true);
- $body = preg_replace_callback('/\[share(.*?)\]/ism','share_unshield',$body);
- }
+
+ // Markdown doesn't work correctly. Do not re-enable unless you're willing to fix it and support it.
+
+ // Sample that will probably give you grief - you must preserve the linebreaks
+ // and provide the correct markdown interpretation and you cannot allow unfiltered HTML
+
+ // Markdown
+ // ========
+ //
+ // **bold** abcde
+ // fghijkl
+ // *italic*
+ // <img src="javascript:alert('hacked');" />
+
+// if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) {
+// require_once('include/bb2diaspora.php');
+// $body = escape_tags(trim($body));
+// $body = str_replace("\n",'<br />', $body);
+// $body = preg_replace_callback('/\[share(.*?)\]/ism','share_shield',$body);
+// $body = diaspora2bb($body,true);
+// $body = preg_replace_callback('/\[share(.*?)\]/ism','share_unshield',$body);
+// }
// BBCODE alert: the following functions assume bbcode input
// and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.)
@@ -618,7 +636,7 @@ function item_post(&$a) {
$r = attach_by_hash_nodata($hash,$rev);
if($r['success']) {
$attachments[] = array(
- 'href' => $a->get_baseurl() . '/attach/' . $r['data']['hash'],
+ 'href' => z_root() . '/attach/' . $r['data']['hash'],
'length' => $r['data']['filesize'],
'type' => $r['data']['filetype'],
'title' => urlencode($r['data']['filename']),
@@ -720,8 +738,7 @@ function item_post(&$a) {
$datarray = array();
- $item_thead_top = ((! $parent) ? 1 : 0);
-
+ $item_thread_top = ((! $parent) ? 1 : 0);
if ((! $plink) && ($item_thread_top)) {
$plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid;
@@ -793,6 +810,9 @@ function item_post(&$a) {
$datarray['plink'] = $plink;
$datarray['route'] = $route;
+ if($iconfig)
+ $datarray['iconfig'] = $iconfig;
+
// preview mode - prepare the body for display and send it via json
if($preview) {
@@ -809,8 +829,6 @@ function item_post(&$a) {
if($orig_post)
$datarray['edit'] = true;
-
-
if(feature_enabled($profile_uid,'suppress_duplicates') && (! $orig_post)) {
$z = q("select created from item where uid = %d and body = '%s'",
@@ -818,25 +836,26 @@ function item_post(&$a) {
dbesc($body)
);
- if($z && $z[0]['created'] > datetime_convert('UTC','UTC', 'now - 2 minutes')) {
- $datarray['cancel'] = 1;
- notice( t('Duplicate post suppressed.') . EOL);
- logger('Duplicate post. Faking plugin cancel.');
+ if($z) {
+ foreach($z as $zz) {
+ if($zz['created'] > datetime_convert('UTC','UTC', 'now - 2 minutes')) {
+ $datarray['cancel'] = 1;
+ notice( t('Duplicate post suppressed.') . EOL);
+ logger('Duplicate post. Faking plugin cancel.');
+ }
+ }
}
}
call_hooks('post_local',$datarray);
if(x($datarray,'cancel')) {
- logger('mod_item: post cancelled by plugin.');
- if($return_path) {
- goaway($a->get_baseurl() . "/" . $return_path);
- }
+ logger('mod_item: post cancelled by plugin or duplicate suppressed.');
+ if($return_path)
+ goaway(z_root() . "/" . $return_path);
$json = array('cancel' => 1);
- if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
- $json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
-
+ $json['reload'] = z_root() . '/' . $_REQUEST['jsreload'];
echo json_encode($json);
killme();
}
@@ -882,7 +901,7 @@ function item_post(&$a) {
if((x($_REQUEST,'return')) && strlen($return_path)) {
logger('return: ' . $return_path);
- goaway($a->get_baseurl() . "/" . $return_path );
+ goaway(z_root() . "/" . $return_path );
}
killme();
}
@@ -907,7 +926,7 @@ function item_post(&$a) {
'from_xchan' => $datarray['author_xchan'],
'to_xchan' => $datarray['owner_xchan'],
'item' => $datarray,
- 'link' => $a->get_baseurl() . '/display/' . $datarray['mid'],
+ 'link' => z_root() . '/display/' . $datarray['mid'],
'verb' => ACTIVITY_POST,
'otype' => 'item',
'parent' => $parent,
@@ -919,13 +938,13 @@ function item_post(&$a) {
else {
$parent = $post_id;
- if($datarray['owner_xchan'] != $datarray['author_xchan']) {
+ if(($datarray['owner_xchan'] != $datarray['author_xchan']) && ($datarray['item_type'] == ITEM_TYPE_POST)) {
notification(array(
'type' => NOTIFY_WALL,
'from_xchan' => $datarray['author_xchan'],
'to_xchan' => $datarray['owner_xchan'],
'item' => $datarray,
- 'link' => $a->get_baseurl() . '/display/' . $datarray['mid'],
+ 'link' => z_root() . '/display/' . $datarray['mid'],
'verb' => ACTIVITY_POST,
'otype' => 'item'
));
@@ -952,7 +971,7 @@ function item_post(&$a) {
else {
logger('mod_item: unable to retrieve post that was just stored.');
notice( t('System error. Post not saved.') . EOL);
- goaway($a->get_baseurl() . "/" . $return_path );
+ goaway(z_root() . "/" . $return_path );
// NOTREACHED
}
@@ -980,7 +999,7 @@ function item_post(&$a) {
}
$datarray['id'] = $post_id;
- $datarray['llink'] = $a->get_baseurl() . '/display/' . $channel['channel_address'] . '/' . $post_id;
+ $datarray['llink'] = z_root() . '/display/' . $channel['channel_address'] . '/' . $post_id;
call_hooks('post_local_end', $datarray);
@@ -1000,12 +1019,12 @@ function item_post(&$a) {
return $post;
if($return_path) {
- goaway($a->get_baseurl() . "/" . $return_path);
+ goaway(z_root() . "/" . $return_path);
}
$json = array('success' => 1);
if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
- $json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
+ $json['reload'] = z_root() . '/' . $_REQUEST['jsreload'];
logger('post_json: ' . print_r($json,true), LOGGER_DEBUG);
@@ -1080,7 +1099,7 @@ function fix_attached_photo_permissions($uid,$xchan_hash,$body,
$images = $match[2];
if($images) {
foreach($images as $image) {
- if(! stristr($image,get_app()->get_baseurl() . '/photo/'))
+ if(! stristr($image,z_root() . '/photo/'))
continue;
$image_uri = substr($image,strrpos($image,'/') + 1);
if(strpos($image_uri,'-') !== false)
diff --git a/mod/layouts.php b/mod/layouts.php
index fd77cfc37..e28c9a066 100644
--- a/mod/layouts.php
+++ b/mod/layouts.php
@@ -9,7 +9,7 @@ function layouts_init(&$a) {
if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
- $a->is_sys = true;
+ App::$is_sys = true;
}
}
@@ -25,24 +25,24 @@ function layouts_init(&$a) {
function layouts_content(&$a) {
- if(! $a->profile) {
+ if(! App::$profile) {
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
$which = argv(1);
- $_SESSION['return_url'] = $a->query_string;
+ $_SESSION['return_url'] = App::$query_string;
$uid = local_channel();
$owner = 0;
$channel = null;
- $observer = $a->get_observer();
+ $observer = App::get_observer();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- if($a->is_sys && is_site_admin()) {
+ if(App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
$uid = $owner = intval($sys['channel_id']);
@@ -113,7 +113,7 @@ function layouts_content(&$a) {
$x = array(
'webpage' => ITEM_TYPE_PDL,
'is_owner' => true,
- 'nickname' => $a->profile['channel_address'],
+ 'nickname' => App::$profile['channel_address'],
'bang' => '',
'showacl' => false,
'visitor' => false,
@@ -122,7 +122,8 @@ function layouts_content(&$a) {
'profile_uid' => intval($owner),
'expanded' => true,
'placeholdertitle' => t('Layout Description (Optional)'),
- 'novoting' => true
+ 'novoting' => true,
+ 'bbco_autocomplete' => 'comanche'
);
if($_REQUEST['title'])
diff --git a/mod/like.php b/mod/like.php
index ce8bc3063..0fbdd5c30 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -9,14 +9,14 @@ function like_content(&$a) {
$o = '';
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$interactive = $_REQUEST['interactive'];
if($interactive) {
$o .= '<h1>' . t('Like/Dislike') . '</h1>';
$o .= EOL . EOL;
if(! $observer) {
- $_SESSION['return_url'] = $a->query_string;
+ $_SESSION['return_url'] = App::$query_string;
$o .= t('This action is restricted to members.') . EOL;
$o .= t('Please <a href="rmagic">login with your $Projectname ID</a> or <a href="register">register as a new $Projectname member</a> to continue.') . EOL;
return $o;
@@ -107,13 +107,13 @@ function like_content(&$a) {
// to them.
$allow_cid = $allow_gid = $deny_cid = $deny_gid = '';
foreach($d as $dd) {
- $allow_gid .= '<' . $dd['abook_xchan'] . '>';
+ $allow_cid .= '<' . $dd['abook_xchan'] . '>';
}
}
$post_type = t('channel');
$objtype = ACTIVITY_OBJ_PROFILE;
-
+ $profile = $r[0];
}
elseif($obj_type == 'thing') {
@@ -299,7 +299,8 @@ function like_content(&$a) {
$verbs = " '".dbesc($activity)."' ";
- $multi_undo = 0;
+
+ $multi_undo = false;
// event participation and consensus items are essentially radio toggles. If you make a subsequent choice,
// we need to eradicate your first choice.
@@ -310,15 +311,14 @@ function like_content(&$a) {
}
if($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) {
$verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' ";
- $multi_undo = 1;
+ $multi_undo = true;
}
$item_normal = item_normal();
$r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) $item_normal
- AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ",
+ AND author_xchan = '%s' AND thr_parent = '%s' and uid = %d ",
dbesc($observer['xchan_hash']),
- intval($item_id),
dbesc($item['mid']),
intval($owner_uid)
);
@@ -338,6 +338,12 @@ function like_content(&$a) {
// don't fall through and create another
if(activity_match($rr['verb'],$activity))
$multi_undo = false;
+
+ // drop_item was not done interactively, so we need to invoke the notifier
+ // in order to push the changes to connections
+
+ proc_run('php','include/notifier.php','drop',$rr['id']);
+
}
if($interactive)
@@ -438,7 +444,7 @@ function like_content(&$a) {
$arr['thr_parent'] = $item['mid'];
$ulink = '[zrl=' . $item_author['xchan_url'] . ']' . $item_author['xchan_name'] . '[/zrl]';
$alink = '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]';
- $plink = '[zrl=' . $a->get_baseurl() . '/display/' . $item['mid'] . ']' . $post_type . '[/zrl]';
+ $plink = '[zrl=' . z_root() . '/display/' . $item['mid'] . ']' . $post_type . '[/zrl]';
$allow_cid = $item['allow_cid'];
$allow_gid = $item['allow_gid'];
$deny_cid = $item['deny_cid'];
@@ -462,6 +468,13 @@ function like_content(&$a) {
if($obj_type === 'thing' && $r[0]['imgurl']) {
$arr['body'] .= "\n\n[zmg=80x80]" . $r[0]['imgurl'] . '[/zmg]';
}
+ if($obj_type === 'profile') {
+ if($public) {
+ $arr['body'] .= "\n\n" . '[embed]' . z_root() . '/profile/' . $ch[0]['channel_address'] . '[/embed]';
+ }
+ else
+ $arr['body'] .= "\n\n[zmg=80x80]" . $profile['thumb'] . '[/zmg]';
+ }
$arr['verb'] = $activity;
diff --git a/mod/linkinfo.php b/mod/linkinfo.php
index c3df1305d..07eaa02a0 100644
--- a/mod/linkinfo.php
+++ b/mod/linkinfo.php
@@ -22,6 +22,8 @@ function linkinfo_content(&$a) {
else
$url = trim($_GET['url']);
+ $url = strip_zids($url);
+
if((substr($url,0,1) != '/') && (substr($url,0,4) != 'http'))
$url = 'http://' . $url;
@@ -113,7 +115,7 @@ function linkinfo_content(&$a) {
// If this is a Red site, use zrl rather than url so they get zids sent to them by default
- if( x($siteinfo,'generator') && (strpos($siteinfo['generator'],PLATFORM_NAME . ' ') === 0))
+ if( x($siteinfo,'generator') && (strpos($siteinfo['generator'], Zotlabs\Project\System::get_platform_name() . ' ') === 0))
$template = str_replace('url','zrl',$template);
if($siteinfo["title"] == "") {
diff --git a/mod/lockview.php b/mod/lockview.php
index 84c16f658..d4a626a11 100644
--- a/mod/lockview.php
+++ b/mod/lockview.php
@@ -14,11 +14,21 @@ function lockview_content(&$a) {
if(! $item_id)
killme();
- if (!in_array($type, array('item','photo','event', 'menu_item')))
+ if (!in_array($type, array('item','photo','event', 'menu_item', 'chatroom')))
killme();
- //we have different naming in in menu_item table
- $id = (($type == 'menu_item') ? 'mitem_id' : 'id');
+ //we have different naming in in menu_item table and chatroom table
+ switch($type) {
+ case 'menu_item':
+ $id = 'mitem_id';
+ break;
+ case 'chatroom':
+ $id = 'cr_id';
+ break;
+ default:
+ $id = 'id';
+ break;
+ }
$r = q("SELECT * FROM %s WHERE $id = %d LIMIT 1",
dbesc($type),
@@ -30,8 +40,18 @@ function lockview_content(&$a) {
$item = $r[0];
- //we have different naming in in menu_item table
- $uid = (($type == 'menu_item') ? $item['mitem_channel_id'] : $item['uid']);
+ //we have different naming in in menu_item table and chatroom table
+ switch($type) {
+ case 'menu_item':
+ $uid = $item['mitem_channel_id'];
+ break;
+ case 'chatroom':
+ $uid = $item['cr_uid'];
+ break;
+ default:
+ $uid = $item['uid'];
+ break;
+ }
if($uid != local_channel()) {
echo '<li>' . t('Remote privacy information not available.') . '</li>';
diff --git a/mod/locs.php b/mod/locs.php
index 9f66e3263..1daf41b89 100644
--- a/mod/locs.php
+++ b/mod/locs.php
@@ -6,7 +6,7 @@ function locs_post(&$a) {
if(! local_channel())
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if($_REQUEST['primary']) {
$hubloc_id = intval($_REQUEST['primary']);
@@ -84,7 +84,7 @@ function locs_content(&$a) {
return;
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if($_REQUEST['sync']) {
proc_run('php','include/notifier.php','location',$channel['channel_id']);
@@ -110,11 +110,12 @@ function locs_content(&$a) {
$o = replace_macros(get_markup_template('locmanage.tpl'), array(
'$header' => t('Manage Channel Locations'),
- '$loc' => t('Location (address)'),
- '$mkprm' => t('Primary Location'),
- '$drop' => t('Drop location'),
+ '$loc' => t('Location'),
+ '$addr' => t('Address'),
+ '$mkprm' => t('Primary'),
+ '$drop' => t('Drop'),
'$submit' => t('Submit'),
- '$sync' => t('Sync now'),
+ '$sync' => t('Sync Now'),
'$sync_text' => t('Please wait several minutes between consecutive operations.'),
'$drop_text' => t('When possible, drop a location by logging into that website/hub and removing your channel.'),
'$last_resort' => t('Use this form to drop the location if the hub is no longer operating.'),
@@ -122,4 +123,4 @@ function locs_content(&$a) {
));
return $o;
-} \ No newline at end of file
+}
diff --git a/mod/login.php b/mod/login.php
index 12c7d339e..31a4e7fc0 100644
--- a/mod/login.php
+++ b/mod/login.php
@@ -3,5 +3,5 @@
function login_content(&$a) {
if(local_channel())
goaway(z_root());
- return login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? false : true);
+ return login((App::$config['system']['register_policy'] == REGISTER_CLOSED) ? false : true);
}
diff --git a/mod/lostpass.php b/mod/lostpass.php
index 3dbc2fe7d..2ae955983 100644
--- a/mod/lostpass.php
+++ b/mod/lostpass.php
@@ -31,10 +31,10 @@ function lostpass_post(&$a) {
$email_tpl = get_intltext_template("lostpass_eml.tpl");
$message = replace_macros($email_tpl, array(
'$sitename' => get_config('system','sitename'),
- '$siteurl' => $a->get_baseurl(),
+ '$siteurl' => z_root(),
'$username' => sprintf( t('Site Member (%s)'), $email),
'$email' => $email,
- '$reset_link' => $a->get_baseurl() . '/lostpass?verify=' . $hash
+ '$reset_link' => z_root() . '/lostpass?verify=' . $hash
));
$subject = email_header_encode(sprintf( t('Password reset requested at %s'),get_config('system','sitename')), 'UTF-8');
@@ -87,10 +87,10 @@ function lostpass_content(&$a) {
'$lbl2' => t('Your password has been reset as requested.'),
'$lbl3' => t('Your new password is'),
'$lbl4' => t('Save or copy your new password - and then'),
- '$lbl5' => '<a href="' . $a->get_baseurl() . '">' . t('click here to login') . '</a>.',
+ '$lbl5' => '<a href="' . z_root() . '/login">' . t('click here to login') . '</a>.',
'$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'),
'$newpass' => $new_password,
- '$baseurl' => $a->get_baseurl()
+ '$baseurl' => z_root()
));
@@ -98,8 +98,8 @@ function lostpass_content(&$a) {
$email_tpl = get_intltext_template("passchanged_eml.tpl");
$message = replace_macros($email_tpl, array(
- '$sitename' => $a->config['sitename'],
- '$siteurl' => $a->get_baseurl(),
+ '$sitename' => App::$config['sitename'],
+ '$siteurl' => z_root(),
'$username' => sprintf( t('Site Member (%s)'), $email),
'$email' => $email,
'$new_password' => $new_password,
diff --git a/mod/magic.php b/mod/magic.php
index 2fee87241..74adbfd6d 100644
--- a/mod/magic.php
+++ b/mod/magic.php
@@ -105,6 +105,7 @@ function magic_init(&$a) {
$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) {
@@ -112,6 +113,7 @@ function magic_init(&$a) {
$_SESSION['delegate'] = get_observer_hash();
$_SESSION['account_id'] = intval($r[0]['channel_account_id']);
change_channel($r[0]['channel_id']);
+
$delegation_success = true;
}
}
@@ -126,21 +128,17 @@ function magic_init(&$a) {
}
if(local_channel()) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$token = random_string();
$token_sig = base64url_encode(rsa_sign($token,$channel['channel_prvkey']));
$channel['token'] = $token;
$channel['token_sig'] = $token_sig;
- $r = q("insert into verify ( type, channel, token, meta, created) values ('%s','%d','%s','%s','%s')",
- dbesc('auth'),
- intval($channel['channel_id']),
- dbesc($token),
- dbesc($x[0]['hubloc_url']),
- dbesc(datetime_convert())
- );
- $target_url = $x[0]['hubloc_callback'] . '/?f=&auth=' . urlencode($channel['channel_address'] . '@' . $a->get_hostname())
+
+ Zotlabs\Zot\Verify::create('auth',$channel['channel_id'],$token,$x[0]['hubloc_url']);
+
+ $target_url = $x[0]['hubloc_callback'] . '/?f=&auth=' . urlencode($channel['channel_address'] . '@' . App::get_hostname())
. '&sec=' . $token . '&dest=' . urlencode($dest) . '&version=' . ZOT_REVISION;
if($delegate)
diff --git a/mod/mail.php b/mod/mail.php
index 59d15772b..1ab2bc5ab 100644
--- a/mod/mail.php
+++ b/mod/mail.php
@@ -26,7 +26,7 @@ function mail_post(&$a) {
// finger them and find out before we try and send it.
if(! $recipient) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$ret = zot_finger($rstr,$channel);
@@ -96,8 +96,8 @@ function mail_post(&$a) {
if(! $recipient) {
notice('No recipient found.');
- $a->argc = 2;
- $a->argv[1] = 'new';
+ App::$argc = 2;
+ App::$argv[1] = 'new';
return;
}
@@ -127,7 +127,7 @@ function mail_content(&$a) {
return login();
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
head_set_icon($channel['xchan_photo_s']);
@@ -149,7 +149,7 @@ function mail_content(&$a) {
if($r) {
//info( t('Message deleted.') . EOL );
}
- goaway($a->get_baseurl(true) . '/mail/' . $mailbox);
+ goaway(z_root() . '/mail/' . $mailbox);
}
if((argc() == 4) && (argv(2) === 'recall')) {
@@ -174,7 +174,7 @@ function mail_content(&$a) {
if($r) {
info( t('Message recalled.') . EOL );
}
- goaway($a->get_baseurl(true) . '/mail/' . $mailbox . '/' . argv(3));
+ goaway(z_root() . '/mail/' . $mailbox . '/' . argv(3));
}
@@ -186,7 +186,7 @@ function mail_content(&$a) {
$r = private_messages_drop(local_channel(), argv(3), true);
if($r)
info( t('Conversation removed.') . EOL );
- goaway($a->get_baseurl(true) . '/mail/' . $mailbox);
+ goaway(z_root() . '/mail/' . $mailbox);
}
if((argc() > 1) && (argv(1) === 'new')) {
@@ -196,14 +196,14 @@ function mail_content(&$a) {
$tpl = get_markup_template('msg-header.tpl');
$header = replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$nickname' => $channel['channel_address'],
'$linkurl' => t('Please enter a link URL:'),
'$expireswhen' => t('Expires YYYY-MM-DD HH:MM')
));
- $a->page['htmlhead'] .= $header;
+ App::$page['htmlhead'] .= $header;
$prename = '';
$preid = '';
@@ -298,20 +298,20 @@ function mail_content(&$a) {
}
if($messages[0]['to_xchan'] === $channel['channel_hash'])
- $a->poi = $messages[0]['from'];
+ App::$poi = $messages[0]['from'];
else
- $a->poi = $messages[0]['to'];
+ App::$poi = $messages[0]['to'];
// require_once('include/Contact.php');
-// $a->set_widget('mail_conversant',vcard_from_xchan($a->poi,$get_observer_hash,'mail'));
+// App::set_widget('mail_conversant',vcard_from_xchan(App::$poi,$get_observer_hash,'mail'));
$tpl = get_markup_template('msg-header.tpl');
- $a->page['htmlhead'] .= replace_macros($tpl, array(
+ App::$page['htmlhead'] .= replace_macros($tpl, array(
'$nickname' => $channel['channel_address'],
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$linkurl' => t('Please enter a link URL:'),
'$expireswhen' => t('Expires YYYY-MM-DD HH:MM')
diff --git a/mod/manage.php b/mod/manage.php
index b609ede44..5ac3e6af8 100644
--- a/mod/manage.php
+++ b/mod/manage.php
@@ -29,7 +29,7 @@ function manage_content(&$a) {
$r = change_channel($change_channel);
if((argc() > 2) && !(argv(2) === 'default')) {
- goaway(z_root() . '/' . implode('/',array_slice($a->argv,2))); // Go to whatever is after /manage/, but with the new channel
+ goaway(z_root() . '/' . implode('/',array_slice(App::$argv,2))); // Go to whatever is after /manage/, but with the new channel
}
else {
if($r && $r['channel_startpage'])
@@ -45,7 +45,7 @@ function manage_content(&$a) {
intval(get_account_id())
);
- $account = get_app()->get_account();
+ $account = App::get_account();
if($r && count($r)) {
$channels = $r;
@@ -134,9 +134,7 @@ function manage_content(&$a) {
}
}
- $links = array(
- array( 'new_channel', t('Create a new channel'), t('Create a new channel'))
- );
+ $create = array( 'new_channel', t('Create a new channel'), t('Create New'));
$delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where
abook_channel = %d and (abook_their_perms & %d) > 0",
@@ -148,14 +146,14 @@ function manage_content(&$a) {
for($x = 0; $x < count($delegates); $x ++) {
$delegates[$x]['link'] = 'magic?f=&dest=' . urlencode($delegates[$x]['xchan_url'])
. '&delegate=' . urlencode($delegates[$x]['xchan_addr']);
+ $delegates[$x]['channel_name'] = $delegates[$x]['xchan_name'];
+ $delegates[$x]['delegate'] = 1;
}
}
else {
$delegates = null;
}
-
-
$o = replace_macros(get_markup_template('channels.tpl'), array(
'$header' => t('Channel Manager'),
'$msg_selected' => t('Current Channel'),
@@ -163,17 +161,15 @@ function manage_content(&$a) {
'$desc' => t('Switch to one of your channels by selecting it.'),
'$msg_default' => t('Default Channel'),
'$msg_make_default' => t('Make Default'),
- '$links' => $links,
+ '$create' => $create,
'$all_channels' => $channels,
'$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,
-
+ '$delegated_desc' => t('Delegated Channel'),
+ '$delegates' => $delegates
));
-
return $o;
}
diff --git a/mod/match.php b/mod/match.php
index fd739ba2c..f7fc6cebd 100644
--- a/mod/match.php
+++ b/mod/match.php
@@ -17,7 +17,7 @@ function match_content(&$a) {
if (! local_channel())
return;
- $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
+ $_SESSION['return_url'] = z_root() . '/' . App::$cmd;
$o .= '<h2>' . t('Profile Match') . '</h2>';
@@ -37,25 +37,25 @@ function match_content(&$a) {
if ($tags) {
$params['s'] = $tags;
- if ($a->pager['page'] != 1)
- $params['p'] = $a->pager['page'];
+ if (App::$pager['page'] != 1)
+ $params['p'] = App::$pager['page'];
// if(strlen(get_config('system','directory_submit_url')))
// $x = post_url('http://dir.friendica.com/msearch', $params);
// else
-// $x = post_url($a->get_baseurl() . '/msearch', $params);
+// $x = post_url(z_root() . '/msearch', $params);
$j = json_decode($x);
if ($j->total) {
- $a->set_pager_total($j->total);
- $a->set_pager_itemspage($j->items_page);
+ App::set_pager_total($j->total);
+ App::set_pager_itemspage($j->items_page);
}
if (count($j->results)) {
$tpl = get_markup_template('match.tpl');
foreach ($j->results as $jj) {
- $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
+ $connlnk = z_root() . '/follow/?url=' . $jj->url;
$o .= replace_macros($tpl,array(
'$url' => zid($jj->url),
'$name' => $jj->name,
diff --git a/mod/menu.php b/mod/menu.php
index bfc45adef..e11483c2d 100644
--- a/mod/menu.php
+++ b/mod/menu.php
@@ -7,7 +7,7 @@ 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;
+ App::$is_sys = true;
}
}
}
@@ -19,7 +19,7 @@ function menu_post(&$a) {
if(array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) {
$sys = get_sys_channel();
$uid = intval($sys['channel_id']);
- $a->is_sys = true;
+ App::$is_sys = true;
}
if(! $uid)
@@ -39,7 +39,7 @@ function menu_post(&$a) {
if($r) {
menu_sync_packet($uid,get_observer_hash(),$menu_id);
//info( t('Menu updated.') . EOL);
- goaway(z_root() . '/mitem/' . $menu_id . (($a->is_sys) ? '?f=&sys=1' : ''));
+ goaway(z_root() . '/mitem/' . $menu_id . ((App::$is_sys) ? '?f=&sys=1' : ''));
}
else
notice( t('Unable to update menu.'). EOL);
@@ -50,7 +50,7 @@ function menu_post(&$a) {
menu_sync_packet($uid,get_observer_hash(),$r);
//info( t('Menu created.') . EOL);
- goaway(z_root() . '/mitem/' . $r . (($a->is_sys) ? '?f=&sys=1' : ''));
+ goaway(z_root() . '/mitem/' . $r . ((App::$is_sys) ? '?f=&sys=1' : ''));
}
else
notice( t('Unable to create menu.'). EOL);
@@ -65,7 +65,7 @@ function menu_content(&$a) {
$uid = local_channel();
- if ($a->is_sys && is_site_admin()) {
+ if (App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
$uid = intval($sys['channel_id']);
}
@@ -95,7 +95,7 @@ function menu_content(&$a) {
'$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,
+ '$sys' => App::$is_sys,
'$display' => 'none'
));
@@ -115,7 +115,7 @@ function menu_content(&$a) {
'$hintdrop' => t('Delete this menu'),
'$hintcontent' => t('Edit menu contents'),
'$hintedit' => t('Edit this menu'),
- '$sys' => $a->is_sys
+ '$sys' => App::$is_sys
));
return $o;
@@ -131,7 +131,7 @@ function menu_content(&$a) {
if(!$r)
notice( t('Menu could not be deleted.'). EOL);
- goaway(z_root() . '/menu' . (($a->is_sys) ? '?f=&sys=1' : ''));
+ goaway(z_root() . '/menu' . ((App::$is_sys) ? '?f=&sys=1' : ''));
}
$m = menu_fetch_id(intval(argv(1)),$uid);
@@ -143,9 +143,9 @@ function menu_content(&$a) {
$o = replace_macros(get_markup_template('menuedit.tpl'), array(
'$header' => t('Edit Menu'),
- '$sys' => $a->is_sys,
+ '$sys' => App::$is_sys,
'$menu_id' => intval(argv(1)),
- '$menu_edit_link' => 'mitem/' . intval(argv(1)) . (($a->is_sys) ? '?f=&sys=1' : ''),
+ '$menu_edit_link' => 'mitem/' . intval(argv(1)) . ((App::$is_sys) ? '?f=&sys=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'), '*'),
diff --git a/mod/message.php b/mod/message.php
index 73239d2cb..f6d1d020c 100644
--- a/mod/message.php
+++ b/mod/message.php
@@ -17,7 +17,7 @@ function message_content(&$a) {
return login();
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
head_set_icon($channel['xchan_photo_s']);
$cipher = get_pconfig(local_channel(),'system','default_cipher');
@@ -32,7 +32,7 @@ function message_content(&$a) {
$r = private_messages_drop(local_channel(), argv(2), true);
if($r)
info( t('Conversation removed.') . EOL );
- goaway($a->get_baseurl(true) . '/mail/combined' );
+ goaway(z_root() . '/mail/combined' );
}
if(argc() == 2) {
@@ -56,7 +56,7 @@ function message_content(&$a) {
// private_messages_list() can do other more complicated stuff, for now keep it simple
- $r = private_messages_list(local_channel(), $mailbox, $a->pager['start'], $a->pager['itemspage']);
+ $r = private_messages_list(local_channel(), $mailbox, App::$pager['start'], App::$pager['itemspage']);
if(! $r) {
info( t('No messages.') . EOL);
diff --git a/mod/mitem.php b/mod/mitem.php
index d6572bd56..5503e93f6 100644
--- a/mod/mitem.php
+++ b/mod/mitem.php
@@ -10,7 +10,7 @@ function mitem_init(&$a) {
if(array_key_exists('sys',$_REQUEST) && $_REQUEST['sys'] && is_site_admin()) {
$sys = get_sys_channel();
$uid = intval($sys['channel_id']);
- $a->is_sys = true;
+ App::$is_sys = true;
}
if(! $uid)
@@ -24,7 +24,7 @@ function mitem_init(&$a) {
notice( t('Menu not found.') . EOL);
return '';
}
- $a->data['menu'] = $m;
+ App::$data['menu'] = $m;
}
@@ -32,7 +32,7 @@ function mitem_post(&$a) {
$uid = local_channel();
- if($a->is_sys && is_site_admin()) {
+ if(App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
$uid = intval($sys['channel_id']);
}
@@ -41,7 +41,7 @@ function mitem_post(&$a) {
return;
}
- if(! $a->data['menu'])
+ if(! App::$data['menu'])
return;
if(!$_REQUEST['mitem_desc'] || !$_REQUEST['mitem_link']) {
@@ -50,7 +50,7 @@ function mitem_post(&$a) {
}
$_REQUEST['mitem_channel_id'] = $uid;
- $_REQUEST['menu_id'] = $a->data['menu']['menu_id'];
+ $_REQUEST['menu_id'] = App::$data['menu']['menu_id'];
$_REQUEST['mitem_flags'] = 0;
if($_REQUEST['usezid'])
@@ -66,7 +66,7 @@ function mitem_post(&$a) {
if($r) {
menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']);
//info( t('Menu element updated.') . EOL);
- goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . (($a->is_sys) ? '?f=&sys=1' : ''));
+ goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . ((App::$is_sys) ? '?f=&sys=1' : ''));
}
else
notice( t('Unable to update menu element.') . EOL);
@@ -78,10 +78,10 @@ function mitem_post(&$a) {
menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']);
//info( t('Menu element added.') . EOL);
if($_REQUEST['submit']) {
- goaway(z_root() . '/menu' . (($a->is_sys) ? '?f=&sys=1' : ''));
+ goaway(z_root() . '/menu' . ((App::$is_sys) ? '?f=&sys=1' : ''));
}
if($_REQUEST['submit-more']) {
- goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . '?f=&display=block' . (($a->is_sys) ? '&sys=1' : '') );
+ goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . '?f=&display=block' . ((App::$is_sys) ? '&sys=1' : '') );
}
}
else
@@ -95,12 +95,12 @@ function mitem_post(&$a) {
function mitem_content(&$a) {
$uid = local_channel();
- $channel = $a->get_channel();
- $observer = $a->get_observer();
+ $channel = App::get_channel();
+ $observer = App::get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
- if($a->is_sys && is_site_admin()) {
+ if(App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
$uid = intval($sys['channel_id']);
$channel = $sys;
@@ -112,13 +112,13 @@ function mitem_content(&$a) {
return '';
}
- if(argc() < 2 || (! $a->data['menu'])) {
+ if(argc() < 2 || (! App::$data['menu'])) {
notice( t('Not found.') . EOL);
return '';
}
- $m = menu_fetch($a->data['menu']['menu_name'],$uid,$ob_hash);
- $a->data['menu_item'] = $m;
+ $m = menu_fetch(App::$data['menu']['menu_name'],$uid,$ob_hash);
+ App::$data['menu_item'] = $m;
$menu_list = menu_list($uid);
@@ -127,13 +127,13 @@ function mitem_content(&$a) {
$menu_names[] = $menus['menu_name'];
}
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$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(App::$data['menu']['menu_id']),
intval($uid)
);
@@ -145,7 +145,7 @@ function mitem_content(&$a) {
}
$create = replace_macros(get_markup_template('mitemedit.tpl'), array(
- '$menu_id' => $a->data['menu']['menu_id'],
+ '$menu_id' => App::$data['menu']['menu_id'],
'$permissions' => t('Menu Item Permissions'),
'$permdesc' => t("\x28click to open/close\x29"),
'$aclselect' => populate_acl($acl->get(),false),
@@ -159,7 +159,7 @@ function mitem_content(&$a) {
'$display' => $display,
'$lockstate' => $lockstate,
'$menu_names' => $menu_names,
- '$sys' => $a->is_sys
+ '$sys' => App::$is_sys
));
$o .= replace_macros(get_markup_template('mitemlist.tpl'),array(
@@ -167,10 +167,10 @@ function mitem_content(&$a) {
'$create' => $create,
'$nametitle' => t('Link Name'),
'$targettitle' => t('Link Target'),
- '$menuname' => $a->data['menu']['menu_name'],
- '$menudesc' => $a->data['menu']['menu_desc'],
+ '$menuname' => App::$data['menu']['menu_name'],
+ '$menudesc' => App::$data['menu']['menu_desc'],
'$edmenu' => t('Edit menu'),
- '$menu_id' => $a->data['menu']['menu_id'],
+ '$menu_id' => App::$data['menu']['menu_id'],
'$mlist' => $r,
'$edit' => t('Edit element'),
'$drop' => t('Drop element'),
@@ -196,7 +196,7 @@ function mitem_content(&$a) {
if(! $m) {
notice( t('Menu item not found.') . EOL);
- goaway(z_root() . '/menu'. (($a->is_sys) ? '?f=&sys=1' : ''));
+ goaway(z_root() . '/menu'. ((App::$is_sys) ? '?f=&sys=1' : ''));
}
$mitem = $m[0];
@@ -212,13 +212,13 @@ function mitem_content(&$a) {
else
notice( t('Menu item could not be deleted.'). EOL);
- goaway(z_root() . '/mitem/' . $mitem['mitem_menu_id'] . (($a->is_sys) ? '?f=&sys=1' : ''));
+ goaway(z_root() . '/mitem/' . $mitem['mitem_menu_id'] . ((App::$is_sys) ? '?f=&sys=1' : ''));
}
// edit menu item
$o = replace_macros(get_markup_template('mitemedit.tpl'), array(
'$header' => t('Edit Menu Element'),
- '$menu_id' => $a->data['menu']['menu_id'],
+ '$menu_id' => App::$data['menu']['menu_id'],
'$permissions' => t('Menu Item Permissions'),
'$permdesc' => t("\x28click to open/close\x29"),
'$aclselect' => populate_acl($mitem,false),
diff --git a/mod/mood.php b/mod/mood.php
index 92a4f391b..3ded65469 100755
--- a/mod/mood.php
+++ b/mod/mood.php
@@ -11,7 +11,7 @@ function mood_init(&$a) {
return;
$uid = local_channel();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$verb = notags(trim($_GET['verb']));
if(! $verb)
@@ -56,7 +56,7 @@ function mood_init(&$a) {
$deny_gid = $channel['channel_deny_gid'];
}
- $poster = $a->get_observer();
+ $poster = App::get_observer();
$mid = item_message_id();
diff --git a/mod/msearch.php b/mod/msearch.php
index b51c4e097..f94b75910 100644
--- a/mod/msearch.php
+++ b/mod/msearch.php
@@ -27,8 +27,8 @@ function msearch_post(&$a) {
foreach($r as $rr)
$results[] = array(
'name' => $rr['name'],
- 'url' => $a->get_baseurl() . '/channel/' . $rr['nickname'],
- 'photo' => $a->get_baseurl() . '/photo/avatar/' . $rr['uid'],
+ 'url' => z_root() . '/channel/' . $rr['nickname'],
+ 'photo' => z_root() . '/photo/avatar/' . $rr['uid'],
'tags' => str_replace(array(',',' '),array(' ',' '),$rr['keywords'])
);
}
diff --git a/mod/network.php b/mod/network.php
index 9f0604296..e6d02f572 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -13,14 +13,14 @@ function network_init(&$a) {
return;
}
- if((count($_GET) < 2) || (count($_GET) < 3 && $_GET['JS'])) {
+ 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();
+ $channel = App::get_channel();
+ App::$profile_uid = local_channel();
head_set_icon($channel['xchan_photo_s']);
}
@@ -28,18 +28,18 @@ function network_init(&$a) {
function network_content(&$a, $update = 0, $load = false) {
if(! local_channel()) {
- $_SESSION['return_url'] = $a->query_string;
+ $_SESSION['return_url'] = App::$query_string;
return login(false);
}
if($load)
$_SESSION['loadtime'] = datetime_convert();
- $arr = array('query' => $a->query_string);
+ $arr = array('query' => App::$query_string);
call_hooks('network_content_init', $arr);
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$item_normal = item_normal();
$datequery = $datequery2 = '';
@@ -89,7 +89,7 @@ function network_content(&$a, $update = 0, $load = false) {
if($update)
killme();
notice( t('No such group') . EOL );
- goaway($a->get_baseurl(true) . '/network');
+ goaway(z_root() . '/network');
// NOTREACHED
}
@@ -129,7 +129,7 @@ function network_content(&$a, $update = 0, $load = false) {
killme();
}
notice( t('No such channel') . EOL );
- goaway($a->get_baseurl(true) . '/network');
+ goaway(z_root() . '/network');
// NOTREACHED
}
if($_GET['pf'] === '1')
@@ -166,16 +166,21 @@ function network_content(&$a, $update = 0, $load = false) {
'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'],
'lockstate' => (($private_editing || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
- 'acl' => populate_acl((($private_editing) ? $def_acl : $channel_acl)),
+ 'acl' => populate_acl((($private_editing) ? $def_acl : $channel_acl), true, (($channel['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : '')),
'bang' => (($private_editing) ? '!' : ''),
'visitor' => true,
- 'profile_uid' => local_channel()
+ 'profile_uid' => local_channel(),
+ 'editor_autocomplete' => true,
+ 'bbco_autocomplete' => 'bbcode',
+ 'bbcode' => true
);
if($deftag)
$x['pretext'] = $deftag;
+
$status_editor = status_editor($a,$x);
$o .= $status_editor;
+
}
@@ -204,7 +209,7 @@ function network_content(&$a, $update = 0, $load = false) {
}
else {
$contact_str = ' 0 ';
- info( t('Collection is empty'));
+ info( t('Privacy group is empty'));
}
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent $item_normal ) ";
@@ -213,7 +218,7 @@ function network_content(&$a, $update = 0, $load = false) {
if($x) {
$title = replace_macros(get_markup_template("section_title.tpl"),array(
- '$title' => t('Collection: ') . $x['name']
+ '$title' => t('Privacy group: ') . $x['name']
));
}
@@ -240,7 +245,7 @@ function network_content(&$a, $update = 0, $load = false) {
}
else {
notice( t('Invalid connection.') . EOL);
- goaway($a->get_baseurl(true) . '/network');
+ goaway(z_root() . '/network');
}
}
@@ -266,10 +271,10 @@ function network_content(&$a, $update = 0, $load = false) {
$o .= '<div id="live-network"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . local_channel()
- . "; var profile_page = " . $a->pager['page']
+ . "; var profile_page = " . App::$pager['page']
. "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
- $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
+ App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
'$baseurl' => z_root(),
'$pgtype' => 'network',
'$uid' => ((local_channel()) ? local_channel() : '0'),
@@ -285,7 +290,7 @@ function network_content(&$a, $update = 0, $load = false) {
'$nouveau' => (($nouveau) ? $nouveau : '0'),
'$wall' => '0',
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
- '$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1),
+ '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
'$search' => (($search) ? $search : ''),
'$order' => $order,
'$file' => $file,
@@ -346,8 +351,8 @@ function network_content(&$a, $update = 0, $load = false) {
}
else {
$itemspage = get_pconfig(local_channel(),'system','itemspage');
- $a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
- $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
+ App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
}
@@ -378,7 +383,7 @@ function network_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']);
+ App::$data['firehose'] = intval($sys['channel_id']);
}
else {
$uids = " and item.uid = " . local_channel() . " ";
diff --git a/mod/new_channel.php b/mod/new_channel.php
index 047048f0a..f3b63b655 100644
--- a/mod/new_channel.php
+++ b/mod/new_channel.php
@@ -8,7 +8,6 @@ function new_channel_init(&$a) {
$cmd = ((argc() > 1) ? argv(1) : '');
-
if($cmd === 'autofill.json') {
require_once('library/urlify/URLify.php');
$result = array('error' => false, 'message' => '');
@@ -59,12 +58,18 @@ function new_channel_init(&$a) {
}
-
function new_channel_post(&$a) {
$arr = $_POST;
- if(($arr['account_id'] = get_account_id()) === false) {
+ $acc = App::get_account();
+ $arr['account_id'] = get_account_id();
+
+ // prevent execution by delegated channels as well as those not logged in.
+ // get_account_id() returns the account_id from the session. But App::$account
+ // may point to the original authenticated account.
+
+ if((! $acc) || ($acc['account_id'] != $arr['account_id'])) {
notice( t('Permission denied.') . EOL );
return;
}
@@ -87,38 +92,51 @@ function new_channel_post(&$a) {
}
+function new_channel_content(&$a) {
+ $acc = App::get_account();
+ if((! $acc) || $acc['account_id'] != get_account_id()) {
+ notice( t('Permission denied.') . EOL);
+ return;
+ }
+ $default_role = '';
+ $aid = get_account_id();
+ if($aid) {
+ $r = q("select count(channel_id) as total from channel where channel_account_id = %d",
+ intval($aid)
+ );
+ if($r && (! intval($r[0]['total']))) {
+ $default_role = get_config('system','default_permissions_role');
+ }
+ $limit = account_service_class_fetch(get_account_id(),'total_identities');
-
-function new_channel_content(&$a) {
-
- if(! get_account_id()) {
- notice( t('Permission denied.') . EOL);
- return;
+ if($r && ($limit !== false)) {
+ $channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit);
+ }
+ else {
+ $channel_usage_message = '';
+ }
}
- $name = ((x($_REQUEST,'name')) ? $_REQUEST['name'] : "" );
- $nickname = ((x($_REQUEST,'nickname')) ? $_REQUEST['nickname'] : "" );
+ $name = array('name', t('Name or caption'), ((x($_REQUEST,'name')) ? $_REQUEST['name'] : ''), t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group"'));
+ $nickhub = '@' . App::get_hostname();
+ $nickname = array('nickname', t('Choose a short nickname'), ((x($_REQUEST,'nickname')) ? $_REQUEST['nickname'] : ''), sprintf( t('Your nickname will be used to create an easy to remember channel address e.g. nickname%s'), $nickhub));
$privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : "" );
+ $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel role with your privacy requirements.') . ' <a href="help/roles" target="_blank">' . t('Read more about roles') . '</a>',get_roles());
$o = replace_macros(get_markup_template('new_channel.tpl'), array(
-
- '$title' => t('Add a Channel'),
- '$desc' => t('A channel is your own collection of related web pages. A channel can be used to hold social network profiles, blogs, conversation groups and forums, celebrity pages, and much more. You may create as many channels as your service provider allows.'),
-
- '$label_name' => t('Channel Name'),
- '$help_name' => t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group" '),
- '$label_nick' => t('Choose a short nickname'),
- '$nick_desc' => t('Your nickname will be used to create an easily remembered channel address (like an email address) which you can share with others.'),
- '$label_import' => t('Or <a href="import">import an existing channel</a> from another location'),
+ '$title' => t('Create Channel'),
+ '$desc' => t('A channel is your identity on this network. It can represent a person, a blog, or a forum to name a few. Channels can make connections with other channels to share information with highly detailed permissions.'),
+ '$label_import' => t('or <a href="import">import an existing channel</a> from another location.'),
'$name' => $name,
- '$help_role' => t('Please choose a channel type (such as social networking or community forum) and privacy requirements so we can select the best permissions for you'),
- '$role' => array('permissions_role' , t('Channel Type'), ($privacy_role) ? $privacy_role : 'social', '<a href="help/roles" target="_blank">'.t('Read more about roles').'</a>',get_roles()),
+ '$role' => $role,
+ '$default_role' => $default_role,
'$nickname' => $nickname,
- '$submit' => t('Create')
+ '$submit' => t('Create'),
+ '$channel_usage_message' => $channel_usage_message
));
return $o;
diff --git a/mod/nojs.php b/mod/nojs.php
new file mode 100644
index 000000000..c6e04a72b
--- /dev/null
+++ b/mod/nojs.php
@@ -0,0 +1,10 @@
+<?php
+
+function nojs_init(&$a) {
+
+ setcookie('jsdisabled', 1, 0);
+ $p = $_GET['query'];
+ $hasq = strpos($p,'?');
+ goaway(z_root() . (($p) ? '/' . $p : '') . (($hasq) ? '' : '?f=' ) . '&jsdisabled=1');
+
+} \ No newline at end of file
diff --git a/mod/notes.php b/mod/notes.php
index 4bb97fc9e..9bf37d0f9 100644
--- a/mod/notes.php
+++ b/mod/notes.php
@@ -6,8 +6,18 @@ function notes_init(&$a) {
return;
$ret = array('success' => true);
- if($_REQUEST['note_text'] || $_REQUEST['note_text'] == '') {
+ if(array_key_exists('note_text',$_REQUEST)) {
$body = escape_tags($_REQUEST['note_text']);
+
+ // I've had my notes vanish into thin air twice in four years.
+ // Provide a backup copy if there were contents previously
+ // and there are none being saved now.
+
+ if(! $body) {
+ $old_text = get_pconfig(local_channel(),'notes','text');
+ if($old_text)
+ set_pconfig(local_channel(),'notes','text.bak',$old_text);
+ }
set_pconfig(local_channel(),'notes','text',$body);
}
diff --git a/mod/notifications.php b/mod/notifications.php
index f679fbb3b..45eb6483b 100644
--- a/mod/notifications.php
+++ b/mod/notifications.php
@@ -6,7 +6,7 @@ function notifications_post(&$a) {
goaway(z_root());
}
- $request_id = (($a->argc > 1) ? $a->argv[1] : 0);
+ $request_id = ((App::$argc > 1) ? App::$argv[1] : 0);
if($request_id === "all")
return;
@@ -46,12 +46,12 @@ function notifications_post(&$a) {
intval(local_channel())
);
}
- goaway($a->get_baseurl(true) . '/notifications/intros');
+ goaway(z_root() . '/notifications/intros');
}
if($_POST['submit'] == t('Ignore')) {
$r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d",
intval($intro_id));
- goaway($a->get_baseurl(true) . '/notifications/intros');
+ goaway(z_root() . '/notifications/intros');
}
}
}
@@ -84,7 +84,7 @@ function notifications_content(&$a) {
$notifications_available =1;
foreach ($r as $it) {
$notif_content .= replace_macros($not_tpl,array(
- '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
+ '$item_link' => z_root().'/notify/view/'. $it['id'],
'$item_image' => $it['photo'],
'$item_text' => strip_tags(bbcode($it['msg'])),
'$item_when' => relative_date($it['date'])
diff --git a/mod/notify.php b/mod/notify.php
index 4c9d1977b..d56871880 100644
--- a/mod/notify.php
+++ b/mod/notify.php
@@ -19,7 +19,7 @@ function notify_init(&$a) {
);
goaway($r[0]['link']);
}
- goaway($a->get_baseurl(true));
+ goaway(z_root());
}
@@ -42,7 +42,7 @@ function notify_content(&$a) {
if($r) {
foreach ($r as $it) {
$notif_content .= replace_macros($not_tpl,array(
- '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
+ '$item_link' => z_root().'/notify/view/'. $it['id'],
'$item_image' => $it['photo'],
'$item_text' => strip_tags(bbcode($it['msg'])),
'$item_when' => relative_date($it['date'])
diff --git a/mod/oembed.php b/mod/oembed.php
index d4a4424f5..a3ac8672d 100644
--- a/mod/oembed.php
+++ b/mod/oembed.php
@@ -2,7 +2,7 @@
require_once("include/oembed.php");
function oembed_init(&$a){
- // logger('mod_oembed ' . $a->query_string, LOGGER_ALL);
+ // logger('mod_oembed ' . App::$query_string, LOGGER_ALL);
if(argc() > 1) {
if (argv(1) == 'b2h'){
diff --git a/mod/oep.php b/mod/oep.php
new file mode 100644
index 000000000..36741a752
--- /dev/null
+++ b/mod/oep.php
@@ -0,0 +1,398 @@
+<?php
+
+// oembed provider
+
+
+
+function oep_init(&$a) {
+
+ logger('oep: ' . print_r($_REQUEST,true), LOGGER_DEBUG, LOG_INFO);
+
+ $html = ((argc() > 1 && argv(1) === 'html') ? true : false);
+ if($_REQUEST['url']) {
+ $_REQUEST['url'] = strip_zids($_REQUEST['url']);
+ $url = $_REQUEST['url'];
+ }
+
+ if(! $url)
+ http_status_exit(404, 'Not found');
+
+ $maxwidth = $_REQUEST['maxwidth'];
+ $maxheight = $_REQUEST['maxheight'];
+ $format = $_REQUEST['format'];
+ if($format && $format !== 'json')
+ http_status_exit(501, 'Not implemented');
+
+ if(fnmatch('*/photos/*/album/*',$url))
+ $arr = oep_album_reply($_REQUEST);
+ elseif(fnmatch('*/photos/*/image/*',$url))
+ $arr = oep_photo_reply($_REQUEST);
+ elseif(fnmatch('*/photos*',$url))
+ $arr = oep_phototop_reply($_REQUEST);
+ elseif(fnmatch('*/display/*',$url))
+ $arr = oep_display_reply($_REQUEST);
+ elseif(fnmatch('*/channel/*mid=*',$url))
+ $arr = oep_mid_reply($_REQUEST);
+ elseif(fnmatch('*/channel*',$url))
+ $arr = oep_profile_reply($_REQUEST);
+ elseif(fnmatch('*/profile/*',$url))
+ $arr = oep_profile_reply($_REQUEST);
+
+ if($arr) {
+ if($html) {
+ if($arr['type'] === 'rich') {
+ header('Content-Type: text/html');
+ echo $arr['html'];
+ }
+ }
+ else {
+ header('Content-Type: application/json+oembed');
+ echo json_encode($arr);
+ }
+ killme();
+ }
+
+ http_status_exit(404,'Not found');
+
+}
+
+function oep_display_reply($args) {
+
+ $ret = array();
+ $url = $args['url'];
+ $maxwidth = intval($args['maxwidth']);
+ $maxheight = intval($args['maxheight']);
+
+ if(preg_match('#//(.*?)/(.*?)/(.*?)/(.*?)mid\=(.*?)(&|$)#',$url,$matches)) {
+ $chn = $matches[3];
+ $res = $matches[5];
+ }
+
+ if(! ($chn && $res))
+ return;
+ $c = q("select * from channel where channel_address = '%s' limit 1",
+ dbesc($chn)
+ );
+
+ if(! $c)
+ return;
+
+ $sql_extra = item_permissions_sql($c[0]['channel_id']);
+
+ $p = q("select * from item where mid = '%s' and uid = %d $sql_extra limit 1",
+ dbesc($res),
+ intval($c[0]['channel_id'])
+ );
+ if(! $p)
+ return;
+
+ xchan_query($p,true);
+ $p = fetch_post_tags($p,true);
+
+ $o = "[share author='".urlencode($p[0]['author']['xchan_name']).
+ "' profile='".$p[0]['author']['xchan_url'] .
+ "' avatar='".$p[0]['author']['xchan_photo_s'].
+ "' link='".$p[0]['plink'].
+ "' posted='".$p[0]['created'].
+ "' message_id='".$p[0]['mid']."']";
+ if($p[0]['title'])
+ $o .= '[b]'.$p[0]['title'].'[/b]'."\r\n";
+ $o .= $p[0]['body'];
+ $o .= "[/share]";
+ $o = bbcode($o);
+
+ $ret['type'] = 'rich';
+
+ $w = (($maxwidth) ? $maxwidth : 640);
+ $h = (($maxheight) ? $maxheight : $w * 2 / 3);
+
+ $ret['html'] = '<div style="width: ' . $w . '; height: ' . $h . '; font-family: sans-serif,arial,freesans;" >' . $o . '</div>';
+
+ $ret['width'] = $w;
+ $ret['height'] = $h;
+
+ return $ret;
+
+}
+
+function oep_mid_reply($args) {
+
+ $ret = array();
+ $url = $args['url'];
+ $maxwidth = intval($args['maxwidth']);
+ $maxheight = intval($args['maxheight']);
+
+ if(preg_match('#//(.*?)/(.*?)/(.*?)/(.*?)mid\=(.*?)(&|$)#',$url,$matches)) {
+ $chn = $matches[3];
+ $res = $matches[5];
+ }
+
+ if(! ($chn && $res))
+ return;
+ $c = q("select * from channel where channel_address = '%s' limit 1",
+ dbesc($chn)
+ );
+
+ if(! $c)
+ return;
+
+ $sql_extra = item_permissions_sql($c[0]['channel_id']);
+
+ $p = q("select * from item where mid = '%s' and uid = %d $sql_extra limit 1",
+ dbesc($res),
+ intval($c[0]['channel_id'])
+ );
+ if(! $p)
+ return;
+
+ xchan_query($p,true);
+ $p = fetch_post_tags($p,true);
+
+ $o = "[share author='".urlencode($p[0]['author']['xchan_name']).
+ "' profile='".$p[0]['author']['xchan_url'] .
+ "' avatar='".$p[0]['author']['xchan_photo_s'].
+ "' link='".$p[0]['plink'].
+ "' posted='".$p[0]['created'].
+ "' message_id='".$p[0]['mid']."']";
+ if($p[0]['title'])
+ $o .= '[b]'.$p[0]['title'].'[/b]'."\r\n";
+ $o .= $p[0]['body'];
+ $o .= "[/share]";
+ $o = bbcode($o);
+
+ $ret['type'] = 'rich';
+
+ $w = (($maxwidth) ? $maxwidth : 640);
+ $h = (($maxheight) ? $maxheight : $w * 2 / 3);
+
+ $ret['html'] = '<div style="width: ' . $w . '; height: ' . $h . '; font-family: sans-serif,arial,freesans;" >' . $o . '</div>';
+
+ $ret['width'] = $w;
+ $ret['height'] = $h;
+
+ return $ret;
+
+}
+
+function oep_profile_reply($args) {
+
+
+ require_once('include/identity.php');
+ require_once('include/Contact.php');
+ $url = $args['url'];
+
+ if(preg_match('#//(.*?)/(.*?)/(.*?)(/|\?|&|$)#',$url,$matches)) {
+ $chn = $matches[3];
+ }
+
+ if(! $chn)
+ return;
+
+ $c = channelx_by_nick($chn);
+
+ if(! $c)
+ return;
+
+
+ $maxwidth = intval($args['maxwidth']);
+ $maxheight = intval($args['maxheight']);
+
+ $width = 800;
+ $height = 375;
+
+ if($maxwidth) {
+ $width = $maxwidth;
+ $height = (375 / 800) * $width;
+ }
+ if($maxheight) {
+ if($maxheight < $height) {
+ $width = (800 / 375) * $maxheight;
+ $height = $maxheight;
+ }
+ }
+ $ret = array();
+
+ $ret['type'] = 'rich';
+ $ret['width'] = intval($width);
+ $ret['height'] = intval($height);
+
+ $ret['html'] = get_zcard($c,get_observer_hash(),array('width' => $width, 'height' => $height));
+
+ return $ret;
+
+}
+
+function oep_album_reply($args) {
+
+ $ret = array();
+ $url = $args['url'];
+ $maxwidth = intval($args['maxwidth']);
+ $maxheight = intval($args['maxheight']);
+
+ if(preg_match('|//(.*?)/(.*?)/(.*?)/album/|',$url,$matches)) {
+ $chn = $matches[3];
+ $res = hex2bin(basename($url));
+ }
+
+ if(! ($chn && $res))
+ return;
+ $c = q("select * from channel where channel_address = '%s' limit 1",
+ dbesc($chn)
+ );
+
+ if(! $c)
+ return;
+
+ $sql_extra = permissions_sql($c[0]['channel_id']);
+
+ $p = q("select resource_id from photo where album = '%s' and uid = %d and scale = 0 $sql_extra order by created desc limit 1",
+ dbesc($res),
+ intval($c[0]['channel_id'])
+ );
+ if(! $p)
+ return;
+
+ $res = $p[0]['resource_id'];
+
+ $r = q("select height, width, scale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by scale asc",
+ intval($c[0]['channel_id']),
+ dbesc($res)
+ );
+
+ if($r) {
+ foreach($r as $rr) {
+ $foundres = false;
+ if($maxheight && $rr['height'] > $maxheight)
+ continue;
+ if($maxwidth && $rr['width'] > $maxwidth)
+ continue;
+ $foundres = true;
+ break;
+ }
+
+ if($foundres) {
+ $ret['type'] = 'link';
+ $ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['scale'];
+ $ret['thumbnail_width'] = $rr['width'];
+ $ret['thumbnail_height'] = $rr['height'];
+ }
+
+
+ }
+ return $ret;
+
+}
+
+
+function oep_phototop_reply($args) {
+
+ $ret = array();
+ $url = $args['url'];
+ $maxwidth = intval($args['maxwidth']);
+ $maxheight = intval($args['maxheight']);
+
+ if(preg_match('|//(.*?)/(.*?)/(.*?)$|',$url,$matches)) {
+ $chn = $matches[3];
+ }
+
+ if(! $chn)
+ return;
+ $c = q("select * from channel where channel_address = '%s' limit 1",
+ dbesc($chn)
+ );
+
+ if(! $c)
+ return;
+
+ $sql_extra = permissions_sql($c[0]['channel_id']);
+
+ $p = q("select resource_id from photo where uid = %d and scale = 0 $sql_extra order by created desc limit 1",
+ intval($c[0]['channel_id'])
+ );
+ if(! $p)
+ return;
+
+ $res = $p[0]['resource_id'];
+
+ $r = q("select height, width, scale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by scale asc",
+ intval($c[0]['channel_id']),
+ dbesc($res)
+ );
+
+ if($r) {
+ foreach($r as $rr) {
+ $foundres = false;
+ if($maxheight && $rr['height'] > $maxheight)
+ continue;
+ if($maxwidth && $rr['width'] > $maxwidth)
+ continue;
+ $foundres = true;
+ break;
+ }
+
+ if($foundres) {
+ $ret['type'] = 'link';
+ $ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['scale'];
+ $ret['thumbnail_width'] = $rr['width'];
+ $ret['thumbnail_height'] = $rr['height'];
+ }
+
+
+ }
+ return $ret;
+
+}
+
+
+function oep_photo_reply($args) {
+
+ $ret = array();
+ $url = $args['url'];
+ $maxwidth = intval($args['maxwidth']);
+ $maxheight = intval($args['maxheight']);
+
+ if(preg_match('|//(.*?)/(.*?)/(.*?)/image/|',$url,$matches)) {
+ $chn = $matches[3];
+ $res = basename($url);
+ }
+
+ if(! ($chn && $res))
+ return;
+ $c = q("select * from channel where channel_address = '%s' limit 1",
+ dbesc($chn)
+ );
+
+ if(! $c)
+ return;
+
+ $sql_extra = permissions_sql($c[0]['channel_id']);
+
+
+ $r = q("select height, width, scale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by scale asc",
+ intval($c[0]['channel_id']),
+ dbesc($res)
+ );
+
+ if($r) {
+ foreach($r as $rr) {
+ $foundres = false;
+ if($maxheight && $rr['height'] > $maxheight)
+ continue;
+ if($maxwidth && $rr['width'] > $maxwidth)
+ continue;
+ $foundres = true;
+ break;
+ }
+
+ if($foundres) {
+ $ret['type'] = 'link';
+ $ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['scale'];
+ $ret['thumbnail_width'] = $rr['width'];
+ $ret['thumbnail_height'] = $rr['height'];
+ }
+
+
+ }
+ return $ret;
+
+} \ No newline at end of file
diff --git a/mod/oexchange.php b/mod/oexchange.php
index 867cea6f2..342b8c3cd 100644
--- a/mod/oexchange.php
+++ b/mod/oexchange.php
@@ -6,7 +6,7 @@ function oexchange_init(&$a) {
if((argc() > 1) && (argv(1) === 'xrd')) {
$tpl = get_markup_template('oexchange_xrd.tpl');
- $o = replace_macros($tpl, array('$base' => $a->get_baseurl()));
+ $o = replace_macros($tpl, array('$base' => z_root()));
echo $o;
killme();
}
@@ -16,7 +16,7 @@ function oexchange_content(&$a) {
if(! local_channel()) {
if(remote_channel()) {
- $observer = $a->get_observer();
+ $observer = App::get_observer();
if($observer && $observer['xchan_url']) {
$parsed = @parse_url($observer['xchan_url']);
if(! $parsed) {
@@ -47,7 +47,7 @@ function oexchange_content(&$a) {
$tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags']))
? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
- $ret = z_fetch_url($a->get_baseurl() . '/urlinfo?f=&url=' . $url . $title . $description . $tags);
+ $ret = z_fetch_url(z_root() . '/urlinfo?f=&url=' . $url . $title . $description . $tags);
if($ret['success'])
$s = $ret['body'];
diff --git a/mod/openid.php b/mod/openid.php
index b9ca672a9..1ca1ba91e 100644
--- a/mod/openid.php
+++ b/mod/openid.php
@@ -66,9 +66,9 @@ function openid_content(&$a) {
$_SESSION['my_address'] = $r[0]['xchan_addr'];
$arr = array('xchan' => $r[0], 'session' => $_SESSION);
call_hooks('magic_auth_openid_success',$arr);
- $a->set_observer($r[0]);
+ App::set_observer($r[0]);
require_once('include/security.php');
- $a->set_groups(init_groups_visitor($_SESSION['visitor_id']));
+ App::set_groups(init_groups_visitor($_SESSION['visitor_id']));
info(sprintf( t('Welcome %s. Remote authentication successful.'),$r[0]['xchan_name']));
logger('mod_openid: remote auth success from ' . $r[0]['xchan_addr']);
if($_SESSION['return_url'])
@@ -175,7 +175,7 @@ function openid_content(&$a) {
$_SESSION['my_address'] = $r[0]['xchan_addr'];
$arr = array('xchan' => $r[0], 'session' => $_SESSION);
call_hooks('magic_auth_openid_success',$arr);
- $a->set_observer($r[0]);
+ App::set_observer($r[0]);
info(sprintf( t('Welcome %s. Remote authentication successful.'),$r[0]['xchan_name']));
logger('mod_openid: remote auth success from ' . $r[0]['xchan_addr']);
if($_SESSION['return_url'])
diff --git a/mod/opensearch.php b/mod/opensearch.php
index d28c4f1b8..19f7985c5 100644
--- a/mod/opensearch.php
+++ b/mod/opensearch.php
@@ -7,8 +7,8 @@ function opensearch_init(&$a) {
header("Content-type: application/opensearchdescription+xml");
$o = replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
- '$nodename' => $a->get_hostname(),
+ '$baseurl' => z_root(),
+ '$nodename' => App::get_hostname(),
));
echo $o;
diff --git a/mod/page.php b/mod/page.php
index ae572ca1e..c7b827e4d 100644
--- a/mod/page.php
+++ b/mod/page.php
@@ -13,21 +13,21 @@ function page_init(&$a) {
- if($a->profile['profile_uid'])
- head_set_icon($a->profile['thumb']);
+ if(App::$profile['profile_uid'])
+ head_set_icon(App::$profile['thumb']);
// load the item here in the init function because we need to extract
// the page layout and initialise the correct theme.
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
// perm_is_allowed is denied unconditionally when 'site blocked to unauthenticated members'.
// This bypasses that restriction for sys channel (public) content
- if((! perm_is_allowed($a->profile['profile_uid'],$ob_hash,'view_pages')) && (! is_sys_channel($a->profile['profile_uid']))) {
+ if((! perm_is_allowed(App::$profile['profile_uid'],$ob_hash,'view_pages')) && (! is_sys_channel(App::$profile['profile_uid']))) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -91,10 +91,13 @@ function page_init(&$a) {
return;
}
+ if($r[0]['title'])
+ App::$page['title'] = escape_tags($r[0]['title']);
+
if($r[0]['item_type'] == ITEM_TYPE_PDL) {
require_once('include/comanche.php');
comanche_parser(get_app(),$r[0]['body']);
- get_app()->pdl = $r[0]['body'];
+ App::$pdl = $r[0]['body'];
}
elseif($r[0]['layout_mid']) {
$l = q("select body from item where mid = '%s' and uid = %d limit 1",
@@ -105,11 +108,11 @@ function page_init(&$a) {
if($l) {
require_once('include/comanche.php');
comanche_parser(get_app(),$l[0]['body']);
- get_app()->pdl = $l[0]['body'];
+ App::$pdl = $l[0]['body'];
}
}
- $a->data['webpage'] = $r;
+ App::$data['webpage'] = $r;
}
@@ -118,7 +121,7 @@ function page_init(&$a) {
function page_content(&$a) {
- $r = $a->data['webpage'];
+ $r = App::$data['webpage'];
if(! $r)
return;
@@ -133,7 +136,7 @@ function page_content(&$a) {
$r = fetch_post_tags($r,true);
if($r[0]['mimetype'] === 'application/x-pdl')
- $a->page['pdl_content'] = true;
+ App::$page['pdl_content'] = true;
$o .= prepare_page($r[0]);
return $o;
diff --git a/mod/pconfig.php b/mod/pconfig.php
index 413dd2911..64fc1271c 100755
--- a/mod/pconfig.php
+++ b/mod/pconfig.php
@@ -68,7 +68,7 @@ function pconfig_content(&$a) {
if(argc() == 2) {
$content .= '<a href="pconfig">pconfig[' . local_channel() . ']</a>' . EOL;
load_pconfig(local_channel(),escape_tags(argv(1)));
- foreach($a->config[local_channel()][escape_tags(argv(1))] as $k => $x) {
+ foreach(App::$config[local_channel()][escape_tags(argv(1))] as $k => $x) {
$content .= '<a href="pconfig/' . escape_tags(argv(1)) . '/' . $k . '" >pconfig[' . local_channel() . '][' . escape_tags(argv(1)) . '][' . $k . ']</a> = ' . escape_tags($x) . EOL;
}
}
diff --git a/mod/pdledit.php b/mod/pdledit.php
index 93b8d52e6..bf29b2da0 100644
--- a/mod/pdledit.php
+++ b/mod/pdledit.php
@@ -10,6 +10,7 @@ function pdledit_post(&$a) {
goaway(z_root() . '/pdledit/' . $_REQUEST['module']);
}
set_pconfig(local_channel(),'system','mod_' . $_REQUEST['module'] . '.pdl',escape_tags($_REQUEST['content']));
+ build_sync_packet();
info( t('Layout updated.') . EOL);
goaway(z_root() . '/pdledit/' . $_REQUEST['module']);
}
@@ -25,6 +26,7 @@ function pdledit_content(&$a) {
if(argc() > 1)
$module = 'mod_' . argv(1) . '.pdl';
else {
+ $o .= '<div class="generic-content-wrapper-styled">';
$o .= '<h1>' . t('Edit System Page Description') . '</h1>';
$files = glob('mod/*');
if($files) {
@@ -37,6 +39,8 @@ function pdledit_content(&$a) {
}
}
+ $o .= '</div>';
+
// list module pdl files
return $o;
}
diff --git a/mod/photo.php b/mod/photo.php
index e8cd95f1c..93c6efa95 100644
--- a/mod/photo.php
+++ b/mod/photo.php
@@ -156,8 +156,8 @@ function photo_init(&$a) {
);
if($r) {
- logger('mod_photo: forbidden. ' . $a->query_string);
- $observer = $a->get_observer();
+ logger('mod_photo: forbidden. ' . App::$query_string);
+ $observer = App::get_observer();
logger('mod_photo: observer = ' . (($observer) ? $observer['xchan_addr'] : '(not authenticated)'));
$data = file_get_contents('images/nosign.png');
$mimetype = 'image/png';
diff --git a/mod/photos.php b/mod/photos.php
index b0d9bc631..bf904db22 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -29,16 +29,16 @@ function photos_init(&$a) {
if(! $channelx)
return;
- $a->data['channel'] = $channelx;
+ App::$data['channel'] = $channelx;
- $observer = $a->get_observer();
- $a->data['observer'] = $observer;
+ $observer = App::get_observer();
+ App::$data['observer'] = $observer;
$observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
- head_set_icon($a->data['channel']['xchan_photo_s']);
+ head_set_icon(App::$data['channel']['xchan_photo_s']);
- $a->page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "'; var profile_uid = " . (($a->data['channel']) ? $a->data['channel']['channel_id'] : 0) . "; </script>" ;
+ App::$page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "'; var profile_uid = " . ((App::$data['channel']) ? App::$data['channel']['channel_id'] : 0) . "; </script>" ;
}
@@ -61,7 +61,7 @@ function photos_post(&$a) {
$can_post = false;
- $page_owner_uid = $a->data['channel']['channel_id'];
+ $page_owner_uid = App::$data['channel']['channel_id'];
if(perm_is_allowed($page_owner_uid,get_observer_hash(),'write_storage'))
$can_post = true;
@@ -85,7 +85,7 @@ function photos_post(&$a) {
$owner_record = $s[0];
- $acl = new AccessList($a->data['channel']);
+ $acl = new Zotlabs\Access\AccessList(App::$data['channel']);
if((argc() > 3) && (argv(2) === 'album')) {
@@ -93,12 +93,12 @@ function photos_post(&$a) {
if($album === t('Profile Photos')) {
// not allowed
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
}
if(! photos_album_exists($page_owner_uid,$album)) {
notice( t('Album not found.') . EOL);
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
}
@@ -111,12 +111,12 @@ function photos_post(&$a) {
// @fixme - syncronise with DAV or disallow completely
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
// $x = photos_album_rename($page_owner_uid,$album,$newalbum);
// if($x) {
// $newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
-// goaway($a->get_baseurl() . '/' . $newurl);
+// goaway(z_root() . '/' . $newurl);
// }
}
@@ -126,6 +126,34 @@ function photos_post(&$a) {
if($_REQUEST['dropalbum'] == t('Delete Album')) {
+
+ // This is dangerous because we combined file storage and photos into one interface
+ // This function will remove all photos from any directory with the same name since
+ // we have not passed the path value.
+
+ // The correct solution would be to use a full pathname from your storage root for 'album'
+ // We also need to prevent/block removing the storage root folder.
+
+ $folder_hash = '';
+
+ $r = q("select * from attach where is_dir = 1 and uid = %d and filename = '%s'",
+ intval($page_owner_uid),
+ dbesc($album)
+ );
+ if(! $r) {
+ notice( t('Album not found.') . EOL);
+ return;
+ }
+ if(count($r) > 1) {
+ notice( t('Multiple storage folders exist with this album name, but within different directories. Please remove the desired folder or folders using the Files manager') . EOL);
+ return;
+ }
+ else {
+ $folder_hash = $r[0]['hash'];
+ }
+
+
+
$res = array();
// get the list of photos we are about to delete
@@ -140,7 +168,7 @@ function photos_post(&$a) {
$str = null;
}
if(! $str) {
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
}
$r = q("select id from item where resource_id in ( $str ) and resource_type = 'photo' and uid = %d " . item_normal(),
@@ -149,9 +177,6 @@ function photos_post(&$a) {
if($r) {
foreach($r as $i) {
attach_delete($page_owner_uid, $i['resource_id'], 1 );
- // This is now being done in attach_delete()
- // drop_item($i['id'],false,DROPITEM_PHASE1,true /* force removal of linked items */);
- // proc_run('php','include/notifier.php','drop',$i['id']);
}
}
@@ -163,9 +188,18 @@ function photos_post(&$a) {
// @FIXME do the same for the linked attach
+ if($folder_hash) {
+ attach_delete($page_owner_uid,$folder_hash, 1);
+
+ $sync = attach_export_data(App::$data['channel'],$folder_hash, true);
+
+ if($sync)
+ build_sync_packet($page_owner_uid,array('file' => array($sync)));
+ }
+
}
- goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address']);
+ goaway(z_root() . '/photos/' . App::$data['channel']['channel_address']);
}
if((argc() > 2) && (x($_REQUEST,'delete')) && ($_REQUEST['delete'] === t('Delete Photo'))) {
@@ -174,39 +208,27 @@ function photos_post(&$a) {
$ob_hash = get_observer_hash();
if(! $ob_hash)
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
$r = q("SELECT `id`, `resource_id` FROM `photo` WHERE ( xchan = '%s' or `uid` = %d ) AND `resource_id` = '%s' LIMIT 1",
dbesc($ob_hash),
intval(local_channel()),
- dbesc($a->argv[2])
+ dbesc(App::$argv[2])
);
if($r) {
-/*
- q("DELETE FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s'",
- intval($page_owner_uid),
- dbesc($r[0]['resource_id'])
- );
-*/
attach_delete($page_owner_uid, $r[0]['resource_id'], 1 );
-/*
- $i = q("SELECT * FROM `item` WHERE `resource_id` = '%s' AND resource_type = 'photo' and `uid` = %d LIMIT 1",
- dbesc($r[0]['resource_id']),
- intval($page_owner_uid)
- );
- if(count($i)) {
- drop_item($i[0]['id'],true,DROPITEM_PHASE1);
- $url = $a->get_baseurl();
- }
-*/
+ $sync = attach_export_data(App::$data['channel'],$r[0]['resource_id'], true);
+
+ if($sync)
+ build_sync_packet($page_owner_uid,array('file' => array($sync)));
}
- goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']);
+ goaway(z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']);
}
- if(($a->argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
+ if((App::$argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
$desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : '');
@@ -218,7 +240,7 @@ function photos_post(&$a) {
$acl->set_from_array($_POST);
$perm = $acl->get();
- $resource_id = $a->argv[2];
+ $resource_id = argv(2);
if(! strlen($albname))
$albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
@@ -349,7 +371,7 @@ function photos_post(&$a) {
$visibility = 1;
if(! $item_id) {
- $item_id = photos_create_item($a->data['channel'],get_observer_hash(),$p[0],$visibility);
+ $item_id = photos_create_item(App::$data['channel'],get_observer_hash(),$p[0],$visibility);
}
@@ -401,7 +423,7 @@ function photos_post(&$a) {
$rawtags = '@' . $rawtags;
require_once('include/text.php');
- $profile_uid = $a->profile['profile_uid'];
+ $profile_uid = App::$profile['profile_uid'];
$results = linkify_tags($a, $rawtags, (local_channel()) ? local_channel() : $profile_uid);
@@ -440,9 +462,14 @@ function photos_post(&$a) {
}
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
return; // NOTREACHED
+ $sync = attach_export_data(App::$data['channel'],$resource_id);
+
+ if($sync)
+ build_sync_packet($page_owner_uid,array('file' => array($sync)));
+
}
@@ -450,8 +477,8 @@ function photos_post(&$a) {
* default post action - upload a photo
*/
- $channel = $a->data['channel'];
- $observer = $a->data['observer'];
+ $channel = App::$data['channel'];
+ $observer = App::$data['observer'];
$_REQUEST['source'] = 'photos';
require_once('include/attach.php');
@@ -463,16 +490,16 @@ function photos_post(&$a) {
$_REQUEST['group_deny'] = expand_acl($channel['channel_deny_gid']);
}
- $r = attach_store($a->channel,get_observer_hash(), '', $_REQUEST);
+ $r = attach_store($channel,get_observer_hash(), '', $_REQUEST);
if(! $r['success']) {
notice($r['message'] . EOL);
}
if($_REQUEST['newalbum'])
- goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($_REQUEST['newalbum']));
+ goaway(z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex($_REQUEST['newalbum']));
else
- goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex(datetime_convert('UTC',date_default_timezone_get(),'now', 'Y')));
+ goaway(z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex(datetime_convert('UTC',date_default_timezone_get(),'now', 'Y')));
}
@@ -497,7 +524,7 @@ function photos_content(&$a) {
require_once('include/security.php');
require_once('include/conversation.php');
- if(! x($a->data,'channel')) {
+ if(! x(App::$data,'channel')) {
notice( t('No photos selected') . EOL );
return;
}
@@ -505,13 +532,13 @@ function photos_content(&$a) {
$ph = photo_factory('');
$phototypes = $ph->supportedTypes();
- $_SESSION['photo_return'] = $a->cmd;
+ $_SESSION['photo_return'] = App::$cmd;
//
// Parse arguments
//
- $can_comment = perm_is_allowed($a->profile['profile_uid'],get_observer_hash(),'post_comments');
+ $can_comment = perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'post_comments');
if(argc() > 3) {
$datatype = argv(2);
@@ -538,10 +565,10 @@ function photos_content(&$a) {
$visitor = 0;
- $owner_uid = $a->data['channel']['channel_id'];
- $owner_aid = $a->data['channel']['channel_account_id'];
+ $owner_uid = App::$data['channel']['channel_id'];
+ $owner_aid = App::$data['channel']['channel_account_id'];
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$can_post = perm_is_allowed($owner_uid,$observer['xchan_hash'],'write_storage');
$can_view = perm_is_allowed($owner_uid,$observer['xchan_hash'],'view_storage');
@@ -555,13 +582,13 @@ function photos_content(&$a) {
$o = "";
- $o .= "<script> var profile_uid = " . $a->profile['profile_uid']
- . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
+ $o .= "<script> var profile_uid = " . App::$profile['profile_uid']
+ . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . "; </script>\r\n";
// tabs
$_is_owner = (local_channel() && (local_channel() == $owner_uid));
- $o .= profile_tabs($a,$_is_owner, $a->data['channel']['channel_address']);
+ $o .= profile_tabs($a,$_is_owner, App::$data['channel']['channel_address']);
/**
* Display upload form
@@ -571,7 +598,7 @@ function photos_content(&$a) {
$uploader = '';
- $ret = array('post_url' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'],
+ $ret = array('post_url' => z_root() . '/photos/' . App::$data['channel']['channel_address'],
'addon_text' => $uploader,
'default_upload' => true);
@@ -580,11 +607,11 @@ function photos_content(&$a) {
/* Show space usage */
$r = q("select sum(size) as total from photo where aid = %d and scale = 0 ",
- intval($a->data['channel']['channel_account_id'])
+ intval(App::$data['channel']['channel_account_id'])
);
- $limit = service_class_fetch($a->data['channel']['channel_id'],'photo_upload_limit');
+ $limit = service_class_fetch(App::$data['channel']['channel_id'],'photo_upload_limit');
if($limit !== false) {
$usage_message = sprintf( t("%1$.2f MB of %2$.2f MB photo storage used."), $r[0]['total'] / 1024000, $limit / 1024000 );
}
@@ -593,9 +620,9 @@ function photos_content(&$a) {
}
if($_is_owner) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$channel_acl = $acl->get();
$lockstate = (($acl->is_private()) ? 'lock' : 'unlock');
@@ -603,12 +630,20 @@ function photos_content(&$a) {
$aclselect = (($_is_owner) ? populate_acl($channel_acl,false) : '');
+ // this is wrong but is to work around an issue with js_upload wherein it chokes if these variables
+ // don't exist. They really should be set to a parseable representation of the channel's default permissions
+ // which can be processed by getSelected()
+
+ if(! $aclselect) {
+ $aclselect = '<input id="group_allow" type="hidden" name="allow_gid[]" value="" /><input id="contact_allow" type="hidden" name="allow_cid[]" value="" /><input id="group_deny" type="hidden" name="deny_gid[]" value="" /><input id="contact_deny" type="hidden" name="deny_cid[]" value="" />';
+ }
+
$selname = (($datum) ? hex2bin($datum) : '');
- $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer']));
+ $albums = ((array_key_exists('albums', App::$data)) ? App::$data['albums'] : photos_albums_list(App::$data['channel'],App::$data['observer']));
if(! $selname) {
- $def_album = get_pconfig($a->data['channel']['channel_id'],'system','photo_path');
+ $def_album = get_pconfig(App::$data['channel']['channel_id'],'system','photo_path');
if($def_album) {
$selname = filepath_macro($def_album);
$albums['album'][] = array('text' => $selname);
@@ -620,7 +655,7 @@ function photos_content(&$a) {
'$pagename' => t('Upload Photos'),
'$sessid' => session_id(),
'$usage' => $usage_message,
- '$nickname' => $a->data['channel']['channel_address'],
+ '$nickname' => App::$data['channel']['channel_address'],
'$newalbum_label' => t('Enter an album name'),
'$newalbum_placeholder' => t('or select an existing album (doubleclick)'),
'$visible' => array('visible', t('Create a status post for this upload'), 0,'', array(t('No'), t('Yes')), 'onclick="showHideBodyTextarea();"'),
@@ -660,6 +695,10 @@ function photos_content(&$a) {
$album = (($datum) ? hex2bin($datum) : '');
+
+ App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$cmd) . '" title="oembed" />' . "\r\n";
+
+
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
AND `scale` <= 4 and photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY `resource_id`",
intval($owner_uid),
@@ -669,10 +708,10 @@ function photos_content(&$a) {
intval($unsafe)
);
if(count($r)) {
- $a->set_pager_total(count($r));
- $a->set_pager_itemspage(60);
+ App::set_pager_total(count($r));
+ App::set_pager_itemspage(60);
} else {
- goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address']);
+ goaway(z_root() . '/photos/' . App::$data['channel']['channel_address']);
}
if($_GET['order'] === 'posted')
@@ -690,8 +729,8 @@ function photos_content(&$a) {
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE),
intval($unsafe),
- intval($a->pager['itemspage']),
- intval($a->pager['start'])
+ intval(App::$pager['itemspage']),
+ intval(App::$pager['start'])
);
//edit album name
@@ -699,7 +738,7 @@ function photos_content(&$a) {
if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
if($can_post) {
$album_e = $album;
- $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer']));
+ $albums = ((array_key_exists('albums', App::$data)) ? App::$data['albums'] : photos_albums_list(App::$data['channel'],App::$data['observer']));
// @fixme - syncronise actions with DAV
@@ -707,7 +746,7 @@ function photos_content(&$a) {
// $album_edit = replace_macros($edit_tpl,array(
// '$nametext' => t('Enter a new album name'),
// '$name_placeholder' => t('or select an existing one (doubleclick)'),
-// '$nickname' => $a->data['channel']['channel_address'],
+// '$nickname' => App::$data['channel']['channel_address'],
// '$album' => $album_e,
// '$albums' => $albums['albums'],
// '$hexalbum' => bin2hex($album),
@@ -719,9 +758,9 @@ function photos_content(&$a) {
}
if($_GET['order'] === 'posted')
- $order = array(t('Show Newest First'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album));
+ $order = array(t('Show Newest First'), z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex($album));
else
- $order = array(t('Show Oldest First'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '?f=&order=posted');
+ $order = array(t('Show Oldest First'), z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex($album) . '?f=&order=posted');
$photos = array();
if(count($r)) {
@@ -738,7 +777,7 @@ function photos_content(&$a) {
$imgalt_e = $rr['filename'];
$desc_e = $rr['description'];
- $imagelink = ($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $rr['resource_id']
+ $imagelink = (z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id']
. (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''));
$photos[] = array(
@@ -746,7 +785,7 @@ function photos_content(&$a) {
'twist' => ' ' . $twist . rand(2,4),
'link' => $imagelink,
'title' => t('View Photo'),
- 'src' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . $rr['scale'] . '.' .$ext,
+ 'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . $rr['scale'] . '.' .$ext,
'alt' => $imgalt_e,
'desc'=> $desc_e,
'ext' => $ext,
@@ -778,7 +817,7 @@ function photos_content(&$a) {
'$album_id' => bin2hex($album),
'$album_edit' => array(t('Edit Album'), $album_edit),
'$can_post' => $can_post,
- '$upload' => array(t('Upload'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/upload/' . bin2hex($album)),
+ '$upload' => array(t('Upload'), z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/upload/' . bin2hex($album)),
'$order' => $order,
'$upload_form' => $upload_form,
'$usage' => $usage_message
@@ -804,6 +843,8 @@ function photos_content(&$a) {
if($datatype === 'image') {
+ App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$cmd) . '" title="oembed" />' . "\r\n";
+
// fetch image, item containing image, then comments
$ph = q("SELECT id,aid,uid,xchan,resource_id,created,edited,title,`description`,album,filename,`type`,height,width,`size`,scale,photo_usage,is_nsfw,allow_cid,allow_gid,deny_cid,deny_gid FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s'
@@ -857,8 +898,8 @@ function photos_content(&$a) {
}
}
- $prevlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
- $nextlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
+ $prevlink = z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
+ $nextlink = z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
}
@@ -875,13 +916,14 @@ function photos_content(&$a) {
}
}
- $album_link = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($ph[0]['album']);
+ $album_link = z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex($ph[0]['album']);
$tools = Null;
$lock = Null;
if($can_post && ($ph[0]['uid'] == $owner_uid)) {
$tools = array(
- 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource_id'], t('Use as profile photo')),
+ 'profile'=>array(z_root() . '/profile_photo/use/'.$ph[0]['resource_id'], t('Use as profile photo')),
+ 'cover'=>array(z_root() . '/cover_photo/use/'.$ph[0]['resource_id'], t('Use as cover photo')),
);
}
@@ -891,20 +933,20 @@ function photos_content(&$a) {
? array('lock', t('Private Photo'))
: array('unlock', Null));
- $a->page['htmlhead'] .= '<script>$(document).keydown(function(event) {' . "\n";
+ App::$page['htmlhead'] .= '<script>$(document).keydown(function(event) {' . "\n";
if($prevlink)
- $a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n";
+ App::$page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n";
if($nextlink)
- $a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = \'' . $nextlink . '\'; }' . "\n";
- $a->page['htmlhead'] .= '});</script>';
+ App::$page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = \'' . $nextlink . '\'; }' . "\n";
+ App::$page['htmlhead'] .= '});</script>';
if($prevlink)
$prevlink = array($prevlink, t('Previous'));
$photo = array(
- 'href' => $a->get_baseurl() . '/photo/' . $hires['resource_id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
+ 'href' => z_root() . '/photo/' . $hires['resource_id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
'title'=> t('View Full Size'),
- 'src' => $a->get_baseurl() . '/photo/' . $lores['resource_id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis')
+ 'src' => z_root() . '/photo/' . $lores['resource_id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis')
);
if($nextlink)
@@ -977,7 +1019,7 @@ function photos_content(&$a) {
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['description'];
$aclselect_e = (($_is_owner) ? populate_acl($ph[0]) : '');
- $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer']));
+ $albums = ((array_key_exists('albums', App::$data)) ? App::$data['albums'] : photos_albums_list(App::$data['channel'],App::$data['observer']));
$_SESSION['album_return'] = bin2hex($ph[0]['album']);
@@ -990,7 +1032,7 @@ function photos_content(&$a) {
'album' => $album_e,
'newalbum_label' => t('Enter a new album name'),
'newalbum_placeholder' => t('or select an existing one (doubleclick)'),
- 'nickname' => $a->data['channel']['channel_address'],
+ 'nickname' => App::$data['channel']['channel_address'],
'resource_id' => $ph[0]['resource_id'],
'capt_label' => t('Caption'),
'caption' => $caption_e,
@@ -1011,7 +1053,7 @@ function photos_content(&$a) {
$cmnt_tpl = get_markup_template('comment_item.tpl');
$tpl = get_markup_template('photo_item.tpl');
- $return_url = $a->cmd;
+ $return_url = App::$cmd;
$like_tpl = get_markup_template('like_noshare.tpl');
@@ -1108,7 +1150,7 @@ function photos_content(&$a) {
if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent']))
continue;
- $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
+ $redirect_url = z_root() . '/redir/' . $item['cid'] ;
$profile_url = zid($item['author']['xchan_url']);
@@ -1218,7 +1260,7 @@ function photos_content(&$a) {
'$paginate' => $paginate,
));
- $a->data['photo_html'] = $o;
+ App::$data['photo_html'] = $o;
return $o;
}
@@ -1226,9 +1268,12 @@ function photos_content(&$a) {
// Default - show recent photos with upload link (if applicable)
//$o = '';
+ App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$cmd) . '" title="oembed" />' . "\r\n";
+
+
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
and photo_usage in ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY `resource_id`",
- intval($a->data['channel']['channel_id']),
+ intval(App::$data['channel']['channel_id']),
dbesc('Contact Photos'),
dbesc( t('Contact Photos')),
intval(PHOTO_NORMAL),
@@ -1236,8 +1281,8 @@ function photos_content(&$a) {
intval($unsafe)
);
if(count($r)) {
- $a->set_pager_total(count($r));
- $a->set_pager_itemspage(60);
+ App::set_pager_total(count($r));
+ App::set_pager_itemspage(60);
}
$r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.album, p.scale, p.created FROM photo p INNER JOIN
@@ -1245,14 +1290,14 @@ function photos_content(&$a) {
WHERE uid=%d AND album != '%s' AND album != '%s'
AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra group by resource_id) ph
ON (p.resource_id = ph.resource_id and p.scale = ph.scale) ORDER by p.created DESC LIMIT %d OFFSET %d",
- intval($a->data['channel']['channel_id']),
+ intval(App::$data['channel']['channel_id']),
dbesc('Contact Photos'),
dbesc( t('Contact Photos')),
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE),
intval($unsafe),
- intval($a->pager['itemspage']),
- intval($a->pager['start'])
+ intval(App::$pager['itemspage']),
+ intval(App::$pager['start'])
);
@@ -1267,7 +1312,7 @@ function photos_content(&$a) {
$twist = 'rotright';
$ext = $phototypes[$rr['type']];
- if($a->get_template_engine() === 'internal') {
+ if(App::get_template_engine() === 'internal') {
$alt_e = template_escape($rr['filename']);
$name_e = template_escape($rr['album']);
}
@@ -1279,12 +1324,12 @@ function photos_content(&$a) {
$photos[] = array(
'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4),
- 'link' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $rr['resource_id'],
+ 'link' => z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id'],
'title' => t('View Photo'),
- 'src' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
+ 'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
'alt' => $alt_e,
'album' => array(
- 'link' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($rr['album']),
+ 'link' => z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex($rr['album']),
'name' => $name_e,
'alt' => t('View Album'),
),
@@ -1313,7 +1358,7 @@ function photos_content(&$a) {
'$title' => t('Recent Photos'),
'$album_id' => bin2hex(t('Recent Photos')),
'$can_post' => $can_post,
- '$upload' => array(t('Upload'), $a->get_baseurl().'/photos/'.$a->data['channel']['channel_address'].'/upload'),
+ '$upload' => array(t('Upload'), z_root().'/photos/'.App::$data['channel']['channel_address'].'/upload'),
'$photos' => $photos,
'$upload_form' => $upload_form,
'$usage' => $usage_message
diff --git a/mod/ping.php b/mod/ping.php
index 394dbf089..32bc9753e 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -93,7 +93,7 @@ function ping_init(&$a) {
$result['notice'] = array();
- if($a->install) {
+ if(App::$install) {
echo json_encode($result);
killme();
}
@@ -224,7 +224,7 @@ function ping_init(&$a) {
if(count($z)) {
foreach($z as $zz) {
$notifs[] = array(
- 'notify_link' => $a->get_baseurl() . '/notify/view/' . $zz['id'],
+ 'notify_link' => z_root() . '/notify/view/' . $zz['id'],
'name' => $zz['name'],
'url' => $zz['url'],
'photo' => $zz['photo'],
@@ -240,7 +240,7 @@ function ping_init(&$a) {
}
if(argc() > 1 && argv(1) === 'messages') {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$t = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan
where channel_id = %d and mail_seen = 0 and mail_deleted = 0
and from_xchan != '%s' order by created desc limit 50",
@@ -251,7 +251,7 @@ function ping_init(&$a) {
if($t) {
foreach($t as $zz) {
$notifs[] = array(
- 'notify_link' => $a->get_baseurl() . '/mail/' . $zz['id'],
+ 'notify_link' => z_root() . '/mail/' . $zz['id'],
'name' => $zz['xchan_name'],
'url' => $zz['xchan_url'],
'photo' => $zz['xchan_photo_s'],
@@ -299,7 +299,7 @@ function ping_init(&$a) {
if($r) {
foreach($r as $rr) {
$result[] = array(
- 'notify_link' => $a->get_baseurl() . '/connedit/' . $rr['abook_id'],
+ 'notify_link' => z_root() . '/connections/ifpending',
'name' => $rr['xchan_name'],
'url' => $rr['xchan_url'],
'photo' => $rr['xchan_photo_s'],
@@ -341,7 +341,7 @@ function ping_init(&$a) {
$when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
$result[] = array(
- 'notify_link' => $a->get_baseurl() . '/events', // FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'],
+ 'notify_link' => z_root() . '/events', // FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'],
'name' => $rr['xchan_name'],
'url' => $rr['xchan_url'],
'photo' => $rr['xchan_photo_s'],
@@ -413,7 +413,7 @@ function ping_init(&$a) {
}
$t4 = dba_timer();
- $channel = get_app()->get_channel();
+ $channel = App::get_channel();
if($vnotify & VNOTIFY_MAIL) {
$mails = q("SELECT count(id) as total from mail
@@ -426,7 +426,7 @@ function ping_init(&$a) {
}
if($vnotify & VNOTIFY_REGISTER) {
- if ($a->config['system']['register_policy'] == REGISTER_APPROVE && is_site_admin()) {
+ if (App::$config['system']['register_policy'] == REGISTER_APPROVE && is_site_admin()) {
$regs = q("SELECT count(account_id) as total from account where (account_flags & %d) > 0",
intval(ACCOUNT_PENDING)
);
diff --git a/mod/poke.php b/mod/poke.php
index f66d28956..7245ceee7 100755
--- a/mod/poke.php
+++ b/mod/poke.php
@@ -22,7 +22,7 @@ function poke_init(&$a) {
return;
$uid = local_channel();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$verb = notags(trim($_REQUEST['verb']));
@@ -158,16 +158,27 @@ function poke_content(&$a) {
if($v[1] !== 'NOTRANSLATION')
$shortlist[] = array($k,$v[1]);
- $tpl = get_markup_template('poke_content.tpl');
- $o = replace_macros($tpl,array(
- '$title' => t('Poke/Prod'),
- '$desc' => t('poke, prod or do other things to somebody'),
+ $poke_basic = get_config('system','poke_basic');
+ if($poke_basic) {
+ $title = t('Poke');
+ $desc = t('Poke somebody');
+ }
+ else {
+ $title = t('Poke/Prod');
+ $desc = t('Poke, prod or do other things to somebody');
+ }
+
+ $o = replace_macros(get_markup_template('poke_content.tpl'),array(
+ '$title' => $title,
+ '$poke_basic' => $poke_basic,
+ '$desc' => $desc,
'$clabel' => t('Recipient'),
'$choice' => t('Choose what you wish to do to recipient'),
'$verbs' => $shortlist,
'$parent' => $parent,
'$prv_desc' => t('Make this post private'),
+ '$private' => array('private', t('Make this post private'), false, ''),
'$submit' => t('Submit'),
'$name' => $name,
'$id' => $id
diff --git a/mod/post.php b/mod/post.php
index 6555a16c2..481a4a896 100644
--- a/mod/post.php
+++ b/mod/post.php
@@ -12,7 +12,6 @@ require_once('include/zot.php');
function post_init(&$a) {
if (array_key_exists('auth', $_REQUEST)) {
- require_once('Zotlabs/Zot/Auth.php');
$x = new Zotlabs\Zot\Auth($_REQUEST);
exit;
}
@@ -22,9 +21,6 @@ function post_init(&$a) {
function post_post(&$a) {
- require_once('Zotlabs/Zot/Receiver.php');
- require_once('Zotlabs/Zot/ZotHandler.php');
-
$z = new Zotlabs\Zot\Receiver($_REQUEST['data'],get_config('system','prvkey'), new Zotlabs\Zot\ZotHandler());
// notreached;
diff --git a/mod/prate.php b/mod/prate.php
index b89d16f42..2da6855dd 100644
--- a/mod/prate.php
+++ b/mod/prate.php
@@ -7,7 +7,7 @@ function prate_init(&$a) {
if(! local_channel())
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$target = argv(1);
if(! $target)
@@ -27,7 +27,7 @@ function prate_post(&$a) {
if(! local_channel())
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$target = trim($_REQUEST['target']);
if(! $target)
diff --git a/mod/probe.php b/mod/probe.php
index 62a2227b0..6408a8c4f 100644
--- a/mod/probe.php
+++ b/mod/probe.php
@@ -13,7 +13,7 @@ function probe_content(&$a) {
$o .= '<br /><br />';
if(x($_GET,'addr')) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$addr = trim($_GET['addr']);
$do_import = ((intval($_GET['import']) && is_site_admin()) ? true : false);
$res = zot_finger($addr,$channel,false);
diff --git a/mod/profile.php b/mod/profile.php
index 430d039e9..09bcfd56a 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -14,12 +14,12 @@ function profile_init(&$a) {
$which = argv(1);
else {
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
$profile = '';
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) {
$which = $channel['channel_address'];
@@ -33,14 +33,14 @@ function profile_init(&$a) {
$profile = $r[0]['profile_guid'];
}
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which .'" />' . "\r\n" ;
+ App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . z_root() . '/feed/' . $which .'" />' . "\r\n" ;
if(! $profile) {
$x = q("select channel_id as profile_uid from channel where channel_address = '%s' limit 1",
dbesc(argv(1))
);
if($x) {
- $a->profile = $x[0];
+ App::$profile = $x[0];
}
}
@@ -60,21 +60,22 @@ function profile_content(&$a, $update = 0) {
$tab = 'profile';
$o = '';
- if(! (perm_is_allowed($a->profile['profile_uid'],get_observer_hash(), 'view_profile'))) {
+ if(! (perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(), 'view_profile'))) {
notice( t('Permission denied.') . EOL);
return;
}
- $is_owner = ((local_channel()) && (local_channel() == $a->profile['profile_uid']) ? true : false);
+ $is_owner = ((local_channel()) && (local_channel() == App::$profile['profile_uid']) ? true : false);
- if($a->profile['hidewall'] && (! $is_owner) && (! remote_channel())) {
+ if(App::$profile['hidewall'] && (! $is_owner) && (! remote_channel())) {
notice( t('Permission denied.') . EOL);
return;
}
- $o .= profile_tabs($a, $is_owner, $a->profile['channel_address']);
+ $o .= profile_tabs($a, $is_owner, App::$profile['channel_address']);
+ App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$query_string) . '" title="oembed" />' . "\r\n";
$o .= advanced_profile($a);
call_hooks('profile_advanced',$o);
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index 2884505f0..bac93555f 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -67,7 +67,7 @@ function profile_photo_init(&$a) {
return;
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
profile_load($a,$channel['channel_address']);
}
@@ -171,7 +171,7 @@ function profile_photo_post(&$a) {
return;
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
// If setting for the default profile, unset the profile photo flag from any other photos I own
@@ -189,8 +189,8 @@ function profile_photo_post(&$a) {
}
else {
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
- dbesc($a->get_baseurl() . '/photo/' . $base_image['resource_id'] . '-4'),
- dbesc($a->get_baseurl() . '/photo/' . $base_image['resource_id'] . '-5'),
+ dbesc(z_root() . '/photo/' . $base_image['resource_id'] . '-4'),
+ dbesc(z_root() . '/photo/' . $base_image['resource_id'] . '-5'),
intval($_REQUEST['profile']),
intval(local_channel())
);
@@ -225,7 +225,7 @@ function profile_photo_post(&$a) {
notice( t('Unable to process image') . EOL);
}
- goaway($a->get_baseurl() . '/profiles');
+ goaway(z_root() . '/profiles');
return; // NOTREACHED
}
@@ -236,7 +236,7 @@ function profile_photo_post(&$a) {
require_once('include/attach.php');
- $res = attach_store($a->get_channel(), get_observer_hash(), '', array('album' => t('Profile Photos'), 'hash' => $hash));
+ $res = attach_store(App::get_channel(), get_observer_hash(), '', array('album' => t('Profile Photos'), 'hash' => $hash));
logger('attach_store: ' . print_r($res,true));
@@ -274,58 +274,6 @@ function profile_photo_post(&$a) {
}
-function send_profile_photo_activity($channel,$photo,$profile) {
-
- // for now only create activities for the default profile
-
- if(! intval($profile['is_default']))
- return;
-
- $arr = array();
- $arr['item_thread_top'] = 1;
- $arr['item_origin'] = 1;
- $arr['item_wall'] = 1;
- $arr['obj_type'] = ACTIVITY_OBJ_PHOTO;
- $arr['verb'] = ACTIVITY_UPDATE;
-
- $arr['object'] = json_encode(array(
- 'type' => $arr['obj_type'],
- 'id' => z_root() . '/photo/profile/l/' . $channel['channel_id'],
- 'link' => array('rel' => 'photo', 'type' => $photo['type'], 'href' => z_root() . '/photo/profile/l/' . $channel['channel_id'])
- ));
-
- if(stripos($profile['gender'],t('female')) !== false)
- $t = t('%1$s updated her %2$s');
- elseif(stripos($profile['gender'],t('male')) !== false)
- $t = t('%1$s updated his %2$s');
- else
- $t = t('%1$s updated their %2$s');
-
- $ptext = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . t('profile photo') . '[/zrl]';
-
- $ltext = '[zrl=' . z_root() . '/profile/' . $channel['channel_address'] . ']' . '[zmg=150x150]' . z_root() . '/photo/' . $photo['resource_id'] . '-4[/zmg][/zrl]';
-
- $arr['body'] = sprintf($t,$channel['channel_name'],$ptext) . "\n\n" . $ltext;
-
- $acl = new AccessList($channel);
- $x = $acl->get();
- $arr['allow_cid'] = $x['allow_cid'];
-
- $arr['allow_gid'] = $x['allow_gid'];
- $arr['deny_cid'] = $x['deny_cid'];
- $arr['deny_gid'] = $x['deny_gid'];
-
- $arr['uid'] = $channel['channel_id'];
- $arr['aid'] = $channel['channel_account_id'];
-
- $arr['owner_xchan'] = $channel['channel_hash'];
- $arr['author_xchan'] = $channel['channel_hash'];
-
- post_activity_item($arr);
-
-
-}
-
/* @brief Generate content of profile-photo view
*
@@ -342,7 +290,7 @@ function profile_photo_content(&$a) {
return;
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$newuser = false;
@@ -397,7 +345,7 @@ function profile_photo_content(&$a) {
profile_photo_set_profile_perms(); //Reset default photo permissions to public
proc_run('php','include/directory.php',local_channel());
- goaway($a->get_baseurl() . '/profiles');
+ goaway(z_root() . '/profiles');
}
$r = q("SELECT `data`, `type`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1",
@@ -441,20 +389,22 @@ function profile_photo_content(&$a) {
intval(local_channel())
);
- if(! x($a->data,'imagecrop')) {
+ if(! x(App::$data,'imagecrop')) {
$tpl = get_markup_template('profile_photo.tpl');
$o .= replace_macros($tpl,array(
- '$user' => $a->channel['channel_address'],
+ '$user' => App::$channel['channel_address'],
'$lbl_upfile' => t('Upload File:'),
'$lbl_profiles' => t('Select a profile:'),
'$title' => t('Upload Profile Photo'),
'$submit' => t('Upload'),
'$profiles' => $profiles,
+ '$single' => ((count($profiles) == 1) ? true : false),
+ '$profile0' => $profiles[0],
'$form_security_token' => get_form_security_token("profile_photo"),
// FIXME - yuk
- '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . $a->get_baseurl() . '">' . t('skip this step') . '</a>' : '<a href="'. $a->get_baseurl() . '/photos/' . $a->channel['channel_address'] . '">' . t('select a photo from your photo albums') . '</a>')
+ '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . z_root() . '">' . t('skip this step') . '</a>' : '<a href="'. z_root() . '/photos/' . App::$channel['channel_address'] . '">' . t('select a photo from your photo albums') . '</a>')
));
call_hooks('profile_photo_content_end', $o);
@@ -462,14 +412,14 @@ function profile_photo_content(&$a) {
return $o;
}
else {
- $filename = $a->data['imagecrop'] . '-' . $a->data['imagecrop_resolution'];
- $resolution = $a->data['imagecrop_resolution'];
+ $filename = App::$data['imagecrop'] . '-' . App::$data['imagecrop_resolution'];
+ $resolution = App::$data['imagecrop_resolution'];
$tpl = get_markup_template("cropbody.tpl");
$o .= replace_macros($tpl,array(
'$filename' => $filename,
'$profile' => intval($_REQUEST['profile']),
- '$resource' => $a->data['imagecrop'] . '-' . $a->data['imagecrop_resolution'],
- '$image_url' => $a->get_baseurl() . '/photo/' . $filename,
+ '$resource' => App::$data['imagecrop'] . '-' . App::$data['imagecrop_resolution'],
+ '$image_url' => z_root() . '/photo/' . $filename,
'$title' => t('Crop Image'),
'$desc' => t('Please adjust the image cropping for optimum viewing.'),
'$form_security_token' => get_form_security_token("profile_photo"),
@@ -502,16 +452,16 @@ function profile_photo_crop_ui_head(&$a, $ph, $hash, $smallest){
$width = $ph->getWidth();
$height = $ph->getHeight();
- if($width < 300 || $height < 300) {
- $ph->scaleImageUp(200);
+ if($width < 500 || $height < 500) {
+ $ph->scaleImageUp(400);
$width = $ph->getWidth();
$height = $ph->getHeight();
}
- $a->data['imagecrop'] = $hash;
- $a->data['imagecrop_resolution'] = $smallest;
- $a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), array());
+ App::$data['imagecrop'] = $hash;
+ App::$data['imagecrop_resolution'] = $smallest;
+ App::$page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), array());
return;
}
diff --git a/mod/profiles.php b/mod/profiles.php
index 282d741ac..75c05b634 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -17,7 +17,7 @@ function profiles_init(&$a) {
);
if(! count($r)) {
notice( t('Profile not found.') . EOL);
- goaway($a->get_baseurl(true) . '/profiles');
+ goaway(z_root() . '/profiles');
return; // NOTREACHED
}
$profile_guid = $r['profile_guid'];
@@ -44,7 +44,7 @@ function profiles_init(&$a) {
// profiles_build_sync(local_channel());
- goaway($a->get_baseurl(true) . '/profiles');
+ goaway(z_root() . '/profiles');
return; // NOTREACHED
}
@@ -83,9 +83,9 @@ function profiles_init(&$a) {
info( t('New profile created.') . EOL);
if(count($r3) == 1)
- goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
+ goaway(z_root() . '/profiles/' . $r3[0]['id']);
- goaway($a->get_baseurl(true) . '/profiles');
+ goaway(z_root() . '/profiles');
}
if((argc() > 2) && (argv(1) === 'clone')) {
@@ -99,11 +99,11 @@ function profiles_init(&$a) {
$name = t('Profile-') . ($num_profiles + 1);
$r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval(local_channel()),
- intval($a->argv[2])
+ intval(App::$argv[2])
);
if(! count($r1)) {
notice( t('Profile unavailable to clone.') . EOL);
- $a->error = 404;
+ App::$error = 404;
return;
}
unset($r1[0]['id']);
@@ -129,9 +129,9 @@ function profiles_init(&$a) {
profiles_build_sync(local_channel());
if(($r3) && (count($r3) == 1))
- goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
+ goaway(z_root() . '/profiles/' . $r3[0]['id']);
- goaway($a->get_baseurl(true) . '/profiles');
+ goaway(z_root() . '/profiles');
return; // NOTREACHED
}
@@ -144,7 +144,7 @@ function profiles_init(&$a) {
);
if(! $r1) {
notice( t('Profile unavailable to export.') . EOL);
- $a->error = 404;
+ App::$error = 404;
return;
}
header('content-type: application/octet_stream');
@@ -168,7 +168,7 @@ function profiles_init(&$a) {
// we start loading content
if(((argc() > 1) && (intval(argv(1)))) || !feature_enabled(local_channel(),'multi_profiles')) {
if(feature_enabled(local_channel(),'multi_profiles'))
- $id = $a->argv[1];
+ $id = App::$argv[1];
else {
$x = q("select id from profile where uid = %d and is_default = 1",
intval(local_channel())
@@ -182,11 +182,11 @@ function profiles_init(&$a) {
);
if(! count($r)) {
notice( t('Profile not found.') . EOL);
- $a->error = 404;
+ App::$error = 404;
return;
}
- $chan = $a->get_channel();
+ $chan = App::get_channel();
profile_load($a,$chan['channel_address'],$r[0]['id']);
}
@@ -234,7 +234,7 @@ function profiles_post(&$a) {
if((argc() > 1) && (argv(1) !== "new") && intval(argv(1))) {
$orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($a->argv[1]),
+ intval(App::$argv[1]),
intval(local_channel())
);
if(! count($orig)) {
@@ -248,7 +248,7 @@ function profiles_post(&$a) {
$profile_name = notags(trim($_POST['profile_name']));
if(! strlen($profile_name)) {
- notify( t('Profile Name is required.') . EOL);
+ notice( t('Profile Name is required.') . EOL);
return;
}
@@ -272,9 +272,17 @@ function profiles_post(&$a) {
$name = escape_tags(trim($_POST['name']));
- if($orig[0]['name'] != $name)
+ if($orig[0]['name'] != $name) {
$namechanged = true;
+ $v = validate_channelname($name);
+ if($v) {
+ notice($v);
+ $namechanged = false;
+ $name = $orig[0]['name'];
+ }
+ }
+
$pdesc = escape_tags(trim($_POST['pdesc']));
$gender = escape_tags(trim($_POST['gender']));
$address = escape_tags(trim($_POST['address']));
@@ -555,7 +563,7 @@ function profiles_post(&$a) {
build_sync_packet(local_channel(),array('profile' => $r));
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if($namechanged && $is_default) {
$r = q("UPDATE xchan SET xchan_name = '%s', xchan_name_date = '%s' WHERE xchan_hash = '%s'",
@@ -563,6 +571,10 @@ function profiles_post(&$a) {
dbesc(datetime_convert()),
dbesc($channel['xchan_hash'])
);
+ $r = q("UPDATE channel SET channel_name = '%s' WHERE channel_hash = '%s'",
+ dbesc($name),
+ dbesc($channel['xchan_hash'])
+ );
}
if($is_default) {
@@ -578,7 +590,7 @@ function profiles_content(&$a) {
$o = '';
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if(! local_channel()) {
notice( t('Permission denied.') . EOL);
@@ -592,7 +604,7 @@ function profiles_content(&$a) {
if(((argc() > 1) && (intval(argv(1)))) || !feature_enabled(local_channel(),'multi_profiles')) {
if(feature_enabled(local_channel(),'multi_profiles'))
- $id = $a->argv[1];
+ $id = App::$argv[1];
else {
$x = q("select id from profile where uid = %d and is_default = 1",
intval(local_channel())
@@ -616,8 +628,8 @@ function profiles_content(&$a) {
// if(feature_enabled(local_channel(),'richtext'))
// $editselect = 'textareas';
- $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
- '$baseurl' => $a->get_baseurl(true),
+ App::$page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
+ '$baseurl' => z_root(),
'$editselect' => $editselect,
));
@@ -627,14 +639,13 @@ function profiles_content(&$a) {
else
$fields = $profile_fields_basic;
-
- $opt_tpl = get_markup_template("profile_hide_friends.tpl");
- $hide_friends = replace_macros($opt_tpl,array('$field' => array(
- 'hide_friends',
- t('Hide your contact/friend list from viewers of this profile?'),
- $r[0]['hide_friends'],
- '',
- )));
+ $hide_friends = array(
+ 'hide_friends',
+ t('Hide your connections list from viewers of this profile'),
+ $r[0]['hide_friends'],
+ '',
+ array(t('No'),t('Yes'))
+ );
$q = q("select * from profdef where true");
if($q) {
@@ -660,6 +671,7 @@ function profiles_content(&$a) {
$f = 'ymd';
$is_default = (($r[0]['is_default']) ? 1 : 0);
+
$tpl = get_markup_template("profile_edit.tpl");
$o .= replace_macros($tpl,array(
@@ -674,92 +686,64 @@ function profiles_content(&$a) {
'$banner' => t('Edit Profile Details'),
'$submit' => t('Submit'),
'$viewprof' => t('View this profile'),
- '$editvis' => t('Edit visibility'),
- '$profpic' => t('Change Profile Photo'),
+ '$editvis' => t('Edit visibility'),
+ '$coverpic' => t('Change cover photo'),
+ '$profpic' => t('Change profile photo'),
'$cr_prof' => t('Create a new profile using these settings'),
'$cl_prof' => t('Clone this profile'),
'$del_prof' => t('Delete this profile'),
+ '$addthing' => t('Add profile things'),
+ '$personal' => t('Personal'),
+ '$location' => t('Location'),
+ '$relation' => t('Relation'),
+ '$miscellaneous'=> t('Miscellaneous'),
'$exportable' => feature_enabled(local_channel(),'profile_export'),
'$lbl_import' => t('Import profile from file'),
'$lbl_export' => t('Export profile to file'),
- '$lbl_profname' => t('Profile Name:'),
- '$lbl_fullname' => t('Your Full Name:'),
- '$lbl_title' => t('Title/Description:'),
- '$lbl_gender' => t('Your Gender:'),
- '$lbl_bd' => t("Birthday :"),
- '$lbl_address' => t('Street Address:'),
- '$lbl_city' => t('Locality/City:'),
- '$lbl_zip' => t('Postal/Zip Code:'),
- '$lbl_country' => t('Country:'),
- '$lbl_region' => t('Region/State:'),
- '$lbl_marital' => t('<span class="heart">&hearts;</span> Marital Status:'),
- '$lbl_with' => t("Who: \x28if applicable\x29"),
- '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'),
- '$lbl_howlong' => t('Since [date]:'),
- '$lbl_sexual' => t('Sexual Preference:'),
- '$lbl_homepage' => t('Homepage URL:'),
- '$lbl_hometown' => t('Hometown:'),
- '$lbl_politic' => t('Political Views:'),
- '$lbl_religion' => t('Religious Views:'),
- '$lbl_pubkey' => t('Keywords:'),
- '$lbl_likes' => t('Likes:'),
- '$lbl_dislikes' => t('Dislikes:'),
- '$lbl_ex2' => t('Example: fishing photography software'),
- '$lbl_pubdsc' => t("Used in directory listings"),
- '$lbl_about' => t('Tell us about yourself...'),
- '$lbl_hobbies' => t('Hobbies/Interests'),
- '$lbl_social' => t('Contact information and Social Networks'),
- '$lbl_channels' => t('My other channels'),
- '$lbl_music' => t('Musical interests'),
- '$lbl_book' => t('Books, literature'),
- '$lbl_tv' => t('Television'),
- '$lbl_film' => t('Film/dance/culture/entertainment'),
- '$lbl_love' => t('Love/romance'),
- '$lbl_work' => t('Work/employment'),
- '$lbl_school' => t('School/education'),
- '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
- '$baseurl' => $a->get_baseurl(true),
+ '$lbl_gender' => t('Your gender'),
+ '$lbl_marital' => t('Marital status'),
+ '$lbl_sexual' => t('Sexual preference'),
+ '$baseurl' => z_root(),
'$profile_id' => $r[0]['id'],
- '$profile_name' => $r[0]['profile_name'],
+ '$profile_name' => array('profile_name', t('Profile name'), $r[0]['profile_name'], t('Required'), '*'),
'$is_default' => $is_default,
'$default' => t('This is your default profile.') . EOL . translate_scope(map_scope($channel['channel_r_profile'])),
'$advanced' => $advanced,
- '$name' => $r[0]['name'],
- '$pdesc' => $r[0]['pdesc'],
+ '$name' => array('name', t('Your full name'), $r[0]['name'], t('Required'), '*'),
+ '$pdesc' => array('pdesc', t('Title/Description'), $r[0]['pdesc']),
'$dob' => dob($r[0]['dob']),
'$hide_friends' => $hide_friends,
- '$address' => $r[0]['address'],
- '$locality' => $r[0]['locality'],
- '$region' => $r[0]['region'],
- '$postal_code' => $r[0]['postal_code'],
- '$country_name' => $r[0]['country_name'],
- '$age' => ((intval($r[0]['dob'])) ? '(' . t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
+ '$address' => array('address', t('Street address'), $r[0]['address']),
+ '$locality' => array('locality', t('Locality/City'), $r[0]['locality']),
+ '$region' => array('region', t('Region/State'), $r[0]['region']),
+ '$postal_code' => array('postal_code', t('Postal/Zip code'), $r[0]['postal_code']),
+ '$country_name' => array('country_name', t('Country'), $r[0]['country_name']),
'$gender' => gender_selector($r[0]['gender']),
- '$gender_min' => gender_selector_min($r[0]['gender']),
+ '$gender_min' => gender_selector_min($r[0]['gender']),
'$marital' => marital_selector($r[0]['marital']),
- '$marital_min' => marital_selector_min($r[0]['marital']),
- '$with' => $r[0]['with'],
- '$howlong' => ($r[0]['howlong'] === NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong'])),
+ '$marital_min' => marital_selector_min($r[0]['marital']),
+ '$with' => array('with', t("Who (if applicable)"), $r[0]['with'], t('Examples: cathy123, Cathy Williams, cathy@example.com')),
+ '$howlong' => array('howlong', t('Since (date)'), ($r[0]['howlong'] === NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))),
'$sexual' => sexpref_selector($r[0]['sexual']),
- '$sexual_min' => sexpref_selector_min($r[0]['sexual']),
- '$about' => $r[0]['about'],
- '$homepage' => $r[0]['homepage'],
- '$hometown' => $r[0]['hometown'],
- '$politic' => $r[0]['politic'],
- '$religion' => $r[0]['religion'],
- '$keywords' => $r[0]['keywords'],
- '$likes' => $r[0]['likes'],
- '$dislikes' => $r[0]['dislikes'],
- '$music' => $r[0]['music'],
- '$book' => $r[0]['book'],
- '$tv' => $r[0]['tv'],
- '$film' => $r[0]['film'],
- '$interest' => $r[0]['interest'],
- '$romance' => $r[0]['romance'],
- '$work' => $r[0]['work'],
- '$education' => $r[0]['education'],
- '$contact' => $r[0]['contact'],
- '$channels' => $r[0]['channels'],
+ '$sexual_min' => sexpref_selector_min($r[0]['sexual']),
+ '$about' => array('about', t('Tell us about yourself'), $r[0]['about']),
+ '$homepage' => array('homepage', t('Homepage URL'), $r[0]['homepage']),
+ '$hometown' => array('hometown', t('Hometown'), $r[0]['hometown']),
+ '$politic' => array('politic', t('Political views'), $r[0]['politic']),
+ '$religion' => array('religion', t('Religious views'), $r[0]['religion']),
+ '$keywords' => array('keywords', t('Keywords used in directory listings'), $r[0]['keywords'], t('Example: fishing photography software')),
+ '$likes' => array('likes', t('Likes'), $r[0]['likes']),
+ '$dislikes' => array('dislikes', t('Dislikes'), $r[0]['dislikes']),
+ '$music' => array('music', t('Musical interests'), $r[0]['music']),
+ '$book' => array('book', t('Books, literature'), $r[0]['book']),
+ '$tv' => array('tv', t('Television'), $r[0]['tv']),
+ '$film' => array('film', t('Film/Dance/Culture/Entertainment'), $r[0]['film']),
+ '$interest' => array('interest', t('Hobbies/Interests'), $r[0]['interest']),
+ '$romance' => array('romance',t('Love/Romance'), $r[0]['romance']),
+ '$work' => array('work', t('Work/Employment'), $r[0]['work']),
+ '$education' => array('education', t('School/Education'), $r[0]['education']),
+ '$contact' => array('contact', t('Contact information and social networks'), $r[0]['contact']),
+ '$channels' => array('channels', t('My other channels'), $r[0]['channels']),
'$extra_fields' => $extra_fields,
));
@@ -774,30 +758,29 @@ function profiles_content(&$a) {
local_channel());
if(count($r)) {
- $tpl_header = get_markup_template('profile_listing_header.tpl');
- $o .= replace_macros($tpl_header,array(
- '$header' => t('Edit/Manage Profiles'),
- '$addstuff' => t('Add profile things'),
- '$stuff_desc' => t('Include desirable objects in your profile'),
- '$chg_photo' => t('Change profile photo'),
- '$cr_new' => t('Create New Profile'),
- '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new")
- ));
-
-
$tpl = get_markup_template('profile_entry.tpl');
-
foreach($r as $rr) {
- $o .= replace_macros($tpl, array(
+ $profiles .= replace_macros($tpl, array(
'$photo' => $rr['thumb'],
'$id' => $rr['id'],
'$alt' => t('Profile Image'),
'$profile_name' => $rr['profile_name'],
'$visible' => (($rr['is_default'])
? '<strong>' . translate_scope(map_scope($channel['channel_r_profile'])) . '</strong>'
- : '<a href="' . $a->get_baseurl(true) . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>')
+ : '<a href="' . z_root() . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>')
));
}
+
+ $tpl_header = get_markup_template('profile_listing_header.tpl');
+ $o .= replace_macros($tpl_header,array(
+ '$header' => t('Edit Profiles'),
+ '$cr_new' => t('Create New'),
+ '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
+ '$profiles' => $profiles
+ ));
+
+
+
}
return $o;
diff --git a/mod/profperm.php b/mod/profperm.php
index 4556119a4..2e3f708c8 100644
--- a/mod/profperm.php
+++ b/mod/profperm.php
@@ -7,10 +7,10 @@ function profperm_init(&$a) {
if(! local_channel())
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$which = $channel['channel_address'];
- $profile = $a->argv[1];
+ $profile = App::$argv[1];
profile_load($a,$which,$profile);
diff --git a/mod/public.php b/mod/public.php
index 45edda6c0..fd89e0776 100644
--- a/mod/public.php
+++ b/mod/public.php
@@ -26,10 +26,10 @@ function public_content(&$a, $update = 0, $load = false) {
$o .= '<div id="live-public"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . ((intval(local_channel())) ? local_channel() : (-1))
- . "; var profile_page = " . $a->pager['page']
+ . "; var profile_page = " . App::$pager['page']
. "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
- $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
+ App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
'$baseurl' => z_root(),
'$pgtype' => 'public',
'$uid' => ((local_channel()) ? local_channel() : '0'),
@@ -45,7 +45,7 @@ function public_content(&$a, $update = 0, $load = false) {
'$nouveau' => '0',
'$wall' => '0',
'$list' => '0',
- '$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1),
+ '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
'$search' => '',
'$order' => 'comment',
'$file' => '',
@@ -63,8 +63,8 @@ function public_content(&$a, $update = 0, $load = false) {
$pager_sql = '';
}
else {
- $a->set_pager_itemspage(20);
- $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
+ App::set_pager_itemspage(20);
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
}
require_once('include/identity.php');
@@ -77,7 +77,7 @@ function public_content(&$a, $update = 0, $load = false) {
$sys = get_sys_channel();
$uids = " and item.uid = " . intval($sys['channel_id']) . " ";
$sql_extra = item_permissions_sql($sys['channel_id']);
- $a->data['firehose'] = intval($sys['channel_id']);
+ App::$data['firehose'] = intval($sys['channel_id']);
}
if(get_config('system','public_list_mode'))
diff --git a/mod/pubsites.php b/mod/pubsites.php
index ae8601366..dc6b09d9b 100644
--- a/mod/pubsites.php
+++ b/mod/pubsites.php
@@ -13,30 +13,39 @@ function pubsites_content(&$a) {
}
$url .= '/sites';
- $o .= '<div class="generic-content-wrapper-styled">';
+ $o .= '<div class="generic-content-wrapper">';
- $o .= '<h1>' . t('Public Sites') . '</h1>';
+ $o .= '<div class="section-title-wrapper"><h2>' . t('Public Hubs') . '</h2></div>';
- $o .= '<div class="descriptive-text">' .
- t('The listed sites allow public registration for the $Projectname network. All sites in the network are interlinked so membership on any of them conveys membership in the network as a whole. Some sites may require subscription or provide tiered service plans. The provider links <strong>may</strong> provide additional details.') . '</div>' . EOL;
+ $o .= '<div class="section-content-tools-wrapper"><div class="descriptive-text">' .
+ t('The listed hubs allow public registration for the $Projectname network. All hubs in the network are interlinked so membership on any of them conveys membership in the network as a whole. Some hubs may require subscription or provide tiered service plans. The hub itself <strong>may</strong> provide additional details.') . '</div>' . EOL;
$ret = z_fetch_url($url);
if($ret['success']) {
$j = json_decode($ret['body'],true);
if($j) {
- $rate_meta = ((local_channel()) ? '<td>' . t('Rate this hub') . '</td>' : '');
- $o .= '<table border="1"><tr><td>' . t('Site URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Location') . '</td><td>' . t('Project') . '</td><td>' . t('View hub ratings') . '</td>' . $rate_meta . '</tr>';
+ $o .= '<table class="table table-striped table-hover"><tr><td>' . t('Hub URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td colspan="2">' . t('Ratings') . '</td></tr>';
if($j['sites']) {
foreach($j['sites'] as $jj) {
+ if($jj['project'] !== Zotlabs\Project\System::get_platform_name())
+ continue;
$host = strtolower(substr($jj['url'],strpos($jj['url'],'://')+3));
$rate_links = ((local_channel()) ? '<td><a href="rate?f=&target=' . $host . '" class="btn-btn-default"><i class="icon-check"></i> ' . t('Rate') . '</a></td>' : '');
- $o .= '<tr><td>' . '<a href="'. (($jj['sellpage']) ? $jj['sellpage'] : $jj['url'] . '/register' ) . '" >' . $jj['url'] . '</a>' . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . $jj['location'] . '</td><td>' . $jj['project'] . '</td><td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="icon-eye-open"></i> ' . t('View ratings') . '</a></td>' . $rate_links . '</tr>';
+ $location = '';
+ if(!empty($jj['location'])) {
+ $location = '<p title="' . t('Location') . '" style="margin: 5px 5px 0 0; text-align: right"><i class="icon-globe"></i> ' . $jj['location'] . '</p>';
+ }
+ else {
+ $location = '<br />&nbsp;';
+ }
+ $urltext = str_replace(array('https://'), '', $jj['url']);
+ $o .= '<tr><td><a href="'. (($jj['sellpage']) ? $jj['sellpage'] : $jj['url'] . '/register' ) . '" ><i class="icon-link"></i> ' . $urltext . '</a>' . $location . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="icon-eye-open"></i> ' . t('View') . '</a></td>' . $rate_links . '</tr>';
}
}
$o .= '</table>';
- $o .= '</div>';
+ $o .= '</div></div>';
}
}
diff --git a/mod/randprof.php b/mod/randprof.php
index 9817685c8..124117e96 100644
--- a/mod/randprof.php
+++ b/mod/randprof.php
@@ -8,5 +8,5 @@ function randprof_init(&$a) {
goaway(chanlink_url($x));
/** FIXME this doesn't work at the moment as a fallback */
- goaway($a->get_baseurl() . '/profile');
+ goaway(z_root() . '/profile');
}
diff --git a/mod/rate.php b/mod/rate.php
index f30afed64..41e06e794 100644
--- a/mod/rate.php
+++ b/mod/rate.php
@@ -6,20 +6,20 @@ function rate_init(&$a) {
if(! local_channel())
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$target = $_REQUEST['target'];
if(! $target)
return;
- $a->data['target'] = $target;
+ App::$data['target'] = $target;
if($target) {
$r = q("SELECT * FROM xchan where xchan_hash like '%s' LIMIT 1",
dbesc($target)
);
if($r) {
- $a->poi = $r[0];
+ App::$poi = $r[0];
}
else {
$r = q("select * from site where site_url like '%s' and site_type = %d",
@@ -27,8 +27,8 @@ function rate_init(&$a) {
intval(SITE_TYPE_ZOT)
);
if($r) {
- $a->data['site'] = $r[0];
- $a->data['site']['site_url'] = strtolower($r[0]['site_url']);
+ App::$data['site'] = $r[0];
+ App::$data['site']['site_url'] = strtolower($r[0]['site_url']);
}
}
}
@@ -44,13 +44,13 @@ function rate_post(&$a) {
if(! local_channel())
return;
- if(! $a->data['target'])
+ if(! App::$data['target'])
return;
if(! $_REQUEST['execute'])
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$rating = intval($_POST['rating']);
if($rating < (-10))
@@ -60,13 +60,13 @@ function rate_post(&$a) {
$rating_text = trim(escape_tags($_REQUEST['rating_text']));
- $signed = $a->data['target'] . '.' . $rating . '.' . $rating_text;
+ $signed = App::$data['target'] . '.' . $rating . '.' . $rating_text;
$sig = base64url_encode(rsa_sign($signed,$channel['channel_prvkey']));
$z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1",
dbesc($channel['channel_hash']),
- dbesc($a->data['target'])
+ dbesc(App::$data['target'])
);
if($z) {
@@ -83,7 +83,7 @@ function rate_post(&$a) {
else {
$w = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_sig, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', '%s', 1 ) ",
dbesc($channel['channel_hash']),
- dbesc($a->data['target']),
+ dbesc(App::$data['target']),
intval($rating),
dbesc($rating_text),
dbesc($sig),
@@ -91,7 +91,7 @@ function rate_post(&$a) {
);
$z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1",
dbesc($channel['channel_hash']),
- dbesc($a->data['target'])
+ dbesc(App::$data['target'])
);
if($z)
$record = $z[0]['xlink_id'];
@@ -112,7 +112,7 @@ function rate_content(&$a) {
return;
}
-// if(! $a->data['target']) {
+// if(! App::$data['target']) {
// notice( t('No recipients.') . EOL);
// return;
// }
@@ -123,14 +123,14 @@ function rate_content(&$a) {
return;
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1",
dbesc($channel['channel_hash']),
- dbesc($a->data['target'])
+ dbesc(App::$data['target'])
);
if($r) {
- $a->data['xlink'] = $r[0];
+ App::$data['xlink'] = $r[0];
$rating_val = $r[0]['xlink_rating'];
$rating_text = $r[0]['xlink_rating_text'];
}
@@ -156,9 +156,9 @@ 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 href="' . $a->data['site']['site_url'] . '" >' . $a->data['site']['site_url'] . '</a>' : ''),
- '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))),
+ '$site' => ((App::$data['site']) ? '<a href="' . App::$data['site']['site_url'] . '" >' . App::$data['site']['site_url'] . '</a>' : ''),
+ 'target' => App::$data['target'],
+ '$tgt_name' => ((App::$poi && App::$poi['xchan_name']) ? App::$poi['xchan_name'] : sprintf( t('Remote Channel [%s] (not yet known on this site)'), substr(App::$data['target'],0,16))),
'$lbl_rating' => t('Rating (this information is public)'),
'$lbl_rating_txt' => t('Optionally explain your rating (this information is public)'),
'$rating_txt' => $rating_text,
diff --git a/mod/ratings.php b/mod/ratings.php
index dc98eb238..d99be974c 100644
--- a/mod/ratings.php
+++ b/mod/ratings.php
@@ -49,23 +49,23 @@ function ratings_init(&$a) {
}
if(array_key_exists('xchan_hash',$results['target']))
- $a->poi = $results['target'];
+ App::$poi = $results['target'];
$friends = array();
$others = array();
if($results['ratings']) {
foreach($results['ratings'] as $n) {
- if(is_array($a->contacts) && array_key_exists($n['xchan_hash'],$a->contacts))
+ if(is_array(App::$contacts) && array_key_exists($n['xchan_hash'],App::$contacts))
$friends[] = $n;
else
$others[] = $n;
}
}
- $a->data = array('target' => $results['target'], 'results' => array_merge($friends,$others));
+ App::$data = array('target' => $results['target'], 'results' => array_merge($friends,$others));
- if(! $a->data['results']) {
+ if(! App::$data['results']) {
notice( t('No ratings') . EOL);
}
@@ -91,8 +91,8 @@ 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 href="' . $a->data['target']['site_url'] . '" >' . $a->data['target']['site_url'] . '</a>' : '');
+ $site_target = ((array_key_exists('target',App::$data) && array_key_exists('site_url',App::$data['target'])) ?
+ '<a href="' . App::$data['target']['site_url'] . '" >' . App::$data['target']['site_url'] . '</a>' : '');
$o = replace_macros(get_markup_template('prep.tpl'),array(
@@ -101,7 +101,7 @@ function ratings_content(&$a) {
'$website' => t('Website: '),
'$site' => $site_target,
'$rating_text_lbl' => t('Description: '),
- '$raters' => $a->data['results']
+ '$raters' => App::$data['results']
));
return $o;
diff --git a/mod/rbmark.php b/mod/rbmark.php
index 4401e3626..979f96f85 100644
--- a/mod/rbmark.php
+++ b/mod/rbmark.php
@@ -1,6 +1,6 @@
<?php /** @file */
-require_once('acl_selectors.php');
+require_once('include/acl_selectors.php');
require_once('include/crypto.php');
require_once('include/items.php');
require_once('include/taxonomy.php');
@@ -30,7 +30,7 @@ function rbmark_post(&$a) {
logger('rbmark_post: ' . print_r($_REQUEST,true));
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$t = array('url' => escape_tags($_REQUEST['url']),'term' => escape_tags($_REQUEST['title']));
bookmark_add($channel,$channel,$t,((x($_REQUEST,'private')) ? intval($_REQUEST['private']) : 0),
@@ -75,7 +75,7 @@ function rbmark_content(&$a) {
goaway(z_root() . '/bookmarks');
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$m = menu_list($channel['channel_id'],'',MENU_BOOKMARK);
diff --git a/mod/register.php b/mod/register.php
index 2e9967c60..712691547 100644
--- a/mod/register.php
+++ b/mod/register.php
@@ -1,5 +1,6 @@
<?php
+require_once('include/identity.php');
function register_init(&$a) {
@@ -97,15 +98,22 @@ function register_post(&$a) {
require_once('include/security.php');
+ if($_REQUEST['name'])
+ set_aconfig($result['account']['account_id'],'register','channel_name',$_REQUEST['name']);
+ if($_REQUEST['nickname'])
+ set_aconfig($result['account']['account_id'],'register','channel_address',$_REQUEST['nickname']);
+ if($_REQUEST['permissions_role'])
+ set_aconfig($result['account']['account_id'],'register','permissions_role',$_REQUEST['permissions_role']);
+
+
$using_invites = intval(get_config('system','invitation_only'));
$num_invites = intval(get_config('system','number_invites'));
$invite_code = ((x($_POST,'invite_code')) ? notags(trim($_POST['invite_code'])) : '');
if($using_invites && $invite_code) {
q("delete * from register where hash = '%s'", dbesc($invite_code));
-// @FIXME - this total needs to be stored by account, but pconfig operates on channels
-// This also needs to be considered when using 'invites_remaining' in mod/invite.php
-// set_pconfig($result['account']['account_id'],'system','invites_remaining',$num_invites);
+ // @FIXME - this also needs to be considered when using 'invites_remaining' in mod/invite.php
+ set_aconfig($result['account']['account_id'],'system','invites_remaining',$num_invites);
}
if($policy == REGISTER_OPEN ) {
@@ -113,7 +121,7 @@ function register_post(&$a) {
$res = verify_email_address($result);
}
else {
- $res = send_verification_email($result['email'],$result['password']);
+ $res = send_register_success_email($result['email'],$result['password']);
}
if($res) {
info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ;
@@ -135,35 +143,51 @@ function register_post(&$a) {
}
authenticate_success($result['account'],true,false,true);
+
+ $new_channel = false;
+ $next_page = 'new_channel';
+
+ if(get_config('system','auto_channel_create') || UNO) {
+ $new_channel = auto_channel_create($result['account']['account_id']);
+ if($new_channel['success']) {
+ $channel_id = $new_channel['channel']['channel_id'];
+ change_channel($channel_id);
+ $next_page = '~';
+ }
+ else
+ $new_channel = false;
+ }
- if(! strlen($next_page = get_config('system','workflow_register_next')))
- $next_page = 'new_channel';
+ $x = get_config('system','workflow_register_next');
+ if($x) {
+ $next_page = $x;
+ $_SESSION['workflow'] = true;
+ }
- $_SESSION['workflow'] = true;
-
goaway(z_root() . '/' . $next_page);
}
-
-
-
-
function register_content(&$a) {
$registration_is = '';
$other_sites = '';
if(get_config('system','register_policy') == REGISTER_CLOSED) {
+ if(get_config('system','directory_mode') == DIRECTORY_MODE_STANDALONE) {
+ notice( t('Registration on this hub is disabled.') . EOL);
+ return;
+ }
+
require_once('mod/pubsites.php');
return pubsites_content($a);
}
if(get_config('system','register_policy') == REGISTER_APPROVE) {
- $registration_is = t('Registration on this site/hub is by approval only.');
- $other_sites = t('<a href="pubsites">Register at another affiliated site/hub</a>');
+ $registration_is = t('Registration on this hub is by approval only.');
+ $other_sites = t('<a href="pubsites">Register at another affiliated hub.</a>');
}
$max_dailies = intval(get_config('system','max_daily_registrations'));
@@ -182,9 +206,9 @@ function register_content(&$a) {
$tosurl = get_config('system','tos_url');
if(! $tosurl)
- $tosurl = $a->get_baseurl() . '/help/TermsOfService';
+ $tosurl = z_root() . '/help/TermsOfService';
- $toslink = '<a href="' . $tosurl . '" >' . t('Terms of Service') . '</a>';
+ $toslink = '<a href="' . $tosurl . '" target="_blank">' . t('Terms of Service') . '</a>';
// Configurable whether to restrict age or not - default is based on international legal requirements
// This can be relaxed if you are on a restricted server that does not share with public servers
@@ -196,11 +220,19 @@ function register_content(&$a) {
$enable_tos = 1 - intval(get_config('system','no_termsofservice'));
- $email = ((x($_REQUEST,'email')) ? strip_tags(trim($_REQUEST['email'])) : "" );
- $password = ((x($_REQUEST,'password')) ? trim($_REQUEST['password']) : "" );
- $password2 = ((x($_REQUEST,'password2')) ? trim($_REQUEST['password2']) : "" );
- $invite_code = ((x($_REQUEST,'invite_code')) ? strip_tags(trim($_REQUEST['invite_code'])) : "" );
+ $email = array('email', t('Your email address'), ((x($_REQUEST,'email')) ? strip_tags(trim($_REQUEST['email'])) : ""));
+ $password = array('password', t('Choose a password'), ((x($_REQUEST,'password')) ? trim($_REQUEST['password']) : ""));
+ $password2 = array('password2', t('Please re-enter your password'), ((x($_REQUEST,'password2')) ? trim($_REQUEST['password2']) : ""));
+ $invite_code = array('invite_code', t('Please enter your invitation code'), ((x($_REQUEST,'invite_code')) ? strip_tags(trim($_REQUEST['invite_code'])) : ""));
+ $name = array('name', t('Name or caption'), ((x($_REQUEST,'name')) ? $_REQUEST['name'] : ''), t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group"'));
+ $nickhub = '@' . str_replace(array('http://','https://','/'), '', get_config('system','baseurl'));
+ $nickname = array('nickname', t('Choose a short nickname'), ((x($_REQUEST,'nickname')) ? $_REQUEST['nickname'] : ''), sprintf( t('Your nickname will be used to create an easy to remember channel address e.g. nickname%s'), $nickhub));
+ $privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : "");
+ $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel role with your privacy requirements.') . ' <a href="help/roles" target="_blank">' . t('Read more about roles') . '</a>',get_roles());
+ $tos = array('tos', $label_tos, '', '', array(t('no'),t('yes')));
+ $auto_create = ((UNO) || (get_config('system','auto_channel_create')) ? true : false);
+ $default_role = ((UNO) ? 'social' : get_config('system','default_permissions_role'));
require_once('include/bbcode.php');
@@ -212,18 +244,18 @@ function register_content(&$a) {
'$other_sites' => $other_sites,
'$invitations' => get_config('system','invitation_only'),
'$invite_desc' => t('Membership on this site is by invitation only.'),
- '$label_invite' => t('Please enter your invitation code'),
'$invite_code' => $invite_code,
-
- '$label_email' => t('Your email address'),
- '$label_pass1' => t('Choose a password'),
- '$label_pass2' => t('Please re-enter your password'),
- '$label_tos' => $label_tos,
- '$enable_tos' => $enable_tos,
+ '$auto_create' => $auto_create,
+ '$name' => $name,
+ '$role' => $role,
+ '$default_role' => $default_role,
+ '$nickname' => $nickname,
+ '$enable_tos' => $enable_tos,
+ '$tos' => $tos,
'$email' => $email,
'$pass1' => $password,
'$pass2' => $password2,
- '$submit' => t('Register')
+ '$submit' => ((UNO || $auto_create || $registration_is) ? t('Register') : t('Proceed to create your first channel'))
));
return $o;
diff --git a/mod/regmod.php b/mod/regmod.php
index c0a75ef48..d500de0dc 100644
--- a/mod/regmod.php
+++ b/mod/regmod.php
@@ -5,11 +5,11 @@ function regmod_content(&$a) {
global $lang;
- $_SESSION['return_url'] = $a->cmd;
+ $_SESSION['return_url'] = App::$cmd;
if(! local_channel()) {
info( t('Please login.') . EOL);
- $o .= '<br /><br />' . login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
+ $o .= '<br /><br />' . login((App::$config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
return $o;
}
@@ -25,10 +25,10 @@ function regmod_content(&$a) {
$hash = argv(2);
if($cmd === 'deny') {
- if (!user_deny($hash)) killme();
+ if (! account_deny($hash)) killme();
}
if($cmd === 'allow') {
- if (!user_allow($hash)) killme();
+ if (! account_allow($hash)) killme();
}
}
diff --git a/mod/regver.php b/mod/regver.php
index c3ade2ee1..a26843376 100644
--- a/mod/regver.php
+++ b/mod/regver.php
@@ -4,7 +4,7 @@ function regver_content(&$a) {
global $lang;
- $_SESSION['return_url'] = $a->cmd;
+ $_SESSION['return_url'] = App::$cmd;
if(argc() != 3)
killme();
@@ -13,10 +13,10 @@ function regver_content(&$a) {
$hash = argv(2);
if($cmd === 'deny') {
- if (!user_deny($hash)) killme();
+ if (! account_deny($hash)) killme();
}
if($cmd === 'allow') {
- if (!user_approve($hash)) killme();
+ if (! account_approve($hash)) killme();
}
}
diff --git a/mod/removeaccount.php b/mod/removeaccount.php
index f3fa53f75..b4c2bad33 100644
--- a/mod/removeaccount.php
+++ b/mod/removeaccount.php
@@ -18,7 +18,7 @@ function removeaccount_post(&$a) {
return;
- $account = $a->get_account();
+ $account = App::get_account();
$account_id = get_account_id();
if(! account_verify_password($account['account_email'],$_POST['qxz_password']))
@@ -52,7 +52,7 @@ function removeaccount_content(&$a) {
$_SESSION['remove_account_verify'] = $hash;
$tpl = get_markup_template('removeaccount.tpl');
$o .= replace_macros($tpl, array(
- '$basedir' => $a->get_baseurl(),
+ '$basedir' => z_root(),
'$hash' => $hash,
'$title' => t('Remove This Account'),
'$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!')),
diff --git a/mod/removeme.php b/mod/removeme.php
index b604bc7db..ab1d5fe4f 100644
--- a/mod/removeme.php
+++ b/mod/removeme.php
@@ -18,7 +18,7 @@ function removeme_post(&$a) {
return;
- $account = $a->get_account();
+ $account = App::get_account();
if(! account_verify_password($account['account_email'],$_POST['qxz_password']))
return;
@@ -52,7 +52,7 @@ function removeme_content(&$a) {
$tpl = get_markup_template('removeme.tpl');
$o .= replace_macros($tpl, array(
- '$basedir' => $a->get_baseurl(),
+ '$basedir' => z_root(),
'$hash' => $hash,
'$title' => t('Remove This Channel'),
'$desc' => array(t('WARNING: '), t('This channel will be completely removed from the network. '), t('This action is permanent and can not be undone!')),
diff --git a/mod/rmagic.php b/mod/rmagic.php
index 597c6ed9c..6a47b495a 100644
--- a/mod/rmagic.php
+++ b/mod/rmagic.php
@@ -14,7 +14,7 @@ function rmagic_init(&$a) {
if($r) {
if($r[0]['hubloc_url'] === z_root())
goaway(z_root() . '/login');
- $dest = z_root() . '/' . str_replace('zid=','zid_=',get_app()->query_string);
+ $dest = z_root() . '/' . str_replace('zid=','zid_=',App::$query_string);
goaway($r[0]['hubloc_url'] . '/magic' . '?f=&dest=' . $dest);
}
}
@@ -70,7 +70,7 @@ function rmagic_post(&$a) {
if($_SESSION['return_url'])
$dest = urlencode(z_root() . '/' . str_replace('zid=','zid_=',$_SESSION['return_url']));
else
- $dest = urlencode(z_root() . '/' . str_replace('zid=','zid_=',$a->query_string));
+ $dest = urlencode(z_root() . '/' . str_replace('zid=','zid_=',App::$query_string));
goaway($url . '/magic' . '?f=&dest=' . $dest);
}
diff --git a/mod/rpost.php b/mod/rpost.php
index d519a996b..69b8c7b7e 100644
--- a/mod/rpost.php
+++ b/mod/rpost.php
@@ -1,6 +1,6 @@
<?php /** @file */
-require_once('acl_selectors.php');
+require_once('include/acl_selectors.php');
require_once('include/crypto.php');
require_once('include/items.php');
require_once('include/taxonomy.php');
@@ -37,9 +37,9 @@ function rpost_content(&$a) {
// by the wretched beast called 'suhosin'. All the browsers now allow long GET requests, but suhosin
// blocks them.
- $url = get_rpost_path($a->get_observer());
+ $url = get_rpost_path(App::get_observer());
// make sure we're not looping to our own hub
- if(($url) && (! stristr($url, $a->get_hostname()))) {
+ if(($url) && (! stristr($url, App::get_hostname()))) {
foreach($_REQUEST as $key => $arg) {
$url .= '&' . $key . '=' . $arg;
}
@@ -92,10 +92,10 @@ function rpost_content(&$a) {
$_REQUEST['body'] = html2bbcode($_REQUEST['body']);
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$channel_acl = $acl->get();
@@ -111,7 +111,7 @@ function rpost_content(&$a) {
'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'],
'lockstate' => (($acl->is_private()) ? 'lock' : 'unlock'),
- 'acl' => populate_acl($channel_acl),
+ 'acl' => populate_acl($channel_acl,true,(($channel['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : '')),
'bang' => '',
'visitor' => true,
'profile_uid' => local_channel(),
diff --git a/mod/rsd_xml.php b/mod/rsd_xml.php
index 6fd9514cd..4ce82dbe0 100644
--- a/mod/rsd_xml.php
+++ b/mod/rsd_xml.php
@@ -10,7 +10,7 @@ function rsd_xml_content(&$a) {
<engineName>Red</engineName>
<engineLink>http://friendica.com/</engineLink>
<apis>
- <api name="Twitter" preferred="true" apiLink="'.$a->get_baseurl().'/api/" blogID="">
+ <api name="Twitter" preferred="true" apiLink="'.z_root().'/api/" blogID="">
<settings>
<docs>http://status.net/wiki/TwitterCompatibleAPI</docs>
<setting name="OAuth">false</setting>
diff --git a/mod/search.php b/mod/search.php
index 555d46f6a..37bd00a66 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -2,7 +2,7 @@
function search_init(&$a) {
if(x($_REQUEST,'search'))
- $a->data['search'] = $_REQUEST['search'];
+ App::$data['search'] = $_REQUEST['search'];
}
@@ -30,7 +30,7 @@ function search_content(&$a,$update = 0, $load = false) {
$update = $load = 1;
}
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$observer_hash = (($observer) ? $observer['xchan_hash'] : '');
$o = '<div id="live-search"></div>' . "\r\n";
@@ -39,8 +39,8 @@ function search_content(&$a,$update = 0, $load = false) {
$o .= '<h3>' . t('Search') . '</h3>';
- if(x($a->data,'search'))
- $search = trim($a->data['search']);
+ if(x(App::$data,'search'))
+ $search = trim(App::$data['search']);
else
$search = ((x($_GET,'search')) ? trim(rawurldecode($_GET['search'])) : '');
@@ -99,12 +99,12 @@ function search_content(&$a,$update = 0, $load = false) {
$o .= '<div id="live-search"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . ((intval(local_channel())) ? local_channel() : (-1))
- . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
+ . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . "; </script>\r\n";
- $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
+ App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
'$baseurl' => z_root(),
'$pgtype' => 'search',
- '$uid' => (($a->profile['profile_uid']) ? $a->profile['profile_uid'] : '0'),
+ '$uid' => ((App::$profile['profile_uid']) ? App::$profile['profile_uid'] : '0'),
'$gid' => '0',
'$cid' => '0',
'$cmin' => '0',
@@ -117,7 +117,7 @@ function search_content(&$a,$update = 0, $load = false) {
'$nouveau' => '0',
'$wall' => '0',
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
- '$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1),
+ '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
'$search' => (($tag) ? urlencode('#') : '') . $search,
'$order' => '',
'$file' => '',
@@ -141,8 +141,8 @@ function search_content(&$a,$update = 0, $load = false) {
if(($update) && ($load)) {
$itemspage = get_pconfig(local_channel(),'system','itemspage');
- $a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
- $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
+ App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
// in case somebody turned off public access to sys channel content with permissions
diff --git a/mod/search_ac.php b/mod/search_ac.php
index 19c1dc940..6ffdc6ed5 100644
--- a/mod/search_ac.php
+++ b/mod/search_ac.php
@@ -50,7 +50,7 @@ function search_ac_init(&$a){
if(count($r)) {
foreach($r as $g) {
$results[] = array(
- "photo" => $a->get_baseurl() . '/images/hashtag.png',
+ "photo" => z_root() . '/images/hashtag.png',
"name" => '#'.$g['term'],
"id" => $g['tid'],
"link" => $g['url'],
diff --git a/mod/service_limits.php b/mod/service_limits.php
index ac96668ab..8ce410ab6 100644
--- a/mod/service_limits.php
+++ b/mod/service_limits.php
@@ -8,7 +8,7 @@ function service_limits_content(&$a) {
return;
}
- $account = $a->get_account();
+ $account = App::get_account();
if($account['account_service_class']) {
$x = get_config('service_class',$account['account_service_class']);
if($x) {
diff --git a/mod/settings.php b/mod/settings.php
index 339f83cfe..dbb381191 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -4,7 +4,7 @@ require_once('include/zot.php');
function get_theme_config_file($theme){
- $base_theme = get_app()->theme_info['extends'];
+ $base_theme = App::$theme_info['extends'];
if (file_exists("view/theme/$theme/php/config.php")){
return "view/theme/$theme/php/config.php";
@@ -22,14 +22,14 @@ function settings_init(&$a) {
if($_SESSION['delegate'])
return;
- $a->profile_uid = local_channel();
+ App::$profile_uid = local_channel();
// default is channel settings in the absence of other arguments
if(argc() == 1) {
// We are setting these values - don't use the argc(), argv() functions here
- $a->argc = 2;
- $a->argv[] = 'channel';
+ App::$argc = 2;
+ App::$argv[] = 'channel';
}
@@ -45,7 +45,7 @@ function settings_post(&$a) {
if($_SESSION['delegate'])
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
logger('mod_settings: ' . print_r($_REQUEST,true));
@@ -57,7 +57,7 @@ function settings_post(&$a) {
q("DELETE FROM tokens WHERE id='%s' AND uid=%d",
dbesc($key),
local_channel());
- goaway($a->get_baseurl(true)."/settings/oauth/");
+ goaway(z_root()."/settings/oauth/");
return;
}
@@ -114,7 +114,7 @@ function settings_post(&$a) {
);
}
}
- goaway($a->get_baseurl(true)."/settings/oauth/");
+ goaway(z_root()."/settings/oauth/");
return;
}
@@ -153,8 +153,9 @@ function settings_post(&$a) {
check_form_security_token_redirectOnErr('/settings/display', 'settings_display');
- $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : $a->channel['channel_theme']);
+ $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : App::$channel['channel_theme']);
$mobile_theme = ((x($_POST,'mobile_theme')) ? notags(trim($_POST['mobile_theme'])) : '');
+ $preload_images = ((x($_POST,'preload_images')) ? intval($_POST['preload_images']) : 0);
$user_scalable = ((x($_POST,'user_scalable')) ? intval($_POST['user_scalable']) : 0);
$nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile']) : 0);
$title_tosource = ((x($_POST,'title_tosource')) ? intval($_POST['title_tosource']) : 0);
@@ -184,6 +185,7 @@ function settings_post(&$a) {
set_pconfig(local_channel(),'system','mobile_theme',$mobile_theme);
}
+ set_pconfig(local_channel(),'system','preload_images',$preload_images);
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);
@@ -194,7 +196,7 @@ function settings_post(&$a) {
set_pconfig(local_channel(),'system','channel_divmore_height', $channel_divmore_height);
set_pconfig(local_channel(),'system','network_divmore_height', $network_divmore_height);
- if ($theme == $a->channel['channel_theme']){
+ if ($theme == App::$channel['channel_theme']){
// call theme_post only if theme has not been changed
if( ($themeconfigfile = get_theme_config_file($theme)) != null){
require_once($themeconfigfile);
@@ -209,7 +211,7 @@ function settings_post(&$a) {
call_hooks('display_settings_post', $_POST);
build_sync_packet();
- goaway($a->get_baseurl(true) . '/settings/display' );
+ goaway(z_root() . '/settings/display' );
return; // NOTREACHED
}
@@ -223,10 +225,44 @@ function settings_post(&$a) {
$errs = array();
+ $email = ((x($_POST,'email')) ? trim(notags($_POST['email'])) : '');
+ $account = App::get_account();
+ if($email != $account['account_email']) {
+ if(! valid_email($email))
+ $errs[] = t('Not valid email.');
+ $adm = trim(get_config('system','admin_email'));
+ if(($adm) && (strcasecmp($email,$adm) == 0)) {
+ $errs[] = t('Protected email address. Cannot change to that email.');
+ $email = App::$user['email'];
+ }
+ if(! $errs) {
+ $r = q("update account set account_email = '%s' where account_id = %d",
+ dbesc($email),
+ intval($account['account_id'])
+ );
+ if(! $r)
+ $errs[] = t('System failure storing new email. Please try again.');
+ }
+ }
+
+ if($errs) {
+ foreach($errs as $err)
+ notice($err . EOL);
+ $errs = array();
+ }
+
+
if((x($_POST,'npassword')) || (x($_POST,'confirm'))) {
- $newpass = $_POST['npassword'];
- $confirm = $_POST['confirm'];
+ $origpass = trim($_POST['origpass']);
+
+ require_once('include/auth.php');
+ if(! account_verify_password($email,$origpass)) {
+ $errs[] = t('Password verification failed.');
+ }
+
+ $newpass = trim($_POST['npassword']);
+ $confirm = trim($_POST['confirm']);
if($newpass != $confirm ) {
$errs[] = t('Passwords do not match. Password unchanged.');
@@ -253,37 +289,12 @@ function settings_post(&$a) {
}
}
- if($errs) {
- foreach($errs as $err)
- notice($err . EOL);
- $errs = array();
- }
-
- $email = ((x($_POST,'email')) ? trim(notags($_POST['email'])) : '');
- $account = $a->get_account();
- if($email != $account['account_email']) {
- if(! valid_email($email))
- $errs[] = t('Not valid email.');
- $adm = trim(get_config('system','admin_email'));
- if(($adm) && (strcasecmp($email,$adm) == 0)) {
- $errs[] = t('Protected email address. Cannot change to that email.');
- $email = $a->user['email'];
- }
- if(! $errs) {
- $r = q("update account set account_email = '%s' where account_id = %d",
- dbesc($email),
- intval($account['account_id'])
- );
- if(! $r)
- $errs[] = t('System failure storing new email. Please try again.');
- }
- }
if($errs) {
foreach($errs as $err)
notice($err . EOL);
}
- goaway($a->get_baseurl(true) . '/settings/account' );
+ goaway(z_root() . '/settings/account' );
}
@@ -312,7 +323,7 @@ function settings_post(&$a) {
foreach($global_perms as $k => $v) {
$set_perms .= ', ' . $v[0] . ' = ' . intval($_POST[$k]) . ' ';
}
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$acl->set_from_array($_POST);
$x = $acl->get();
@@ -354,7 +365,7 @@ function settings_post(&$a) {
);
}
else {
- notice( sprintf('Default privacy collection \'%s\' not found. Please create and re-submit permission change.', t('Friends')) . EOL);
+ notice( sprintf('Default privacy group \'%s\' not found. Please create and re-submit permission change.', t('Friends')) . EOL);
return;
}
}
@@ -367,7 +378,7 @@ function settings_post(&$a) {
}
$r = q("update abook set abook_my_perms = %d where abook_channel = %d and abook_self = 1",
- intval(($role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0),
+ intval((array_key_exists('perms_accept',$role_permissions)) ? $role_permissions['perms_accept'] : 0),
intval(local_channel())
);
set_pconfig(local_channel(),'system','autoperms',(($role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0));
@@ -417,7 +428,7 @@ function settings_post(&$a) {
$cal_first_day = (((x($_POST,'first_day')) && (intval($_POST['first_day']) == 1)) ? 1: 0);
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$pageflags = $channel['channel_pageflags'];
$existing_adult = (($pageflags & PAGE_ADULT) ? 1 : 0);
if($adult != $existing_adult)
@@ -471,7 +482,7 @@ function settings_post(&$a) {
$always_show_in_notices = x($_POST,'always_show_in_notices') ? 1 : 0;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$err = '';
@@ -545,14 +556,14 @@ function settings_post(&$a) {
//$_SESSION['theme'] = $theme;
- if($email_changed && $a->config['system']['register_policy'] == REGISTER_VERIFY) {
+ if($email_changed && App::$config['system']['register_policy'] == REGISTER_VERIFY) {
// FIXME - set to un-verified, blocked and redirect to logout
// Why? Are we verifying people or email addresses?
}
- goaway($a->get_baseurl(true) . '/settings' );
+ goaway(z_root() . '/settings' );
return; // NOTREACHED
}
@@ -570,7 +581,7 @@ function settings_content(&$a) {
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if($channel)
head_set_icon($channel['xchan_photo_s']);
@@ -600,7 +611,7 @@ function settings_content(&$a) {
local_channel());
if (!count($r)){
- notice(t("You can't edit this application."));
+ notice(t('Application not found.'));
return;
}
$app = $r[0];
@@ -626,7 +637,7 @@ function settings_content(&$a) {
$r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
dbesc(argv(3)),
local_channel());
- goaway($a->get_baseurl(true)."/settings/oauth/");
+ goaway(z_root()."/settings/oauth/");
return;
}
@@ -642,7 +653,7 @@ function settings_content(&$a) {
$tpl = get_markup_template("settings_oauth.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_oauth"),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$title' => t('Connected Apps'),
'$add' => t('Add application'),
'$edit' => t('Edit'),
@@ -686,15 +697,16 @@ function settings_content(&$a) {
call_hooks('account_settings', $account_settings);
- $email = $a->account['account_email'];
+ $email = App::$account['account_email'];
$tpl = get_markup_template("settings_account.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_account"),
'$title' => t('Account Settings'),
- '$password1'=> array('npassword', t('Enter New Password:'), '', ''),
- '$password2'=> array('confirm', t('Confirm New Password:'), '', t('Leave password fields blank unless changing')),
+ '$origpass' => array('origpass', t('Current Password'), ' ',''),
+ '$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'),
@@ -803,6 +815,9 @@ function settings_content(&$a) {
$theme_selected = (!x($_SESSION,'theme')? $default_theme : $_SESSION['theme']);
$mobile_theme_selected = (!x($_SESSION,'mobile_theme')? $default_mobile_theme : $_SESSION['mobile_theme']);
+ $preload_images = get_pconfig(local_channel(),'system','preload_images');
+ $preload_images = (($preload_images===false)? '0': $preload_images); // default if not set: 0
+
$user_scalable = get_pconfig(local_channel(),'system','user_scalable');
$user_scalable = (($user_scalable===false)? '1': $user_scalable); // default if not set: 1
@@ -832,11 +847,12 @@ function settings_content(&$a) {
'$d_cset' => t('Content Settings'),
'$form_security_token' => get_form_security_token("settings_display"),
'$submit' => t('Submit'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$uid' => local_channel(),
'$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),
+ '$mobile_theme' => (($mobile_themes) ? array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, '') : false),
+ '$preload_images' => array('preload_images', t("Preload images before rendering the page"), $preload_images, t("The subjective page load time will be longer but the page will be ready when displayed"), $yes_no),
'$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')),
@@ -846,9 +862,9 @@ function settings_content(&$a) {
'$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)'), $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),
+ '$network_list_mode' => array('network_list_mode', t('Use blog/list mode on grid 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')),
+ '$network_divmore_height' => array('network_divmore_height', t('Grid 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')),
));
@@ -874,7 +890,7 @@ function settings_content(&$a) {
load_pconfig(local_channel(),'expire');
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$global_perms = get_perms();
@@ -917,9 +933,10 @@ function settings_content(&$a) {
$maxreq = $channel['channel_max_friend_req'];
$expire = $channel['channel_expire_days'];
$adult_flag = intval($channel['channel_pageflags'] & PAGE_ADULT);
+ $sys_expire = get_config('system','default_expire_days');
-// $unkmail = $a->user['unkmail'];
-// $cntunkmail = $a->user['cntunkmail'];
+// $unkmail = App::$user['unkmail'];
+// $cntunkmail = App::$user['cntunkmail'];
$hide_presence = intval(get_pconfig(local_channel(), 'system','hide_online_status'));
@@ -972,7 +989,7 @@ function settings_content(&$a) {
));
- $subdir = ((strlen($a->get_path())) ? '<br />' . t('or') . ' ' . $a->get_baseurl(true) . '/channel/' . $nickname : '');
+ $subdir = ((strlen(App::get_path())) ? '<br />' . t('or') . ' ' . z_root() . '/channel/' . $nickname : '');
$tpl_addr = get_markup_template("settings_nick_set.tpl");
@@ -980,12 +997,12 @@ function settings_content(&$a) {
'$desc' => t('Your channel address is'),
'$nickname' => $nickname,
'$subdir' => $subdir,
- '$basepath' => $a->get_hostname()
+ '$basepath' => App::get_hostname()
));
$stpl = get_markup_template('settings.tpl');
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$perm_defaults = $acl->get();
require_once('include/group.php');
@@ -1012,6 +1029,7 @@ function settings_content(&$a) {
$permissions_role = 'custom';
$permissions_set = (($permissions_role != 'custom') ? true : false);
+
$vnotify = get_pconfig(local_channel(),'system','vnotify');
$always_show_in_notices = get_pconfig(local_channel(),'system','always_show_in_notices');
if($vnotify === false)
@@ -1021,7 +1039,7 @@ function settings_content(&$a) {
'$ptitle' => t('Channel Settings'),
'$submit' => t('Submit'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => z_root(),
'$uid' => local_channel(),
'$form_security_token' => get_form_security_token("settings"),
'$nickname_block' => $prof_addr,
@@ -1036,6 +1054,7 @@ function settings_content(&$a) {
'$h_prv' => t('Security and Privacy Settings'),
'$permissions_set' => $permissions_set,
+ '$server_role' => Zotlabs\Project\System::get_server_role(),
'$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'), $yes_no),
@@ -1050,7 +1069,7 @@ function settings_content(&$a) {
'$lbl_p2macro' => t('Advanced Privacy Settings'),
- '$expire' => array('expire',t('Expire other channel content after this many days'),$expire,t('0 or blank prevents expiration')),
+ '$expire' => array('expire',t('Expire other channel content after this many days'),$expire,sprintf( t('0 or blank to use the website limit. The website expires after %d days.'),intval($sys_expire))),
'$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']) , t('May reduce spam activity')),
'$permissions' => t('Default Post Permissions'),
'$permdesc' => t("\x28click to open/close\x29"),
@@ -1084,7 +1103,7 @@ function settings_content(&$a) {
'$lbl_vnot' => t('Show visual notifications including:'),
- '$vnotify1' => array('vnotify1', t('Unseen matrix activity'), ($vnotify & VNOTIFY_NETWORK), VNOTIFY_NETWORK, '', $yes_no),
+ '$vnotify1' => array('vnotify1', t('Unseen grid 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),
diff --git a/mod/setup.php b/mod/setup.php
index 5c9e988d9..5dccc1711 100755
--- a/mod/setup.php
+++ b/mod/setup.php
@@ -41,6 +41,9 @@ function setup_init(&$a) {
global $install_wizard_pass;
if (x($_POST, 'pass'))
$install_wizard_pass = intval($_POST['pass']);
+ else
+ $install_wizard_pass = 1;
+
}
/**
@@ -57,7 +60,7 @@ function setup_post(&$a) {
return;
break; // just in case return don't return :)
case 3:
- $urlpath = $a->get_path();
+ $urlpath = App::get_path();
$dbhost = trim($_POST['dbhost']);
$dbport = intval(trim($_POST['dbport']));
$dbuser = trim($_POST['dbuser']);
@@ -67,7 +70,8 @@ function setup_post(&$a) {
$phpath = trim($_POST['phpath']);
$adminmail = trim($_POST['adminmail']);
$siteurl = trim($_POST['siteurl']);
-
+ $advanced = ((intval($_POST['advanced'])) ? 1 : 0);
+
// $siteurl should not have a trailing slash
$siteurl = rtrim($siteurl,'/');
@@ -79,7 +83,7 @@ function setup_post(&$a) {
if(! $db->connected) {
echo 'Database Connect failed: ' . $db->error;
killme();
- $a->data['db_conn_failed']=true;
+ App::$data['db_conn_failed']=true;
}
/*if(get_db_errno()) {
unset($db);
@@ -93,10 +97,10 @@ function setup_post(&$a) {
unset($db);
$db = new dba($dbhost, $dbport, $dbuser, $dbpass, $dbdata, true);
} else {
- $a->data['db_create_failed']=true;
+ App::$data['db_create_failed']=true;
}
} else {
- $a->data['db_conn_failed']=true;
+ App::$data['db_conn_failed']=true;
return;
}
}*/
@@ -107,7 +111,7 @@ function setup_post(&$a) {
return;
break;
case 4:
- $urlpath = $a->get_path();
+ $urlpath = App::get_path();
$dbhost = notags(trim($_POST['dbhost']));
$dbport = intval(notags(trim($_POST['dbport'])));
$dbuser = notags(trim($_POST['dbuser']));
@@ -118,12 +122,13 @@ function setup_post(&$a) {
$timezone = notags(trim($_POST['timezone']));
$adminmail = notags(trim($_POST['adminmail']));
$siteurl = notags(trim($_POST['siteurl']));
+ $advanced = ((intval($_POST['advanced'])) ? 1 : 0);
if($siteurl != z_root()) {
$test = z_fetch_url($siteurl."/setup/testrewrite");
if((! $test['success']) || ($test['body'] != 'ok')) {
- $a->data['url_fail'] = true;
- $a->data['url_error'] = $test['error'];
+ App::$data['url_fail'] = true;
+ App::$data['url_error'] = $test['error'];
return;
}
}
@@ -138,30 +143,31 @@ function setup_post(&$a) {
$tpl = get_intltext_template('htconfig.tpl');
$txt = replace_macros($tpl,array(
- '$dbhost' => $dbhost,
- '$dbport' => $dbport,
- '$dbuser' => $dbuser,
- '$dbpass' => $dbpass,
- '$dbdata' => $dbdata,
- '$dbtype' => $dbtype,
- '$timezone' => $timezone,
- '$siteurl' => $siteurl,
- '$site_id' => random_string(),
- '$phpath' => $phpath,
+ '$dbhost' => $dbhost,
+ '$dbport' => $dbport,
+ '$dbuser' => $dbuser,
+ '$dbpass' => $dbpass,
+ '$dbdata' => $dbdata,
+ '$dbtype' => $dbtype,
+ '$uno' => 1 - $advanced,
+ '$timezone' => $timezone,
+ '$siteurl' => $siteurl,
+ '$site_id' => random_string(),
+ '$phpath' => $phpath,
'$adminmail' => $adminmail
));
$result = file_put_contents('.htconfig.php', $txt);
if(! $result) {
- $a->data['txt'] = $txt;
+ App::$data['txt'] = $txt;
}
$errors = load_database($db);
if($errors)
- $a->data['db_failed'] = $errors;
+ App::$data['db_failed'] = $errors;
else
- $a->data['db_installed'] = true;
+ App::$data['db_installed'] = true;
return;
break;
@@ -190,31 +196,31 @@ function setup_content(&$a) {
$wizard_status = '';
$install_title = t('$Projectname Server - Setup');
- if(x($a->data, 'db_conn_failed')) {
+ if(x(App::$data, 'db_conn_failed')) {
$install_wizard_pass = 2;
$wizard_status = t('Could not connect to database.');
}
- if(x($a->data, 'url_fail')) {
+ if(x(App::$data, 'url_fail')) {
$install_wizard_pass = 3;
$wizard_status = t('Could not connect to specified site URL. Possible SSL certificate or DNS issue.');
- if($a->data['url_error'])
- $wizard_status .= ' ' . $a->data['url_error'];
+ if(App::$data['url_error'])
+ $wizard_status .= ' ' . App::$data['url_error'];
}
- if(x($a->data, 'db_create_failed')) {
+ if(x(App::$data, 'db_create_failed')) {
$install_wizard_pass = 2;
$wizard_status = t('Could not create table.');
}
$db_return_text = '';
- if(x($a->data, 'db_installed')) {
+ if(x(App::$data, 'db_installed')) {
$txt = '<p style="font-size: 130%;">';
$txt .= t('Your site database has been installed.') . EOL;
$db_return_text .= $txt;
}
- if(x($a->data, 'db_failed')) {
+ if(x(App::$data, 'db_failed')) {
$txt = t('You may need to import the file "install/schema_xxx.sql" manually using a database client.') . EOL;
$txt .= t('Please see the file "install/INSTALL.txt".') . EOL ."<hr>" ;
- $txt .= "<pre>".$a->data['db_failed'] . "</pre>". EOL ;
+ $txt .= "<pre>".App::$data['db_failed'] . "</pre>". EOL ;
$db_return_text .= $txt;
}
if($db && $db->connected) {
@@ -230,7 +236,7 @@ function setup_content(&$a) {
}
}
- if(x($a->data, 'txt') && strlen($a->data['txt'])) {
+ if(x(App::$data, 'txt') && strlen(App::$data['txt'])) {
$db_return_text .= manual_config($a);
}
@@ -285,7 +291,7 @@ function setup_content(&$a) {
'$next' => t('Next'),
'$reload' => t('Check again'),
'$phpath' => $phpath,
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => z_root(),
));
return $o;
}; break;
@@ -321,10 +327,9 @@ function setup_content(&$a) {
'$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')),
'$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')),
-
'$lbl_10' => t('Please select a default timezone for your website'),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => z_root(),
'$phpath' => $phpath,
@@ -363,10 +368,11 @@ function setup_content(&$a) {
'$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')),
'$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')),
+ '$advanced' => array('advanced', t('Enable $Projectname <strong>advanced</strong> features?'), 1, t('Some advanced features, while useful - may be best suited for technically proficient audiences')),
'$timezone' => array('timezone', t('Please select a default timezone for your website'), $timezone, '', get_timezones()),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => z_root(),
'$submit' => t('Submit'),
));
@@ -627,7 +633,7 @@ function check_htaccess(&$checks) {
$help = '';
$ssl_error = false;
- $url = $a->get_baseurl() . '/setup/testrewrite';
+ $url = z_root() . '/setup/testrewrite';
if (function_exists('curl_init')){
$test = z_fetch_url($url);
@@ -670,7 +676,7 @@ function check_htaccess(&$checks) {
function manual_config(&$a) {
- $data = htmlspecialchars($a->data['txt'], ENT_COMPAT, 'UTF-8');
+ $data = htmlspecialchars(App::$data['txt'], ENT_COMPAT, 'UTF-8');
$o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.');
$o .= "<textarea rows=\"24\" cols=\"80\" >$data</textarea>";
@@ -727,7 +733,7 @@ function what_next() {
require_once ('include/identity.php');
create_sys_channel();
- $baseurl = $a->get_baseurl();
+ $baseurl = z_root();
return
t('<h1>What next</h1>')
."<p>".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.')
diff --git a/mod/share.php b/mod/share.php
index 7ed6cf9a6..43206b487 100644
--- a/mod/share.php
+++ b/mod/share.php
@@ -1,7 +1,7 @@
<?php
require_once('include/security.php');
-require_once('bbcode.php');
+require_once('include/bbcode.php');
function share_init(&$a) {
@@ -45,7 +45,7 @@ function share_init(&$a) {
$is_photo = (($r[0]['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false);
if($is_photo) {
$object = json_decode($r[0]['object'],true);
- $photo_bb = $object['bbcode'];
+ $photo_bb = $object['body'];
}
if (strpos($r[0]['body'], "[/share]") !== false) {
@@ -69,7 +69,7 @@ function share_init(&$a) {
killme();
}
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$parsed = $observer['xchan_url'];
if($parsed) {
$post_url = $parsed['scheme'] . ':' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '')
diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php
index bee072ea7..27c238270 100644
--- a/mod/sharedwithme.php
+++ b/mod/sharedwithme.php
@@ -8,7 +8,7 @@ function sharedwithme_content(&$a) {
return;
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$is_owner = (local_channel() && (local_channel() == $channel['channel_id']));
diff --git a/mod/siteinfo.php b/mod/siteinfo.php
index 52d014de1..7711fafb2 100644
--- a/mod/siteinfo.php
+++ b/mod/siteinfo.php
@@ -12,10 +12,10 @@ function siteinfo_init(&$a) {
function siteinfo_content(&$a) {
if(! get_config('system','hidden_version_siteinfo')) {
- $version = sprintf( t('Version %s'), RED_VERSION );
+ $version = sprintf( t('Version %s'), Zotlabs\Project\System::get_project_version());
if(@is_dir('.git') && function_exists('shell_exec')) {
$commit = @shell_exec('git log -1 --format="%h"');
- $tag = get_std_version(); // @shell_exec('git describe --tags --abbrev=0');
+ $tag = Zotlabs\Project\System::get_std_version(); // @shell_exec('git describe --tags --abbrev=0');
}
if(! isset($commit) || strlen($commit) > 16)
$commit = '';
@@ -24,7 +24,7 @@ function siteinfo_content(&$a) {
$version = $commit = '';
}
$visible_plugins = array();
- if(is_array($a->plugins) && count($a->plugins)) {
+ if(is_array(App::$plugins) && count(App::$plugins)) {
$r = q("select * from addon where hidden = 0");
if(count($r))
foreach($r as $rr)
diff --git a/mod/smilies.php b/mod/smilies.php
index b22d0c6d2..2ccc007b4 100644
--- a/mod/smilies.php
+++ b/mod/smilies.php
@@ -1,7 +1,7 @@
<?php
function smilies_content(&$a) {
- if ($a->argv[1]==="json"){
+ if (App::$argv[1]==="json"){
$tmp = list_smilies();
$results = array();
for($i = 0; $i < count($tmp['texts']); $i++) {
diff --git a/mod/sources.php b/mod/sources.php
index 0aaaa82b1..6ea0743aa 100644
--- a/mod/sources.php
+++ b/mod/sources.php
@@ -14,7 +14,7 @@ function sources_post(&$a) {
$frequency = $_REQUEST['frequency'];
$name = $_REQUEST['name'];
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if($name == '*')
$xchan = '*';
diff --git a/mod/subthread.php b/mod/subthread.php
index ce087806e..aca034d43 100755
--- a/mod/subthread.php
+++ b/mod/subthread.php
@@ -37,7 +37,7 @@ function subthread_content(&$a) {
$item = $r[0];
$owner_uid = $item['uid'];
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
if(! perm_is_allowed($owner_uid,$ob_hash,'post_comments'))
@@ -134,7 +134,7 @@ function subthread_content(&$a) {
$ulink = '[zrl=' . $item_author['xchan_url'] . ']' . $item_author['xchan_name'] . '[/zrl]';
$alink = '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]';
- $plink = '[zrl=' . $a->get_baseurl() . '/display/' . $item['mid'] . ']' . $post_type . '[/zrl]';
+ $plink = '[zrl=' . z_root() . '/display/' . $item['mid'] . ']' . $post_type . '[/zrl]';
$arr['body'] = sprintf( $bodyverb, $alink, $ulink, $plink );
diff --git a/mod/suggest.php b/mod/suggest.php
index 438d884ca..ca888310a 100644
--- a/mod/suggest.php
+++ b/mod/suggest.php
@@ -27,7 +27,7 @@ function suggest_content(&$a) {
return;
}
- $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
+ $_SESSION['return_url'] = z_root() . '/' . App::$cmd;
$r = suggestion_query(local_channel(),get_observer_hash());
@@ -40,7 +40,7 @@ function suggest_content(&$a) {
foreach($r as $rr) {
- $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['xchan_addr'];
+ $connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
$arr[] = array(
'url' => chanlink_url($rr['xchan_url']),
@@ -48,7 +48,7 @@ function suggest_content(&$a) {
'profile' => $rr['xchan_url'],
'name' => $rr['xchan_name'],
'photo' => $rr['xchan_photo_m'],
- 'ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['xchan_hash'],
+ 'ignlnk' => z_root() . '/suggest?ignore=' . $rr['xchan_hash'],
'conntxt' => t('Connect'),
'connlnk' => $connlnk,
'ignore' => t('Ignore/Hide')
diff --git a/mod/tagger.php b/mod/tagger.php
index 27a8a15ea..330b65b91 100644
--- a/mod/tagger.php
+++ b/mod/tagger.php
@@ -80,9 +80,9 @@ function tagger_content(&$a) {
$link = xmlify('<link rel="alternate" type="text/html" href="'
- . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
+ . z_root() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
- $tagid = $a->get_baseurl() . '/search?tag=' . $term;
+ $tagid = z_root() . '/search?tag=' . $term;
$objtype = ACTIVITY_OBJ_TAGTERM;
$obj = json_encode(array(
@@ -98,9 +98,9 @@ function tagger_content(&$a) {
// saving here for reference
// also check out x22d5 and x2317 and x0d6b and x0db8 and x24d0 and xff20 !!!
- $termlink = html_entity_decode('&#x22d5;') . '[zrl=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/zrl]';
+ $termlink = html_entity_decode('&#x22d5;') . '[zrl=' . z_root() . '/search?tag=' . urlencode($term) . ']'. $term . '[/zrl]';
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$arr = array();
diff --git a/mod/tagrm.php b/mod/tagrm.php
index 56e842fb8..e10bbad73 100644
--- a/mod/tagrm.php
+++ b/mod/tagrm.php
@@ -1,15 +1,15 @@
<?php
-require_once('bbcode.php');
+require_once('include/bbcode.php');
function tagrm_post(&$a) {
if(! local_channel())
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
if((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel')))
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
$tag = ((x($_POST,'tag')) ? trim($_POST['tag']) : '');
$item = ((x($_POST,'item')) ? intval($_POST['item']) : 0 );
@@ -20,7 +20,7 @@ function tagrm_post(&$a) {
);
if(! $r)
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
$r = fetch_post_tags($r,true);
@@ -42,7 +42,7 @@ function tagrm_post(&$a) {
item_store_update($item);
info( t('Tag removed') . EOL );
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
// NOTREACHED
@@ -53,7 +53,7 @@ function tagrm_post(&$a) {
function tagrm_content(&$a) {
if(! local_channel()) {
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
// NOTREACHED
}
@@ -69,7 +69,7 @@ function tagrm_content(&$a) {
);
if(! $r)
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
$r = fetch_post_tags($r,true);
@@ -92,7 +92,7 @@ function tagrm_content(&$a) {
item_store_update($item);
info( t('Tag removed') . EOL );
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
}
@@ -109,12 +109,12 @@ function tagrm_content(&$a) {
);
if(! $r)
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
$r = fetch_post_tags($r,true);
if(! count($r[0]['term']))
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(z_root() . '/' . $_SESSION['photo_return']);
$o .= '<h3>' . t('Remove Item Tag') . '</h3>';
diff --git a/mod/tasks.php b/mod/tasks.php
index b1b81473b..e11166f93 100644
--- a/mod/tasks.php
+++ b/mod/tasks.php
@@ -37,7 +37,7 @@ function tasks_post(&$a) {
if(! local_channel())
return;
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if((argc() > 2) && (argv(1) === 'complete') && intval(argv(2))) {
$ret = array('success' => false);
diff --git a/mod/thing.php b/mod/thing.php
index 280cc194d..44e9d9e2e 100644
--- a/mod/thing.php
+++ b/mod/thing.php
@@ -14,8 +14,7 @@ function thing_init(&$a) {
if(! local_channel())
return;
- $account_id = $a->get_account();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$term_hash = (($_REQUEST['term_hash']) ? $_REQUEST['term_hash'] : '');
@@ -66,7 +65,7 @@ function thing_init(&$a) {
if((! $name) || (! $translated_verb))
return;
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
if(array_key_exists('contact_allow',$_REQUEST)
|| array_key_exists('group_allow',$_REQUEST)
@@ -265,14 +264,14 @@ function thing_content(&$a) {
}
}
- $channel = $a->get_channel();
+ $channel = App::get_channel();
if(! (local_channel() && $channel)) {
notice( t('Permission denied.') . EOL);
return;
}
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$channel_acl = $acl->get();
$lockstate = (($acl->is_private()) ? 'lock' : 'unlock');
diff --git a/mod/toggle_mobile.php b/mod/toggle_mobile.php
index 06dadca04..918c4aad6 100644
--- a/mod/toggle_mobile.php
+++ b/mod/toggle_mobile.php
@@ -10,7 +10,7 @@ function toggle_mobile_init(&$a) {
if(isset($_GET['address']))
$address = $_GET['address'];
else
- $address = $a->get_baseurl();
+ $address = z_root();
goaway($address);
}
diff --git a/mod/uexport.php b/mod/uexport.php
index ee22383a3..4a16903f8 100644
--- a/mod/uexport.php
+++ b/mod/uexport.php
@@ -5,7 +5,7 @@ function uexport_init(&$a) {
killme();
if(argc() > 1) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
require_once('include/identity.php');
diff --git a/mod/update_display.php b/mod/update_display.php
index b448c76ee..52903bb8c 100644
--- a/mod/update_display.php
+++ b/mod/update_display.php
@@ -39,4 +39,4 @@ function update_display_content(&$a) {
// logger('update_display: ' . $text);
killme();
-} \ No newline at end of file
+}
diff --git a/mod/view.php b/mod/view.php
index d4381743c..f18646cb9 100644
--- a/mod/view.php
+++ b/mod/view.php
@@ -1,6 +1,6 @@
<?php
/**
- * load view/theme/$current_theme/style.php with Red context
+ * load view/theme/$current_theme/style.php with Hubzilla context
*/
function view_init($a){
diff --git a/mod/viewconnections.php b/mod/viewconnections.php
index d9a9aecc1..6e0daab6e 100644
--- a/mod/viewconnections.php
+++ b/mod/viewconnections.php
@@ -18,21 +18,21 @@ function viewconnections_content(&$a) {
return;
}
- if(((! count($a->profile)) || ($a->profile['hide_friends']))) {
+ if(((! count(App::$profile)) || (App::$profile['hide_friends']))) {
notice( t('Permission denied.') . EOL);
return;
}
- if(! perm_is_allowed($a->profile['uid'], get_observer_hash(),'view_contacts')) {
+ if(! perm_is_allowed(App::$profile['uid'], get_observer_hash(),'view_contacts')) {
notice( t('Permission denied.') . EOL);
return;
}
if(! $_REQUEST['aj'])
- $_SESSION['return_url'] = $a->query_string;
+ $_SESSION['return_url'] = App::$query_string;
- $is_owner = ((local_channel() && local_channel() == $a->profile['uid']) ? true : false);
+ $is_owner = ((local_channel() && local_channel() == App::$profile['uid']) ? true : false);
$abook_flags = " and abook_pending = 0 and abook_self = 0 ";
$sql_extra = '';
@@ -43,16 +43,16 @@ function viewconnections_content(&$a) {
}
$r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ",
- intval($a->profile['uid'])
+ intval(App::$profile['uid'])
);
if($r) {
- $a->set_pager_total($r[0]['total']);
+ App::set_pager_total($r[0]['total']);
}
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra order by xchan_name LIMIT %d OFFSET %d ",
- intval($a->profile['uid']),
- intval($a->pager['itemspage']),
- intval($a->pager['start'])
+ intval(App::$profile['uid']),
+ intval(App::$pager['itemspage']),
+ intval(App::$pager['start'])
);
if((! $r) && (! $_REQUEST['aj'])) {
diff --git a/mod/viewsrc.php b/mod/viewsrc.php
index cffb01b6e..a4efd1214 100644
--- a/mod/viewsrc.php
+++ b/mod/viewsrc.php
@@ -16,7 +16,7 @@ function viewsrc_content(&$a) {
if(! $item_id) {
- $a->error = 404;
+ App::$error = 404;
notice( t('Item not found.') . EOL);
}
diff --git a/mod/wall_attach.php b/mod/wall_attach.php
index f52a4f2e5..7f054705f 100644
--- a/mod/wall_attach.php
+++ b/mod/wall_attach.php
@@ -8,9 +8,9 @@ function wall_attach_post(&$a) {
$using_api = false;
- if($a->data['api_info'] && array_key_exists('media',$_FILES)) {
+ if(App::$data['api_info'] && array_key_exists('media',$_FILES)) {
$using_api = true;
- $user_info = $a->data['api_info'];
+ $user_info = App::$data['api_info'];
$nick = $user_info['screen_name'];
$channel = get_channel_by_nick($user_info['screen_name']);
}
@@ -20,26 +20,9 @@ function wall_attach_post(&$a) {
if(! $channel)
killme();
- $observer = $a->get_observer();
+ $observer = App::get_observer();
-// if($_FILES['userfile']['tmp_name']) {
-// $x = @getimagesize($_FILES['userfile']['tmp_name']);
-// logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
-// 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']) {
-// echo "\n\n" . $ret['body'] . "\n\n";
-// killme();
-// }
-// if($using_api)
-// return;
-// notice($ret['message']);
-// killme();
-// }
-// }
-
$def_album = get_pconfig($channel['channel_id'],'system','photo_path');
$def_attach = get_pconfig($channel['channel_id'],'system','attach_path');
diff --git a/mod/wall_upload.php b/mod/wall_upload.php
index 31a497f0f..54e2f8526 100644
--- a/mod/wall_upload.php
+++ b/mod/wall_upload.php
@@ -30,7 +30,7 @@ function wall_upload_post(&$a) {
killme();
}
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$args = array( 'source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash']));
diff --git a/mod/webfinger.php b/mod/webfinger.php
index 74bfc3ce5..e35767338 100644
--- a/mod/webfinger.php
+++ b/mod/webfinger.php
@@ -4,6 +4,7 @@
function webfinger_content(&$a) {
+
$o .= '<h3>Webfinger Diagnostic</h3>';
$o .= '<form action="webfinger" method="get">';
@@ -11,18 +12,34 @@ function webfinger_content(&$a) {
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
-
+
+ $old = false;
if(x($_GET,'addr')) {
$addr = trim($_GET['addr']);
- if(strpos($addr,'@') !== false) {
+// if(strpos($addr,'@') !== false) {
$res = webfinger_rfc7033($addr,true);
- if(! $res)
+ if(! $res) {
$res = old_webfinger($addr);
+ $old = true;
+ }
+// }
+// else {
+// if(function_exists('lrdd'))
+// $res = lrdd($addr);
+// }
+
+ if($res && $old) {
+ foreach($res as $r) {
+ if($r['@attributes']['rel'] === 'http://microformats.org/profile/hcard') {
+ $hcard = unamp($r['@attributes']['href']);
+ require_once('library/HTML5/Parser.php');
+ $res['vcard'] = scrape_vcard($hcard);
+ break;
+ }
+ }
}
- else {
- if(function_exists('lrdd'))
- $res = lrdd($addr);
- }
+
+
$o .= '<pre>';
$o .= str_replace("\n",'<br />',print_r($res,true));
$o .= '</pre>';
diff --git a/mod/webpages.php b/mod/webpages.php
index 8e12b5910..c20a147da 100644
--- a/mod/webpages.php
+++ b/mod/webpages.php
@@ -9,7 +9,7 @@ function webpages_init(&$a) {
if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
- $a->is_sys = true;
+ App::$is_sys = true;
}
}
@@ -25,24 +25,24 @@ function webpages_init(&$a) {
function webpages_content(&$a) {
- if(! $a->profile) {
+ if(! App::$profile) {
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
$which = argv(1);
- $_SESSION['return_url'] = $a->query_string;
+ $_SESSION['return_url'] = App::$query_string;
$uid = local_channel();
$owner = 0;
$channel = null;
- $observer = $a->get_observer();
+ $observer = App::get_observer();
- $channel = $a->get_channel();
+ $channel = App::get_channel();
- if($a->is_sys && is_site_admin()) {
+ if(App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
$uid = $owner = intval($sys['channel_id']);
@@ -84,8 +84,8 @@ function webpages_content(&$a) {
// 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();
+ if((! $channel) && ($uid) && ($uid == App::$profile_uid)) {
+ $channel = App::get_channel();
}
if($channel) {
$channel_acl = array(
@@ -99,12 +99,12 @@ function webpages_content(&$a) {
$channel_acl = array();
$is_owner = ($uid && $uid == $owner);
- $o = profile_tabs($a, $is_owner, $a->profile['channel_address']);
+ $o = profile_tabs($a, $is_owner, App::$profile['channel_address']);
$x = array(
'webpage' => ITEM_TYPE_WEBPAGE,
'is_owner' => true,
- 'nickname' => $a->profile['channel_address'],
+ 'nickname' => App::$profile['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'bang' => '',
'acl' => (($is_owner) ? populate_acl($channel_acl,false) : ''),
@@ -114,7 +114,9 @@ function webpages_content(&$a) {
'mimetype' => $mimetype,
'layout' => $layout,
'expanded' => true,
- 'novoting' => true
+ 'novoting'=> true,
+ 'bbco_autocomplete' => 'bbcode',
+ 'bbcode' => true
);
if($_REQUEST['title'])
@@ -128,6 +130,8 @@ 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 */
$sql_extra = item_permissions_sql($owner);
diff --git a/mod/wfinger.php b/mod/wfinger.php
index 8b9abe4af..445dbb349 100644
--- a/mod/wfinger.php
+++ b/mod/wfinger.php
@@ -32,7 +32,7 @@ function wfinger_init(&$a) {
$channel = str_replace('acct:','',$resource);
if(strpos($channel,'@') !== false) {
$host = substr($channel,strpos($channel,'@')+1);
- if(strcasecmp($host,get_app()->get_hostname())) {
+ if(strcasecmp($host,App::get_hostname())) {
goaway('https://' . $host . '/.well-known/webfinger?f=&resource=' . $resource . (($zot) ? '&zot=' . $zot : ''));
}
$channel = substr($channel,0,strpos($channel,'@'));
@@ -51,8 +51,6 @@ function wfinger_init(&$a) {
header('Access-Control-Allow-Origin: *');
- header('Content-type: application/jrd+json');
-
if($resource && $r) {
@@ -75,13 +73,15 @@ function wfinger_init(&$a) {
$result['aliases'] = array();
- $result['properties'] = array('http://webfinger.net/ns/name' => $r[0]['channel_name']);
+ $result['properties'] = array(
+ 'http://webfinger.net/ns/name' => $r[0]['channel_name'],
+ 'http://xmlns.com/foaf/0.1/name' => $r[0]['channel_name']
+ );
foreach($aliases as $alias)
if($alias != $resource)
$result['aliases'][] = $alias;
-
$result['links'] = array(
array(
@@ -101,8 +101,18 @@ function wfinger_init(&$a) {
),
array(
+ 'rel' => 'http://ostatus.org/schema/1.0/subscribe',
+ 'template' => z_root() . '/follow/url={uri}',
+ ),
+
+ array(
'rel' => 'http://purl.org/zot/protocol',
'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'],
+ ),
+
+ array(
+ 'rel' => 'magic-public-key',
+ 'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']),
)
);
@@ -119,7 +129,6 @@ function wfinger_init(&$a) {
$arr = array('channel' => $r[0], 'request' => $_REQUEST, 'result' => $result);
call_hooks('webfinger',$arr);
- echo json_encode($arr['result']);
- killme();
+ json_return_and_die($arr['result'],'application/jrd+json');
-} \ No newline at end of file
+}
diff --git a/mod/xrd.php b/mod/xrd.php
index a373f8bf5..463cda662 100644
--- a/mod/xrd.php
+++ b/mod/xrd.php
@@ -7,8 +7,12 @@ function xrd_init(&$a) {
$uri = urldecode(notags(trim($_GET['uri'])));
logger('xrd: ' . $uri,LOGGER_DEBUG);
- if(substr($uri,0,4) === 'http')
+ $resource = $uri;
+
+ if(substr($uri,0,4) === 'http') {
+ $uri = str_replace('~','',$uri);
$name = basename($uri);
+ }
else {
$local = str_replace('acct:', '', $uri);
if(substr($local,0,2) == '//')
@@ -24,8 +28,8 @@ function xrd_init(&$a) {
killme();
$dspr = replace_macros(get_markup_template('xrd_diaspora.tpl'),array(
- '$baseurl' => $a->get_baseurl(),
- '$dspr_guid' => $r[0]['channel_guid'] . str_replace('.','',$a->get_hostname()),
+ '$baseurl' => z_root(),
+ '$dspr_guid' => $r[0]['channel_guid'] . str_replace('.','',App::get_hostname()),
'$dspr_key' => base64_encode(pemtorsa($r[0]['channel_pubkey']))
));
@@ -35,22 +39,30 @@ function xrd_init(&$a) {
header("Content-type: application/xrd+xml");
- $tpl = get_markup_template('view/xrd_person.tpl');
+ $aliases = array('acct:' . $r[0]['channel_address'] . '@' . App::get_hostname(), z_root() . '/channel/' . $r[0]['channel_address'], z_root() . '/~' . $r[0]['channel_address']);
+
+ for($x = 0; $x < count($aliases); $x ++) {
+ if($aliases[$x] === $resource)
+ unset($aliases[$x]);
+ }
+
$o = replace_macros(get_markup_template('xrd_person.tpl'), array(
'$nick' => $r[0]['channel_address'],
- '$accturi' => $uri,
- '$profile_url' => $a->get_baseurl() . '/channel/' . $r[0]['channel_address'],
- '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['channel_address'],
- '$atom' => $a->get_baseurl() . '/feed/' . $r[0]['channel_address'],
- '$zot_post' => $a->get_baseurl() . '/post/' . $r[0]['channel_address'],
- '$poco_url' => $a->get_baseurl() . '/poco/' . $r[0]['channel_address'],
- '$photo' => $a->get_baseurl() . '/photo/profile/l/' . $r[0]['channel_id'],
+ '$accturi' => $resource,
+ '$aliases' => $aliases,
+ '$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'],
+ '$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'],
+ '$atom' => z_root() . '/feed/' . $r[0]['channel_address'],
+ '$zot_post' => z_root() . '/post/' . $r[0]['channel_address'],
+ '$poco_url' => z_root() . '/poco/' . $r[0]['channel_address'],
+ '$photo' => z_root() . '/photo/profile/l/' . $r[0]['channel_id'],
'$dspr' => $dspr,
-// '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['channel_address'],
-// '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['channel_address'] . '/mention',
+// '$salmon' => z_root() . '/salmon/' . $r[0]['channel_address'],
+// '$salmen' => z_root() . '/salmon/' . $r[0]['channel_address'] . '/mention',
'$modexp' => 'data:application/magic-public-key,' . $salmon_key,
-// '$bigkey' => salmon_key($r[0]['pubkey'])
+ '$subscribe' => z_root() . '/follow?url={uri}',
+ '$bigkey' => salmon_key($r[0]['channel_pubkey'])
));
diff --git a/mod/zotfeed.php b/mod/zotfeed.php
index fffb0e4ab..5041532ae 100644
--- a/mod/zotfeed.php
+++ b/mod/zotfeed.php
@@ -16,7 +16,7 @@ function zotfeed_init(&$a) {
json_return_and_die($result);
}
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$channel_address = ((argc() > 1) ? argv(1) : '');
diff --git a/mod/zping.php b/mod/zping.php
index 311517701..4cc4abb73 100644
--- a/mod/zping.php
+++ b/mod/zping.php
@@ -21,7 +21,7 @@ function zping_content(&$a) {
return;
- $m = zot_build_packet($a->get_channel(),'ping');
+ $m = zot_build_packet(App::get_channel(),'ping');
$r = zot_zot($url,$m);
return print_r($r,true);