diff options
Diffstat (limited to 'include/identity.php')
-rw-r--r-- | include/identity.php | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/include/identity.php b/include/identity.php index 29d9ef022..184e9c308 100644 --- a/include/identity.php +++ b/include/identity.php @@ -24,9 +24,8 @@ require_once('include/crypto.php'); function identity_check_service_class($account_id) { $ret = array('success' => false, 'message' => ''); - $r = q("select count(channel_id) as total from channel where channel_account_id = %d and not ( channel_pageflags & %d )>0 ", - intval($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($account_id) ); if(! ($r && count($r))) { $ret['total_identities'] = 0; @@ -98,9 +97,9 @@ function create_sys_channel() { 'account_id' => 'xxx', // This will create an identity with an (integer) account_id of 0, but account_id is required 'nickname' => 'sys', 'name' => 'System', - 'pageflags' => PAGE_SYSTEM, + 'pageflags' => 0, 'publish' => 0, - 'xchanflags' => XCHAN_FLAGS_SYSTEM + 'system' => 1 )); } @@ -111,9 +110,7 @@ function create_sys_channel() { * @return array|boolean */ function get_sys_channel() { - $r = q("select * from channel left join xchan on channel_hash = xchan_hash where (channel_pageflags & %d)>0 limit 1", - intval(PAGE_SYSTEM) - ); + $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_system = 1 limit 1"); if ($r) return $r[0]; @@ -129,11 +126,11 @@ function get_sys_channel() { * @return boolean */ function is_sys_channel($channel_id) { - $r = q("select channel_pageflags from channel where channel_id = %d limit 1", + $r = q("select channel_system from channel where channel_id = %d and channel_system = 1 limit 1", intval($channel_id) ); - if (($r) && ($r[0]['channel_pageflags'] & PAGE_SYSTEM)) + if($r) return true; return false; @@ -149,9 +146,7 @@ function is_sys_channel($channel_id) { * on error returns boolean false */ function channel_total() { - $r = q("select channel_id from channel where not ( channel_pageflags & %d )>0", - intval(PAGE_REMOVED) - ); + $r = q("select channel_id from channel where channel_removed = 0"); if (is_array($r)) return count($r); @@ -201,14 +196,14 @@ function create_identity($arr) { $name = escape_tags($arr['name']); $pageflags = ((x($arr,'pageflags')) ? intval($arr['pageflags']) : PAGE_NORMAL); - $xchanflags = ((x($arr,'xchanflags')) ? intval($arr['xchanflags']) : XCHAN_FLAGS_NORMAL); + $system = ((x($arr,'system')) ? intval($arr['system']) : 0); $name_error = validate_channelname($arr['name']); if($name_error) { $ret['message'] = $name_error; return $ret; } - if($nick === 'sys' && (! ($pageflags & PAGE_SYSTEM))) { + if($nick === 'sys' && (! $system)) { $ret['message'] = t('Reserved nickname. Please choose another.'); return $ret; } @@ -265,8 +260,8 @@ function create_identity($arr) { $r = q("insert into channel ( channel_account_id, channel_primary, channel_name, channel_address, channel_guid, channel_guid_sig, - channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_expire_days, channel_timezone $perms_keys ) - values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s' $perms_vals ) ", + channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_system, channel_expire_days, channel_timezone $perms_keys ) + values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s' $perms_vals ) ", intval($arr['account_id']), intval($primary), @@ -278,6 +273,7 @@ function create_identity($arr) { dbesc($key['prvkey']), dbesc($key['pubkey']), intval($pageflags), + intval($system), intval($expire), dbesc($a->timezone) ); @@ -300,14 +296,14 @@ function create_identity($arr) { // Create a verified hub location pointing to this site. - $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags, + $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_primary, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_network ) values ( '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s' )", dbesc($guid), dbesc($sig), dbesc($hash), dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()), - intval(($primary) ? HUBLOC_FLAGS_PRIMARY : 0), + intval($primary), dbesc(z_root()), dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))), dbesc(get_app()->get_hostname()), @@ -320,7 +316,7 @@ function create_identity($arr) { $newuid = $ret['channel']['channel_id']; - $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", + $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_system ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", dbesc($hash), dbesc($guid), dbesc($sig), @@ -336,7 +332,7 @@ function create_identity($arr) { dbesc('zot'), dbesc(datetime_convert()), dbesc(datetime_convert()), - intval($xchanflags) + intval($system) ); // Not checking return value. @@ -363,7 +359,7 @@ function create_identity($arr) { |PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT |PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE; - $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_closeness, abook_created, abook_updated, abook_flags, abook_my_perms ) + $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_closeness, abook_created, abook_updated, abook_self, abook_my_perms ) values ( %d, %d, '%s', %d, '%s', '%s', %d, %d ) ", intval($ret['channel']['channel_account_id']), intval($newuid), @@ -371,7 +367,7 @@ function create_identity($arr) { intval(0), dbesc(datetime_convert()), dbesc(datetime_convert()), - intval(ABOOK_FLAG_SELF), + intval(1), intval($myperms) ); @@ -583,9 +579,7 @@ function identity_basic_export($channel_id, $items = false) { /** @warning this may run into memory limits on smaller systems */ - $r = q("select * from item where (item_flags & %d)>0 and not (item_restrict & %d)>0 and uid = %d", - intval(ITEM_WALL), - intval(ITEM_DELETED), + $r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d", intval($channel_id) ); if($r) { @@ -621,9 +615,8 @@ function profile_load(&$a, $nickname, $profile = '') { logger('profile_load: ' . $nickname . (($profile) ? ' profile: ' . $profile : '')); - $user = q("select channel_id from channel where channel_address = '%s' and not ( channel_pageflags & %d ) > 0 limit 1", - dbesc($nickname), - intval(PAGE_REMOVED) + $user = q("select channel_id from channel where channel_address = '%s' and channel_removed = 0 limit 1", + dbesc($nickname) ); if(! $user) { @@ -666,10 +659,9 @@ function profile_load(&$a, $nickname, $profile = '') { if(! $p) { $p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile LEFT JOIN channel ON profile.uid = channel.channel_id - WHERE channel.channel_address = '%s' and not ( channel_pageflags & %d )>0 + WHERE channel.channel_address = '%s' and channel_removed = 0 AND profile.is_default = 1 LIMIT 1", - dbesc($nickname), - intval(PAGE_REMOVED) + dbesc($nickname) ); } @@ -1376,7 +1368,7 @@ function get_default_profile_photo($size = 175) { } /** - * @brief Test whether a given identity is NOT a member of the Red Matrix. + * @brief Test whether a given identity is NOT a member of the Hubzilla. * * @param string $s; * xchan_hash of the identity in question @@ -1387,7 +1379,7 @@ function is_foreigner($s) { } /** - * @brief Test whether a given identity is a member of the Red Matrix. + * @brief Test whether a given identity is a member of the Hubzilla. * * @param string $s; * xchan_hash of the identity in question @@ -1459,9 +1451,8 @@ function get_channel_by_nick($nick) { */ function identity_selector() { 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 (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()) ); if (count($r) > 1) { //$account = get_app()->get_account(); @@ -1557,9 +1548,8 @@ function notifications_on($channel_id,$value) { function get_channel_default_perms($uid) { - $r = q("select abook_my_perms from abook where abook_channel = %d and (abook_flags & %d) > 0 limit 1", - intval($uid), - intval(ABOOK_FLAG_SELF) + $r = q("select abook_my_perms from abook where abook_channel = %d and abook_self = 1 limit 1", + intval($uid) ); if($r) return $r[0]['abook_my_perms']; |