aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/acl.php37
-rw-r--r--mod/admin.php26
-rw-r--r--mod/attach.php2
-rw-r--r--mod/block.php8
-rw-r--r--mod/blocks.php34
-rw-r--r--mod/bookmarks.php6
-rw-r--r--mod/branchtopic.php3
-rw-r--r--mod/channel.php43
-rw-r--r--mod/cloud.php33
-rw-r--r--mod/connections.php56
-rw-r--r--mod/connedit.php56
-rw-r--r--mod/contactgroup.php5
-rw-r--r--mod/dav.php6
-rw-r--r--mod/directory.php2
-rw-r--r--mod/dirsearch.php23
-rw-r--r--mod/display.php19
-rw-r--r--mod/editblock.php14
-rw-r--r--mod/editlayout.php2
-rw-r--r--mod/editpost.php4
-rw-r--r--mod/editwebpage.php4
-rwxr-xr-xmod/events.php7
-rw-r--r--mod/filer.php3
-rw-r--r--mod/group.php18
-rw-r--r--mod/help.php155
-rw-r--r--mod/home.php2
-rw-r--r--mod/impel.php13
-rw-r--r--mod/import.php103
-rw-r--r--mod/item.php149
-rw-r--r--mod/layouts.php10
-rwxr-xr-xmod/like.php35
-rw-r--r--mod/locs.php20
-rw-r--r--mod/mail.php5
-rw-r--r--mod/manage.php26
-rw-r--r--mod/message.php2
-rwxr-xr-xmod/mood.php11
-rw-r--r--mod/network.php42
-rw-r--r--mod/openid.php7
-rw-r--r--mod/p.php5
-rw-r--r--mod/page.php18
-rw-r--r--mod/photo.php17
-rw-r--r--mod/photos.php93
-rw-r--r--mod/ping.php45
-rwxr-xr-xmod/poke.php11
-rw-r--r--mod/post.php34
-rw-r--r--mod/profile_photo.php107
-rw-r--r--mod/public.php20
-rw-r--r--mod/receive.php5
-rw-r--r--mod/search.php17
-rw-r--r--mod/settings.php16
-rw-r--r--mod/siteinfo.php2
-rw-r--r--mod/starred.php8
-rwxr-xr-xmod/subthread.php32
-rw-r--r--mod/tagger.php6
-rw-r--r--mod/thing.php4
-rw-r--r--mod/update_channel.php2
-rw-r--r--mod/update_display.php2
-rw-r--r--mod/update_home.php2
-rw-r--r--mod/update_network.php2
-rw-r--r--mod/update_public.php2
-rw-r--r--mod/update_search.php2
-rw-r--r--mod/viewconnections.php21
-rw-r--r--mod/viewsrc.php6
-rw-r--r--mod/wall_attach.php44
-rw-r--r--mod/webpages.php6
-rw-r--r--mod/zfinger.php17
-rw-r--r--mod/zotfeed.php9
66 files changed, 836 insertions, 710 deletions
diff --git a/mod/acl.php b/mod/acl.php
index e919bb912..6383d774c 100644
--- a/mod/acl.php
+++ b/mod/acl.php
@@ -90,23 +90,21 @@ function acl_init(&$a){
// Getting info from the abook is better for local users because it contains info about permissions
if(local_channel()) {
if($extra_channels_sql != '')
- $extra_channels_sql = " OR (abook_channel IN ($extra_channels_sql)) and not (abook_flags & ". intval(ABOOK_FLAG_HIDDEN) . ') > 0';
+ $extra_channels_sql = " OR (abook_channel IN ($extra_channels_sql)) and abook_hidden = 0 ";
$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
FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE (abook_channel = %d $extra_channels_sql) AND not ( abook_flags & %d )>0 and not (xchan_flags & %d )>0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
- intval(local_channel()),
- intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED),
- intval(XCHAN_FLAGS_DELETED)
+ 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" ,
+ intval(local_channel())
);
}
else { // Visitors
$r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags
FROM xchan left join xlink on xlink_link = xchan_hash
- WHERE xlink_xchan = '%s' AND NOT (xchan_flags & %d) > 0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
- dbesc(get_observer_hash()),
- intval(XCHAN_FLAGS_DELETED));
+ WHERE xlink_xchan = '%s' AND xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
+ dbesc(get_observer_hash())
+ );
// Find contacts of extra channels
// This is probably more complicated than it needs to be
@@ -120,10 +118,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
FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel IN ($extra_channels_sql) $known_hashes_sql AND not ( abook_flags & %d )>0 and not (xchan_flags & %d )>0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
- intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED|ABOOK_FLAG_HIDDEN),
- intval(XCHAN_FLAGS_DELETED)
- );
+ 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");
if($r2)
$r = array_merge($r,$r2);
@@ -152,8 +147,7 @@ function acl_init(&$a){
if((count($r) < 100) && $type == 'c') {
$r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags
FROM xchan
- WHERE not (xchan_flags & %d )>0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
- intval(XCHAN_FLAGS_DELETED)
+ WHERE xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc"
);
if($r2)
$r = array_merge($r,$r2);
@@ -165,24 +159,21 @@ function acl_init(&$a){
$r = q("SELECT xchan_hash as id, xchan_name as name, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d and ( (abook_their_perms = null) or (abook_their_perms & %d )>0)
- and not (xchan_flags & %d)>0
+ and xchan_deleted = 0
$sql_extra3
ORDER BY `xchan_name` ASC ",
intval(local_channel()),
- intval(PERMS_W_MAIL),
- intval(XCHAN_FLAGS_DELETED)
+ intval(PERMS_W_MAIL)
);
}
elseif(($type == 'a') || ($type == 'p')) {
$r = q("SELECT abook_id as id, xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d
- and not (xchan_flags & %d)>0
+ and xchan_deleted = 0
$sql_extra3
ORDER BY xchan_name ASC ",
- intval(local_channel()),
- intval(XCHAN_FLAGS_DELETED)
-
+ intval(local_channel())
);
}
@@ -226,7 +217,7 @@ function acl_init(&$a){
"xid" => $g['hash'],
"link" => $g['nick'],
"nick" => substr($g['nick'],0,strpos($g['nick'],'@')),
- "self" => (($g['abook_flags'] & ABOOK_FLAG_SELF) ? 'abook-self' : ''),
+ "self" => (intval($g['abook_self']) ? 'abook-self' : ''),
"taggable" => 'taggable',
"label" => t('network')
);
@@ -239,7 +230,7 @@ function acl_init(&$a){
"xid" => $g['hash'],
"link" => $g['nick'],
"nick" => (($g['nick']) ? substr($g['nick'],0,strpos($g['nick'],'@')) : t('RSS')),
- "self" => (($g['abook_flags'] & ABOOK_FLAG_SELF) ? 'abook-self' : ''),
+ "self" => (intval($g['abook_self']) ? 'abook-self' : ''),
"taggable" => '',
"label" => '',
);
diff --git a/mod/admin.php b/mod/admin.php
index 74abc0b34..3b8cd2a95 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -1,7 +1,7 @@
<?php
/**
* @file mod/admin.php
- * @brief RedMatrix's admin controller.
+ * @brief Hubzilla's admin controller.
*
* Controller for the /admin/ area.
*/
@@ -89,6 +89,7 @@ function admin_content(&$a) {
*/
// array( url, name, extra css classes )
+
$aside = array(
'site' => array($a->get_baseurl(true)."/admin/site/", t("Site") , "site"),
'users' => array($a->get_baseurl(true)."/admin/users/", t("Accounts") , "users"),
@@ -99,6 +100,7 @@ function admin_content(&$a) {
// 'hubloc' => array($a->get_baseurl(true)."/admin/hubloc/", t("Server") , "server"),
'profs' => array(z_root() . '/admin/profs', t('Profile Config'), 'profs'),
'dbsync' => array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync")
+
);
/* get plugins admin page */
@@ -148,9 +150,9 @@ function admin_content(&$a) {
case 'themes':
$o = admin_page_themes($a);
break;
- case 'hubloc':
- $o = admin_page_hubloc($a);
- break;
+// case 'hubloc':
+// $o = admin_page_hubloc($a);
+// break;
case 'logs':
$o = admin_page_logs($a);
break;
@@ -209,9 +211,7 @@ function admin_page_summary(&$a) {
// available channels, primary and clones
$channels = array();
- $r = q("SELECT COUNT(*) AS total, COUNT(CASE WHEN channel_primary = 1 THEN 1 ELSE NULL END) AS main, COUNT(CASE WHEN channel_primary = 0 THEN 1 ELSE NULL END) AS clones FROM channel WHERE NOT (channel_pageflags & %d)>0",
- intval(PAGE_REMOVED)
- );
+ $r = q("SELECT COUNT(*) AS total, COUNT(CASE WHEN channel_primary = 1 THEN 1 ELSE NULL END) AS main, COUNT(CASE WHEN channel_primary = 0 THEN 1 ELSE NULL END) AS clones FROM channel WHERE channel_removed = 0");
if ($r) {
$channels['total'] = array('label' => t('# Channels'), 'val' => $r[0]['total']);
$channels['main'] = array('label' => t('# primary'), 'val' => $r[0]['main']);
@@ -786,11 +786,10 @@ function admin_page_users(&$a){
$users = q("SELECT `account_id` , `account_email`, `account_lastlog`, `account_created`, `account_expires`, " . "`account_service_class`, ( account_flags & %d )>0 as `blocked`, " .
"(SELECT %s FROM channel as ch " .
- "WHERE ch.channel_account_id = ac.account_id and not (ch.channel_pageflags & %d )>0) as `channels` " .
+ "WHERE ch.channel_account_id = ac.account_id and ch.channel_removed = 0 ) as `channels` " .
"FROM account as ac where true $serviceclass $order limit %d offset %d ",
intval(ACCOUNT_BLOCKED),
db_concat('ch.channel_address', ' '),
- intval(PAGE_REMOVED),
intval($a->pager['itemspage']),
intval($a->pager['start'])
);
@@ -948,9 +947,7 @@ function admin_page_channels(&$a){
/* get channels */
- $total = q("SELECT count(*) as total FROM channel where not (channel_pageflags & %d)>0",
- intval(PAGE_REMOVED|PAGE_SYSTEM)
- );
+ $total = q("SELECT count(*) as total FROM channel where channel_removed = 0 and channel_system = 0");
if($total) {
$a->set_pager_total($total[0]['total']);
$a->set_pager_itemspage(100);
@@ -958,8 +955,7 @@ function admin_page_channels(&$a){
$order = " order by channel_name asc ";
- $channels = q("SELECT * from channel where not ( channel_pageflags & %d )>0 $order limit %d offset %d ",
- intval(PAGE_REMOVED|PAGE_SYSTEM),
+ $channels = q("SELECT * from channel where channel_removed = 0 and channel_system = 0 $order limit %d offset %d ",
intval($a->pager['itemspage']),
intval($a->pager['start'])
);
@@ -1477,4 +1473,4 @@ function admin_page_profs(&$a) {
'$submit' => t('Save')
));
}
-} \ No newline at end of file
+}
diff --git a/mod/attach.php b/mod/attach.php
index 118c67dd5..ad5dead07 100644
--- a/mod/attach.php
+++ b/mod/attach.php
@@ -35,7 +35,7 @@ function attach_init(&$a) {
}
header('Content-disposition: attachment; filename="' . $r['data']['filename'] . '"');
- if($r['data']['flags'] & ATTACH_FLAG_OS ) {
+ if(intval($r['data']['os_storage'])) {
$fname = dbunescbin($r['data']['data']);
$istream = fopen('store/' . $c[0]['channel_address'] . '/' . $fname,'rb');
$ostream = fopen('php://output','wb');
diff --git a/mod/block.php b/mod/block.php
index 043b0e9e8..df3909629 100644
--- a/mod/block.php
+++ b/mod/block.php
@@ -50,10 +50,10 @@ function block_content(&$a) {
$r = q("select item.* from item left join item_id on item.id = item_id.iid
where item.uid = %d and sid = '%s' and service = 'BUILDBLOCK' and
- item_restrict = %d $sql_options $revision limit 1",
+ item_type = %d $sql_options $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
- intval(ITEM_BUILDBLOCK)
+ intval(ITEM_TYPE_BLOCK)
);
if(! $r) {
@@ -62,10 +62,10 @@ function block_content(&$a) {
$x = q("select item.* from item left join item_id on item.id = item_id.iid
where item.uid = %d and sid = '%s' and service = 'BUILDBLOCK' and
- item_restrict = %d $revision limit 1",
+ item_type = %d $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
- intval(ITEM_BUILDBLOCK)
+ intval(ITEM_TYPE_BLOCK)
);
if($x) {
// Yes, it's there. You just aren't allowed to see it.
diff --git a/mod/blocks.php b/mod/blocks.php
index 11e7d4a30..97cc5cd53 100644
--- a/mod/blocks.php
+++ b/mod/blocks.php
@@ -84,7 +84,7 @@ function blocks_content(&$a) {
}
$x = array(
- 'webpage' => ITEM_BUILDBLOCK,
+ 'webpage' => ITEM_TYPE_BLOCK,
'is_owner' => true,
'nickname' => $a->profile['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
@@ -108,9 +108,9 @@ function blocks_content(&$a) {
$editor = status_editor($a,$x);
$r = q("select iid, sid, mid, title, body, mimetype, created, edited from item_id left join item on item_id.iid = item.id
- where item_id.uid = %d and service = 'BUILDBLOCK' and item_restrict = %d order by item.created desc",
+ where item_id.uid = %d and service = 'BUILDBLOCK' and item_type = %d order by item.created desc",
intval($owner),
- intval(ITEM_BUILDBLOCK)
+ intval(ITEM_TYPE_BLOCK)
);
$pages = null;
@@ -143,21 +143,21 @@ function blocks_content(&$a) {
$url = z_root() . '/editblock/' . $which;
$o .= replace_macros(get_markup_template('blocklist.tpl'), array(
- '$baseurl' => $url,
- '$title' => t('Blocks'),
- '$name' => t('Block Name'),
+ '$baseurl' => $url,
+ '$title' => t('Blocks'),
+ '$name' => t('Block Name'),
'$blocktitle' => t('Block Title'),
- '$created' => t('Created'),
- '$edited' => t('Edited'),
- '$create' => t('Create'),
- '$edit' => t('Edit'),
- '$share' => t('Share'),
- '$delete' => t('Delete'),
- '$editor' => $editor,
- '$pages' => $pages,
- '$channel' => $which,
- '$view' => t('View'),
- '$preview' => '1',
+ '$created' => t('Created'),
+ '$edited' => t('Edited'),
+ '$create' => t('Create'),
+ '$edit' => t('Edit'),
+ '$share' => t('Share'),
+ '$delete' => t('Delete'),
+ '$editor' => $editor,
+ '$pages' => $pages,
+ '$channel' => $which,
+ '$view' => t('View'),
+ '$preview' => '1',
));
return $o;
diff --git a/mod/bookmarks.php b/mod/bookmarks.php
index a5b9c473f..c3d25253f 100644
--- a/mod/bookmarks.php
+++ b/mod/bookmarks.php
@@ -9,7 +9,9 @@ function bookmarks_init(&$a) {
$u = $a->get_channel();
- $i = q("select * from item where id = %d and uid = %d limit 1",
+ $item_normal = item_normal();
+
+ $i = q("select * from item where id = %d and uid = %d $item_normal limit 1",
intval($item_id),
intval(local_channel())
);
@@ -23,7 +25,7 @@ function bookmarks_init(&$a) {
$terms = get_terms_oftype($item['term'],TERM_BOOKMARK);
- if($terms && (! $item['item_restrict'])) {
+ if($terms) {
require_once('include/bookmarks.php');
$s = q("select * from xchan where xchan_hash = '%s' limit 1",
diff --git a/mod/branchtopic.php b/mod/branchtopic.php
index 609cb19ec..d49bbaf4c 100644
--- a/mod/branchtopic.php
+++ b/mod/branchtopic.php
@@ -33,8 +33,7 @@ function branchtopic_init(&$a) {
intval(local_channel())
);
- $x = q("update item set parent = id, route = '', item_flags = (item_flags | %d) where id = %d",
- intval(ITEM_THREAD_TOP),
+ $x = q("update item set parent = id, route = '', item_thread_top = 1 where id = %d",
intval($item_id)
);
diff --git a/mod/channel.php b/mod/channel.php
index b06602994..9a98ade60 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -145,7 +145,7 @@ function channel_content(&$a, $update = 0, $load = false) {
* Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
*/
-
+ $item_normal = item_normal();
$sql_extra = item_permissions_sql($a->profile['profile_uid']);
if(get_pconfig($a->profile['profile_uid'],'system','channel_list_mode') && (! $mid))
@@ -165,23 +165,20 @@ function channel_content(&$a, $update = 0, $load = false) {
if(($update) && (! $load)) {
if ($mid) {
- $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d AND item_restrict = 0
- AND (item_flags & %d) > 0 $simple_update $sql_extra limit 1",
+ $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d $item_normal
+ AND item_wall = 1 AND item_unseen = 1 $sql_extra limit 1",
dbesc($mid . '%'),
- intval($a->profile['profile_uid']),
- intval(ITEM_WALL)
+ intval($a->profile['profile_uid'])
);
} else {
$r = q("SELECT distinct parent AS `item_id`, created from item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
- WHERE uid = %d AND item_restrict = 0
- AND (item_flags & %d) > 0 $simple_update
- AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
+ WHERE uid = %d $item_normal
+ AND item_wall = 1 AND item_unseen = 1
+ AND (abook.blocked = 0 or abook.abook_flags is null)
$sql_extra
ORDER BY created DESC",
- intval($a->profile['profile_uid']),
- intval(ITEM_WALL),
- intval(ABOOK_FLAG_BLOCKED)
+ intval($a->profile['profile_uid'])
);
$_SESSION['loadtime'] = datetime_convert();
}
@@ -209,11 +206,10 @@ function channel_content(&$a, $update = 0, $load = false) {
if($load || ($_COOKIE['jsAvailable'] != 1)) {
if ($mid) {
- $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0
- AND (item_flags & %d)>0 $sql_extra limit 1",
+ $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal
+ AND item_wall = 1 $sql_extra limit 1",
dbesc($mid),
- intval($a->profile['profile_uid']),
- intval(ITEM_WALL)
+ intval($a->profile['profile_uid'])
);
if (! $r) {
notice( t('Permission denied.') . EOL);
@@ -222,15 +218,12 @@ function channel_content(&$a, $update = 0, $load = false) {
} else {
$r = q("SELECT distinct id AS item_id, created FROM item
left join abook on item.author_xchan = abook.abook_xchan
- WHERE uid = %d AND item_restrict = 0
- AND (item_flags & %d)>0 and (item_flags & %d)>0
- AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
+ WHERE uid = %d $item_normal
+ AND item_wall = 1 and item_thread_top = 1
+ AND (abook_blocked = 0 or abook.abook_flags is null)
$sql_extra $sql_extra2
ORDER BY created DESC $pager_sql ",
- intval($a->profile['profile_uid']),
- intval(ITEM_WALL),
- intval(ITEM_THREAD_TOP),
- intval(ABOOK_FLAG_BLOCKED)
+ intval($a->profile['profile_uid'])
);
}
}
@@ -245,7 +238,7 @@ function channel_content(&$a, $update = 0, $load = false) {
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`
FROM `item`
- WHERE `item`.`uid` = %d AND `item`.`item_restrict` = 0
+ WHERE `item`.`uid` = %d $item_normal
AND `item`.`parent` IN ( %s )
$sql_extra ",
intval($a->profile['profile_uid']),
@@ -338,9 +331,7 @@ function channel_content(&$a, $update = 0, $load = false) {
}
if($is_owner && $update_unseen) {
- $r = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1
- AND (item_flags & %d) > 0 AND uid = %d $update_unseen",
- intval(ITEM_WALL),
+ $r = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 and item_wall = 1 AND uid = %d $update_unseen",
intval(local_channel())
);
}
diff --git a/mod/cloud.php b/mod/cloud.php
index 4b5d45f97..7f6dc0962 100644
--- a/mod/cloud.php
+++ b/mod/cloud.php
@@ -1,7 +1,7 @@
<?php
/**
* @file mod/cloud.php
- * @brief Initialize RedMatrix's cloud (SabreDAV).
+ * @brief Initialize Hubzilla's cloud (SabreDAV).
*
* Module for accessing the DAV storage area.
*/
@@ -12,30 +12,12 @@ use RedMatrix\RedDAV;
// composer autoloader for SabreDAV
require_once('vendor/autoload.php');
-// workaround for HTTP-auth in CGI mode
-if (x($_SERVER, 'REDIRECT_REMOTE_USER')) {
- $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ;
- if(strlen($userpass)) {
- list($name, $password) = explode(':', $userpass);
- $_SERVER['PHP_AUTH_USER'] = $name;
- $_SERVER['PHP_AUTH_PW'] = $password;
- }
-}
-
-if (x($_SERVER, 'HTTP_AUTHORIZATION')) {
- $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ;
- if(strlen($userpass)) {
- list($name, $password) = explode(':', $userpass);
- $_SERVER['PHP_AUTH_USER'] = $name;
- $_SERVER['PHP_AUTH_PW'] = $password;
- }
-}
-
/**
* @brief Fires up the SabreDAV server.
*
* @param App &$a
*/
+
function cloud_init(&$a) {
require_once('include/reddav.php');
@@ -116,17 +98,12 @@ function cloud_init(&$a) {
}
if ((! $auth->observer) && (! $isapublic_file) && (! $davguest)) {
- try {
- $auth->Authenticate($server, t('$Projectname - Guests: Username: {your email address}, Password: +++'));
- }
- catch (Exception $e) {
- logger('mod_cloud: auth exception' . $e->getMessage());
- http_status_exit($e->getHTTPCode(), $e->getMessage());
- }
+ logger('mod_cloud: auth exception');
+ http_status_exit(401, 'Permission denied.');
}
require_once('include/RedDAV/RedBrowser.php');
- // provide a directory view for the cloud in Red Matrix
+ // provide a directory view for the cloud in Hubzilla
$browser = new RedDAV\RedBrowser($auth);
$auth->setBrowserPlugin($browser);
diff --git a/mod/connections.php b/mod/connections.php
index 469d3a62f..2f1a1fdf5 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -71,21 +71,18 @@ function connections_post(&$a) {
}
}
- $abook_flags = $orig_record[0]['abook_flags'];
$new_friend = false;
-
- if(($_REQUEST['pending']) && ($abook_flags & ABOOK_FLAG_PENDING)) {
- $abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING );
+ if(($_REQUEST['pending']) && intval($orig_record[0]['abook_pending'])) {
$new_friend = true;
}
- $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d
+ $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_pending = %d
where abook_id = %d AND abook_channel = %d",
dbesc($profile_id),
intval($abook_my_perms),
intval($closeness),
- intval($abook_flags),
+ intval(1 - intval($new_friend)),
intval($contact_id),
intval(local_channel())
);
@@ -96,7 +93,7 @@ function connections_post(&$a) {
notice( t('Failed to update connection record.') . EOL);
if((x($a->data,'abook')) && $a->data['abook']['abook_my_perms'] != $abook_my_perms
- && (! ($a->data['abook']['abook_flags'] & ABOOK_FLAG_SELF))) {
+ && (! intval($a->data['abook']['abook_self']))) {
proc_run('php', 'include/notifier.php', 'permission_update', $contact_id);
}
@@ -182,46 +179,43 @@ function connections_content(&$a) {
if(! $_REQUEST['aj'])
$_SESSION['return_url'] = $a->query_string;
- $search_flags = 0;
+ $search_flags = '';
$head = '';
if(argc() == 2) {
switch(argv(1)) {
case 'blocked':
- $search_flags = ABOOK_FLAG_BLOCKED;
+ $search_flags = " and abook_blocked = 1 ";
$head = t('Blocked');
$blocked = true;
break;
case 'ignored':
- $search_flags = ABOOK_FLAG_IGNORED;
+ $search_flags = " and abook_ignored = 1 ";
$head = t('Ignored');
$ignored = true;
break;
case 'hidden':
- $search_flags = ABOOK_FLAG_HIDDEN;
+ $search_flags = " and abook_hidden = 1 ";
$head = t('Hidden');
$hidden = true;
break;
case 'archived':
- $search_flags = ABOOK_FLAG_ARCHIVED;
+ $search_flags = " and abook_archived = 1 ";
$head = t('Archived');
$archived = true;
break;
case 'pending':
- $search_flags = ABOOK_FLAG_PENDING;
+ $search_flags = " and abook_pending = 1 ";
$head = t('New');
$pending = true;
nav_set_selected('intros');
break;
case 'ifpending':
- $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d)>0 and not ((abook_flags & %d)>0 or (xchan_flags & %d)>0)",
- intval(local_channel()),
- intval(ABOOK_FLAG_PENDING),
- intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
- intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
+ $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ",
+ intval(local_channel())
);
if($r && $r[0]['total']) {
- $search_flags = ABOOK_FLAG_PENDING;
+ $search_flags = " and abook_pending = 1 ";
$head = t('New');
$pending = true;
nav_set_selected('intros');
@@ -229,7 +223,7 @@ function connections_content(&$a) {
}
else {
$head = t('All');
- $search_flags = 0;
+ $search_flags = '';
$all = true;
$a->argc = 1;
unset($a->argv[1]);
@@ -237,7 +231,7 @@ function connections_content(&$a) {
nav_set_selected('intros');
break;
// case 'unconnected':
-// $search_flags = ABOOK_FLAG_UNCONNECTED;
+// $search_flags = " and abook_unconnected = 1 ";
// $head = t('Unconnected');
// $unconnected = true;
// break;
@@ -245,19 +239,19 @@ function connections_content(&$a) {
case 'all':
$head = t('All');
default:
- $search_flags = 0;
+ $search_flags = '';
$all = true;
break;
}
- $sql_extra = (($search_flags) ? " and ( abook_flags & " . $search_flags . " )>0 " : "");
+ $sql_extra = $search_flags;
if(argv(1) === 'pending')
- $sql_extra .= " and not ( abook_flags & " . ABOOK_FLAG_IGNORED . " )>0 ";
+ $sql_extra .= " and abook_ignored = 0 ";
}
else {
- $sql_extra = " and not ( abook_flags & " . ABOOK_FLAG_BLOCKED . " )>0 ";
+ $sql_extra = " and abook_blocked = 0 ";
$unblocked = true;
}
@@ -343,10 +337,8 @@ function connections_content(&$a) {
}
$r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
- where abook_channel = %d and not (abook_flags & %d)>0 and not (xchan_flags & %d )>0 $sql_extra $sql_extra2 ",
- intval(local_channel()),
- intval(ABOOK_FLAG_SELF),
- intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
+ where abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ",
+ intval(local_channel())
);
if($r) {
$a->set_pager_total($r[0]['total']);
@@ -354,10 +346,8 @@ function connections_content(&$a) {
}
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
- WHERE abook_channel = %d and not (abook_flags & %d)>0 and not ( xchan_flags & %d)>0 $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d OFFSET %d ",
+ WHERE abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d OFFSET %d ",
intval(local_channel()),
- intval(ABOOK_FLAG_SELF),
- intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN),
intval($a->pager['itemspage']),
intval($a->pager['start'])
);
@@ -377,7 +367,7 @@ function connections_content(&$a) {
'thumb' => $rr['xchan_photo_m'],
'name' => $rr['xchan_name'],
'username' => $rr['xchan_name'],
- 'classes' => (($rr['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'archived' : ''),
+ 'classes' => (intval($rr['abook_archived']) ? 'archived' : ''),
'link' => z_root() . '/connedit/' . $rr['abook_id'],
'edit' => t('Edit'),
'url' => chanlink_url($rr['xchan_url']),
diff --git a/mod/connedit.php b/mod/connedit.php
index 71166b2cc..46546caa1 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -79,7 +79,7 @@ function connedit_post(&$a) {
call_hooks('contact_edit_post', $_POST);
- if($orig_record[0]['abook_flags'] & ABOOK_FLAG_SELF) {
+ if(intval($orig_record[0]['abook_self'])) {
$autoperms = intval($_POST['autoperms']);
$is_self = true;
}
@@ -177,8 +177,7 @@ function connedit_post(&$a) {
}
}
- if(($_REQUEST['pending']) && ($abook_flags & ABOOK_FLAG_PENDING)) {
- $abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING );
+ if(($_REQUEST['pending']) && intval($orig_record[0]['abook_pending'])) {
$new_friend = true;
if(! $abook_my_perms) {
@@ -193,13 +192,14 @@ function connedit_post(&$a) {
}
}
- $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d,
+
+ $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_pending = %d,
abook_incl = '%s', abook_excl = '%s'
where abook_id = %d AND abook_channel = %d",
dbesc($profile_id),
intval($abook_my_perms),
intval($closeness),
- intval($abook_flags),
+ intval(1 - intval($new_friend)),
dbesc($abook_incl),
dbesc($abook_excl),
intval($contact_id),
@@ -222,7 +222,7 @@ function connedit_post(&$a) {
notice( t('Failed to update connection record.') . EOL);
if($a->poi && $a->poi['abook_my_perms'] != $abook_my_perms
- && (! ($a->poi['abook_flags'] & ABOOK_FLAG_SELF))) {
+ && (! intval($a->poi['abook_self']))) {
proc_run('php', 'include/notifier.php', 'permission_update', $contact_id);
}
@@ -242,11 +242,12 @@ function connedit_post(&$a) {
$pr = q("select * from profile where uid = %d and is_default = 1 and hide_friends = 0",
intval($channel['channel_id'])
);
- if(($pr) && (! ($abook_flags & ABOOK_FLAG_HIDDEN))
- && (intval(get_pconfig($channel['channel_id'],'system','post_newfriend')))) {
+ if(($pr) && (! intval($orig_record[0]['abook_hidden'])) && (intval(get_pconfig($channel['channel_id'],'system','post_newfriend')))) {
$xarr = array();
$xarr['verb'] = ACTIVITY_FRIEND;
- $xarr['item_flags'] = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
+ $xarr['item_wall'] = 1;
+ $xarr['item_origin'] = 1;
+ $xarr['item_thread_top'] = 1;
$xarr['owner_xchan'] = $xarr['author_xchan'] = $channel['channel_hash'];
$xarr['allow_cid'] = $channel['channel_allow_cid'];
$xarr['allow_gid'] = $channel['channel_allow_gid'];
@@ -371,10 +372,9 @@ function connedit_content(&$a) {
$cmd = argv(2);
$orig_record = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_id = %d AND abook_channel = %d AND NOT ( abook_flags & %d )>0 LIMIT 1",
+ WHERE abook_id = %d AND abook_channel = %d AND abook_self = 0 LIMIT 1",
intval($contact_id),
- intval(local_channel()),
- intval(ABOOK_FLAG_SELF)
+ intval(local_channel())
);
if(! count($orig_record)) {
@@ -398,7 +398,7 @@ function connedit_content(&$a) {
if($cmd === 'block') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_BLOCKED)) {
- info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_BLOCKED)
+ info((intval($orig_record[0]['abook_blocked'])
? t('Channel has been unblocked')
: t('Channel has been blocked')) . EOL );
connedit_clone($a);
@@ -410,7 +410,7 @@ function connedit_content(&$a) {
if($cmd === 'ignore') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_IGNORED)) {
- info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_IGNORED)
+ info((intval($orig_record[0]['abook_ignored'])
? t('Channel has been unignored')
: t('Channel has been ignored')) . EOL );
connedit_clone($a);
@@ -422,7 +422,7 @@ function connedit_content(&$a) {
if($cmd === 'archive') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_ARCHIVED)) {
- info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_ARCHIVED)
+ info((intval($orig_record[0]['abook_archived'])
? t('Channel has been unarchived')
: t('Channel has been archived')) . EOL );
connedit_clone($a);
@@ -434,7 +434,7 @@ function connedit_content(&$a) {
if($cmd === 'hide') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_HIDDEN)) {
- info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_HIDDEN)
+ info((intval($orig_record[0]['abook_hidden'])
? t('Channel has been unhidden')
: t('Channel has been hidden')) . EOL );
connedit_clone($a);
@@ -448,9 +448,9 @@ function connedit_content(&$a) {
// Though maybe somebody will want this eventually (??)
if($cmd === 'approve') {
- if($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING) {
+ if(intval($orig_record[0]['abook_pending'])) {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_PENDING)) {
- info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING)
+ info((intval($orig_record[0]['abook_pending'])
? t('Channel has been approved')
: t('Channel has been unapproved')) . EOL );
connedit_clone($a);
@@ -520,28 +520,28 @@ function connedit_content(&$a) {
$buttons = array(
array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? t('Unblock') : t('Block')),
+ 'label' => (intval($contact['abook_blocked']) ? t('Unblock') : t('Block')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/block',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? 'active' : ''),
+ 'sel' => (intval($contact['abook_blocked']) ? 'active' : ''),
'title' => t('Block (or Unblock) all communications with this connection'),
),
array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? t('Unignore') : t('Ignore')),
+ 'label' => (intval($contact['abook_ignored']) ? t('Unignore') : t('Ignore')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/ignore',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? 'active' : ''),
+ 'sel' => (intval($contact['abook_ignored']) ? 'active' : ''),
'title' => t('Ignore (or Unignore) all inbound communications from this connection'),
),
array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? t('Unarchive') : t('Archive')),
+ 'label' => (intval($contact['abook_archived']) ? t('Unarchive') : t('Archive')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/archive',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'active' : ''),
+ 'sel' => (intval($contact['abook_archived']) ? 'active' : ''),
'title' => t('Archive (or Unarchive) this connection - mark channel dead but keep content'),
),
array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? t('Unhide') : t('Hide')),
+ 'label' => (intval($contact['abook_hidden']) ? t('Unhide') : t('Hide')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/hide',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? 'active' : ''),
+ 'sel' => (intval($contact['abook_hidden']) ? 'active' : ''),
'title' => t('Hide or Unhide this connection from your other connections'),
),
@@ -556,7 +556,7 @@ function connedit_content(&$a) {
$self = false;
- if(! ($contact['abook_flags'] & ABOOK_FLAG_SELF)) {
+ if(! intval($contact['abook_self'])) {
$tab_tpl = get_markup_template('common_tabs.tpl');
$t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
}
@@ -678,7 +678,7 @@ function connedit_content(&$a) {
'$tabs' => $t,
'$tab_str' => $tab_str,
'$perms_step1' => t('Default permissions for your channel type have (just) been applied. They have not yet been submitted. Please review the permissions on this page and make any desired changes at this time. This new connection may <em>not</em> be able to communicate with you until you submit this page, which will install and apply the selected permissions.'),
- '$is_pending' => (($contact['abook_flags'] & ABOOK_FLAG_PENDING) ? 1 : ''),
+ '$is_pending' => (intval($contact['abook_pending']) ? 1 : ''),
'$unapproved' => $unapproved,
'$inherited' => t('inherited'),
'$approve' => t('Approve this connection'),
diff --git a/mod/contactgroup.php b/mod/contactgroup.php
index 6138f9e19..61ca37054 100644
--- a/mod/contactgroup.php
+++ b/mod/contactgroup.php
@@ -9,10 +9,9 @@ function contactgroup_content(&$a) {
}
if((argc() > 2) && (intval(argv(1))) && (argv(2))) {
- $r = q("SELECT abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d and not ( abook_flags & %d )>0 limit 1",
+ $r = q("SELECT abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1",
dbesc(base64url_decode(argv(2))),
- intval(local_channel()),
- intval(ABOOK_FLAG_SELF)
+ intval(local_channel())
);
if($r)
$change = $r[0]['abook_xchan'];
diff --git a/mod/dav.php b/mod/dav.php
index 2f811a7f0..d4695a544 100644
--- a/mod/dav.php
+++ b/mod/dav.php
@@ -1,7 +1,7 @@
<?php
/**
* @file mod/dav.php
- * @brief Initialize RedMatrix's cloud (SabreDAV).
+ * @brief Initialize Hubzilla's cloud (SabreDAV).
*
* Module for accessing the DAV storage area from a DAV client.
*/
@@ -127,12 +127,10 @@ function dav_init(&$a) {
}
require_once('include/RedDAV/RedBrowser.php');
- // provide a directory view for the cloud in Red Matrix
+ // provide a directory view for the cloud in Hubzilla
$browser = new RedDAV\RedBrowser($auth);
$auth->setBrowserPlugin($browser);
- $server->addPlugin($browser);
-
// Experimental QuotaPlugin
// require_once('include/RedDAV/QuotaPlugin.php');
// $server->addPlugin(new RedDAV\QuotaPlugin($auth));
diff --git a/mod/directory.php b/mod/directory.php
index 44d80cff1..3c230e173 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -251,7 +251,7 @@ function directory_content(&$a) {
$hometown = ((x($profile,'hometown') == 1) ? $profile['hometown'] : False);
- $about = ((x($profile,'about') == 1) ? bbcode(strip_bbimage($profile['about'])) : False);
+ $about = ((x($profile,'about') == 1) ? bbcode($profile['about']) : False);
$keywords = ((x($profile,'keywords')) ? $profile['keywords'] : '');
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index d997020b2..132ed252b 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -127,7 +127,6 @@ function dirsearch_content(&$a) {
if($forums)
$safesql .= dir_flag_build(' AND ','xchan_flags',XCHAN_FLAGS_PUBFORUM, $forums);
-
// we only support an age range currently. You must set both agege
// (greater than or equal) and agele (less than or equal)
@@ -170,21 +169,16 @@ function dirsearch_content(&$a) {
$sql_extra .= " and xchan_addr like '%%" . get_app()->get_hostname() . "' ";
}
-
- $safesql .= (($safe > 0) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " )>0 " : '');
+ $safesql = (($safe > 0) ? " and xchan_censored = 0 and xchan_selfcensored = 0 " : '');
if($safe < 0)
- $safesql .= " and ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " )>0 ";
+ $safesql = " and ( xchan_censored = 1 OR xchan_selfcensored = 1 ) ";
if($limit)
$qlimit = " LIMIT $limit ";
else {
$qlimit = " LIMIT " . intval($perpage) . " OFFSET " . intval($startrec);
if($return_total) {
- $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and xchan_network = 'zot' and not ( xchan_flags & %d)>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql ",
- intval(XCHAN_FLAGS_HIDDEN),
- intval(XCHAN_FLAGS_ORPHAN),
- intval(XCHAN_FLAGS_DELETED)
- );
+ $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and xchan_network = 'zot' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql ");
if($r) {
$ret['total_items'] = $r[0]['total'];
}
@@ -251,13 +245,10 @@ function dirsearch_content(&$a) {
json_return_and_die($spkt);
}
else {
-
- $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql $order $qlimit ",
- intval(XCHAN_FLAGS_HIDDEN),
- intval(XCHAN_FLAGS_ORPHAN),
- intval(XCHAN_FLAGS_DELETED)
+ $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash
+ where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0
+ $safesql $order $qlimit "
);
-
$ret['page'] = $page + 1;
$ret['records'] = count($r);
}
@@ -283,7 +274,7 @@ function dirsearch_content(&$a) {
$entry['name'] = $rr['xchan_name'];
$entry['hash'] = $rr['xchan_hash'];
- $entry['public_forum'] = (($rr['xchan_flags'] & XCHAN_FLAGS_PUBFORUM) ? true : false);
+ $entry['public_forum'] = (intval($rr['xchan_pubforum']) ? true : false);
$entry['url'] = $rr['xchan_url'];
$entry['photo_l'] = $rr['xchan_photo_l'];
diff --git a/mod/display.php b/mod/display.php
index 8c4707bb2..b2d9ba34b 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -85,7 +85,7 @@ function display_content(&$a, $update = 0, $load = false) {
$target_item = null;
- $r = q("select id, uid, mid, parent_mid, item_restrict from item where mid like '%s' limit 1",
+ $r = q("select id, uid, mid, parent_mid, item_type, item_deleted from item where mid like '%s' limit 1",
dbesc($item_hash . '%')
);
@@ -95,7 +95,7 @@ function display_content(&$a, $update = 0, $load = false) {
$r = null;
- if($target_item['item_restrict'] & ITEM_WEBPAGE) {
+ if($target_item['item_type'] == ITEM_TYPE_WEBPAGE) {
$x = q("select * from channel where channel_id = %d limit 1",
intval($target_item['uid'])
);
@@ -161,6 +161,7 @@ function display_content(&$a, $update = 0, $load = false) {
}
$observer_hash = get_observer_hash();
+ $item_normal = item_normal();
$sql_extra = public_permissions_sql($observer_hash);
@@ -179,9 +180,9 @@ function display_content(&$a, $update = 0, $load = false) {
if(local_channel()) {
$r = q("SELECT * from item
- WHERE item_restrict = 0
- and uid = %d
+ WHERE uid = %d
and mid = '%s'
+ $item_normal
limit 1",
intval(local_channel()),
dbesc($target_item['parent_mid'])
@@ -202,13 +203,13 @@ function display_content(&$a, $update = 0, $load = false) {
$r = q("SELECT * from item
- WHERE item_restrict = 0
- and mid = '%s'
+ 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
limit 1",
dbesc($target_item['parent_mid']),
intval($sysid)
@@ -228,7 +229,7 @@ function display_content(&$a, $update = 0, $load = false) {
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`
FROM `item`
- WHERE item_restrict = 0 and parent in ( %s ) ",
+ WHERE parent in ( %s ) $item_normal ",
dbesc($parents_str)
);
@@ -251,7 +252,7 @@ function display_content(&$a, $update = 0, $load = false) {
}
if($updateable) {
- $x = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 AND uid = %d and parent = %d ",
+ $x = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d and parent = %d ",
intval(local_channel()),
intval($r[0]['parent'])
);
@@ -270,7 +271,7 @@ function display_content(&$a, $update = 0, $load = false) {
dbesc($item_hash)
);
if($r) {
- if($r[0]['item_flags'] & ITEM_DELETED) {
+ if(intval($r[0]['item_deleted'])) {
notice( t('Item has been removed.') . EOL );
}
else {
diff --git a/mod/editblock.php b/mod/editblock.php
index faa283b63..818dc5ec7 100644
--- a/mod/editblock.php
+++ b/mod/editblock.php
@@ -130,14 +130,14 @@ function editblock_content(&$a) {
$editor = replace_macros($tpl,array(
'$return_path' => $rp,
'$action' => 'item',
- '$webpage' => ITEM_BUILDBLOCK,
+ '$webpage' => ITEM_TYPE_BLOCK,
'$share' => t('Edit'),
- '$bold' => t('Bold'),
- '$italic' => t('Italic'),
- '$underline' => t('Underline'),
- '$quote' => t('Quote'),
- '$code' => t('Code'),
- '$writefiles' => (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage')),
+ '$bold' => t('Bold'),
+ '$italic' => t('Italic'),
+ '$underline' => t('Underline'),
+ '$quote' => t('Quote'),
+ '$code' => t('Code'),
+ '$writefiles' => (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage')),
'$upload' => t('Upload photo'),
'$attach' => t('Attach file'),
'$weblink' => t('Insert web link'),
diff --git a/mod/editlayout.php b/mod/editlayout.php
index a39611a58..6ea7f4100 100644
--- a/mod/editlayout.php
+++ b/mod/editlayout.php
@@ -129,7 +129,7 @@ function editlayout_content(&$a) {
$editor = replace_macros($tpl,array(
'$return_path' => $rp,
'$action' => 'item',
- '$webpage' => ITEM_PDL,
+ '$webpage' => ITEM_TYPE_PDL,
'$share' => t('Edit'),
'$bold' => t('Bold'),
'$italic' => t('Italic'),
diff --git a/mod/editpost.php b/mod/editpost.php
index e907a07d0..235ae9def 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -48,7 +48,7 @@ function editpost_content(&$a) {
'$confirmdelete' => t('Delete item?'),
));
- if($itm[0]['item_flags'] & ITEM_OBSCURED) {
+ if(intval($itm[0]['item_obscured'])) {
$key = get_config('system','prvkey');
if($itm[0]['title'])
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']),$key);
@@ -119,7 +119,7 @@ function editpost_content(&$a) {
'$noloc' => t('Clear browser location'),
'$voting' => t('Toggle voting'),
'$feature_voting' => $voting,
- '$consensus' => (($itm[0]['item_flags'] & ITEM_CONSENSUS) ? 1 : 0),
+ '$consensus' => intval($itm[0]['item_consensus']),
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
'$ptyp' => $itm[0]['type'],
diff --git a/mod/editwebpage.php b/mod/editwebpage.php
index cdf5d8c20..3b0b543a6 100644
--- a/mod/editwebpage.php
+++ b/mod/editwebpage.php
@@ -102,7 +102,7 @@ function editwebpage_content(&$a) {
return;
}
- if($itm[0]['item_flags'] & ITEM_OBSCURED) {
+ if(intval($itm[0]['item_obscured'])) {
$key = get_config('system','prvkey');
if($itm[0]['title'])
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']),$key);
@@ -169,7 +169,7 @@ function editwebpage_content(&$a) {
$editor = replace_macros($tpl,array(
'$return_path' => $rp,
- '$webpage' => ITEM_WEBPAGE,
+ '$webpage' => ITEM_TYPE_WEBPAGE,
'$placeholdpagetitle' => t('Page link title'),
'$pagetitle' => $page_title,
'$writefiles' => (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage')),
diff --git a/mod/events.php b/mod/events.php
index 289ddfb15..a89bbb760 100755
--- a/mod/events.php
+++ b/mod/events.php
@@ -414,8 +414,9 @@ function events_content(&$a) {
$is_first = ($d !== $last_date);
$last_date = $d;
-// FIXME
- $edit = (($rr['item_flags'] & ITEM_WALL) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null);
+
+ $edit = (intval($rr['item_wall']) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null);
+
$drop = array($a->get_baseurl().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
@@ -632,7 +633,7 @@ function events_content(&$a) {
'$s_text' => t('Event Starts:'),
'$stext' => $stext,
'$ftext' => $ftext,
- '$required' => ' <span class="required" title="' . t('Required') . '">*</span>',
+ '$required' => '<span class="required" title="' . t('Required') . '">*</span>',
'$ModalCANCEL' => t('Cancel'),
'$ModalOK' => t('OK'),
'$s_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$syear+5),DateTime::createFromFormat('Y-m-d H:i',"$syear-$smonth-$sday $shour:$sminute"),'start_text',true,true,'','',true),
diff --git a/mod/filer.php b/mod/filer.php
index e8160bba2..8d69503b2 100644
--- a/mod/filer.php
+++ b/mod/filer.php
@@ -27,8 +27,7 @@ function filer_content(&$a) {
intval(local_channel())
);
if($r) {
- $x = q("update item set item_flags = ( item_flags | %d ) where id = %d and uid = %d",
- intval(ITEM_RETAINED),
+ $x = q("update item set item_retained = 1 where id = %d and uid = %d",
intval($r[0]['parent']),
intval(local_channel())
);
diff --git a/mod/group.php b/mod/group.php
index 66297d6ac..ce9633669 100644
--- a/mod/group.php
+++ b/mod/group.php
@@ -117,12 +117,9 @@ 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 not (xchan_flags & %d)>0 and not (abook_flags & %d)>0 and not (abook_flags & %d)>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_blocked = 0 and abook_pending = 0 limit 1",
dbesc(base64url_decode(argv(2))),
- intval(local_channel()),
- intval(XCHAN_FLAGS_DELETED),
- intval(ABOOK_FLAG_BLOCKED),
- intval(ABOOK_FLAG_PENDING)
+ intval(local_channel())
);
if(count($r))
$change = base64url_decode(argv(2));
@@ -203,7 +200,7 @@ function group_content(&$a) {
$textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
foreach($members as $member) {
if($member['xchan_url']) {
- $member['archived'] = (($member['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? true : false);
+ $member['archived'] = (intval($member['abook_archived']) ? true : false);
$member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
$groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode);
}
@@ -211,18 +208,15 @@ 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 not (abook_flags & %d)>0 and not (xchan_flags & %d)>0 and not (abook_flags & %d)>0 order by xchan_name asc",
- intval(local_channel()),
- intval(ABOOK_FLAG_BLOCKED),
- intval(XCHAN_FLAGS_DELETED),
- intval(ABOOK_FLAG_PENDING)
+ $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",
+ intval(local_channel())
);
if(count($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
foreach($r as $member) {
if(! in_array($member['xchan_hash'],$preselected)) {
- $member['archived'] = (($member['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? true : false);
+ $member['archived'] = (intval($member['abook_archived']) ? true : false);
$member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
$groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode);
}
diff --git a/mod/help.php b/mod/help.php
index 694b356aa..809313a3e 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -11,25 +11,172 @@
*/
-if(! function_exists('load_doc_file')) {
+
+
+
+
function load_doc_file($s) {
$lang = get_app()->language;
if(! isset($lang))
$lang = 'en';
$b = basename($s);
$d = dirname($s);
- if(file_exists("$d/$lang/$b"))
- return file_get_contents("$d/$lang/$b");
+
+ $c = find_doc_file("$d/$lang/$b");
+ if($c)
+ return $c;
+ $c = find_doc_file($s);
+ if($c)
+ return $c;
+ return '';
+}
+
+function find_doc_file($s) {
+
+ // If the file was edited more recently than we've stored a copy in the database, use the file.
+ // The stored database item will be searchable, the file won't be.
+
+ $r = q("select item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and
+ sid = '%s' and item_type = %d limit 1",
+ dbesc($s),
+ intval(ITEM_TYPE_DOC)
+ );
+
+ if($r) {
+ if(file_exists($s) && (filemtime($s) > datetime_convert('UTC','UTC',$r[0]['edited'],'U')))
+ return file_get_contents($s);
+ return($r[0]['body']);
+ }
if(file_exists($s))
return file_get_contents($s);
return '';
-}}
+}
+
+function search_doc_files($s) {
+
+ $a = get_app();
+
+ $itemspage = get_pconfig(local_channel(),'system','itemspage');
+ $a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
+
+ // If the file was edited more recently than we've stored a copy in the database, use the file.
+ // The stored database item will be searchable, the file won't be.
+
+ $regexop = db_getfunc('REGEXP');
+
+ $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and
+ body $regexop '%s' and item_type = %d $pager_sql",
+ dbesc($s),
+ intval(ITEM_TYPE_DOC)
+ );
+
+ $r = fetch_post_tags($r,true);
+ require_once('include/html2plain.php');
+
+ for($x = 0; $x < count($r); $x ++) {
+
+ $r[$x]['text'] = html2plain(prepare_text($r[$x]['body'],$r[$x]['mimetype'], true));
+
+ $r[$x]['rank'] = 0;
+ if($r[$x]['term']) {
+ foreach($r[$x]['term'] as $t) {
+ if(stristr($t['term'],$s)) {
+ $r[$x]['rank'] ++;
+ }
+ }
+ }
+ if(stristr($r[$x]['sid'],$s))
+ $r[$x]['rank'] ++;
+ $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']),strtolower($s));
+ }
+ usort($r,'doc_rank_sort');
+ return $r;
+}
+
+
+function doc_rank_sort($a,$b) {
+ if($a['rank'] == $b['rank'])
+ return 0;
+ return (($a['rank'] < $b['rank']) ? 1 : (-1));
+}
+
+
+
+
+
+function store_doc_file($s) {
+
+ if(is_dir($s))
+ return;
+ $item = array();
+ $sys = get_sys_channel();
+
+ $item['aid'] = 0;
+ $item['uid'] = $sys['channel_id'];
+
+
+ if(strpos($s,'.md'))
+ $item['mimetype'] = 'text/markdown';
+ elseif(strpos($s,'.html'))
+ $item['mimetype'] = 'text/html';
+ else
+ $item['mimetype'] = 'text/bbcode';
+
+
+ $item['body'] = file_get_contents($s);
+ $item['plink'] = z_root() . '/' . str_replace('doc','help',$s);
+ $item['owner_xchan'] = $item['author_xchan'] = $sys['channel_hash'];
+ $item['item_type'] = ITEM_TYPE_DOC;
+
+ $r = q("select item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and
+ sid = '%s' and item_type = %d limit 1",
+ dbesc($s),
+ intval(ITEM_TYPE_DOC)
+ );
+
+ if($r) {
+ $item['id'] = $r[0]['id'];
+ $item['mid'] = $item['parent_mid'] = $r[0]['mid'];
+ $x = item_store_update($item);
+ }
+ else {
+ $item['mid'] = $item['parent_mid'] = item_message_id();
+ $x = item_store($item);
+ }
+
+ if($x['success']) {
+ update_remote_id($sys,$x['item_id'],ITEM_TYPE_DOC,$s,'docfile',0,$item['mid']);
+ }
+
+
+}
function help_content(&$a) {
nav_set_selected('help');
+ if($_REQUEST['search']) {
+ $r = search_doc_files($_REQUEST['search']);
+ if($r) {
+ $o .= '<ul>';
+ foreach($r as $rr) {
+ $dirname = dirname($rr['sid']);
+ $fname = basename($rr['sid']);
+ $fname = substr($fname,0,strrpos($fname,'.'));
+ $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>';
+
+ }
+ $o .= '</ul>';
+ }
+ return $o;
+ }
+
+
global $lang;
$doctype = 'markdown';
diff --git a/mod/home.php b/mod/home.php
index 3091be3a1..242b2dcec 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -44,7 +44,6 @@ function home_content(&$a, $update = 0, $load = false) {
$splash = ((argc() > 1 && argv(1) === 'splash') ? true : false);
-
call_hooks('home_content',$o);
if($o)
return $o;
@@ -68,6 +67,7 @@ function home_content(&$a, $update = 0, $load = false) {
goaway(z_root() . '/' . $frontpage);
}
+
$sitename = get_config('system','sitename');
if($sitename)
$o .= '<h1>' . sprintf( t("Welcome to %s") ,$sitename) . '</h1>';
diff --git a/mod/impel.php b/mod/impel.php
index 0b29bcf02..da7138438 100644
--- a/mod/impel.php
+++ b/mod/impel.php
@@ -32,17 +32,17 @@ function impel_init(&$a) {
switch($j['type']) {
case 'webpage':
- $arr['item_restrict'] = ITEM_WEBPAGE;
+ $arr['item_type'] = ITEM_TYPE_WEBPAGE;
$namespace = 'WEBPAGE';
$installed_type = t('webpage');
break;
case 'block':
- $arr['item_restrict'] = ITEM_BUILDBLOCK;
+ $arr['item_type'] = ITEM_TYPE_BLOCK;
$namespace = 'BUILDBLOCK';
$installed_type = t('block');
break;
case 'layout':
- $arr['item_restrict'] = ITEM_PDL;
+ $arr['item_type'] = ITEM_TYPE_PDL;
$namespace = 'PDL';
$installed_type = t('layout');
break;
@@ -157,7 +157,8 @@ function impel_init(&$a) {
dbesc($namespace),
intval(local_channel())
);
- $i = q("select id, edited, item_restrict from item where mid = '%s' and uid = %d limit 1",
+
+ $i = q("select id, edited, item_deleted from item where mid = '%s' and uid = %d limit 1",
dbesc($arr['mid']),
intval(local_channel())
);
@@ -170,7 +171,7 @@ function impel_init(&$a) {
$x = item_store_update($arr,$execflag);
}
else {
- if(($i) && ($i[0]['item_restrict'] & ITEM_DELETED)) {
+ if(($i) && (intval($i[0]['item_deleted']))) {
// was partially deleted already, finish it off
q("delete from item where mid = '%s' and uid = %d",
dbesc($arr['mid']),
@@ -182,7 +183,7 @@ function impel_init(&$a) {
if($x['success']) {
$item_id = $x['item_id'];
- update_remote_id($channel,$item_id,$arr['item_restrict'],$pagetitle,$namespace,$remote_id,$arr['mid']);
+ update_remote_id($channel,$item_id,$arr['item_type'],$pagetitle,$namespace,$remote_id,$arr['mid']);
}
}
diff --git a/mod/import.php b/mod/import.php
index 9877ce9f3..f8ab8a0a2 100644
--- a/mod/import.php
+++ b/mod/import.php
@@ -106,21 +106,21 @@ function import_post(&$a) {
if(array_key_exists('compatibility',$data) && array_key_exists('database',$data['compatibility'])) {
$v1 = substr($data['compatibility']['database'],-4);
$v2 = substr(DB_UPDATE_VERSION,-4);
- if($data['compatibility']['project'] !== PLATFORM_NAME) {
- notice( t('The data provided is not compatible with this project.') );
- return;
+ if($v2 > $v1) {
+ $t = sprintf( t('Warning: Database versions differ by %1$d updates.'), $v2 - $v1 );
+ notice($t);
}
}
- if($v2 > $v1) {
- $t = sprintf( t('Warning: Database versions differ by %1$d updates.'), $v2 - $v1 );
- notice($t);
- }
-
// import channel
$channel = $data['channel'];
+ if(! array_key_exists('channel_system',$channel)) {
+ $channel['channel_system'] = (($channel['channel_pageflags'] & 0x1000) ? 1 : 0);
+ $channel['channel_removed'] = (($channel['channel_pageflags'] & 0x8000) ? 1 : 0);
+ }
+
$r = q("select * from channel where (channel_guid = '%s' or channel_hash = '%s' or channel_address = '%s' ) limit 1",
dbesc($channel['channel_guid']),
dbesc($channel['channel_hash']),
@@ -191,6 +191,22 @@ function import_post(&$a) {
set_default_login_identity(get_account_id(),$channel['channel_id'],false);
+
+ $configs = $data['config'];
+ if($configs) {
+ foreach($configs as $config) {
+ unset($config['id']);
+ $config['uid'] = $channel['channel_id'];
+ dbesc_array($config);
+ $r = dbq("INSERT INTO pconfig (`"
+ . implode("`, `", array_keys($config))
+ . "`) VALUES ('"
+ . implode("', '", array_values($config))
+ . "')" );
+ }
+ }
+
+
if($data['photo']) {
require_once('include/photo/photo_driver.php');
import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],get_account_id(),$channel['channel_id']);
@@ -223,14 +239,22 @@ function import_post(&$a) {
$hublocs = $data['hubloc'];
if($hublocs) {
foreach($hublocs as $hubloc) {
+
+ if(! array_key_exists('hubloc_primary',$hublocs)) {
+ $hubloc['hubloc_primary'] = (($hubloc['hubloc_flags'] & 0x0001) ? 1 : 0);
+ $hubloc['hubloc_orphancheck'] = (($hubloc['hubloc_flags'] & 0x0004) ? 1 : 0);
+ $hubloc['hubloc_error'] = (($hubloc['hubloc_status'] & 0x0003) ? 1 : 0);
+ $hubloc['hubloc_deleted'] = (($hubloc['hubloc_flags'] & 0x1000) ? 1 : 0);
+ }
+
$arr = array(
'guid' => $hubloc['hubloc_guid'],
'guid_sig' => $hubloc['guid_sig'],
'url' => $hubloc['hubloc_url'],
'url_sig' => $hubloc['hubloc_url_sig']
);
- if(($hubloc['hubloc_hash'] === $channel['channel_hash']) && ($hubloc['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && ($seize))
- $hubloc['hubloc_flags'] = ($hubloc['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY);
+ if(($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize))
+ $hubloc['hubloc_primary'] = 0;
if(! zot_gethub($arr)) {
unset($hubloc['hubloc_id']);
@@ -249,7 +273,7 @@ function import_post(&$a) {
// create new hubloc for the new channel at this site
- $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_network, hubloc_flags,
+ $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_network, hubloc_primary,
hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey )
values ( '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s' )",
dbesc($channel['channel_guid']),
@@ -257,7 +281,7 @@ function import_post(&$a) {
dbesc($channel['channel_hash']),
dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()),
dbesc('zot'),
- intval(($seize) ? HUBLOC_FLAGS_PRIMARY : 0),
+ intval(($seize) ? 1 : 0),
dbesc(z_root()),
dbesc(base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))),
dbesc(get_app()->get_hostname()),
@@ -268,9 +292,7 @@ function import_post(&$a) {
// reset the original primary hubloc if it is being seized
if($seize)
- $r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where (hubloc_flags & %d)>0 and hubloc_hash = '%s' and hubloc_url != '%s' ",
- intval(HUBLOC_FLAGS_PRIMARY),
- intval(HUBLOC_FLAGS_PRIMARY),
+ $r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ",
dbesc($channel['channel_hash']),
dbesc(z_root())
);
@@ -285,7 +307,7 @@ function import_post(&$a) {
dbesc($channel['channel_hash'])
);
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
+ $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_hidden, xchan_orphan, xchan_censored, xchan_selfcensored, xchan_system, xchan_pubforum, xchan_deleted ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, %d )",
dbesc($channel['channel_hash']),
dbesc($channel['channel_guid']),
dbesc($channel['channel_guid_sig']),
@@ -300,13 +322,23 @@ function import_post(&$a) {
dbesc($channel['channel_name']),
dbesc('zot'),
dbesc(datetime_convert()),
- dbesc(datetime_convert())
+ dbesc(datetime_convert()),
+ 0,0,0,0,0,0,0
);
}
$xchans = $data['xchan'];
if($xchans) {
foreach($xchans as $xchan) {
+ if(! array_key_exists('xchan_hidden',$xchan)) {
+ $xchan['xchan_hidden'] = (($xchan['xchan_flags'] & 0x0001) ? 1 : 0);
+ $xchan['xchan_orphan'] = (($xchan['xchan_flags'] & 0x0002) ? 1 : 0);
+ $xchan['xchan_censored'] = (($xchan['xchan_flags'] & 0x0004) ? 1 : 0);
+ $xchan['xchan_selfcensored'] = (($xchan['xchan_flags'] & 0x0008) ? 1 : 0);
+ $xchan['xchan_system'] = (($xchan['xchan_flags'] & 0x0010) ? 1 : 0);
+ $xchan['xchan_pubforum'] = (($xchan['xchan_flags'] & 0x0020) ? 1 : 0);
+ $xchan['xchan_deleted'] = (($xchan['xchan_flags'] & 0x1000) ? 1 : 0);
+ }
$r = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1",
dbesc($xchan['xchan_hash'])
@@ -355,12 +387,32 @@ function import_post(&$a) {
foreach($abooks as $abook) {
if($max_friends !== false && $friends > $max_friends)
continue;
- if($max_feeds !== false && ($abook['abook_flags'] & ABOOK_FLAG_FEED) && $feeds > $max_feeds)
+ if($max_feeds !== false && intval($abook['abook_feed']) && ($feeds > $max_feeds))
continue;
unset($abook['abook_id']);
$abook['abook_account'] = get_account_id();
$abook['abook_channel'] = $channel['channel_id'];
+ if(! array_key_exists('abook_blocked',$abook)) {
+ $abook['abook_blocked'] = (($abook['abook_flags'] & 0x0001 ) ? 1 : 0);
+ $abook['abook_ignored'] = (($abook['abook_flags'] & 0x0002 ) ? 1 : 0);
+ $abook['abook_hidden'] = (($abook['abook_flags'] & 0x0004 ) ? 1 : 0);
+ $abook['abook_archived'] = (($abook['abook_flags'] & 0x0008 ) ? 1 : 0);
+ $abook['abook_pending'] = (($abook['abook_flags'] & 0x0010 ) ? 1 : 0);
+ $abook['abook_unconnected'] = (($abook['abook_flags'] & 0x0020 ) ? 1 : 0);
+ $abook['abook_self'] = (($abook['abook_flags'] & 0x0080 ) ? 1 : 0);
+ $abook['abook_feed'] = (($abook['abook_flags'] & 0x0100 ) ? 1 : 0);
+ }
+
+ if($abook['abook_self']) {
+ $role = get_pconfig($channel['channel_id'],'system','permissions_role');
+ if(($role === 'forum') || ($abook['abook_my_perms'] & PERMS_W_TAGWALL)) {
+ q("update xchan set xchan_pubforum = 1 where xchan_hash = '%s' ",
+ dbesc($abook['abook_xchan'])
+ );
+ }
+ }
+
dbesc_array($abook);
$r = dbq("INSERT INTO abook (`"
. implode("`, `", array_keys($abook))
@@ -369,25 +421,12 @@ function import_post(&$a) {
. "')" );
$friends ++;
- if($abook['abook_flags'] & ABOOK_FLAG_FEED)
+ if(intval($abook['abook_feed']))
$feeds ++;
}
}
- $configs = $data['config'];
- if($configs) {
- foreach($configs as $config) {
- unset($config['id']);
- $config['uid'] = $channel['channel_id'];
- dbesc_array($config);
- $r = dbq("INSERT INTO pconfig (`"
- . implode("`, `", array_keys($config))
- . "`) VALUES ('"
- . implode("', '", array_values($config))
- . "')" );
- }
- }
$groups = $data['group'];
if($groups) {
diff --git a/mod/item.php b/mod/item.php
index bc2710b42..57a905395 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -115,7 +115,7 @@ function item_post(&$a) {
* Check service class limits
*/
if ($uid && !(x($_REQUEST,'parent')) && !(x($_REQUEST,'post_id'))) {
- $ret = item_check_service_class($uid,(($_REQUEST['webpage'] == ITEM_WEBPAGE) ? true : false));
+ $ret = item_check_service_class($uid,(($_REQUEST['webpage'] == ITEM_TYPE_WEBPAGE) ? true : false));
if (!$ret['success']) {
notice( t($ret['message']) . EOL) ;
if(x($_REQUEST,'return'))
@@ -197,7 +197,7 @@ function item_post(&$a) {
if($parent) {
logger('mod_item: item_post parent=' . $parent);
$can_comment = false;
- if((array_key_exists('owner',$parent_item)) && ($parent_item['owner']['abook_flags'] & ABOOK_FLAG_SELF))
+ if((array_key_exists('owner',$parent_item)) && intval($parent_item['owner']['abook_self']))
$can_comment = perm_is_allowed($profile_uid,$observer['xchan_hash'],'post_comments');
else
$can_comment = can_comment_on_post($observer['xchan_hash'],$parent_item);
@@ -295,7 +295,7 @@ function item_post(&$a) {
// For comments, We need to additionally look at the parent and see if it's a wall post that originated locally.
if($observer['xchan_name'] != $owner_xchan['xchan_name']) {
- if($parent_item && ($parent_item['item_flags'] & (ITEM_WALL|ITEM_ORIGIN)) == (ITEM_WALL|ITEM_ORIGIN)) {
+ if(($parent_item) && ($parent_item['item_wall'] && $parent_item['item_origin'])) {
$walltowall_comment = true;
$walltowall = true;
}
@@ -347,12 +347,32 @@ function item_post(&$a) {
$body = trim($_REQUEST['body']);
$item_flags = $orig_post['item_flags'];
- // force us to recalculate if we need to obscure this post
+ $item_origin = $orig_post['item_origin'];
+ $item_unseen = $orig_post['item_unseen'];
+ $item_starred = $orig_post['item_starred'];
+ $item_uplink = $orig_post['item_uplink'];
+ $item_consensus = $orig_post['item_consensus'];
+ $item_wall = $orig_post['item_wall'];
+ $item_thread_top = $orig_post['item_thread_top'];
+ $item_notshown = $orig_post['item_notshown'];
+ $item_nsfw = $orig_post['item_nsfw'];
+ $item_relay = $orig_post['item_relay'];
+ $item_mentionsme = $orig_post['item_mentionsme'];
+ $item_nocomment = $orig_post['item_nocomment'];
+ $item_obscured = $orig_post['item_obscured'];
+ $item_verified = $orig_post['item_verified'];
+ $item_retained = $orig_post['item_retained'];
+ $item_rss = $orig_post['item_rss'];
+ $item_deleted = $orig_post['item_deleted'];
+ $item_type = $orig_post['item_type'];
+ $item_hidden = $orig_post['item_hidden'];
+ $item_unpublished = $orig_post['item_unpublished'];
+ $item_delayed = $orig_post['item_delayed'];
+ $item_pending_remove = $orig_post['item_pending_remove'];
+ $item_blocked = $orig_post['item_blocked'];
+
- if($item_flags & ITEM_OBSCURED)
- $item_flags = ($item_flags ^ ITEM_OBSCURED);
- $item_restrict = $orig_post['item_restrict'];
$postopts = $orig_post['postopts'];
$created = $orig_post['created'];
$mid = $orig_post['mid'];
@@ -629,6 +649,7 @@ function item_post(&$a) {
if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) {
$attachments = array();
foreach($match[2] as $mtch) {
+ $attach_link = '';
$hash = substr($mtch,0,strpos($mtch,','));
$rev = intval(substr($mtch,strpos($mtch,',')));
$r = attach_by_hash_nodata($hash,$rev);
@@ -641,7 +662,12 @@ function item_post(&$a) {
'revision' => $r['data']['revision']
);
}
- $body = str_replace($match[1],'',$body);
+ $ext = substr($r['data']['filename'],strrpos($r['data']['filename'],'.'));
+ if(strpos($r['data']['filetype'],'audio/') !== false)
+ $attach_link = '[audio]' . z_root() . '/attach/' . $r['data']['hash'] . '/' . $r['data']['revision'] . (($ext) ? $ext : '') . '[/audio]';
+ elseif(strpos($r['data']['filetype'],'video/') !== false)
+ $attach_link = '[video]' . z_root() . '/attach/' . $r['data']['hash'] . '/' . $r['data']['revision'] . (($ext) ? $ext : '') . '[/video]';
+ $body = str_replace($match[1],$attach_link,$body);
}
}
@@ -662,31 +688,27 @@ function item_post(&$a) {
}
}
- $item_unseen = 1;
-
+
+ $item_unseen = ((local_channel() != $profile_uid) ? 1 : 0);
+ $item_wall = (($post_type === 'wall' || $post_type === 'wall-comment') ? 1 : 0);
+ $item_origin = (($origin) ? 1 : 0);
+
// determine if this is a wall post
if($parent) {
- if($parent_item['item_flags'] & ITEM_WALL) {
- $item_flags = $item_flags | ITEM_WALL;
- }
+ $item_wall = $parent_item['item_wall'];
}
else {
if(! $webpage) {
- $item_flags = $item_flags | ITEM_WALL;
+ $item_wall = 1;
}
}
- if($origin)
- $item_flags = $item_flags | ITEM_ORIGIN;
if($moderated)
- $item_restrict = $item_restrict | ITEM_MODERATED;
+ $item_blocked = ITEM_MODERATED;
- if($webpage)
- $item_restrict = $item_restrict | $webpage;
-
if(! strlen($verb))
$verb = ACTIVITY_POST ;
@@ -710,14 +732,10 @@ function item_post(&$a) {
$datarray = array();
- if(! $parent) {
- $item_flags = $item_flags | ITEM_THREAD_TOP;
- }
+ $item_thead_top = ((! $parent) ? 1 : 0);
- if($consensus)
- $item_flags |= ITEM_CONSENSUS;
- if ((! $plink) && ($item_flags & ITEM_THREAD_TOP)) {
+ if ((! $plink) && ($item_thread_top)) {
$plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid;
}
@@ -747,18 +765,41 @@ function item_post(&$a) {
$datarray['deny_cid'] = $str_contact_deny;
$datarray['deny_gid'] = $str_group_deny;
$datarray['item_private'] = $private;
+ $datarray['item_wall'] = $item_wall;
$datarray['attach'] = $attachments;
$datarray['thr_parent'] = $thr_parent;
$datarray['postopts'] = $postopts;
- $datarray['item_restrict'] = $item_restrict;
- $datarray['item_flags'] = $item_flags;
+ $datarray['item_unseen'] = $item_unseen;
+ $datarray['item_wall'] = $item_wall;
+ $datarray['item_origin'] = $item_origin;
+ $datarray['item_type'] = $webpage;
+ $datarray['item_thread_top'] = $item_thread_top;
+ $datarray['item_unseen'] = $item_unseen;
+ $datarray['item_starred'] = $item_starred;
+ $datarray['item_uplink'] = $item_uplink;
+ $datarray['item_consensus'] = $item_consensus;
+ $datarray['item_notshown'] = $item_notshown;
+ $datarray['item_nsfw'] = $item_nsfw;
+ $datarray['item_relay'] = $item_relay;
+ $datarray['item_mentionsme'] = $item_mentionsme;
+ $datarray['item_nocomment'] = $item_nocomment;
+ $datarray['item_obscured'] = $item_obscured;
+ $datarray['item_verified'] = $item_verified;
+ $datarray['item_retained'] = $item_retained;
+ $datarray['item_rss'] = $item_rss;
+ $datarray['item_deleted'] = $item_deleted;
+ $datarray['item_hidden'] = $item_hidden;
+ $datarray['item_unpublished'] = $item_unpublished;
+ $datarray['item_delayed'] = $item_delayed;
+ $datarray['item_pending_remove'] = $item_pending_remove;
+ $datarray['item_blocked'] = $item_blocked;
+
$datarray['layout_mid'] = $layout_mid;
$datarray['public_policy'] = $public_policy;
$datarray['comment_policy'] = map_scope($channel['channel_w_comment']);
$datarray['term'] = $post_tags;
$datarray['plink'] = $plink;
$datarray['route'] = $route;
- $datarray['item_unseen'] = $item_unseen;
// preview mode - prepare the body for display and send it via json
@@ -803,17 +844,9 @@ function item_post(&$a) {
if($uid) {
if($channel['channel_hash'] === $datarray['author_xchan']) {
$datarray['sig'] = base64url_encode(rsa_sign($datarray['body'],$channel['channel_prvkey']));
- $datarray['item_flags'] = $datarray['item_flags'] | ITEM_VERIFIED;
+ $datarray['item_verified'] = 1;
}
}
-
- logger('Encrypting local storage');
- $key = get_config('system','pubkey');
- $datarray['item_flags'] = $datarray['item_flags'] | ITEM_OBSCURED;
- if($datarray['title'])
- $datarray['title'] = json_encode(crypto_encapsulate($datarray['title'],$key));
- if($datarray['body'])
- $datarray['body'] = json_encode(crypto_encapsulate($datarray['body'],$key));
}
if($orig_post) {
@@ -847,7 +880,7 @@ function item_post(&$a) {
// only send comment notification if this is a wall-to-wall comment,
// otherwise it will happen during delivery
- if(($datarray['owner_xchan'] != $datarray['author_xchan']) && ($parent_item['item_flags'] & ITEM_WALL)) {
+ if(($datarray['owner_xchan'] != $datarray['author_xchan']) && (intval($parent_item['item_wall']))) {
notification(array(
'type' => NOTIFY_COMMENT,
'from_xchan' => $datarray['author_xchan'],
@@ -877,7 +910,7 @@ function item_post(&$a) {
));
}
- if($uid && $uid == $profile_uid && (! $datarray['item_restrict'])) {
+ if($uid && $uid == $profile_uid && (is_item_normal($datarray))) {
q("update channel set channel_lastpost = '%s' where channel_id = %d",
dbesc(datetime_convert()),
intval($uid)
@@ -889,9 +922,8 @@ function item_post(&$a) {
// This way we don't see every picture in your new photo album posted to your wall at once.
// They will show up as people comment on them.
- if($parent_item['item_restrict'] & ITEM_HIDDEN) {
- $r = q("UPDATE `item` SET `item_restrict` = %d WHERE `id` = %d",
- intval($parent_item['item_restrict'] - ITEM_HIDDEN),
+ if(intval($parent_item['item_hidden'])) {
+ $r = q("UPDATE item SET item_hidden = 0 WHERE id = %d",
intval($parent_item['id'])
);
}
@@ -956,7 +988,7 @@ function item_content(&$a) {
if((argc() == 3) && (argv(1) === 'drop') && intval(argv(2))) {
require_once('include/items.php');
- $i = q("select id, uid, author_xchan, owner_xchan, source_xchan, item_restrict from item where id = %d limit 1",
+ $i = q("select id, uid, author_xchan, owner_xchan, source_xchan, item_type from item where id = %d limit 1",
intval(argv(2))
);
@@ -982,7 +1014,7 @@ function item_content(&$a) {
// if this is a different page type or it's just a local delete
// but not by the item author or owner, do a simple deletion
- if($i[0]['item_restrict'] || ($local_delete && (! $can_delete))) {
+ if(intval($i[0]['item_type']) || ($local_delete && (! $can_delete))) {
drop_item($i[0]['id']);
}
else {
@@ -1061,6 +1093,21 @@ function fix_attached_photo_permissions($uid,$xchan_hash,$body,
intval($uid)
);
}
+ $r = q("select id from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($image_uri),
+ intval($uid)
+ );
+ if($r) {
+ q("update attach SET allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s'
+ WHERE id = %d AND uid = %d",
+ dbesc($str_contact_allow),
+ dbesc($str_group_allow),
+ dbesc($str_contact_deny),
+ dbesc($str_group_deny),
+ intval($r[0]['id']),
+ intval($uid)
+ );
+ }
}
}
}
@@ -1100,17 +1147,15 @@ function item_check_service_class($channel_id,$iswebpage) {
$ret = array('success' => false, 'message' => '');
if ($iswebpage) {
- // note: we aren't counting comanche templates and blocks, only webpages
- $r = q("select count(id) as total from item where parent = id
- and ( item_restrict & %d ) > 0 and ( item_restrict & %d ) = 0 and uid = %d ",
- intval(ITEM_WEBPAGE),
- intval(ITEM_DELETED),
+ $r = q("select count(i.id) as total from item i
+ right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id )
+ and i.parent=i.id and i.item_type = %d and i.item_deleted = 0 and i.uid= %d ",
+ intval(ITEM_TYPE_WEBPAGE),
intval($channel_id)
);
}
else {
- $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and (item_flags & %d) > 0 and uid = %d ",
- intval(ITEM_WALL),
+ $r = q("select count(id) as total from item where parent = id and item_wall = 1 and uid = %d " . item_normal(),
intval($channel_id)
);
}
diff --git a/mod/layouts.php b/mod/layouts.php
index 689a31c8c..fd77cfc37 100644
--- a/mod/layouts.php
+++ b/mod/layouts.php
@@ -99,7 +99,7 @@ function layouts_content(&$a) {
dbesc(argv(3))
);
if($r) {
- header('Content-type: application/x-redmatrix-layout');
+ header('Content-type: application/x-hubzilla-layout');
header('Content-disposition: attachment; filename="' . $r[0]['sid'] . '.pdl"');
echo json_encode($r);
killme();
@@ -111,7 +111,7 @@ function layouts_content(&$a) {
// This lets you post pages at other people's channels.
$x = array(
- 'webpage' => ITEM_PDL,
+ 'webpage' => ITEM_TYPE_PDL,
'is_owner' => true,
'nickname' => $a->profile['channel_address'],
'bang' => '',
@@ -134,10 +134,10 @@ function layouts_content(&$a) {
$editor = status_editor($a,$x);
- $r = q("select iid, sid, mid, title, body, mimetype, created, edited from item_id left join item on item_id.iid = item.id
- where item_id.uid = %d and service = 'PDL' and item_restrict = %d order by item.created desc",
+ $r = q("select iid, sid, mid, title, body, mimetype, created, edited, item_type from item_id left join item on item_id.iid = item.id
+ where item_id.uid = %d and service = 'PDL' and item_type = %d order by item.created desc",
intval($owner),
- intval(ITEM_PDL)
+ intval(ITEM_TYPE_PDL)
);
$pages = null;
diff --git a/mod/like.php b/mod/like.php
index e79ff5f48..ffd302efa 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -241,9 +241,10 @@ function like_content(&$a) {
// get the item. Allow linked photos (which are normally hidden) to be liked
- $r = q("SELECT * FROM item WHERE id = %d and (item_restrict = 0 or item_restrict = %d) LIMIT 1",
- intval($item_id),
- intval(ITEM_HIDDEN)
+ $r = q("SELECT * FROM item WHERE id = %d
+ and item_blocked = 0 and item_moderated = 0 and item_spam = 0
+ and item_deleted = 0 and item_unpublished = 0 and item_delayed_publish = 0 LIMIT 1",
+ intval($item_id)
);
if(! $item_id || (! $r)) {
@@ -303,7 +304,9 @@ function like_content(&$a) {
$multi_undo = 1;
}
- $r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) AND item_restrict = 0
+ $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 ",
dbesc($observer['xchan_hash']),
intval($item_id),
@@ -338,9 +341,12 @@ function like_content(&$a) {
$mid = item_message_id();
- if($extended_like) {
- $item_flags = ITEM_THREAD_TOP|ITEM_ORIGIN|ITEM_WALL;
+ $arr = array();
+ if($extended_like) {
+ $arr['item_thread_top'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = 1;
}
else {
$post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status'));
@@ -372,18 +378,19 @@ function like_content(&$a) {
),
));
- if(! ($item['item_flags'] & ITEM_THREAD_TOP))
+ if(! intval($item['item_thread_top']))
$post_type = 'comment';
- $item_flags = ITEM_ORIGIN | ITEM_NOTSHOWN;
- if($item['item_flags'] & ITEM_WALL)
- $item_flags |= ITEM_WALL;
+ $arr['item_origin'] = 1;
+ $arr['item_notshown'] = 1;
+
+ if(intval($item['item_wall']))
+ $arr['item_wall'] = 1;
// if this was a linked photo and was hidden, unhide it.
- if($item['item_restrict'] & ITEM_HIDDEN) {
- $r = q("update item set item_restrict = (item_restrict ^ %d) where id = %d",
- intval(ITEM_HIDDEN),
+ if(intval($item['item_hidden'])) {
+ $r = q("update item set item_hidden = 0 where id = %d",
intval($item['id'])
);
}
@@ -411,7 +418,6 @@ function like_content(&$a) {
killme();
- $arr = array();
if($extended_like) {
$ulink = '[zrl=' . $ch[0]['xchan_url'] . ']' . $ch[0]['xchan_name'] . '[/zrl]';
@@ -437,6 +443,7 @@ function like_content(&$a) {
$arr['aid'] = (($extended_like) ? $ch[0]['channel_account_id'] : $owner_aid);
$arr['uid'] = $owner_uid;
$arr['item_flags'] = $item_flags;
+ $arr['item_wall'] = $item_wall;
$arr['parent_mid'] = (($extended_like) ? $mid : $item['mid']);
$arr['owner_xchan'] = (($extended_like) ? $ch[0]['xchan_hash'] : $thread_owner['xchan_hash']);
$arr['author_xchan'] = $observer['xchan_hash'];
diff --git a/mod/locs.php b/mod/locs.php
index 5b04bb343..3f8bd9029 100644
--- a/mod/locs.php
+++ b/mod/locs.php
@@ -22,13 +22,10 @@ function locs_post(&$a) {
return;
}
- $r = q("update hubloc set hubloc_flags = (hubloc_flags - %d) where (hubloc_flags & %d)>0 and hubloc_hash = '%s' ",
- intval(HUBLOC_FLAGS_PRIMARY),
- intval(HUBLOC_FLAGS_PRIMARY),
+ $r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' ",
dbesc($channel['channel_hash'])
);
- $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d and hubloc_hash = '%s'",
- intval(HUBLOC_FLAGS_PRIMARY),
+ $r = q("update hubloc set hubloc_primary = 1 where hubloc_id = %d and hubloc_hash = '%s'",
intval($hubloc_id),
dbesc($channel['channel_hash'])
);
@@ -42,7 +39,7 @@ function locs_post(&$a) {
$hubloc_id = intval($_REQUEST['drop']);
if($hubloc_id) {
- $r = q("select hubloc_id, hubloc_flags from hubloc where hubloc_id = %d and hubloc_url != '%s' and hubloc_hash = '%s' limit 1",
+ $r = q("select * from hubloc where hubloc_id = %d and hubloc_url != '%s' and hubloc_hash = '%s' limit 1",
intval($hubloc_id),
dbesc(z_root()),
dbesc($channel['channel_hash'])
@@ -52,12 +49,12 @@ function locs_post(&$a) {
notice( t('Location not found.') . EOL);
return;
}
- if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) {
+ if(intval($r[0]['hubloc_primary'])) {
notice( t('Primary location cannot be removed.') . EOL);
return;
}
- $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d and hubloc_hash = '%s'",
- intval(HUBLOC_FLAGS_DELETED),
+
+ $r = q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d and hubloc_hash = '%s'",
intval($hubloc_id),
dbesc($channel['channel_hash'])
);
@@ -72,7 +69,6 @@ function locs_post(&$a) {
function locs_content(&$a) {
-
if(! local_channel()) {
notice( t('Permission denied.') . EOL);
return;
@@ -91,8 +87,8 @@ function locs_content(&$a) {
for($x = 0; $x < count($r); $x ++) {
- $r[$x]['primary'] = (($r[$x]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) ? true : false);
- $r[$x]['deleted'] = (($r[$x]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) ? true : false);
+ $r[$x]['primary'] = (intval($r[$x]['hubloc_primary']) ? true : false);
+ $r[$x]['deleted'] = (intval($r[$x]['hubloc_deleted']) ? true : false);
}
diff --git a/mod/mail.php b/mod/mail.php
index 1b0ea17c4..152db3231 100644
--- a/mod/mail.php
+++ b/mod/mail.php
@@ -145,8 +145,7 @@ function mail_content(&$a) {
if(! intval(argv(2)))
return;
$cmd = argv(1);
- $r = q("update mail set mail_flags = mail_flags | %d where id = %d and channel_id = %d",
- intval(MAIL_RECALLED),
+ $r = q("update mail set mail_recalled = 1 where id = %d and channel_id = %d",
intval(argv(2)),
intval(local_channel())
);
@@ -312,7 +311,7 @@ function mail_content(&$a) {
'delete' => t('Delete message'),
'recall' => t('Recall message'),
'can_recall' => (($channel['channel_hash'] == $message['from_xchan']) ? true : false),
- 'is_recalled' => (($message['mail_flags'] & MAIL_RECALLED) ? t('Message has been recalled.') : ''),
+ 'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''),
'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
);
diff --git a/mod/manage.php b/mod/manage.php
index 3712be6f1..b609ede44 100644
--- a/mod/manage.php
+++ b/mod/manage.php
@@ -41,9 +41,8 @@ function manage_content(&$a) {
$channels = null;
if(local_channel()) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and not ( channel_pageflags & %d )>0 order by channel_name ",
- intval(get_account_id()),
- intval(PAGE_REMOVED)
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ",
+ intval(get_account_id())
);
$account = get_app()->get_account();
@@ -56,14 +55,14 @@ function manage_content(&$a) {
$channels[$x]['default_links'] = '1';
- $c = q("SELECT id, item_restrict, item_flags FROM item
- WHERE item_restrict = 0 and item_unseen = 1 and uid = %d",
+ $c = q("SELECT id, item_wall FROM item
+ WHERE item_unseen = 1 and uid = %d " . item_normal(),
intval($channels[$x]['channel_id'])
);
if($c) {
foreach ($c as $it) {
- if($it['item_flags'] & ITEM_WALL)
+ if(intval($it['item_wall']))
$channels[$x]['home'] ++;
else
$channels[$x]['network'] ++;
@@ -71,20 +70,16 @@ function manage_content(&$a) {
}
- $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d)>0 and not ((abook_flags & %d)>0 or (xchan_flags & %d)>0)",
- intval($channels[$x]['channel_id']),
- intval(ABOOK_FLAG_PENDING),
- intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
- intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
+ $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ",
+ intval($channels[$x]['channel_id'])
);
if($intr)
$channels[$x]['intros'] = intval($intr[0]['total']);
- $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND not (mail_flags & %d)>0 and from_xchan != '%s' ",
+ $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ",
intval($channels[$x]['channel_id']),
- intval(MAIL_SEEN),
dbesc($channels[$x]['channel_hash'])
);
@@ -127,9 +122,8 @@ function manage_content(&$a) {
}
}
- $r = q("select count(channel_id) as total from channel where channel_account_id = %d and not ( channel_pageflags & %d )>0",
- intval(get_account_id()),
- intval(PAGE_REMOVED)
+ $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0",
+ intval(get_account_id())
);
$limit = account_service_class_fetch(get_account_id(),'total_identities');
if($limit !== false) {
diff --git a/mod/message.php b/mod/message.php
index 4a1ff26d1..9cf4b6987 100644
--- a/mod/message.php
+++ b/mod/message.php
@@ -25,7 +25,6 @@ function message_content(&$a) {
$cipher = 'aes256';
-
$tpl = get_markup_template('mail_head.tpl');
$header = replace_macros($tpl, array(
'$messages' => t('Messages'),
@@ -49,7 +48,6 @@ function message_content(&$a) {
// private_messages_list() can do other more complicated stuff, for now keep it simple
-
$r = private_messages_list(local_channel(), '', $a->pager['start'], $a->pager['itemspage']);
if(! $r) {
diff --git a/mod/mood.php b/mod/mood.php
index 7663b2632..92a4f391b 100755
--- a/mod/mood.php
+++ b/mod/mood.php
@@ -61,9 +61,6 @@ function mood_init(&$a) {
$mid = item_message_id();
$action = sprintf( t('%1$s is %2$s','mood'), '[zrl=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/zrl]' , $verbs[$verb]);
- $item_flags = ITEM_WALL|ITEM_ORIGIN;
- if(! $parent_mid)
- $item_flags |= ITEM_THREAD_TOP;
$arr = array();
@@ -71,7 +68,6 @@ function mood_init(&$a) {
$arr['uid'] = $uid;
$arr['mid'] = $mid;
$arr['parent_mid'] = (($parent_mid) ? $parent_mid : $mid);
- $arr['item_flags'] = $item_flags;
$arr['author_xchan'] = $poster['xchan_hash'];
$arr['owner_xchan'] = (($parent_mid) ? $r[0]['owner_xchan'] : $poster['xchan_hash']);
$arr['title'] = '';
@@ -82,8 +78,13 @@ function mood_init(&$a) {
$arr['item_private'] = $private;
$arr['verb'] = $activity;
$arr['body'] = $action;
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = 1;
+ $arr['item_unseen'] = 1;
+ if(! $parent_mid)
+ $item['item_thread_top'] = 1;
- if ((! $arr['plink']) && ($arr['item_flags'] & ITEM_THREAD_TOP)) {
+ if ((! $arr['plink']) && intval($arr['item_thread_top'])) {
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
}
diff --git a/mod/network.php b/mod/network.php
index e8630278a..d5e305687 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -40,7 +40,7 @@ function network_content(&$a, $update = 0, $load = false) {
call_hooks('network_content_init', $arr);
$channel = $a->get_channel();
-
+ $item_normal = item_normal();
$datequery = $datequery2 = '';
@@ -176,12 +176,12 @@ function network_content(&$a, $update = 0, $load = false) {
$sql_options = (($star)
- ? " and (item_flags & " . intval(ITEM_STARRED) . ") > 0"
+ ? " and item_starred = 1 "
: '');
$sql_nets = '';
- $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE (item_flags & " . intval(ITEM_THREAD_TOP) . ")>0 $sql_options ) ";
+ $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE item_thread_top = 1 $sql_options ) ";
if($group) {
$contact_str = '';
@@ -198,7 +198,7 @@ function network_content(&$a, $update = 0, $load = false) {
info( t('Collection 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 and item_restrict = 0 ) ";
+ $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 ) ";
$x = group_rec_byhash(local_channel(), $group_hash);
@@ -216,12 +216,12 @@ function network_content(&$a, $update = 0, $load = false) {
elseif($cid) {
- $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and not ( abook_flags & " . intval(ABOOK_FLAG_BLOCKED) . ") > 0 limit 1",
+ $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1",
intval($cid),
intval(local_channel())
);
if($r) {
- $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) and item_restrict = 0 ) ";
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) $item_normal ) ";
$title = replace_macros(get_markup_template("section_title.tpl"),array(
'$title' => t('Connection: ') . $r[0]['xchan_name']
));
@@ -324,9 +324,8 @@ function network_content(&$a, $update = 0, $load = false) {
}
if($conv) {
- $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan like '%s' or ( item_flags & %d ) > 0) and item_restrict = 0 ) ",
- dbesc(protect_sprintf($channel['channel_hash'])),
- intval(ITEM_MENTIONSME)
+ $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ",
+ dbesc(protect_sprintf($channel['channel_hash']))
);
}
@@ -405,12 +404,11 @@ function network_content(&$a, $update = 0, $load = false) {
$items = q("SELECT item.*, item.id AS item_id, received FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
- WHERE true $uids AND item_restrict = 0
- and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
+ WHERE true $uids $item_normal
+ and (abook.abook_blocked = 0 or abook.abook_flags is null)
$simple_update
$sql_extra $sql_nets
- ORDER BY item.received DESC $pager_sql ",
- intval(ABOOK_FLAG_BLOCKED)
+ ORDER BY item.received DESC $pager_sql "
);
require_once('include/items.php');
@@ -434,12 +432,11 @@ function network_content(&$a, $update = 0, $load = false) {
$r = q("SELECT distinct item.id AS item_id, $ordering FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
- WHERE true $uids AND item.item_restrict = 0
+ WHERE true $uids $item_normal
AND item.parent = item.id
- and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
+ and (abook.abook_blocked = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets
- ORDER BY $ordering DESC $pager_sql ",
- intval(ABOOK_FLAG_BLOCKED)
+ ORDER BY $ordering DESC $pager_sql "
);
}
@@ -447,10 +444,9 @@ function network_content(&$a, $update = 0, $load = false) {
// this is an update
$r = q("SELECT item.parent AS item_id FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
- WHERE true $uids AND item.item_restrict = 0 $simple_update
- and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
- $sql_extra3 $sql_extra $sql_nets ",
- intval(ABOOK_FLAG_BLOCKED)
+ WHERE true $uids $item_normal $simple_update
+ and (abook.abook_blocked = 0 or abook.abook_flags is null)
+ $sql_extra3 $sql_extra $sql_nets "
);
$_SESSION['loadtime'] = datetime_convert();
}
@@ -464,7 +460,7 @@ function network_content(&$a, $update = 0, $load = false) {
$parents_str = ids_to_querystr($r,'item_id');
$items = q("SELECT item.*, item.id AS item_id FROM item
- WHERE true $uids AND item.item_restrict = 0
+ WHERE true $uids $item_normal
AND item.parent IN ( %s )
$sql_extra ",
dbesc($parents_str)
@@ -500,7 +496,7 @@ function network_content(&$a, $update = 0, $load = false) {
}
if(($update_unseen) && (! $firehose))
- $r = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d $update_unseen ",
+ $r = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 AND uid = %d $update_unseen ",
intval(local_channel())
);
diff --git a/mod/openid.php b/mod/openid.php
index 1af95a81c..70da2690a 100644
--- a/mod/openid.php
+++ b/mod/openid.php
@@ -131,8 +131,8 @@ function openid_content(&$a) {
$x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype,
xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date,
- xchan_name_date, xchan_flags)
- values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d) ",
+ xchan_name_date, xchan_hidden)
+ values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', 1) ",
dbesc($url),
dbesc(''),
dbesc(''),
@@ -147,8 +147,7 @@ function openid_content(&$a) {
dbesc($name),
dbesc($network),
dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval(XCHAN_FLAGS_HIDDEN)
+ dbesc(datetime_convert())
);
if($x) {
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
diff --git a/mod/p.php b/mod/p.php
index 924fd7eba..4e411a17b 100644
--- a/mod/p.php
+++ b/mod/p.php
@@ -11,9 +11,8 @@ function p_init(&$a) {
$mid = str_replace('.xml','',argv(1));
- $r = q("select * from item where mid = '%s' and (item_flags & %d)>0 and item_private = 0 limit 1",
- dbesc($mid),
- intval(ITEM_WALL)
+ $r = q("select * from item where mid = '%s' and item_wall = 1 and item_private = 0 limit 1",
+ dbesc($mid)
);
diff --git a/mod/page.php b/mod/page.php
index 3cb63a2bc..b635a60f2 100644
--- a/mod/page.php
+++ b/mod/page.php
@@ -62,12 +62,12 @@ function page_init(&$a) {
$sql_options = item_permissions_sql($u[0]['channel_id']);
$r = q("select item.* from item left join item_id on item.id = item_id.iid
- where item.uid = %d and sid = '%s' and (( service = 'WEBPAGE' and
- item_restrict = %d ) or ( service = 'PDL' and item_restrict = %d )) $sql_options $revision limit 1",
+ where item.uid = %d and sid = '%s' and (( service = 'WEBPAGE' and item_type = %d )
+ OR ( service = 'PDL' AND item_type = %d )) $sql_options $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
- intval(ITEM_WEBPAGE),
- intval(ITEM_PDL)
+ intval(ITEM_TYPE_WEBPAGE),
+ intval(ITEM_TYPE_PDL)
);
if(! $r) {
@@ -75,10 +75,10 @@ function page_init(&$a) {
$x = q("select item.* from item left join item_id on item.id = item_id.iid
where item.uid = %d and sid = '%s' and service = 'WEBPAGE' and
- item_restrict = %d $revision limit 1",
+ item_type = %d $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
- intval(ITEM_WEBPAGE)
+ intval(ITEM_TYPE_WEBPAGE)
);
if($x) {
@@ -91,7 +91,7 @@ function page_init(&$a) {
return;
}
- if($r[0]['item_restrict'] == ITEM_PDL) {
+ if($r[0]['item_type'] == ITEM_TYPE_PDL) {
require_once('include/comanche.php');
comanche_parser(get_app(),$r[0]['body']);
get_app()->pdl = $r[0]['body'];
@@ -122,8 +122,8 @@ function page_content(&$a) {
if(! $r)
return;
- if($r[0]['item_restrict'] == ITEM_PDL) {
- $r[0]['body'] = t('Lorem Ipsum');
+ if($r[0]['item_type'] == ITEM_TYPE_PDL) {
+ $r[0]['body'] = t('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.');
$r[0]['mimetype'] = 'text/plain';
$r[0]['title'] = '';
diff --git a/mod/photo.php b/mod/photo.php
index 66280cb76..2e16fc1d9 100644
--- a/mod/photo.php
+++ b/mod/photo.php
@@ -22,14 +22,6 @@ function photo_init(&$a) {
// NOTREACHED
}
- if($photo === 'qr') {
- $t = $_GET['qr'];
- require_once('library/phpqrcode/phpqrcode.php');
- header("Content-type: image/png");
- QRcode::png(($t) ? $t : '.');
- killme();
- }
-
$observer_xchan = get_observer_hash();
$default = get_default_profile_photo();
@@ -61,14 +53,17 @@ function photo_init(&$a) {
$uid = $person;
- $r = q("SELECT * FROM photo WHERE scale = %d AND uid = %d AND profile = 1 LIMIT 1",
+ $r = q("SELECT * FROM photo WHERE scale = %d AND uid = %d AND photo_usage = %d LIMIT 1",
intval($resolution),
- intval($uid)
+ intval($uid),
+ intval(PHOTO_PROFILE)
);
if(count($r)) {
$data = dbunescbin($r[0]['data']);
$mimetype = $r[0]['type'];
}
+ if(intval($r[0]['os_storage']))
+ $data = file_get_contents($data);
if(! isset($data)) {
$data = file_get_contents($default);
$mimetype = 'image/png';
@@ -142,6 +137,8 @@ function photo_init(&$a) {
if($r && $allowed) {
$data = dbunescbin($r[0]['data']);
$mimetype = $r[0]['type'];
+ if(intval($r[0]['os_storage']))
+ $data = file_get_contents($data);
}
else {
diff --git a/mod/photos.php b/mod/photos.php
index 2af90610e..c65c87c27 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -6,6 +6,7 @@ require_once('include/acl_selectors.php');
require_once('include/bbcode.php');
require_once('include/security.php');
require_once('include/Contact.php');
+require_once('include/attach.php');
require_once('include/text.php');
@@ -136,14 +137,14 @@ function photos_post(&$a) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
- $r = q("select id, item_restrict from item where resource_id in ( $str ) and resource_type = 'photo' and uid = %d",
+ $r = q("select id from item where resource_id in ( $str ) and resource_type = 'photo' and uid = %d " . item_normal(),
intval($page_owner_uid)
);
if($r) {
foreach($r as $i) {
+ attach_delete($page_owner_uid, $i['resource_id'], 1 );
drop_item($i['id'],false,DROPITEM_PHASE1,true /* force removal of linked items */);
- if(! $item_restrict)
- proc_run('php','include/notifier.php','drop',$i['id']);
+ proc_run('php','include/notifier.php','drop',$i['id']);
}
}
@@ -152,6 +153,9 @@ function photos_post(&$a) {
q("delete from photo where resource_id in ( $str ) and uid = %d",
intval($page_owner_uid)
);
+
+ // @FIXME do the same for the linked attach
+
}
goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address']);
@@ -176,24 +180,15 @@ function photos_post(&$a) {
intval($page_owner_uid),
dbesc($r[0]['resource_id'])
);
+ attach_delete($page_owner_uid, $r[0]['resource_id'], 1 );
+
$i = q("SELECT * FROM `item` WHERE `resource_id` = '%s' AND resource_type = 'photo' and `uid` = %d LIMIT 1",
dbesc($r[0]['resource_id']),
intval($page_owner_uid)
);
if(count($i)) {
- q("UPDATE `item` SET item_restrict = (item_restrict | %d), `edited` = '%s', `changed` = '%s' WHERE `parent_mid` = '%s' AND `uid` = %d",
- intval(ITEM_DELETED),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- dbesc($i[0]['mid']),
- intval($page_owner_uid)
- );
-
+ drop_item($i[0]['id'],true,DROPITEM_PHASE1);
$url = $a->get_baseurl();
- $drop_id = intval($i[0]['id']);
-
- if($i[0]['visible'])
- proc_run('php',"include/notifier.php","drop","$drop_id");
}
}
@@ -207,7 +202,7 @@ function photos_post(&$a) {
$rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : '');
$item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0);
$albname = ((x($_POST,'albname')) ? notags(trim($_POST['albname'])) : '');
- $adult = ((x($_POST,'adult')) ? intval($_POST['adult']) : 0);
+ $is_nsfw = ((x($_POST,'adult')) ? intval($_POST['adult']) : 0);
$str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']);
$str_group_deny = perms2str($_POST['group_deny']);
@@ -282,9 +277,8 @@ function photos_post(&$a) {
if($p) {
$ext = $phototypes[$p[0]['type']];
- $r = q("UPDATE `photo` SET `description` = '%s', `album` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `resource_id` = '%s' AND `uid` = %d",
+ $r = q("UPDATE `photo` SET `description` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `resource_id` = '%s' AND `uid` = %d",
dbesc($desc),
- dbesc($albname),
dbesc($str_contact_allow),
dbesc($str_group_allow),
dbesc($str_contact_deny),
@@ -296,10 +290,10 @@ function photos_post(&$a) {
$item_private = (($str_contact_allow || $str_group_allow || $str_contact_deny || $str_group_deny) ? true : false);
- $old_adult = (($p[0]['photo_flags'] & PHOTO_ADULT) ? 1 : 0);
- if($old_adult != $adult) {
- $r = q("update photo set photo_flags = ( photo_flags ^ %d) where resource_id = '%s' and uid = %d",
- intval(PHOTO_ADULT),
+ $old_is_nsfw = $p[0]['is_nsfw'];
+ if($old_is_nsfw != $is_nsfw) {
+ $r = q("update photo set is_nsfw = %d where resource_id = '%s' and uid = %d",
+ intval($is_nsfw),
dbesc($resource_id),
intval($page_owner_uid)
);
@@ -340,6 +334,17 @@ function photos_post(&$a) {
intval($item_id)
);
+ // make sure the attach has the same permissions as the photo regardless of any other changes
+ $x = q("update attach set allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where hash = '%s' and uid = %d and is_photo = 1",
+ dbesc($str_contact_allow),
+ dbesc($str_group_allow),
+ dbesc($str_contact_deny),
+ dbesc($str_group_deny),
+ dbesc($resource_id),
+ intval($page_owner_uid)
+ );
+
+
if(strlen($rawtags)) {
@@ -406,6 +411,7 @@ function photos_post(&$a) {
$observer = $a->data['observer'];
$_REQUEST['source'] = 'photos';
+ require_once('include/attach.php');
if(!local_channel()) {
$_REQUEST['contact_allow'] = expand_acl($channel['channel_allow_cid']);
@@ -414,7 +420,7 @@ function photos_post(&$a) {
$_REQUEST['group_deny'] = expand_acl($channel['channel_deny_gid']);
}
- $r = photo_upload($channel, $observer, $_REQUEST);
+ $r = attach_store($a->channel,get_observer_hash(), '', $_REQUEST);
if(! $r['success']) {
notice($r['message'] . EOL);
@@ -557,14 +563,20 @@ function photos_content(&$a) {
$albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer']));
+ $def_album = get_pconfig($a->data['channel']['channel_id'],'system','photo_path');
+ if($def_album) {
+ $selname = filepath_macro($def_album);
+ $albums['album'][] = array('text' => $selname);
+ }
+
$tpl = get_markup_template('photos_upload.tpl');
$upload_form = replace_macros($tpl,array(
'$pagename' => t('Upload Photos'),
'$sessid' => session_id(),
'$usage' => $usage_message,
'$nickname' => $a->data['channel']['channel_address'],
- '$newalbum_label' => t('Enter a new album name'),
- '$newalbum_placeholder' => t('or select an existing one (doubleclick)'),
+ '$newalbum_label' => t('Enter an album name'),
+ '$newalbum_placeholder' => t('or select an existing album (doubleclick)'),
'$visible' => array('visible', t('Create a status post for this upload'), 0, '', array(t('No'), t('Yes'))),
'$albums' => $albums['albums'],
'$selname' => $selname,
@@ -601,11 +613,12 @@ function photos_content(&$a) {
$album = hex2bin($datum);
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
- AND `scale` <= 4 and ((photo_flags = %d) or (photo_flags & %d ) > 0) $sql_extra GROUP BY `resource_id`",
+ AND `scale` <= 4 and photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY `resource_id`",
intval($owner_uid),
dbesc($album),
intval(PHOTO_NORMAL),
- intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE)
+ intval(PHOTO_PROFILE),
+ intval($unsafe)
);
if(count($r)) {
$a->set_pager_total(count($r));
@@ -621,13 +634,14 @@ function photos_content(&$a) {
$r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.scale, p.description, p.created FROM photo p INNER JOIN
- (SELECT resource_id, max(scale) scale FROM photo WHERE uid = %d AND album = '%s' AND scale <= 4 AND (photo_flags = %d or photo_flags = %d ) $sql_extra GROUP BY resource_id) ph
+ (SELECT resource_id, max(scale) 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) ph
ON (p.resource_id = ph.resource_id AND p.scale = ph.scale)
ORDER BY created $order LIMIT %d OFFSET %d",
intval($owner_uid),
dbesc($album),
- intvaL(PHOTO_NORMAL),
- intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE),
+ intval(PHOTO_NORMAL),
+ intval(PHOTO_PROFILE),
+ intval($unsafe),
intval($a->pager['itemspage']),
intval($a->pager['start'])
);
@@ -743,7 +757,7 @@ function photos_content(&$a) {
// fetch image, item containing image, then comments
- $ph = q("SELECT aid,uid,xchan,resource_id,created,edited,title,`description`,album,filename,`type`,height,width,`size`,scale,profile,photo_flags,allow_cid,allow_gid,deny_cid,deny_gid FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s'
+ $ph = q("SELECT 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'
$sql_extra ORDER BY `scale` ASC ",
intval($owner_uid),
dbesc($datum)
@@ -863,9 +877,10 @@ function photos_content(&$a) {
$linked_items = fetch_post_tags($linked_items,true);
$link_item = $linked_items[0];
+ $item_normal = item_normal();
$r = q("select * from item where parent_mid = '%s'
- and item_restrict = 0 and uid = %d $sql_extra ",
+ $item_normal and uid = %d $sql_extra ",
dbesc($link_item['mid']),
intval($link_item['uid'])
@@ -891,7 +906,7 @@ function photos_content(&$a) {
}
if((local_channel()) && (local_channel() == $link_item['uid'])) {
- q("UPDATE `item` SET item_unseen = 0 WHERE item_unseen = 1 AND parent = %d AND uid = %d ",
+ q("UPDATE `item` SET item_unseen = 0 WHERE parent = %d and uid = %d and item_unseen = 1",
intval($link_item['parent']),
intval(local_channel())
);
@@ -937,7 +952,7 @@ function photos_content(&$a) {
'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com'),
'item_id' => ((count($linked_items)) ? $link_item['id'] : 0),
'adult_enabled' => feature_enabled($owner_uid,'adult_photo_flagging'),
- 'adult' => array('adult',t('Flag as adult in album view'), (($ph[0]['photo_flags'] & PHOTO_ADULT) ? 1 : 0),''),
+ 'adult' => array('adult',t('Flag as adult in album view'), intval($ph[0]['is_nsfw']),''),
'submit' => t('Submit'),
'delete' => t('Delete Photo')
);
@@ -1163,12 +1178,13 @@ function photos_content(&$a) {
//$o = '';
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
- and ((photo_flags = %d) or (photo_flags & %d) > 0) $sql_extra GROUP BY `resource_id`",
+ and photo_usage in ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY `resource_id`",
intval($a->data['channel']['channel_id']),
dbesc('Contact Photos'),
dbesc( t('Contact Photos')),
intval(PHOTO_NORMAL),
- intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE)
+ intval(PHOTO_PROFILE),
+ intval($unsafe)
);
if(count($r)) {
$a->set_pager_total(count($r));
@@ -1178,13 +1194,14 @@ function photos_content(&$a) {
$r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.album, p.scale, p.created FROM photo p INNER JOIN
(SELECT resource_id, max(scale) scale FROM photo
WHERE uid=%d AND album != '%s' AND album != '%s'
- AND (photo_flags = %d or ( photo_flags & %d ) > 0 ) $sql_extra group by resource_id) ph
+ AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra group by resource_id) ph
ON (p.resource_id = ph.resource_id and p.scale = ph.scale) ORDER by p.created DESC LIMIT %d OFFSET %d",
intval($a->data['channel']['channel_id']),
dbesc('Contact Photos'),
dbesc( t('Contact Photos')),
intval(PHOTO_NORMAL),
- intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE),
+ intval(PHOTO_PROFILE),
+ intval($unsafe),
intval($a->pager['itemspage']),
intval($a->pager['start'])
);
diff --git a/mod/ping.php b/mod/ping.php
index b676726fe..719183388 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -43,6 +43,8 @@ function ping_init(&$a) {
$vnotify = false;
+ $item_normal = item_normal();
+
if(local_channel()) {
$vnotify = get_pconfig(local_channel(),'system','vnotify');
$evdays = intval(get_pconfig(local_channel(),'system','evdays'));
@@ -156,16 +158,13 @@ function ping_init(&$a) {
);
break;
case 'home':
- $r = q("update item set item_unseen = 0 where item_unseen = 1 and (item_flags & %d) > 0 and uid = %d",
- intval(ITEM_WALL),
+ $r = q("update item set item_unseen = 0 where item_unseen = 1 and item_wall = 1 and uid = %d",
intval(local_channel())
);
break;
case 'messages':
- $r = q("update mail set mail_flags = ( mail_flags | %d ) where channel_id = %d and not (mail_flags & %d) > 0",
- intval(MAIL_SEEN),
- intval(local_channel()),
- intval(MAIL_SEEN)
+ $r = q("update mail set mail_seen = 1 where mail_seen = 0 and channel_id = %d ",
+ intval(local_channel())
);
break;
case 'all_events':
@@ -243,11 +242,9 @@ function ping_init(&$a) {
if(argc() > 1 && argv(1) === 'messages') {
$channel = $a->get_channel();
$t = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan
- where channel_id = %d and not ( mail_flags & %d ) > 0 and not (mail_flags & %d ) > 0
+ where channel_id = %d and mail_seen = 0 and mail_deleted = 0
and from_xchan != '%s' order by created desc limit 50",
intval(local_channel()),
- intval(MAIL_SEEN),
- intval(MAIL_DELETED),
dbesc($channel['channel_hash'])
);
@@ -259,7 +256,7 @@ function ping_init(&$a) {
'url' => $zz['xchan_url'],
'photo' => $zz['xchan_photo_s'],
'when' => relative_date($zz['created']),
- 'hclass' => (($zz['mail_flags'] & MAIL_SEEN) ? 'notify-seen' : 'notify-unseen'),
+ 'hclass' => (intval($zz['mail_seen']) ? 'notify-seen' : 'notify-unseen'),
'message' => t('sent you a private message'),
);
}
@@ -273,7 +270,7 @@ function ping_init(&$a) {
$result = array();
$r = q("SELECT * FROM item
- WHERE item_restrict = 0 and item_unseen = 1 and uid = %d
+ WHERE item_unseen = 1 and uid = %d $item_normal
and author_xchan != '%s' ORDER BY created DESC limit 300",
intval(local_channel()),
dbesc($ob_hash)
@@ -282,7 +279,7 @@ function ping_init(&$a) {
if($r) {
xchan_query($r);
foreach($r as $item) {
- if((argv(1) === 'home') && (! ($item['item_flags'] & ITEM_WALL)))
+ if((argv(1) === 'home') && (! intval($item['item_wall'])))
continue;
$result[] = format_notification($item);
}
@@ -295,11 +292,8 @@ function ping_init(&$a) {
if(argc() > 1 && (argv(1) === 'intros')) {
$result = array();
- $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0) ORDER BY abook_created DESC LIMIT 50",
- intval(local_channel()),
- intval(ABOOK_FLAG_PENDING),
- intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
- intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
+ $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ORDER BY abook_created DESC LIMIT 50",
+ intval(local_channel())
);
if($r) {
@@ -378,8 +372,9 @@ function ping_init(&$a) {
$t1 = dba_timer();
if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) {
- $r = q("SELECT id, item_restrict, item_flags FROM item
- WHERE item_restrict = 0 and item_unseen = 1 and uid = %d
+ $r = q("SELECT id, item_wall FROM item
+ WHERE item_unseen = 1 and uid = %d
+ $item_normal
and author_xchan != '%s'",
intval(local_channel()),
dbesc($ob_hash)
@@ -390,7 +385,7 @@ function ping_init(&$a) {
call_hooks('network_ping', $arr);
foreach ($r as $it) {
- if($it['item_flags'] & ITEM_WALL)
+ if(intval($it['item_wall']))
$result['home'] ++;
else
$result['network'] ++;
@@ -406,11 +401,8 @@ function ping_init(&$a) {
$t2 = dba_timer();
if($vnotify & VNOTIFY_INTRO) {
- $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0)",
- intval(local_channel()),
- intval(ABOOK_FLAG_PENDING),
- intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
- intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
+ $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ",
+ intval(local_channel())
);
$t3 = dba_timer();
@@ -424,9 +416,8 @@ function ping_init(&$a) {
if($vnotify & VNOTIFY_MAIL) {
$mails = q("SELECT count(id) as total from mail
- WHERE channel_id = %d AND not (mail_flags & %d) > 0 and from_xchan != '%s' ",
+ WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ",
intval(local_channel()),
- intval(MAIL_SEEN),
dbesc($channel['channel_hash'])
);
if($mails)
diff --git a/mod/poke.php b/mod/poke.php
index 6257a2821..f66d28956 100755
--- a/mod/poke.php
+++ b/mod/poke.php
@@ -87,10 +87,8 @@ function poke_init(&$a) {
$arr = array();
- $arr['item_flags'] = ITEM_WALL | ITEM_ORIGIN;
- if($parent_item)
- $arr['item_flags'] |= ITEM_THREAD_TOP;
+ $arr['item_wall'] = 1;
$arr['owner_xchan'] = (($parent_item) ? $parent_item['owner_xchan'] : $channel['channel_hash']);
$arr['parent_mid'] = (($parent_mid) ? $parent_mid : $mid);
$arr['title'] = '';
@@ -115,6 +113,13 @@ function poke_init(&$a) {
$arr['object'] = json_encode($obj);
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = 1;
+ $arr['item_unseen'] = 1;
+ if(! $parent_item)
+ $item['item_thread_top'] = 1;
+
+
post_activity_item($arr);
return;
diff --git a/mod/post.php b/mod/post.php
index 908b9eb1d..dfda7db9d 100644
--- a/mod/post.php
+++ b/mod/post.php
@@ -103,9 +103,7 @@ function post_init(&$a) {
// Any channel will do, providing it's currently active. We just need to have an
// identity to attach to the packet we send back. So find one.
- $c = q("select * from channel where not ( channel_pageflags & %d )>0 limit 1",
- intval(PAGE_REMOVED)
- );
+ $c = q("select * from channel where channel_removed = 0 limit 1");
if (! $c) {
// nobody here
@@ -285,20 +283,13 @@ function post_init(&$a) {
$a->set_groups(init_groups_visitor($_SESSION['visitor_id']));
info(sprintf( t('Welcome %s. Remote authentication successful.'),$x[0]['xchan_name']));
logger('mod_zot: auth success from ' . $x[0]['xchan_addr']);
- q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ",
- intval(HUBLOC_WORKS),
- intval($x[0]['hubloc_id'])
- );
- } else {
- if ($test) {
+ }
+ else {
+ if($test) {
$ret['message'] .= 'auth failure. ' . print_r($_REQUEST,true) . print_r($j,true) . EOL;
json_return_and_die($ret);
}
logger('mod_zot: magic-auth failure - not authenticated: ' . $x[0]['xchan_addr']);
- q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ",
- intval(HUBLOC_RECEIVE_ERROR),
- intval($x[0]['hubloc_id'])
- );
}
/**
@@ -693,20 +684,16 @@ function post_post(&$a) {
// a dead hub came back to life - reset any tombstones we might have
- if ($hub['hubloc_status'] & HUBLOC_OFFLINE) {
- q("update hubloc set hubloc_status = (hubloc_status & ~%d) where hubloc_id = %d",
- intval(HUBLOC_OFFLINE),
+ if(intval($hub['hubloc_error'])) {
+ q("update hubloc set hubloc_error = 0 where hubloc_id = %d",
intval($hub['hubloc_id'])
);
- if ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) {
- q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d",
- intval(HUBLOC_FLAGS_ORPHANCHECK),
+ if(intval($r[0]['hubloc_orphancheck'])) {
+ q("update hubloc set hubloc_orhpancheck = 0 where hubloc_id = %d",
intval($hub['hubloc_id'])
);
}
- q("update xchan set xchan_flags = (xchan_flags & ~%d) where (xchan_flags & %d)>0 and xchan_hash = '%s'",
- intval(XCHAN_FLAGS_ORPHAN),
- intval(XCHAN_FLAGS_ORPHAN),
+ q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'",
dbesc($hub['hubloc_hash'])
);
}
@@ -718,8 +705,7 @@ function post_post(&$a) {
* Get rid of them (mark them deleted). There's a good chance they were re-installs.
*/
- q("update hubloc set hubloc_flags = ( hubloc_flags | %d ) where hubloc_url = '%s' and hubloc_sitekey != '%s' ",
- intval(HUBLOC_FLAGS_DELETED),
+ q("update hubloc set hubloc_deleted = 1 where hubloc_url = '%s' and hubloc_sitekey != '%s' ",
dbesc($hub['hubloc_url']),
dbesc($hub['hubloc_sitekey'])
);
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index c70e8fc94..13923a655 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -143,7 +143,7 @@ function profile_photo_post(&$a) {
'filename' => $base_image['filename'], 'album' => t('Profile Photos'));
$p['scale'] = 4;
- $p['photo_flags'] = (($is_default_profile) ? PHOTO_PROFILE : PHOTO_NORMAL);
+ $p['photo_usage'] = (($is_default_profile) ? PHOTO_PROFILE : PHOTO_NORMAL);
$r1 = $im->save($p);
@@ -170,13 +170,9 @@ function profile_photo_post(&$a) {
// If setting for the default profile, unset the profile photo flag from any other photos I own
if($is_default_profile) {
- $r = q("UPDATE photo SET profile = 0 WHERE profile = 1 AND resource_id != '%s' AND `uid` = %d",
- dbesc($base_image['resource_id']),
- intval(local_channel())
- );
- $r = q("UPDATE photo SET photo_flags = ( photo_flags & ~%d ) WHERE ( photo_flags & %d )>0
+ $r = q("UPDATE photo SET photo_usage = %d WHERE photo_usage = %d
AND resource_id != '%s' AND `uid` = %d",
- intval(PHOTO_PROFILE),
+ intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE),
dbesc($base_image['resource_id']),
intval(local_channel())
@@ -221,31 +217,45 @@ function profile_photo_post(&$a) {
return; // NOTREACHED
}
- $src = $_FILES['userfile']['tmp_name'];
- $filename = basename($_FILES['userfile']['name']);
- $filesize = intval($_FILES['userfile']['size']);
- $filetype = $_FILES['userfile']['type'];
- if ($filetype=="") $filetype=guess_image_type($filename);
-
- $maximagesize = get_config('system','maximagesize');
-
- if(($maximagesize) && ($filesize > $maximagesize)) {
- notice( sprintf(t('Image exceeds size limit of %d'), $maximagesize) . EOL);
- @unlink($src);
- return;
+
+
+ $hash = photo_new_resource();
+ $smallest = 0;
+
+ require_once('include/attach.php');
+
+ $res = attach_store($a->get_channel(), get_observer_hash(), '', array('album' => t('Profile 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 order by scale",
+ dbesc($hash),
+ intval(local_channel())
+ );
+
+ if(! $i) {
+ notice( t('Image upload failed.') . EOL );
+ return;
+ }
+ foreach($i as $ii) {
+ if(intval($ii['scale']) < 2) {
+ $smallest = intval($ii['scale']);
+ $imagedata = $ii['data'];
+ $filetype = $ii['type'];
+ }
+ }
}
- $imagedata = @file_get_contents($src);
+// $imagedata = @file_get_contents($src);
$ph = photo_factory($imagedata, $filetype);
if(! $ph->is_valid()) {
notice( t('Unable to process image.') . EOL );
- @unlink($src);
return;
}
- $ph->orient($src);
- @unlink($src);
- return profile_photo_crop_ui_head($a, $ph);
+
+ return profile_photo_crop_ui_head($a, $ph, $hash, $smallest);
}
@@ -257,7 +267,6 @@ function profile_photo_post(&$a) {
*/
-if(! function_exists('profile_photo_content')) {
function profile_photo_content(&$a) {
if(! local_channel()) {
@@ -301,20 +310,12 @@ function profile_photo_content(&$a) {
if(($r[0]['album'] == t('Profile Photos')) && ($havescale)) {
// unset any existing profile photos
- $r = q("UPDATE photo SET profile = 0 WHERE profile = 1 AND uid = %d",
- intval(local_channel()));
- $r = q("UPDATE photo SET photo_flags = (photo_flags & ~%d ) WHERE (photo_flags & %d )>0 AND uid = %d",
- intval(PHOTO_PROFILE),
+ $r = q("UPDATE photo SET photo_usage = %d WHERE photo_usage = %d AND uid = %d",
+ intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE),
intval(local_channel()));
- // set all sizes of this one as profile photos
- $r = q("UPDATE photo SET profile = 1 WHERE uid = %d AND resource_id = '%s'",
- intval(local_channel()),
- dbesc($resource_id)
- );
-
- $r = q("UPDATE photo SET photo_flags = ( photo_flags | %d ) WHERE uid = %d AND resource_id = '%s'",
+ $r = q("UPDATE photo SET photo_usage = %d WHERE uid = %d AND resource_id = '%s'",
intval(PHOTO_PROFILE),
intval(local_channel()),
dbesc($resource_id)
@@ -371,7 +372,7 @@ function profile_photo_content(&$a) {
return $o;
}
else {
- $filename = $a->data['imagecrop'] . '-' . $a->data['imagecrop_resolution'] . '.' . $a->data['imagecrop_ext'];
+ $filename = $a->data['imagecrop'] . '-' . $a->data['imagecrop_resolution'];
$resolution = $a->data['imagecrop_resolution'];
$tpl = get_markup_template("cropbody.tpl");
$o .= replace_macros($tpl,array(
@@ -388,7 +389,7 @@ function profile_photo_content(&$a) {
}
return; // NOTREACHED
-}}
+}
/* @brief Generate the UI for photo-cropping
*
@@ -399,8 +400,8 @@ function profile_photo_content(&$a) {
*/
-if(! function_exists('profile_photo_crop_ui_head')) {
-function profile_photo_crop_ui_head(&$a, $ph){
+
+function profile_photo_crop_ui_head(&$a, $ph, $hash, $smallest){
$max_length = get_config('system','max_image_length');
if(! $max_length)
@@ -417,34 +418,10 @@ function profile_photo_crop_ui_head(&$a, $ph){
$height = $ph->getHeight();
}
- $hash = photo_new_resource();
- $smallest = 0;
-
- $p = array('aid' => get_account_id(), 'uid' => local_channel(), 'resource_id' => $hash,
- 'filename' => $filename, 'album' => t('Profile Photos'), 'scale' => 0);
- $r = $ph->save($p);
-
- if($r)
- info( t('Image uploaded successfully.') . EOL );
- else
- notice( t('Image upload failed.') . EOL );
-
- if($width > 640 || $height > 640) {
- $ph->scaleImage(640);
- $p['scale'] = 1;
-
- $r = $ph->save($p);
-
- if($r === false)
- notice( sprintf(t('Image size reduction [%s] failed.'),"640") . EOL );
- else
- $smallest = 1;
- }
$a->data['imagecrop'] = $hash;
$a->data['imagecrop_resolution'] = $smallest;
- $a->data['imagecrop_ext'] = $ph->getExt();
$a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), array());
return;
-}}
+}
diff --git a/mod/public.php b/mod/public.php
index 64ae9d20a..2106be7a6 100644
--- a/mod/public.php
+++ b/mod/public.php
@@ -16,6 +16,8 @@ function public_content(&$a, $update = 0, $load = false) {
if(get_config('system','disable_discover_tab'))
return;
+ $item_normal = item_normal();
+
if(! $update) {
$maxheight = get_config('system','home_divmore_height');
@@ -69,7 +71,7 @@ function public_content(&$a, $update = 0, $load = false) {
require_once('include/security.php');
if(get_config('system','site_firehose')) {
- $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and (item_flags & " . intval(ITEM_WALL) . " ) > 0 ";
+ $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 ";
}
else {
$sys = get_sys_channel();
@@ -101,12 +103,11 @@ function public_content(&$a, $update = 0, $load = false) {
$r = q("SELECT distinct item.id AS item_id, $ordering FROM item
left join abook on item.author_xchan = abook.abook_xchan
- WHERE true $uids AND item.item_restrict = 0
+ WHERE true $uids $item_normal
AND item.parent = item.id
- and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
+ and (abook.abook_blocked = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets
- ORDER BY $ordering DESC $pager_sql ",
- intval(ABOOK_FLAG_BLOCKED)
+ ORDER BY $ordering DESC $pager_sql "
);
@@ -115,11 +116,10 @@ function public_content(&$a, $update = 0, $load = false) {
$r = q("SELECT distinct item.id AS item_id, $ordering FROM item
left join abook on item.author_xchan = abook.abook_xchan
- WHERE true $uids AND item.item_restrict = 0
+ WHERE true $uids $item_normal
AND item.parent = item.id $simple_update
- and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
- $sql_extra3 $sql_extra $sql_nets",
- intval(ABOOK_FLAG_BLOCKED)
+ and (abook.abook_blocked = 0 or abook.abook_flags is null)
+ $sql_extra3 $sql_extra $sql_nets"
);
$_SESSION['loadtime'] = datetime_convert();
}
@@ -132,7 +132,7 @@ function public_content(&$a, $update = 0, $load = false) {
$parents_str = ids_to_querystr($r,'item_id');
$items = q("SELECT item.*, item.id AS item_id FROM item
- WHERE true $uids AND item.item_restrict = 0
+ WHERE true $uids $item_normal
AND item.parent IN ( %s )
$sql_extra ",
dbesc($parents_str)
diff --git a/mod/receive.php b/mod/receive.php
index deaf8cb37..571f736ed 100644
--- a/mod/receive.php
+++ b/mod/receive.php
@@ -31,9 +31,8 @@ function receive_post(&$a) {
// Diaspora sites *may* provide a truncated guid.
- $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_guid like '%s' AND (channel_pageflags & %d ) = 0 LIMIT 1",
- dbesc($guid . '%'),
- intval(PAGE_REMOVED)
+ $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_guid like '%s' AND channel_removed = 0 LIMIT 1",
+ dbesc($guid . '%')
);
if(! $r)
http_status_exit(500);
diff --git a/mod/search.php b/mod/search.php
index 426642141..ce8357fb9 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -59,6 +59,10 @@ function search_content(&$a,$update = 0, $load = false) {
$search = substr($search,1);
goaway(z_root() . '/directory' . '?f=1&navsearch=1&search=' . $search);
}
+ if(strpos($search,'?') === 0) {
+ $search = substr($search,1);
+ goaway(z_root() . '/help' . '?f=1&navsearch=1&search=' . $search);
+ }
// look for a naked webbie
if(strpos($search,'@') !== false) {
@@ -125,6 +129,7 @@ function search_content(&$a,$update = 0, $load = false) {
}
+ $item_normal = item_normal();
$pub_sql = public_permissions_sql($observer_hash);
require_once('include/identity.php');
@@ -143,7 +148,7 @@ function search_content(&$a,$update = 0, $load = false) {
if($load) {
$r = null;
-
+
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$prefix = 'distinct on (created, mid)';
$suffix = 'ORDER BY created DESC, mid';
@@ -153,26 +158,24 @@ function search_content(&$a,$update = 0, $load = false) {
}
if(local_channel()) {
$r = q("SELECT $prefix mid, item.id as item_id, item.* from item
- WHERE item_restrict = 0 AND ( item_flags & %d ) = 0
- AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 )
+ WHERE ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 )
OR ( `item`.`uid` = %d )) OR item.owner_xchan = '%s' )
+ $item_normal
$sql_extra
$suffix $pager_sql ",
- intval(ITEM_OBSCURED),
intval(local_channel()),
dbesc($sys['xchan_hash'])
);
}
if($r === null) {
$r = q("SELECT $prefix mid, item.id as item_id, item.* from item
- WHERE item_restrict = 0 AND ( item_flags & %d ) = 0
- AND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
+ WHERE (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
AND `item`.`deny_gid` = '' AND item_private = 0 )
and owner_xchan in ( " . stream_perms_xchans(($observer) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " ))
$pub_sql ) OR owner_xchan = '%s')
+ $item_normal
$sql_extra
$suffix $pager_sql",
- intval(ITEM_OBSCURED),
dbesc($sys['xchan_hash'])
);
}
diff --git a/mod/settings.php b/mod/settings.php
index b0ba04dfc..f26182dc6 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -373,10 +373,9 @@ function settings_post(&$a) {
);
}
- $r = q("update abook set abook_my_perms = %d where abook_channel = %d and (abook_flags & %d)>0",
+ $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(local_channel()),
- intval(ABOOK_FLAG_SELF)
+ intval(local_channel())
);
set_pconfig(local_channel(),'system','autoperms',(($role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0));
@@ -401,6 +400,8 @@ function settings_post(&$a) {
$maxreq = ((x($_POST,'maxreq')) ? intval($_POST['maxreq']) : 0);
$expire = ((x($_POST,'expire')) ? intval($_POST['expire']) : 0);
$evdays = ((x($_POST,'evdays')) ? intval($_POST['evdays']) : 3);
+ $photo_path = ((x($_POST,'photo_path')) ? escape_tags(trim($_POST['photo_path'])) : '');
+ $attach_path = ((x($_POST,'attach_path')) ? escape_tags(trim($_POST['attach_path'])) : '');
$channel_menu = ((x($_POST['channel_menu'])) ? htmlspecialchars_decode(trim($_POST['channel_menu']),ENT_QUOTES) : '');
@@ -507,6 +508,8 @@ function settings_post(&$a) {
set_pconfig(local_channel(),'system','vnotify',$vnotify);
set_pconfig(local_channel(),'system','always_show_in_notices',$always_show_in_notices);
set_pconfig(local_channel(),'system','evdays',$evdays);
+ set_pconfig(local_channel(),'system','photo_path',$photo_path);
+ set_pconfig(local_channel(),'system','attach_path',$attach_path);
$r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d",
dbesc($username),
@@ -669,8 +672,6 @@ function settings_content(&$a) {
if($diaspora_enabled) {
$dspr_allowed = get_pconfig(local_channel(),'system','diaspora_allowed');
- if($dspr_allowed === false)
- $dspr_allowed = 1;
$pubcomments = get_pconfig(local_channel(),'system','diaspora_public_comments');
if($pubcomments === false)
$pubcomments = 1;
@@ -1014,7 +1015,6 @@ function settings_content(&$a) {
'deny_gid' => $channel['channel_deny_gid']
);
-
require_once('include/group.php');
$group_select = mini_group_select(local_channel(),$channel['channel_default_group']);
@@ -1132,7 +1132,9 @@ function settings_content(&$a) {
'$expert' => feature_enabled(local_channel(),'expert'),
'$hint' => t('Please enable expert mode (in <a href="settings/features">Settings > Additional features</a>) to adjust!'),
'$lbl_misc' => t('Miscellaneous Settings'),
- '$menus' => $menu,
+ '$photo_path' => array('photo_path', t('Default photo upload folder'), get_pconfig(local_channel(),'system','photo_path'), '%Y - current year, %m - current month'),
+ '$attach_path' => array('attach_path', t('Default file upload folder'), get_pconfig(local_channel(),'system','attach_path'), '%Y - current year, %m - current month'),
+ '$menus' => $menu,
'$menu_desc' => t('Personal menu to display in your channel pages'),
'$removeme' => t('Remove Channel'),
'$removechannel' => t('Remove this channel.'),
diff --git a/mod/siteinfo.php b/mod/siteinfo.php
index c5a1cf12b..61c20d66f 100644
--- a/mod/siteinfo.php
+++ b/mod/siteinfo.php
@@ -163,7 +163,7 @@ function siteinfo_content(&$a) {
'$web_location' => t('Running at web location') . ' ' . z_root(),
'$visit' => t('Please visit <a href="https://redmatrix.me">redmatrix.me</a> to learn more about $Projectname.'),
'$bug_text' => t('Bug reports and issues: please visit'),
- '$bug_link_url' => 'https://github.com/redmatrix/redmatrix/issues',
+ '$bug_link_url' => 'https://github.com/redmatrix/hubzilla/issues',
'$bug_link_text' => t('$projectname issues'),
'$contact' => t('Suggestions, praise, etc. - please email "redmatrix" at librelist - dot com'),
'$donate' => $donate,
diff --git a/mod/starred.php b/mod/starred.php
index b6736fd85..103e5f4b4 100644
--- a/mod/starred.php
+++ b/mod/starred.php
@@ -19,15 +19,15 @@ function starred_init(&$a) {
if(! count($r))
killme();
- $item_flags = ( $r[0]['item_flags'] ^ ITEM_STARRED );
+ $item_starred = (intval($r[0]['item_starred']) ? 0 : 1);
- $r = q("UPDATE item SET item_flags = %d WHERE uid = %d and id = %d",
- intval($item_flags),
+ $r = q("UPDATE item SET item_starred = %d WHERE uid = %d and id = %d",
+ intval($item_starred),
intval(local_channel()),
intval($message_id)
);
header('Content-type: application/json');
- echo json_encode(array('result' => (($item_flags & ITEM_STARRED) ? 1 : 0)));
+ echo json_encode(array('result' => $item_starred));
killme();
}
diff --git a/mod/subthread.php b/mod/subthread.php
index eeb8f131d..9cfe5c24d 100755
--- a/mod/subthread.php
+++ b/mod/subthread.php
@@ -96,30 +96,28 @@ function subthread_content(&$a) {
),
));
- if(! ($item['item_flags'] & ITEM_THREAD_TOP))
+ if(! intval($item['item_thread_top']))
$post_type = 'comment';
-
$bodyverb = t('%1$s is following %2$s\'s %3$s');
- $item_flags = ITEM_ORIGIN | ITEM_NOTSHOWN;
- if($item['item_flags'] & ITEM_WALL)
- $item_flags |= ITEM_WALL;
-
-
$arr = array();
- $arr['mid'] = $mid;
- $arr['aid'] = $owner_aid;
- $arr['uid'] = $owner_uid;
- $arr['item_flags'] = $item_flags;
- $arr['parent'] = $item['id'];
- $arr['parent_mid'] = $item['mid'];
- $arr['thr_parent'] = $item['mid'];
- $arr['owner_xchan'] = $thread_owner['xchan_hash'];
- $arr['author_xchan'] = $observer['xchan_hash'];
+ $arr['mid'] = $mid;
+ $arr['aid'] = $owner_aid;
+ $arr['uid'] = $owner_uid;
+ $arr['parent'] = $item['id'];
+ $arr['parent_mid'] = $item['mid'];
+ $arr['thr_parent'] = $item['mid'];
+ $arr['owner_xchan'] = $thread_owner['xchan_hash'];
+ $arr['author_xchan'] = $observer['xchan_hash'];
+ $arr['item_origin'] = 1;
+ $arr['item_notshown'] = 1;
+ if(intval($item['item_wall']))
+ $arr['item_wall'] = 1;
+ else
+ $arr['item_wall'] = 0;
-
$ulink = '[zrl=' . $item_author['xchan_url'] . ']' . $item_author['xchan_name'] . '[/zrl]';
$alink = '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]';
$plink = '[zrl=' . $a->get_baseurl() . '/display/' . $item['mid'] . ']' . $post_type . '[/zrl]';
diff --git a/mod/tagger.php b/mod/tagger.php
index f411bd6d5..9f9855ed8 100644
--- a/mod/tagger.php
+++ b/mod/tagger.php
@@ -107,11 +107,9 @@ function tagger_content(&$a) {
$arr['owner_xchan'] = $item['owner_xchan'];
$arr['author_xchan'] = $channel['channel_hash'];
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = ((intval($item['item_wall'])) ? 1 : 0);
- $arr['item_flags'] = ITEM_ORIGIN;
- if($item['item_flags'] & ITEM_WALL)
- $arr['item_flags'] |= ITEM_WALL;
-
$ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]';
$alink = '[zrl=' . $item['xchan_url'] . ']' . $item['xchan_name'] . '[/zrl]';
$plink = '[zrl=' . $item['plink'] . ']' . $post_type . '[/zrl]';
diff --git a/mod/thing.php b/mod/thing.php
index c6b70fbb4..b4b8ad027 100644
--- a/mod/thing.php
+++ b/mod/thing.php
@@ -177,7 +177,9 @@ function thing_init(&$a) {
$arr['owner_xchan'] = $channel['channel_hash'];
$arr['author_xchan'] = $channel['channel_hash'];
- $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP;
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = 1;
+ $arr['item_thread_top'] = 1;
$ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]';
$plink = '[zrl=' . $term['url'] . ']' . $term['term'] . '[/zrl]';
diff --git a/mod/update_channel.php b/mod/update_channel.php
index bdde0a3be..5f4436d59 100644
--- a/mod/update_channel.php
+++ b/mod/update_channel.php
@@ -37,7 +37,7 @@ function update_channel_content(&$a) {
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
- $text = preg_replace($pattern, $replace, $text);
+// $text = preg_replace($pattern, $replace, $text);
if(! $load) {
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
diff --git a/mod/update_display.php b/mod/update_display.php
index 5802852bb..d41e2e5cb 100644
--- a/mod/update_display.php
+++ b/mod/update_display.php
@@ -19,7 +19,7 @@ function update_display_content(&$a) {
$text = display_content($a,$profile_uid, $load);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
- $text = preg_replace($pattern, $replace, $text);
+// $text = preg_replace($pattern, $replace, $text);
if(! $load) {
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
diff --git a/mod/update_home.php b/mod/update_home.php
index c139682e1..80ae2438f 100644
--- a/mod/update_home.php
+++ b/mod/update_home.php
@@ -15,7 +15,7 @@ function update_home_content(&$a) {
$text = home_content($a,$profile_uid, $load);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
- $text = preg_replace($pattern, $replace, $text);
+// $text = preg_replace($pattern, $replace, $text);
if(! $load) {
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
diff --git a/mod/update_network.php b/mod/update_network.php
index 0021af876..acd5ccdc8 100644
--- a/mod/update_network.php
+++ b/mod/update_network.php
@@ -17,7 +17,7 @@ function update_network_content(&$a) {
$text = network_content($a,$profile_uid, $load);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
- $text = preg_replace($pattern, $replace, $text);
+// $text = preg_replace($pattern, $replace, $text);
if(! $load) {
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
diff --git a/mod/update_public.php b/mod/update_public.php
index d0a08e0e6..bac1ccf15 100644
--- a/mod/update_public.php
+++ b/mod/update_public.php
@@ -15,7 +15,7 @@ function update_public_content(&$a) {
$text = public_content($a,$profile_uid, $load);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
- $text = preg_replace($pattern, $replace, $text);
+// $text = preg_replace($pattern, $replace, $text);
if(! $load) {
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
diff --git a/mod/update_search.php b/mod/update_search.php
index ec7599b79..de29e89bd 100644
--- a/mod/update_search.php
+++ b/mod/update_search.php
@@ -40,7 +40,7 @@ function update_search_content(&$a) {
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
- $text = preg_replace($pattern, $replace, $text);
+// $text = preg_replace($pattern, $replace, $text);
if(! $load) {
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
diff --git a/mod/viewconnections.php b/mod/viewconnections.php
index ef6681e64..d9a9aecc1 100644
--- a/mod/viewconnections.php
+++ b/mod/viewconnections.php
@@ -34,26 +34,23 @@ function viewconnections_content(&$a) {
$is_owner = ((local_channel() && local_channel() == $a->profile['uid']) ? true : false);
- $abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF;
- $xchan_flags = XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED;
+ $abook_flags = " and abook_pending = 0 and abook_self = 0 ";
+ $sql_extra = '';
+
if(! $is_owner) {
- $abook_flags = $abook_flags | ABOOK_FLAG_HIDDEN;
- $xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN;
+ $abook_flags = " and abook_hidden = 0 ";
+ $sql_extra = " and xchan_hidden = 0 ";
}
- $r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not (abook_flags & %d )>0 and not ( xchan_flags & %d )>0 ",
- intval($a->profile['uid']),
- intval($abook_flags),
- intval($xchan_flags)
+ $r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ",
+ intval($a->profile['uid'])
);
if($r) {
$a->set_pager_total($r[0]['total']);
}
- $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not ( abook_flags & %d )>0 and not ( xchan_flags & %d )>0 order by xchan_name LIMIT %d OFFSET %d ",
+ $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra order by xchan_name LIMIT %d OFFSET %d ",
intval($a->profile['uid']),
- intval($abook_flags),
- intval($xchan_flags),
intval($a->pager['itemspage']),
intval($a->pager['start'])
);
@@ -71,7 +68,7 @@ function viewconnections_content(&$a) {
if($url) {
$contacts[] = array(
'id' => $rr['abook_id'],
- 'archived' => (($rr['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? true : false),
+ 'archived' => (intval($rr['abook_archived']) ? true : false),
'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $rr['xchan_name'], $rr['xchan_url']),
'thumb' => $rr['xchan_photo_m'],
'name' => substr($rr['xchan_name'],0,20),
diff --git a/mod/viewsrc.php b/mod/viewsrc.php
index 3125ae4c0..cffb01b6e 100644
--- a/mod/viewsrc.php
+++ b/mod/viewsrc.php
@@ -20,15 +20,17 @@ function viewsrc_content(&$a) {
notice( t('Item not found.') . EOL);
}
+ $item_normal = item_normal();
+
if(local_channel() && $item_id) {
- $r = q("select item_flags, body, id from item where item_restrict = 0 and uid in (%d , %d) and id = %d limit 1",
+ $r = q("select id, item_flags, item_obscured, body from item where uid in (%d , %d) and id = %d $item_normal limit 1",
intval(local_channel()),
intval($sys['channel_id']),
intval($item_id)
);
if($r) {
- if($r[0]['item_flags'] & ITEM_OBSCURED)
+ if(intval($r[0]['item_obscured']))
$r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'],true),get_config('system','prvkey'));
$o = (($json) ? json_encode($r[0]['body']) : str_replace("\n",'<br />',$r[0]['body']));
}
diff --git a/mod/wall_attach.php b/mod/wall_attach.php
index 4b7103802..f08f931c2 100644
--- a/mod/wall_attach.php
+++ b/mod/wall_attach.php
@@ -21,30 +21,38 @@ function wall_attach_post(&$a) {
$observer = $a->get_observer();
- if($_FILES['userfile']['tmp_name']) {
- $x = @getimagesize($_FILES['userfile']['tmp_name']);
- logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
- if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
- $args = array( 'source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash']));
- $ret = photo_upload($channel,$observer,$args);
- if($ret['success']) {
- echo "\n\n" . $ret['body'] . "\n\n";
- killme();
- }
- if($using_api)
- return;
- notice($ret['message']);
- killme();
- }
- }
-
- $r = attach_store($channel,(($observer) ? $observer['xchan_hash'] : ''));
+// if($_FILES['userfile']['tmp_name']) {
+// $x = @getimagesize($_FILES['userfile']['tmp_name']);
+// logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
+// if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
+// $args = array( 'source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash']));
+// $ret = photo_upload($channel,$observer,$args);
+// if($ret['success']) {
+// echo "\n\n" . $ret['body'] . "\n\n";
+// killme();
+// }
+// if($using_api)
+// return;
+// notice($ret['message']);
+// killme();
+// }
+// }
+
+ $def_album = get_pconfig($channel['channel_id'],'system','photo_path');
+ $def_attach = get_pconfig($channel['channel_id'],'system','attach_path');
+
+ $r = attach_store($channel,(($observer) ? $observer['xchan_hash'] : ''),'', array('source' => 'editor', 'visible' => 0, 'album' => $def_album, 'directory' => $def_attach, 'allow_cid' => '<' . $channel['channel_hash'] . '>'));
if(! $r['success']) {
notice( $r['message'] . EOL);
killme();
}
+ if(intval($r['data']['is_photo'])) {
+ echo "\n\n" . $r['body'] . "\n\n";
+ if($using_api)
+ return;
+ }
echo "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n";
killme();
diff --git a/mod/webpages.php b/mod/webpages.php
index 362f7bacb..8e12b5910 100644
--- a/mod/webpages.php
+++ b/mod/webpages.php
@@ -102,7 +102,7 @@ function webpages_content(&$a) {
$o = profile_tabs($a, $is_owner, $a->profile['channel_address']);
$x = array(
- 'webpage' => ITEM_WEBPAGE,
+ 'webpage' => ITEM_TYPE_WEBPAGE,
'is_owner' => true,
'nickname' => $a->profile['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
@@ -133,9 +133,9 @@ function webpages_content(&$a) {
$sql_extra = item_permissions_sql($owner);
$r = q("select * from item_id left join item on item_id.iid = item.id
- where item_id.uid = %d and service = 'WEBPAGE' and item_restrict = %d $sql_extra order by item.created desc",
+ where item_id.uid = %d and service = 'WEBPAGE' and item_type = %d $sql_extra order by item.created desc",
intval($owner),
- intval(ITEM_WEBPAGE)
+ intval(ITEM_TYPE_WEBPAGE)
);
$pages = null;
diff --git a/mod/zfinger.php b/mod/zfinger.php
index 6b93b3410..8ddd92f3d 100644
--- a/mod/zfinger.php
+++ b/mod/zfinger.php
@@ -74,14 +74,10 @@ function zfinger_init(&$a) {
*/
$r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
- where ( channel_pageflags & %d )>0 order by channel_id limit 1",
- intval(PAGE_SYSTEM)
- );
+ where channel_system = 1 order by channel_id limit 1");
if(! $r) {
$r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
- where not ( channel_pageflags & %d )>0 order by channel_id limit 1",
- intval(PAGE_REMOVED)
- );
+ where channel_removed = 0 order by channel_id limit 1");
}
}
}
@@ -99,12 +95,12 @@ function zfinger_init(&$a) {
$id = $e['channel_id'];
- $sys_channel = (($e['channel_pageflags'] & PAGE_SYSTEM) ? true : false);
+ $sys_channel = (intval($e['channel_system']) ? true : false);
$special_channel = (($e['channel_pageflags'] & PAGE_PREMIUM) ? true : false);
$adult_channel = (($e['channel_pageflags'] & PAGE_ADULT) ? true : false);
$censored = (($e['channel_pageflags'] & PAGE_CENSORED) ? true : false);
$searchable = (($e['channel_pageflags'] & PAGE_HIDDEN) ? false : true);
- $deleted = (($e['xchan_flags'] & XCHAN_FLAGS_DELETED) ? true : false);
+ $deleted = (intval($e['xchan_deleted']) ? true : false);
if($deleted || $censored || $sys_channel)
$searchable = false;
@@ -117,9 +113,8 @@ function zfinger_init(&$a) {
}
else {
// check if it has characteristics of a public forum based on custom permissions.
- $t = q("select abook_my_perms from abook where abook_channel = %d and (abook_flags & %d)>0 limit 1",
- intval($e['channel_id']),
- intval(ABOOK_FLAG_SELF)
+ $t = q("select abook_my_perms from abook where abook_channel = %d and abook_self = 1 limit 1",
+ intval($e['channel_id'])
);
if($t && ($t[0]['abook_my_perms'] & PERMS_W_TAGWALL))
$public_forum = true;
diff --git a/mod/zotfeed.php b/mod/zotfeed.php
index 78a667330..fffb0e4ab 100644
--- a/mod/zotfeed.php
+++ b/mod/zotfeed.php
@@ -9,7 +9,7 @@ function zotfeed_init(&$a) {
$mindate = (($_REQUEST['mindate']) ? datetime_convert('UTC','UTC',$_REQUEST['mindate']) : '');
if(! $mindate)
- $mindate = datetime_convert('UTC','UTC', 'now - 4 days');
+ $mindate = datetime_convert('UTC','UTC', 'now - 14 days');
if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) {
$result['message'] = 'Public access denied';
@@ -21,16 +21,15 @@ function zotfeed_init(&$a) {
$channel_address = ((argc() > 1) ? argv(1) : '');
if($channel_address) {
- $r = q("select channel_id, channel_name from channel where channel_address = '%s' and not (channel_pageflags & %d) > 0 limit 1",
- dbesc(argv(1)),
- intval(PAGE_REMOVED)
+ $r = q("select channel_id, channel_name from channel where channel_address = '%s' and channel_removed = 0 limit 1",
+ dbesc(argv(1))
);
}
else {
$x = get_sys_channel();
if($x)
$r = array($x);
- $mindate = datetime_convert('UTC','UTC', 'now - 2 days');
+ $mindate = datetime_convert('UTC','UTC', 'now - 14 days');
}
if(! $r) {
$result['message'] = 'Channel not found.';