aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/_well_known.php22
-rw-r--r--mod/acl.php19
-rw-r--r--mod/admin.php351
-rwxr-xr-xmod/cal.php346
-rw-r--r--mod/channel.php6
-rw-r--r--mod/chat.php6
-rw-r--r--mod/cloud.php14
-rw-r--r--mod/connections.php71
-rw-r--r--mod/connedit.php90
-rw-r--r--mod/cover_photo.php417
-rw-r--r--mod/dav.php16
-rw-r--r--mod/directory.php7
-rw-r--r--mod/dirsearch.php2
-rw-r--r--mod/display.php52
-rwxr-xr-xmod/events.php13
-rw-r--r--mod/feed.php2
-rw-r--r--mod/filestorage.php2
-rw-r--r--mod/follow.php8
-rw-r--r--mod/group.php26
-rw-r--r--mod/help.php12
-rw-r--r--mod/hostxrd.php1
-rw-r--r--mod/import.php28
-rw-r--r--mod/import_items.php6
-rw-r--r--mod/invite.php12
-rw-r--r--mod/item.php73
-rwxr-xr-xmod/like.php25
-rw-r--r--mod/linkinfo.php4
-rw-r--r--mod/lostpass.php2
-rw-r--r--mod/magic.php2
-rw-r--r--mod/manage.php14
-rw-r--r--mod/mitem.php2
-rw-r--r--mod/network.php8
-rw-r--r--mod/new_channel.php64
-rw-r--r--mod/oep.php398
-rw-r--r--mod/pdledit.php4
-rw-r--r--mod/photos.php24
-rw-r--r--mod/ping.php2
-rwxr-xr-xmod/poke.php19
-rw-r--r--mod/post.php4
-rw-r--r--mod/profile.php1
-rw-r--r--mod/profile_photo.php58
-rw-r--r--mod/profiles.php169
-rw-r--r--mod/pubsites.php25
-rw-r--r--mod/register.php86
-rw-r--r--mod/regmod.php4
-rw-r--r--mod/regver.php4
-rw-r--r--mod/rpost.php4
-rw-r--r--mod/settings.php97
-rwxr-xr-xmod/setup.php30
-rw-r--r--mod/share.php2
-rw-r--r--mod/siteinfo.php4
-rw-r--r--mod/thing.php5
-rw-r--r--mod/update_display.php2
-rw-r--r--mod/webfinger.php31
-rw-r--r--mod/webpages.php2
-rw-r--r--mod/wfinger.php23
-rw-r--r--mod/xrd.php5
57 files changed, 2230 insertions, 496 deletions
diff --git a/mod/_well_known.php b/mod/_well_known.php
index d88bc2391..46714deaa 100644
--- a/mod/_well_known.php
+++ b/mod/_well_known.php
@@ -7,6 +7,22 @@ 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;
@@ -33,6 +49,12 @@ function _well_known_init(&$a){
break;
default:
+ if(file_exists($a->cmd)) {
+ echo file_get_contents($a->cmd);
+ killme();
+ }
+ elseif(file_exists($a->cmd . '.php'))
+ require_once($a->cmd . '.php');
break;
}
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..6300ac027 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
@@ -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;
@@ -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;
@@ -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 == '') {
@@ -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"),
));
}
@@ -530,6 +539,121 @@ function admin_page_hubloc_post(&$a){
goaway($a->get_baseurl(true) . '/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");
@@ -552,6 +676,54 @@ function admin_page_hubloc(&$a) {
));
}
+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 = '';
@@ -689,13 +861,13 @@ 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);
}
}
@@ -1018,6 +1190,23 @@ function admin_page_plugins(&$a){
return '';
}
+ $enabled = in_array($plugin,$a->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, $a->plugins);
+ if ($idz !== false) {
+ unset($a->plugins[$idz]);
+ uninstall_plugin($plugin);
+ set_config("system","addon", implode(", ",$a->plugins));
+ }
+ }
+ $info['disabled'] = 1-intval($x);
+
if (x($_GET,"a") && $_GET['a']=="t"){
check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't');
@@ -1068,6 +1257,7 @@ function admin_page_plugins(&$a){
}
}
+
$t = get_markup_template('admin_plugins_details.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
@@ -1079,9 +1269,14 @@ function admin_page_plugins(&$a){
'$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,$a->plugins);
+ $x = check_plugin_versions($info);
+
+ // disable plugins which are installed but incompatible versions
+
+ if($enabled && ! $x) {
+ $enabled = false;
+ $idz = array_search($id, $a->plugins);
+ if ($idz !== false) {
+ unset($a->plugins[$idz]);
+ uninstall_plugin($id);
+ set_config("system","addon", implode(", ",$a->plugins));
+ }
+ }
+ $info['disabled'] = 1-intval($x);
+
+ $plugins[] = array( $id, (($enabled)?"on":"off") , $info);
}
}
}
@@ -1116,6 +1327,7 @@ function admin_page_plugins(&$a){
'$baseurl' => $a->get_baseurl(true),
'$function' => 'plugins',
'$plugins' => $plugins,
+ '$disabled' => t('Disabled - version incompatibility'),
'$form_security_token' => get_form_security_token('admin_plugins'),
));
}
@@ -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/cal.php b/mod/cal.php
new file mode 100755
index 000000000..453f46f69
--- /dev/null
+++ b/mod/cal.php
@@ -0,0 +1,346 @@
+<?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('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;
+
+ $a->data['channel'] = $channelx;
+
+ $observer = $a->get_observer();
+ $a->data['observer'] = $observer;
+
+ $observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
+
+ head_set_icon($a->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>" ;
+
+ }
+
+ return;
+}
+
+
+
+function cal_content(&$a) {
+
+ $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');
+ $a->page['htmlhead'] .= replace_macros($htpl,array(
+ '$baseurl' => $a->get_baseurl(),
+ '$module_url' => '/cal/' . $channel['channel_address'],
+ '$modparams' => 2,
+ '$lang' => $a->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($a->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] = $a->get_baseurl() . '/' . $a->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' => $a->get_baseurl(),
+ '$new_event' => array($a->get_baseurl().'/cal',(($event_id) ? t('Edit Event') : t('Create Event')),'',''),
+ '$previus' => array($a->get_baseurl()."/cal/$nick/$prevyear/$prevmonth",t('Previous'),'',''),
+ '$next' => array($a->get_baseurl()."/cal/$nick/$nextyear/$nextmonth",t('Next'),'',''),
+ '$export' => array($a->get_baseurl()."/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..dcccb16b6 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -128,7 +128,7 @@ function channel_content(&$a, $update = 0, $load = 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) : ''),
+ 'acl' => (($is_owner) ? populate_acl($channel_acl,true,(($a->profile['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : '')) : ''),
'showacl' => (($is_owner) ? 'yes' : ''),
'bang' => '',
'visitor' => (($is_owner || $observer) ? true : false),
@@ -156,6 +156,8 @@ function channel_content(&$a, $update = 0, $load = false) {
$abook_uids = " and abook.abook_channel = " . intval($a->profile['profile_uid']) . " ";
$simple_update = (($update) ? " AND item_unseen = 1 " : '');
+
+ $a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->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,6 +165,7 @@ 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",
@@ -258,7 +261,6 @@ 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,
diff --git a/mod/chat.php b/mod/chat.php
index 79a5c050b..f219bde73 100644
--- a/mod/chat.php
+++ b/mod/chat.php
@@ -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();
@@ -162,7 +162,7 @@ function chat_content(&$a) {
intval($a->profile['profile_uid'])
);
if($x) {
- $acl = new AccessList(false);
+ $acl = new Zotlabs\Access\AccessList(false);
$acl->set($x[0]);
$private = $acl->is_private();
@@ -199,7 +199,7 @@ function chat_content(&$a) {
if(local_channel() && argc() > 2 && argv(2) === 'new') {
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$channel_acl = $acl->get();
require_once('include/acl_selectors.php');
diff --git a/mod/cloud.php b/mod/cloud.php
index 67fc199bf..82d454477 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');
@@ -35,7 +35,7 @@ function cloud_init(&$a) {
if ($which)
profile_load($a, $which, $profile);
- $auth = new RedDAV\RedBasicAuth();
+ $auth = new Zotlabs\Storage\BasicAuth();
$ob_hash = get_observer_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);
@@ -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/connections.php b/mod/connections.php
index 2060ca85e..1de8279c4 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -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) {
@@ -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,12 +295,13 @@ 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,
diff --git a/mod/connedit.php b/mod/connedit.php
index 9c46fa999..008bc21ac 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -25,7 +25,7 @@ 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()),
@@ -58,14 +58,14 @@ function connedit_post(&$a) {
$channel = $a->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())
@@ -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,7 +224,7 @@ function connedit_post(&$a) {
else
notice( t('Failed to update connection record.') . EOL);
- if($a->poi && $a->poi['abook_my_perms'] != $abook_my_perms
+ if($a->poi && $a->poi['abook_my_perms'] != $abook_my_perms
&& (! intval($a->poi['abook_self']))) {
proc_run('php', 'include/notifier.php', (($new_friend) ? 'permission_create' : 'permission_update'), $contact_id);
}
@@ -238,8 +238,8 @@ function connedit_post(&$a) {
group_add_member(local_channel(),'',$a->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",
@@ -285,7 +285,7 @@ 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()),
@@ -300,11 +300,14 @@ function connedit_post(&$a) {
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($a->get_baseurl(true) . '/connections/ifpending');
+
return;
}
@@ -319,7 +322,10 @@ function connedit_clone(&$a) {
if(! $a->poi)
return;
- $r = q("SELECT abook.*, xchan.*
+
+ $channel = $a->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()),
@@ -335,6 +341,10 @@ function connedit_clone(&$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)));
}
@@ -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() {
@@ -395,9 +407,8 @@ function connedit_content(&$a) {
notice( t('Could not access address book record.') . EOL);
goaway($a->get_baseurl(true) . '/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);
@@ -405,8 +416,15 @@ function connedit_content(&$a) {
}
if($cmd === 'refresh') {
- if(! zot_refresh($orig_record[0],get_app()->get_channel()))
- notice( t('Refresh failed - channel is currently unavailable.') );
+ if($orig_record[0]['xchan_network'] === 'zot') {
+ if(! zot_refresh($orig_record[0],get_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($a->get_baseurl(true) . '/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))
@@ -496,28 +514,28 @@ function connedit_content(&$a) {
'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' => $a->get_baseurl(true) . '/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' => $a->get_baseurl(true) . '/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' => $a->get_baseurl(true) . '/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' => $a->get_baseurl(true) . '/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' => $a->get_baseurl(true) . '/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' => $a->get_baseurl(true) . '/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' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/drop',
'sel' => '',
'title' => t('Delete this connection'),
),
@@ -630,7 +648,7 @@ function connedit_content(&$a) {
$channel = $a->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..9c99859ea
--- /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 = $a->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 = $a->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 = $a->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($a->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 = $a->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($a->data,'imagecrop')) {
+
+ $tpl = get_markup_template('cover_photo.tpl');
+
+ $o .= replace_macros($tpl,array(
+ '$user' => $a->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="' . $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>')
+ ));
+
+ call_hooks('cover_photo_content_end', $o);
+
+ return $o;
+ }
+ else {
+ $filename = $a->data['imagecrop'] . '-3';
+ $resolution = 3;
+ $tpl = get_markup_template("cropcover.tpl");
+ $o .= replace_macros($tpl,array(
+ '$filename' => $filename,
+ '$profile' => intval($_REQUEST['profile']),
+ '$resource' => $a->data['imagecrop'] . '-3',
+ '$image_url' => $a->get_baseurl() . '/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();
+ }
+
+
+ $a->data['imagecrop'] = $hash;
+ $a->data['imagecrop_resolution'] = $smallest;
+ $a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), array());
+ return;
+}
+
diff --git a/mod/dav.php b/mod/dav.php
index d4695a544..272dae4c8 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');
@@ -54,7 +54,7 @@ function dav_init(&$a) {
if ($which)
profile_load($a, $which, $profile);
- $auth = new RedDAV\RedBasicAuth();
+ $auth = new Zotlabs\Storage\BasicAuth();
$ob_hash = get_observer_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);
@@ -108,7 +108,7 @@ function dav_init(&$a) {
if ((! $auth->observer) && ($_SERVER['REQUEST_METHOD'] === 'GET')) {
try {
$x = RedFileData('/' . $a->cmd, $auth);
- if($x instanceof RedDAV\RedFile)
+ 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..dca96694e 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -144,11 +144,14 @@ 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)
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index 388e5f3ac..bc2fa108f 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -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
diff --git a/mod/display.php b/mod/display.php
index b2d9ba34b..40427846b 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -116,7 +116,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 = '';
@@ -217,9 +217,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) {
@@ -284,6 +329,5 @@ function display_content(&$a, $update = 0, $load = false) {
}
*/
- return $o;
}
diff --git a/mod/events.php b/mod/events.php
index 74b44906c..8e3b3e06b 100755
--- a/mod/events.php
+++ b/mod/events.php
@@ -118,7 +118,7 @@ function events_post(&$a) {
$channel = $a->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",
@@ -283,6 +283,8 @@ function events_content(&$a) {
$htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl,array(
'$baseurl' => $a->get_baseurl(),
+ '$module_url' => '/events',
+ '$modparams' => 1,
'$lang' => $a->language,
'$first_day' => $first_day
));
@@ -296,6 +298,11 @@ function events_content(&$a) {
$m = 0;
$ignored = ((x($_REQUEST,'ignored')) ? " and ignored = " . intval($_REQUEST['ignored']) . " " : '');
+
+ // logger('args: ' . print_r($a->argv,true));
+
+
+
if(argc() > 1) {
if(argc() > 2 && argv(1) === 'add') {
$mode = 'add';
@@ -422,7 +429,7 @@ 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');
@@ -434,7 +441,7 @@ function events_content(&$a) {
'$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')),
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/filestorage.php b/mod/filestorage.php
index 7ba8c1801..753300e89 100644
--- a/mod/filestorage.php
+++ b/mod/filestorage.php
@@ -30,7 +30,7 @@ function filestorage_post(&$a) {
$channel = $a->get_channel();
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$acl->set_from_array($_REQUEST);
$x = $acl->get();
diff --git a/mod/follow.php b/mod/follow.php
index 3ad2cb3bb..73e87c16f 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 = $a->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/group.php b/mod/group.php
index ce9633669..c63ccfa9b 100644
--- a/mod/group.php
+++ b/mod/group.php
@@ -17,13 +17,13 @@ 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);
}
else
- notice( t('Could not create collection.') . EOL );
+ notice( t('Could not create privacy group.') . EOL );
goaway($a->get_baseurl() . '/group');
}
@@ -35,7 +35,7 @@ function group_post(&$a) {
intval(local_channel())
);
if(! $r) {
- notice( t('Collection not found.') . EOL );
+ notice( t('Privacy group not found.') . EOL );
goaway($a->get_baseurl() . '/connections');
}
@@ -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));
@@ -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,9 +104,9 @@ 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');
// 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,7 +134,7 @@ function group_content(&$a) {
intval(local_channel())
);
if(! $r) {
- notice( t('Collection not found.') . EOL );
+ notice( t('Privacy group not found.') . EOL );
goaway($a->get_baseurl() . '/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/help.php b/mod/help.php
index c4549a2bd..19bf251bd 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -145,7 +145,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 +160,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;
}
@@ -229,6 +233,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 +254,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/hostxrd.php b/mod/hostxrd.php
index 0e18c133b..18066b7bf 100644
--- a/mod/hostxrd.php
+++ b/mod/hostxrd.php
@@ -12,6 +12,7 @@ function hostxrd_init(&$a) {
));
$arr = array('xrd' => $x);
call_hooks('hostxrd',$arr);
+
echo $arr['xrd'];
killme();
}
diff --git a/mod/import.php b/mod/import.php
index 02e71233a..f91f261a5 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 {
@@ -180,7 +187,7 @@ function import_account(&$a, $account_id) {
if($completed < 4) {
- if(is_array($data['hubloc'])) {
+ if(is_array($data['hubloc']) && (! $moving)) {
import_hublocs($channel,$data['hubloc'],$seize);
}
@@ -332,6 +339,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,6 +384,17 @@ 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');
diff --git a/mod/import_items.php b/mod/import_items.php
index 6b97939c9..f369ad780 100644
--- a/mod/import_items.php
+++ b/mod/import_items.php
@@ -86,14 +86,11 @@ function import_items_post(&$a) {
$channel = $a->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..7f4df6cc8 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();
- $res = mail($recip, sprintf( t('Please join us on $Projectname'), $a->config['sitename']),
- $nmessage,
+ $res = mail($recip, sprintf( t('Please join us on $Projectname'), $a->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);
@@ -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..038a967b2 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -210,7 +210,7 @@ function item_post(&$a) {
}
}
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 );
@@ -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,6 +243,9 @@ function item_post(&$a) {
if(! count($i))
killme();
$orig_post = $i[0];
+ $iconfig = q("select * from iconfig where iid = %d",
+ intval($post_id)
+ );
}
@@ -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));
@@ -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)
);
@@ -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.)
@@ -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) {
+ logger('mod_item: post cancelled by plugin or duplicate suppressed.');
+ if($return_path)
goaway($a->get_baseurl() . "/" . $return_path);
- }
$json = array('cancel' => 1);
- if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
- $json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
-
+ $json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
echo json_encode($json);
killme();
}
@@ -919,7 +938,7 @@ 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'],
diff --git a/mod/like.php b/mod/like.php
index ce8bc3063..1de7882e9 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -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)
@@ -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/lostpass.php b/mod/lostpass.php
index 3dbc2fe7d..ffdd7b62e 100644
--- a/mod/lostpass.php
+++ b/mod/lostpass.php
@@ -87,7 +87,7 @@ 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="' . $a->get_baseurl() . '/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()
diff --git a/mod/magic.php b/mod/magic.php
index 2fee87241..12679773b 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;
}
}
diff --git a/mod/manage.php b/mod/manage.php
index b609ede44..cb845befe 100644
--- a/mod/manage.php
+++ b/mod/manage.php
@@ -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,17 @@ 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'),
+ '$delegated_desc' => t('Delegated Channel'),
'$delegates' => $delegates,
+ '$locs' => t('Manage locations')
));
-
return $o;
}
diff --git a/mod/mitem.php b/mod/mitem.php
index d6572bd56..7f582c649 100644
--- a/mod/mitem.php
+++ b/mod/mitem.php
@@ -127,7 +127,7 @@ 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');
diff --git a/mod/network.php b/mod/network.php
index 9f0604296..134a4081d 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -166,7 +166,7 @@ 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()
@@ -174,8 +174,10 @@ function network_content(&$a, $update = 0, $load = false) {
if($deftag)
$x['pretext'] = $deftag;
+
$status_editor = status_editor($a,$x);
$o .= $status_editor;
+
}
@@ -204,7 +206,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 +215,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']
));
}
diff --git a/mod/new_channel.php b/mod/new_channel.php
index 047048f0a..577137c37 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 = $a->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 $a->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 = $a->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 = '@' . 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());
$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/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/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/photos.php b/mod/photos.php
index b0d9bc631..07138e6cf 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -85,7 +85,7 @@ function photos_post(&$a) {
$owner_record = $s[0];
- $acl = new AccessList($a->data['channel']);
+ $acl = new Zotlabs\Access\AccessList($a->data['channel']);
if((argc() > 3) && (argv(2) === 'album')) {
@@ -463,7 +463,7 @@ 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);
@@ -595,7 +595,7 @@ function photos_content(&$a) {
if($_is_owner) {
$channel = $a->get_channel();
- $acl = new AccessList($channel);
+ $acl = new Zotlabs\Access\AccessList($channel);
$channel_acl = $acl->get();
$lockstate = (($acl->is_private()) ? 'lock' : 'unlock');
@@ -603,6 +603,14 @@ 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']));
@@ -660,6 +668,10 @@ function photos_content(&$a) {
$album = (($datum) ? hex2bin($datum) : '');
+
+ $a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->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),
@@ -804,6 +816,8 @@ function photos_content(&$a) {
if($datatype === 'image') {
+ $a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->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'
@@ -882,6 +896,7 @@ function photos_content(&$a) {
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')),
+ 'cover'=>array($a->get_baseurl() . '/cover_photo/use/'.$ph[0]['resource_id'], t('Use as cover photo')),
);
}
@@ -1226,6 +1241,9 @@ function photos_content(&$a) {
// Default - show recent photos with upload link (if applicable)
//$o = '';
+ $a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->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']),
diff --git a/mod/ping.php b/mod/ping.php
index 394dbf089..69d504da1 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -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' => $a->get_baseurl() . '/connections/ifpending',
'name' => $rr['xchan_name'],
'url' => $rr['xchan_url'],
'photo' => $rr['xchan_photo_s'],
diff --git a/mod/poke.php b/mod/poke.php
index f66d28956..15a69780c 100755
--- a/mod/poke.php
+++ b/mod/poke.php
@@ -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/profile.php b/mod/profile.php
index 430d039e9..7ee03a77b 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -75,6 +75,7 @@ function profile_content(&$a, $update = 0) {
$o .= profile_tabs($a, $is_owner, $a->profile['channel_address']);
+ $a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->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..9dc71f256 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -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
*
@@ -452,6 +400,8 @@ function profile_photo_content(&$a) {
'$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>')
@@ -502,8 +452,8 @@ 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();
}
diff --git a/mod/profiles.php b/mod/profiles.php
index 282d741ac..f891c6033 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -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']));
@@ -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) {
@@ -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;"' : ''),
+ '$lbl_gender' => t('Your gender'),
+ '$lbl_marital' => t('Marital status'),
+ '$lbl_sexual' => t('Sexual preference'),
'$baseurl' => $a->get_baseurl(true),
'$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,21 +758,9 @@ 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'),
@@ -798,6 +770,17 @@ function profiles_content(&$a) {
: '<a href="' . $a->get_baseurl(true) . '/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/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/register.php b/mod/register.php
index 2e9967c60..b533483f7 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'));
@@ -184,7 +208,7 @@ function register_content(&$a) {
if(! $tosurl)
$tosurl = $a->get_baseurl() . '/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..a1d300e56 100644
--- a/mod/regmod.php
+++ b/mod/regmod.php
@@ -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..78f146ec5 100644
--- a/mod/regver.php
+++ b/mod/regver.php
@@ -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/rpost.php b/mod/rpost.php
index d519a996b..915b1ca96 100644
--- a/mod/rpost.php
+++ b/mod/rpost.php
@@ -95,7 +95,7 @@ function rpost_content(&$a) {
$channel = $a->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/settings.php b/mod/settings.php
index 339f83cfe..a6655f46a 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -155,6 +155,7 @@ function settings_post(&$a) {
$theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : $a->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);
@@ -223,10 +225,44 @@ function settings_post(&$a) {
$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);
+ $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,31 +289,6 @@ 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)
@@ -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));
@@ -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];
@@ -693,8 +704,9 @@ function settings_content(&$a) {
$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
@@ -836,7 +851,8 @@ function settings_content(&$a) {
'$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')),
));
@@ -917,6 +933,7 @@ 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'];
@@ -985,7 +1002,7 @@ function settings_content(&$a) {
$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)
@@ -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..282b9cbef 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;
+
}
/**
@@ -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,'/');
@@ -118,6 +122,7 @@ 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");
@@ -138,16 +143,17 @@ 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
));
@@ -321,7 +327,6 @@ 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(),
@@ -363,6 +368,7 @@ 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()),
diff --git a/mod/share.php b/mod/share.php
index 7ed6cf9a6..198a6b210 100644
--- a/mod/share.php
+++ b/mod/share.php
@@ -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) {
diff --git a/mod/siteinfo.php b/mod/siteinfo.php
index 52d014de1..19b566b73 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 = '';
diff --git a/mod/thing.php b/mod/thing.php
index 280cc194d..7e7d1bdc7 100644
--- a/mod/thing.php
+++ b/mod/thing.php
@@ -14,7 +14,6 @@ function thing_init(&$a) {
if(! local_channel())
return;
- $account_id = $a->get_account();
$channel = $a->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)
@@ -272,7 +271,7 @@ function thing_content(&$a) {
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/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/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..6b157073e 100644
--- a/mod/webpages.php
+++ b/mod/webpages.php
@@ -128,6 +128,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..5c1a74f10 100644
--- a/mod/wfinger.php
+++ b/mod/wfinger.php
@@ -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..da4ab51a4 100644
--- a/mod/xrd.php
+++ b/mod/xrd.php
@@ -35,8 +35,6 @@ function xrd_init(&$a) {
header("Content-type: application/xrd+xml");
- $tpl = get_markup_template('view/xrd_person.tpl');
-
$o = replace_macros(get_markup_template('xrd_person.tpl'), array(
'$nick' => $r[0]['channel_address'],
'$accturi' => $uri,
@@ -50,7 +48,8 @@ function xrd_init(&$a) {
// '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['channel_address'],
// '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['channel_address'] . '/mention',
'$modexp' => 'data:application/magic-public-key,' . $salmon_key,
-// '$bigkey' => salmon_key($r[0]['pubkey'])
+ '$subscribe' => $a->get_baseurl() . '/follow?url={uri}',
+ '$bigkey' => salmon_key($r[0]['channel_pubkey'])
));