diff options
Diffstat (limited to 'mod')
56 files changed, 501 insertions, 593 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..fb5645d8a 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_BUILDBLOCK) ); 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_BUILDBLOCK) ); 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..95979a304 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_BUILDBLOCK, '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_BUILDBLOCK) ); $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/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 cb524547c..88304d2ed 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; } @@ -174,8 +174,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) { @@ -190,12 +189,12 @@ 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 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()) ); @@ -216,7 +215,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); } @@ -236,11 +235,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']; @@ -365,10 +365,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)) { @@ -392,7 +391,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); @@ -404,7 +403,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); @@ -416,7 +415,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); @@ -428,7 +427,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); @@ -442,9 +441,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); @@ -514,28 +513,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'), ), @@ -550,7 +549,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)); } @@ -669,7 +668,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/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 b5daea2de..2f61e688a 100644 --- a/mod/display.php +++ b/mod/display.php @@ -81,7 +81,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 . '%') ); @@ -91,7 +91,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']) ); @@ -157,6 +157,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); @@ -175,9 +176,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']) @@ -198,13 +199,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) @@ -224,7 +225,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) ); @@ -247,7 +248,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']) ); @@ -266,7 +267,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 a0ece8133..9f9770e77 100644 --- a/mod/editblock.php +++ b/mod/editblock.php @@ -136,14 +136,14 @@ function editblock_content(&$a) { $o .= replace_macros($tpl,array( '$return_path' => $rp, '$action' => 'item', - '$webpage' => ITEM_BUILDBLOCK, + '$webpage' => ITEM_TYPE_BUILDBLOCK, '$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 8ab5aab22..d61a14a48 100644 --- a/mod/editlayout.php +++ b/mod/editlayout.php @@ -135,7 +135,7 @@ function editlayout_content(&$a) { $o .= 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 81bb91b2a..66196b2d2 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -55,7 +55,7 @@ function editpost_content(&$a) { - 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); 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/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 088c5cb61..d3864c077 100644 --- a/mod/import.php +++ b/mod/import.php @@ -200,8 +200,8 @@ function import_post(&$a) { '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']); @@ -220,7 +220,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']), @@ -228,7 +228,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()), @@ -239,9 +239,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()) ); @@ -326,7 +324,7 @@ 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']); @@ -340,7 +338,7 @@ function import_post(&$a) { . "')" ); $friends ++; - if($abook['abook_flags'] & ABOOK_FLAG_FEED) + if(intval($abook['abook_feed'])) $feeds ++; } } diff --git a/mod/item.php b/mod/item.php index 3ff286268..db0218136 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; } @@ -345,14 +345,33 @@ function item_post(&$a) { $app = $orig_post['app']; $title = $_REQUEST['title']; $body = $_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']; @@ -662,31 +681,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 +725,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 +758,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 +837,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 +873,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 +903,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 +915,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 +981,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 +1007,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 { @@ -1100,17 +1125,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/manage.php b/mod/manage.php index 3712be6f1..c86db55e8 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,11 +70,8 @@ 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 = 0 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ", + intval($channels[$x]['channel_id']) ); if($intr) @@ -127,9 +123,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", @@ -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..f757372bf 100644 --- a/mod/photo.php +++ b/mod/photo.php @@ -69,6 +69,8 @@ function photo_init(&$a) { $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 +144,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 e88d1497e..68077a5b1 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -135,14 +135,13 @@ 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) { 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']); } } @@ -180,19 +179,8 @@ function photos_post(&$a) { 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"); } } @@ -206,7 +194,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']); @@ -295,10 +283,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) ); @@ -402,8 +390,9 @@ function photos_post(&$a) { */ $_REQUEST['source'] = 'photos'; + require_once('include/attach.php'); - $r = photo_upload($a->channel,$a->get_observer(), $_REQUEST); + $r = attach_store($a->channel,get_observer_hash(), $_REQUEST); if(! $r['success']) { notice($r['message'] . EOL); } @@ -589,11 +578,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)); @@ -609,13 +599,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']) ); @@ -731,7 +722,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) @@ -851,9 +842,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']) @@ -878,8 +870,8 @@ 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 ", + if((local_channel()) && (local_user() == $link_item['uid'])) { + q("UPDATE `item` SET item_unseen = 0 WHERE parent = %d and uid = %d and item_unseen = 1", intval($link_item['parent']), intval(local_channel()) ); @@ -925,7 +917,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') ); @@ -1151,12 +1143,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)); @@ -1166,13 +1159,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..b093c1cab 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,8 +158,7 @@ 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; @@ -273,7 +274,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 +283,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 +296,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 +376,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 +389,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 +405,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(); 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 597b5f66d..79f84c690 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()) @@ -301,20 +297,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) diff --git a/mod/public.php b/mod/public.php index 64ae9d20a..fe3f3aa21 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'); @@ -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..0363a225f 100644 --- a/mod/search.php +++ b/mod/search.php @@ -125,6 +125,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 +144,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,23 +154,22 @@ 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), diff --git a/mod/settings.php b/mod/settings.php index b0ba04dfc..9284033e6 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)); @@ -669,8 +668,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; diff --git a/mod/siteinfo.php b/mod/siteinfo.php index 904228f13..1282e2f17 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' => '$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 aafad58cf..c6365d707 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/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..c3c0bff03 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -21,31 +21,37 @@ 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(); +// } +// } + + $r = attach_store($channel,(($observer) ? $observer['xchan_hash'] : ''),array('source' => 'editor')); if(! $r['success']) { notice( $r['message'] . EOL); killme(); } - echo "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n"; + if(intval($r['data']['is_photo'])) { + echo "\n\n" . $r['body'] . "\n\n"; + if($using_api) + return; + } + else + 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..b2f2e0465 100644 --- a/mod/zotfeed.php +++ b/mod/zotfeed.php @@ -21,9 +21,8 @@ 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 { |