diff options
author | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2015-07-29 22:04:07 +0200 |
---|---|---|
committer | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2015-07-29 22:04:07 +0200 |
commit | 98fa996b3f5125b60e2653bca2218b08041ad6a4 (patch) | |
tree | 685c3909ac49f7a25cd39877f74ed56ada9b15e0 /mod | |
parent | 07e890a79a5c506b2e32272edf86ad4aba3b8fba (diff) | |
parent | cbb6d37b6ca7e5d9e476fd3e7bea3ba56d3271e1 (diff) | |
download | volse-hubzilla-98fa996b3f5125b60e2653bca2218b08041ad6a4.tar.gz volse-hubzilla-98fa996b3f5125b60e2653bca2218b08041ad6a4.tar.bz2 volse-hubzilla-98fa996b3f5125b60e2653bca2218b08041ad6a4.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'mod')
-rw-r--r-- | mod/block.php | 4 | ||||
-rw-r--r-- | mod/blocks.php | 4 | ||||
-rw-r--r-- | mod/channel.php | 2 | ||||
-rw-r--r-- | mod/connedit.php | 154 | ||||
-rw-r--r-- | mod/directory.php | 35 | ||||
-rw-r--r-- | mod/display.php | 6 | ||||
-rw-r--r-- | mod/editblock.php | 19 | ||||
-rw-r--r-- | mod/editlayout.php | 16 | ||||
-rw-r--r-- | mod/editpost.php | 14 | ||||
-rw-r--r-- | mod/editwebpage.php | 5 | ||||
-rwxr-xr-x | mod/events.php | 22 | ||||
-rw-r--r-- | mod/import.php | 644 | ||||
-rwxr-xr-x | mod/like.php | 4 | ||||
-rw-r--r-- | mod/menu.php | 2 | ||||
-rw-r--r-- | mod/mitem.php | 9 | ||||
-rw-r--r-- | mod/photo.php | 2 | ||||
-rw-r--r-- | mod/photos.php | 6 | ||||
-rw-r--r-- | mod/profile_photo.php | 4 | ||||
-rwxr-xr-x | mod/setup.php | 2 | ||||
-rw-r--r-- | mod/uexport.php | 14 |
20 files changed, 516 insertions, 452 deletions
diff --git a/mod/block.php b/mod/block.php index fb5645d8a..df3909629 100644 --- a/mod/block.php +++ b/mod/block.php @@ -53,7 +53,7 @@ function block_content(&$a) { item_type = %d $sql_options $revision limit 1", intval($u[0]['channel_id']), dbesc($page_id), - intval(ITEM_TYPE_BUILDBLOCK) + intval(ITEM_TYPE_BLOCK) ); if(! $r) { @@ -65,7 +65,7 @@ function block_content(&$a) { item_type = %d $revision limit 1", intval($u[0]['channel_id']), dbesc($page_id), - intval(ITEM_TYPE_BUILDBLOCK) + intval(ITEM_TYPE_BLOCK) ); if($x) { // Yes, it's there. You just aren't allowed to see it. diff --git a/mod/blocks.php b/mod/blocks.php index 95979a304..97cc5cd53 100644 --- a/mod/blocks.php +++ b/mod/blocks.php @@ -84,7 +84,7 @@ function blocks_content(&$a) { } $x = array( - 'webpage' => ITEM_TYPE_BUILDBLOCK, + 'webpage' => ITEM_TYPE_BLOCK, 'is_owner' => true, 'nickname' => $a->profile['channel_address'], 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), @@ -110,7 +110,7 @@ function blocks_content(&$a) { $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_type = %d order by item.created desc", intval($owner), - intval(ITEM_TYPE_BUILDBLOCK) + intval(ITEM_TYPE_BLOCK) ); $pages = null; diff --git a/mod/channel.php b/mod/channel.php index 9a98ade60..d1064e939 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -175,7 +175,7 @@ function channel_content(&$a, $update = 0, $load = false) { left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE uid = %d $item_normal AND item_wall = 1 AND item_unseen = 1 - AND (abook.blocked = 0 or abook.abook_flags is null) + AND (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra ORDER BY created DESC", intval($a->profile['profile_uid']) diff --git a/mod/connedit.php b/mod/connedit.php index 46546caa1..866f83615 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -130,7 +130,6 @@ function connedit_post(&$a) { } } - $abook_flags = $orig_record[0]['abook_flags']; $new_friend = false; if(! $is_self) { @@ -144,7 +143,6 @@ function connedit_post(&$a) { dbesc($orig_record[0]['abook_xchan']) ); - if($z) { $record = $z[0]['xlink_id']; $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s' @@ -192,6 +190,7 @@ function connedit_post(&$a) { } } + $abook_pending = $new_friend ? 0 : $orig_record[0]['abook_pending']; $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_pending = %d, abook_incl = '%s', abook_excl = '%s' @@ -199,7 +198,7 @@ function connedit_post(&$a) { dbesc($profile_id), intval($abook_my_perms), intval($closeness), - intval(1 - intval($new_friend)), + intval($abook_pending), dbesc($abook_incl), dbesc($abook_excl), intval($contact_id), @@ -398,9 +397,6 @@ function connedit_content(&$a) { if($cmd === 'block') { if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_BLOCKED)) { - info((intval($orig_record[0]['abook_blocked']) - ? t('Channel has been unblocked') - : t('Channel has been blocked')) . EOL ); connedit_clone($a); } else @@ -410,9 +406,6 @@ function connedit_content(&$a) { if($cmd === 'ignore') { if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_IGNORED)) { - info((intval($orig_record[0]['abook_ignored']) - ? t('Channel has been unignored') - : t('Channel has been ignored')) . EOL ); connedit_clone($a); } else @@ -422,9 +415,6 @@ function connedit_content(&$a) { if($cmd === 'archive') { if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_ARCHIVED)) { - info((intval($orig_record[0]['abook_archived']) - ? t('Channel has been unarchived') - : t('Channel has been archived')) . EOL ); connedit_clone($a); } else @@ -434,9 +424,6 @@ function connedit_content(&$a) { if($cmd === 'hide') { if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_HIDDEN)) { - info((intval($orig_record[0]['abook_hidden']) - ? t('Channel has been unhidden') - : t('Channel has been hidden')) . EOL ); connedit_clone($a); } else @@ -450,9 +437,6 @@ function connedit_content(&$a) { if($cmd === 'approve') { if(intval($orig_record[0]['abook_pending'])) { if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_PENDING)) { - info((intval($orig_record[0]['abook_pending']) - ? t('Channel has been approved') - : t('Channel has been unapproved')) . EOL ); connedit_clone($a); } else @@ -493,59 +477,62 @@ function connedit_content(&$a) { $contact_id = $a->poi['abook_id']; $contact = $a->poi; + $buttons = array( - $tabs = array( - - array( + 'view' => array( 'label' => t('View Profile'), 'url' => chanlink_cid($contact['abook_id']), 'sel' => '', 'title' => sprintf( t('View %s\'s profile'), $contact['xchan_name']), ), - array( + 'refresh' => array( 'label' => t('Refresh Permissions'), 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/refresh', 'sel' => '', 'title' => t('Fetch updated permissions'), ), - array( + 'recent' => array( 'label' => t('Recent Activity'), 'url' => $a->get_baseurl(true) . '/network/?f=&cid=' . $contact['abook_id'], 'sel' => '', 'title' => t('View recent posts and comments'), - ) - ); + ), - $buttons = array( - array( + 'block' => array( 'label' => (intval($contact['abook_blocked']) ? t('Unblock') : t('Block')), 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/block', 'sel' => (intval($contact['abook_blocked']) ? 'active' : ''), 'title' => t('Block (or Unblock) all communications with this connection'), + 'info' => (intval($contact['abook_blocked']) ? t('This connection is blocked!') : ''), ), - array( + 'ignore' => array( 'label' => (intval($contact['abook_ignored']) ? t('Unignore') : t('Ignore')), 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/ignore', 'sel' => (intval($contact['abook_ignored']) ? 'active' : ''), 'title' => t('Ignore (or Unignore) all inbound communications from this connection'), + 'info' => (intval($contact['abook_ignored']) ? t('This connection is ignored!') : ''), ), - array( + + 'archive' => array( 'label' => (intval($contact['abook_archived']) ? t('Unarchive') : t('Archive')), 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/archive', 'sel' => (intval($contact['abook_archived']) ? 'active' : ''), 'title' => t('Archive (or Unarchive) this connection - mark channel dead but keep content'), + 'info' => (intval($contact['abook_archived']) ? t('This connection is archived!') : ''), ), - array( + + 'hide' => array( 'label' => (intval($contact['abook_hidden']) ? t('Unhide') : t('Hide')), 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/hide', 'sel' => (intval($contact['abook_hidden']) ? 'active' : ''), 'title' => t('Hide or Unhide this connection from your other connections'), + 'info' => (intval($contact['abook_hidden']) ? t('This connection is hidden!') : ''), ), - array( + 'delete' => array( 'label' => t('Delete'), 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/drop', 'sel' => '', @@ -556,18 +543,9 @@ function connedit_content(&$a) { $self = false; - if(! intval($contact['abook_self'])) { - $tab_tpl = get_markup_template('common_tabs.tpl'); - $t = replace_macros($tab_tpl, array('$tabs'=>$tabs)); - } - else + if(intval($contact['abook_self'])) $self = true; - $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array( - '$baseurl' => $a->get_baseurl(true), - '$editselect' => $editselect - )); - require_once('include/contact_selectors.php'); $tpl = get_markup_template("abook_edit.tpl"); @@ -616,7 +594,6 @@ function connedit_content(&$a) { $rating_text = $xl[0]['xlink_rating_text']; } - $poco_rating = get_config('system','poco_rating_enable'); // if unset default to enabled @@ -640,101 +617,78 @@ function connedit_content(&$a) { $global_perms = get_perms(); $existing = get_all_perms(local_channel(),$contact['abook_xchan']); - $unapproved = array('pending', t('Approve this connection'), '', t('Accept connection to allow communication')); - + $unapproved = array('pending', t('Approve this connection'), '', t('Accept connection to allow communication'), array(t('No'),('Yes'))); + + $multiprofs = ((feature_enabled(local_channel(),'multi_profiles')) ? true : false); + + if($slide && !$multiprofs) + $affinity = t('Set Affinity'); + + if(!$slide && $multiprofs) + $affinity = t('Set Profile'); + + if($slide && $multiprofs) + $affinity = t('Set Affinity & Profile'); + foreach($global_perms as $k => $v) { $thisperm = (($contact['abook_my_perms'] & $v[1]) ? "1" : ''); + $checkinherited = ((($channel[$v[0]]) && ($channel[$v[0]] != PERMS_SPECIFIC)) ? "1" : ''); // For auto permissions (when $self is true) we don't want to look at existing // permissions because they are enabled for the channel owner - if((! $self) && ($existing[$k])) $thisperm = "1"; - $perms[] = array('perms_' . $k, $v[3], (($contact['abook_their_perms'] & $v[1]) ? "1" : ""),$thisperm, $v[1], (($channel[$v[0]] == PERMS_SPECIFIC || $self) ? '' : '1'), $v[4]); + $perms[] = array('perms_' . $k, $v[3], (($contact['abook_their_perms'] & $v[1]) ? "1" : ""),$thisperm, $v[1], (($channel[$v[0]] == PERMS_SPECIFIC) ? '' : '1'), $v[4], $checkinherited); } $o .= replace_macros($tpl,array( - '$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connections: settings for %s'),$contact['xchan_name'])), - '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), ''), + '$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])), + '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), 'Connection requests will be approved without your interaction', array(t('No'),('Yes'))), '$addr' => $contact['xchan_addr'], + '$addr_text' => t('This connection\'s address is'), '$notself' => (($self) ? '' : '1'), '$self' => (($self) ? '1' : ''), - '$autolbl' => t('Apply the permissions indicated on this page to all new connections.'), + '$autolbl' => t('The permissions indicated on this page will be applied to all new connections.'), '$buttons' => (($self) ? '' : $buttons), - '$viewprof' => t('View Profile'), - '$clickme' => t('Click to open/close'), '$lbl_slider' => t('Slide to adjust your degree of friendship'), - '$lbl_rating' => t('Rating (this information is public)'), - '$lbl_rating_txt' => t('Optionally explain your rating (this information is public)'), + '$lbl_rating' => t('Rating'), + '$lbl_rating_label' => t('Slide to adjust your rating'), + '$lbl_rating_txt' => t('Optionally explain your rating'), '$connfilter' => feature_enabled(local_channel(),'connfilter'), + '$connfilter_label' => t('Custom Filter'), '$incl' => array('abook_incl',t('Only import posts with this text'), $contact['abook_incl'],t('words one per line or #tags or /patterns/, leave blank to import all posts')), '$excl' => array('abook_excl',t('Do not import posts with this text'), $contact['abook_excl'],t('words one per line or #tags or /patterns/, leave blank to import all posts')), - '$rating_text' => array('rating_text', t('Optionally explain your rating (this information is public)'),$rating_text,''), + '$rating_text' => array('rating_text', t('Optionally explain your rating'),$rating_text,''), + '$rating_info' => t('This information is public!'), '$rating' => $rating, '$rating_val' => $rating_val, '$slide' => $slide, - '$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.'), + '$affinity' => $affinity, + '$pending_label' => t('Connection Pending Approval'), + '$pending_modal_title' => t('Connection Request'), + '$pending_modal_body' => sprintf(t('(%s) would like to connect with you. Please approve this connection to allow communication.'), $contact['xchan_addr']), + '$pending_modal_approve' => t('Approve'), + '$pending_modal_dismiss' => t('Approve Later'), '$is_pending' => (intval($contact['abook_pending']) ? 1 : ''), '$unapproved' => $unapproved, '$inherited' => t('inherited'), - '$approve' => t('Approve this connection'), - '$noperms' => (($contact['abook_my_perms']) ? false : true), - '$no_perms' => (((! $self) && (! $contact['abook_my_perms'])) ? t('Connection has no individual permissions!') : ''), - '$noperm_desc' => (((! $self) && (! $contact['abook_my_perms'])) ? t('This may be appropriate based on your <a href="settings">privacy settings</a>, though you may wish to review the "Advanced Permissions".') : ''), '$submit' => t('Submit'), - '$lbl_vis1' => t('Profile Visibility'), '$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['xchan_name']), - '$lbl_info1' => t('Contact Information / Notes'), - '$infedit' => t('Edit contact notes'), '$close' => $contact['abook_closeness'], '$them' => t('Their Settings'), '$me' => t('My Settings'), '$perms' => $perms, - '$perms_new' => t('Default permissions for this channel type have (just) been applied. They have <em>not</em> been saved and there are currently no stored default permissions. Please review/edit the applied settings and click [Submit] to finalize.'), - '$clear' => t('Clear/Disable Automatic Permissions'), - '$forum' => t('Forum Members'), - '$soapbox' => t('Soapbox'), - '$full' => t('Full Sharing (typical social network permissions)'), - '$cautious' => t('Cautious Sharing '), - '$follow' => t('Follow Only'), '$permlbl' => t('Individual Permissions'), - '$permnote' => t('Some permissions may be inherited from your channel <a href="settings">privacy settings</a>, which have higher priority than individual settings. Changing those inherited settings on this page will have no effect.'), - '$advanced' => t('Advanced Permissions'), - '$quick' => t('Simple Permissions (select one and submit)'), - '$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_channel() . '/' . $contact['id'], - '$all_friends' => $all_friends, - '$relation_text' => $relation_text, - '$visit' => sprintf( t('Visit %s\'s profile - %s'),$contact['xchan_name'],$contact['xchan_url']), - '$blockunblock' => t('Block/Unblock contact'), - '$ignorecont' => t('Ignore contact'), - '$lblcrepair' => t("Repair URL settings"), - '$lblrecent' => t('View conversations'), - '$lblsuggest' => $lblsuggest, - '$delete' => t('Delete contact'), - - '$poll_interval' => contact_poll_interval($contact['priority'],(! $poll_enabled)), - '$poll_enabled' => $poll_enabled, + '$permnote' => t('Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can <strong>not</strong> change those settings here.'), + '$permnote_self' => t('Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can change those settings here but they wont have any impact unless the inherited setting changes.'), '$lastupdtext' => t('Last update:'), - '$lost_contact' => $lost_contact, - '$updpub' => t('Update public posts'), '$last_update' => relative_date($contact['abook_connected']), - '$udnow' => t('Update now'), '$profile_select' => contact_profile_assign($contact['abook_profile']), - '$multiprofs' => feature_enabled(local_channel(),'multi_profiles'), + '$multiprofs' => $multiprofs, '$contact_id' => $contact['abook_id'], - '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ), - '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ), - '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''), - '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''), - '$archived' => (($contact['archive']) ? t('Currently archived') : ''), - '$pending' => (($contact['archive']) ? t('Currently pending') : ''), - '$name' => $contact['name'], - '$alt_text' => $alt_text, - '$url' => $url + '$name' => $contact['xchan_name'], )); diff --git a/mod/directory.php b/mod/directory.php index f01efc053..3c230e173 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -19,6 +19,7 @@ function directory_init(&$a) { $observer = get_observer_hash(); $global_changed = false; $safe_changed = false; + $pubforums_changed = false; if(array_key_exists('global',$_REQUEST)) { $globaldir = intval($_REQUEST['global']); @@ -28,7 +29,7 @@ function directory_init(&$a) { $_SESSION['globaldir'] = $globaldir; if($observer) set_xconfig($observer,'directory','globaldir',$globaldir); - } + } if(array_key_exists('safe',$_REQUEST)) { $safemode = intval($_REQUEST['safe']); @@ -37,9 +38,19 @@ function directory_init(&$a) { if($safe_changed) { $_SESSION['safemode'] = $safemode; if($observer) - set_xconfig($observer,'directory','safe_mode',$safemode); - } + set_xconfig($observer,'directory','safemode',$safemode); + } + + if(array_key_exists('pubforums',$_REQUEST)) { + $pubforums = intval($_REQUEST['pubforums']); + $pubforums_changed = true; + } + if($pubforums_changed) { + $_SESSION['pubforums'] = $pubforums; + if($observer) + set_xconfig($observer,'directory','pubforums',$pubforums); + } } function directory_content(&$a) { @@ -51,18 +62,14 @@ function directory_content(&$a) { $observer = get_observer_hash(); - $globaldir = get_globaldir_setting($observer); + $globaldir = get_directory_setting($observer, 'globaldir'); // override your personal global search pref if we're doing a navbar search of the directory if(intval($_REQUEST['navsearch'])) $globaldir = 1; - $safe_mode = get_safemode_setting($observer); + $safe_mode = get_directory_setting($observer, 'safemode'); - $pubforums = null; - if(array_key_exists('pubforums',$_REQUEST)) - $pubforums = intval($_REQUEST['pubforums']); - if(! $pubforums) - $pubforums = null; + $pubforums = get_directory_setting($observer, 'pubforums'); $o = ''; nav_set_selected('directory'); @@ -375,7 +382,13 @@ function directory_content(&$a) { '$entries' => $entries, '$dirlbl' => $suggest ? t('Channel Suggestions') : $dirtitle, '$submit' => t('Find'), - '$next' => alt_pager($a,$j['records'], t('next page'), t('previous page')) + '$next' => alt_pager($a,$j['records'], t('next page'), t('previous page')), + '$sort' => t('Sort options'), + '$normal' => t('Alphabetic'), + '$reverse' => t('Reverse Alphabetic'), + '$date' => t('Newest to Oldest'), + '$reversedate' => t('Oldest to Newest'), + '$suggest' => $suggest ? '&suggest=1' : '' )); diff --git a/mod/display.php b/mod/display.php index 2f61e688a..b2d9ba34b 100644 --- a/mod/display.php +++ b/mod/display.php @@ -52,6 +52,7 @@ function display_content(&$a, $update = 0, $load = false) { 'deny_gid' => $channel['channel_deny_gid'] ); + $x = array( 'is_owner' => true, 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''), @@ -63,10 +64,13 @@ function display_content(&$a, $update = 0, $load = false) { 'bang' => '', 'visitor' => true, 'profile_uid' => local_channel(), - 'return_path' => 'channel/' . $channel['channel_address'] + 'return_path' => 'channel/' . $channel['channel_address'], + 'expanded' => true ); + $o = '<div id="jot-popup">'; $o .= status_editor($a,$x); + $o .= '</div>'; } diff --git a/mod/editblock.php b/mod/editblock.php index 9f9770e77..b4d954ef5 100644 --- a/mod/editblock.php +++ b/mod/editblock.php @@ -108,12 +108,6 @@ function editblock_content(&$a) { else $mimeselect = mimetype_select($itm[0]['uid'],$mimetype); - $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( - '$title' => t('Edit Block'), - '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), - '$id' => $itm[0]['id'] - )); - $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( '$baseurl' => $a->get_baseurl(), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), @@ -133,17 +127,17 @@ function editblock_content(&$a) { $rp = 'blocks/' . $channel['channel_address']; - $o .= replace_macros($tpl,array( + $editor = replace_macros($tpl,array( '$return_path' => $rp, '$action' => 'item', - '$webpage' => ITEM_TYPE_BUILDBLOCK, + '$webpage' => ITEM_TYPE_BLOCK, '$share' => t('Edit'), '$bold' => t('Bold'), '$italic' => t('Italic'), '$underline' => t('Underline'), '$quote' => t('Quote'), '$code' => t('Code'), - '$writefiles' => (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage')), + '$writefiles' => perm_is_allowed($owner, get_observer_hash(), 'write_storage'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), @@ -181,6 +175,13 @@ function editblock_content(&$a) { '$expires' => t('Set expiration date'), )); + $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( + '$title' => t('Edit Block'), + '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), + '$id' => $itm[0]['id'], + '$editor' => $editor + )); + return $o; } diff --git a/mod/editlayout.php b/mod/editlayout.php index d61a14a48..6ea7f4100 100644 --- a/mod/editlayout.php +++ b/mod/editlayout.php @@ -101,12 +101,6 @@ function editlayout_content(&$a) { $layout_title = $item_id[0]['sid']; $plaintext = true; - - $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( - '$title' => t('Edit Layout'), - '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), - '$id' => $itm[0]['id'] - )); $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( '$baseurl' => $a->get_baseurl(), @@ -132,7 +126,7 @@ function editlayout_content(&$a) { $rp = 'layouts/' . $which; - $o .= replace_macros($tpl,array( + $editor = replace_macros($tpl,array( '$return_path' => $rp, '$action' => 'item', '$webpage' => ITEM_TYPE_PDL, @@ -178,6 +172,14 @@ function editlayout_content(&$a) { '$expires' => t('Set expiration date'), )); + + $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( + '$title' => t('Edit Layout'), + '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), + '$id' => $itm[0]['id'], + '$editor' => $editor + )); + return $o; } diff --git a/mod/editpost.php b/mod/editpost.php index 8e4b37103..235ae9def 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -38,11 +38,6 @@ function editpost_content(&$a) { $channel = $a->get_channel(); - $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( - '$title' => t('Edit post') - )); - - $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( '$baseurl' => $a->get_baseurl(), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), @@ -53,8 +48,6 @@ function editpost_content(&$a) { '$confirmdelete' => t('Delete item?'), )); - - if(intval($itm[0]['item_obscured'])) { $key = get_config('system','prvkey'); if($itm[0]['title']) @@ -107,7 +100,7 @@ function editpost_content(&$a) { $cipher = 'aes256'; - $o .= replace_macros($tpl,array( + $editor = replace_macros($tpl,array( '$return_path' => $_SESSION['return_url'], '$action' => 'item', '$share' => t('Edit'), @@ -161,6 +154,11 @@ function editpost_content(&$a) { '$expiryModalCANCEL' => t('Cancel'), )); + $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( + '$title' => t('Edit post'), + '$editor' => $editor + )); + return $o; } diff --git a/mod/editwebpage.php b/mod/editwebpage.php index 3b0b543a6..974e8cc38 100644 --- a/mod/editwebpage.php +++ b/mod/editwebpage.php @@ -165,15 +165,12 @@ function editwebpage_content(&$a) { $rp = 'webpages/' . $which; - logger('canwrite: ' . (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage'))); - $editor = replace_macros($tpl,array( '$return_path' => $rp, '$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')), - + '$writefiles' => perm_is_allowed($owner, get_observer_hash(), 'write_storage'), '$action' => 'item', '$share' => t('Edit'), '$bold' => t('Bold'), diff --git a/mod/events.php b/mod/events.php index a89bbb760..0af81278f 100755 --- a/mod/events.php +++ b/mod/events.php @@ -13,6 +13,20 @@ function events_post(&$a) { if(! local_channel()) return; + if(($_FILES) && array_key_exists('userfile',$_FILES) && intval($_FILES['userfile']['size'])) { + $src = $_FILES['userfile']['tmp_name']; + if($src) { + $result = parse_ical_file($src,local_channel()); + if($result) + info( t('Calendar entries imported.') . EOL); + else + notice( t('No calendar entries found.') . EOL); + @unlink($src); + } + goaway(z_root() . '/events'); + } + + $event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0); $event_hash = ((x($_POST,'event_hash')) ? $_POST['event_hash'] : ''); @@ -148,10 +162,9 @@ function events_post(&$a) { } } else { - // Note: do not set `private` field for self-only events. It will - // keep even you from seeing them! $str_contact_allow = '<' . $channel['channel_hash'] . '>'; $str_group_allow = $str_contact_deny = $str_group_deny = ''; + $private_event = true; } } @@ -451,6 +464,7 @@ function events_content(&$a) { if($export) { header('Content-type: text/calendar'); + header('content-disposition: attachment; filename="' . t('calendar') . '-' . $channel['channel_address'] . '.ics"' ); echo ical_wrapper($r); killme(); } @@ -477,8 +491,8 @@ function events_content(&$a) { '$export' => array($a->get_baseurl()."/events/$y/$m/export",t('Export'),'',''), '$calendar' => cal($y,$m,$links, ' eventcal'), '$events' => $events, - - + '$upload' => t('Upload'), + '$submit' => t('Submit') )); if (x($_GET,'id')){ echo $o; killme(); } diff --git a/mod/import.php b/mod/import.php index f8ab8a0a2..92de33059 100644 --- a/mod/import.php +++ b/mod/import.php @@ -36,6 +36,9 @@ function import_post(&$a) { $filesize = intval($_FILES['filename']['size']); $filetype = $_FILES['filename']['type']; + $completed = ((array_key_exists('import_step',$_SESSION)) ? intval($_SESSION['import_step']) : 0); + if($completed) + logger('saved import step: ' . $_SESSION['import_step']); if($src) { @@ -114,360 +117,430 @@ function import_post(&$a) { // import channel - $channel = $data['channel']; + if(array_key_exists('channel',$data)) { + $channel = $data['channel']; - if(! array_key_exists('channel_system',$channel)) { - $channel['channel_system'] = (($channel['channel_pageflags'] & 0x1000) ? 1 : 0); - $channel['channel_removed'] = (($channel['channel_pageflags'] & 0x8000) ? 1 : 0); - } + if($completed < 1) { - $r = q("select * from channel where (channel_guid = '%s' or channel_hash = '%s' or channel_address = '%s' ) limit 1", - dbesc($channel['channel_guid']), - dbesc($channel['channel_hash']), - dbesc($channel['channel_address']) - ); + if(! array_key_exists('channel_system',$channel)) { + $channel['channel_system'] = (($channel['channel_pageflags'] & 0x1000) ? 1 : 0); + $channel['channel_removed'] = (($channel['channel_pageflags'] & 0x8000) ? 1 : 0); + } - // We should probably also verify the hash + $r = q("select * from channel where (channel_guid = '%s' or channel_hash = '%s' or channel_address = '%s' ) limit 1", + dbesc($channel['channel_guid']), + dbesc($channel['channel_hash']), + dbesc($channel['channel_address']) + ); - if($r) { - if($r[0]['channel_guid'] === $channel['channel_guid'] || $r[0]['channel_hash'] === $channel['channel_hash']) { - logger('mod_import: duplicate channel. ', print_r($channel,true)); - notice( t('Cannot create a duplicate channel identifier on this system. Import failed.') . EOL); - return; - } - else { - // try at most ten times to generate a unique address. - $x = 0; - $found_unique = false; - do { - $tmp = $channel['channel_address'] . mt_rand(1000,9999); - $r = q("select * from channel where channel_address = '%s' limit 1", - dbesc($tmp) - ); - if(! $r) { - $channel['channel_address'] = $tmp; - $found_unique = true; - break; + // We should probably also verify the hash + + if($r) { + if($r[0]['channel_guid'] === $channel['channel_guid'] || $r[0]['channel_hash'] === $channel['channel_hash']) { + logger('mod_import: duplicate channel. ', print_r($channel,true)); + notice( t('Cannot create a duplicate channel identifier on this system. Import failed.') . EOL); + return; } - $x ++; - } while ($x < 10); - if(! $found_unique) { - logger('mod_import: duplicate channel. randomisation failed.', print_r($channel,true)); - notice( t('Unable to create a unique channel address. Import failed.') . EOL); - return; + else { + // try at most ten times to generate a unique address. + $x = 0; + $found_unique = false; + do { + $tmp = $channel['channel_address'] . mt_rand(1000,9999); + $r = q("select * from channel where channel_address = '%s' limit 1", + dbesc($tmp) + ); + if(! $r) { + $channel['channel_address'] = $tmp; + $found_unique = true; + break; + } + $x ++; + } while ($x < 10); + if(! $found_unique) { + logger('mod_import: duplicate channel. randomisation failed.', print_r($channel,true)); + notice( t('Unable to create a unique channel address. Import failed.') . EOL); + return; + } + } } - } - } - unset($channel['channel_id']); - $channel['channel_account_id'] = get_account_id(); - $channel['channel_primary'] = (($seize) ? 1 : 0); + unset($channel['channel_id']); + $channel['channel_account_id'] = get_account_id(); + $channel['channel_primary'] = (($seize) ? 1 : 0); - dbesc_array($channel); - - $r = dbq("INSERT INTO channel (`" - . implode("`, `", array_keys($channel)) - . "`) VALUES ('" - . implode("', '", array_values($channel)) - . "')" ); + dbesc_array($channel); - if(! $r) { - logger('mod_import: channel clone failed. ', print_r($channel,true)); - notice( t('Channel clone failed. Import failed.') . EOL); - return; - } - - $r = q("select * from channel where channel_account_id = %d and channel_guid = '%s' limit 1", - intval(get_account_id()), - $channel['channel_guid'] // Already dbesc'd - ); - if(! $r) { - logger('mod_import: channel not found. ', print_r($channel,true)); - notice( t('Cloned channel not found. Import failed.') . EOL); - return; - } - // reset - $channel = $r[0]; + $r = dbq("INSERT INTO channel (`" + . implode("`, `", array_keys($channel)) + . "`) VALUES ('" + . implode("', '", array_values($channel)) + . "')" ); - set_default_login_identity(get_account_id(),$channel['channel_id'],false); + if(! $r) { + logger('mod_import: channel clone failed. ', print_r($channel,true)); + notice( t('Channel clone failed. Import failed.') . EOL); + return; + } + $r = q("select * from channel where channel_account_id = %d and channel_guid = '%s' limit 1", + intval(get_account_id()), + $channel['channel_guid'] // Already dbesc'd + ); + if(! $r) { + logger('mod_import: channel not found. ', print_r($channel,true)); + notice( t('Cloned channel not found. Import failed.') . EOL); + return; + } + // reset + $channel = $r[0]; - $configs = $data['config']; - if($configs) { - foreach($configs as $config) { - unset($config['id']); - $config['uid'] = $channel['channel_id']; - dbesc_array($config); - $r = dbq("INSERT INTO pconfig (`" - . implode("`, `", array_keys($config)) - . "`) VALUES ('" - . implode("', '", array_values($config)) - . "')" ); + set_default_login_identity(get_account_id(),$channel['channel_id'],false); + logger('import step 1'); + $_SESSION['import_step'] = 1; + ref_session_write(session_id(), serialize($_SESSION)); + } + } + else { + $r = q("select * from channel where channel_account_id = %d and channel_guid = '%s' limit 1", + intval(get_account_id()), + dbesc($channel['channel_guid']) + ); + if($r) + $channel = $r[0]; + else { + logger('mod_import: channel not found. ', print_r($channel,true)); + notice( t('Cloned channel not found. Import failed.') . EOL); + return; } } + if($completed < 2) { - if($data['photo']) { - require_once('include/photo/photo_driver.php'); - import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],get_account_id(),$channel['channel_id']); + $configs = $data['config']; + if($configs) { + foreach($configs as $config) { + unset($config['id']); + $config['uid'] = $channel['channel_id']; + dbesc_array($config); + $r = dbq("INSERT INTO pconfig (`" + . implode("`, `", array_keys($config)) + . "`) VALUES ('" + . implode("', '", array_values($config)) + . "')" ); + } + } + logger('import step 2'); + $_SESSION['import_step'] = 2; + ref_session_write(session_id(), serialize($_SESSION)); } - $profiles = $data['profile']; - if($profiles) { - foreach($profiles as $profile) { - unset($profile['id']); - $profile['aid'] = get_account_id(); - $profile['uid'] = $channel['channel_id']; - // we are going to reset all profile photos to the original - // somebody will have to fix this later and put all the applicable photos into the export - $profile['photo'] = z_root() . '/photo/profile/l/' . $channel['channel_id']; - $profile['thumb'] = z_root() . '/photo/profile/m/' . $channel['channel_id']; + if($completed < 3) { - - dbesc_array($profile); - $r = dbq("INSERT INTO profile (`" - . implode("`, `", array_keys($profile)) - . "`) VALUES ('" - . implode("', '", array_values($profile)) - . "')" ); + if($data['photo']) { + require_once('include/photo/photo_driver.php'); + import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],get_account_id(),$channel['channel_id']); } - } - - $hublocs = $data['hubloc']; - if($hublocs) { - foreach($hublocs as $hubloc) { + $profiles = $data['profile']; + if($profiles) { + foreach($profiles as $profile) { + unset($profile['id']); + $profile['aid'] = get_account_id(); + $profile['uid'] = $channel['channel_id']; - if(! array_key_exists('hubloc_primary',$hublocs)) { - $hubloc['hubloc_primary'] = (($hubloc['hubloc_flags'] & 0x0001) ? 1 : 0); - $hubloc['hubloc_orphancheck'] = (($hubloc['hubloc_flags'] & 0x0004) ? 1 : 0); - $hubloc['hubloc_error'] = (($hubloc['hubloc_status'] & 0x0003) ? 1 : 0); - $hubloc['hubloc_deleted'] = (($hubloc['hubloc_flags'] & 0x1000) ? 1 : 0); - } + // we are going to reset all profile photos to the original + // somebody will have to fix this later and put all the applicable photos into the export + + $profile['photo'] = z_root() . '/photo/profile/l/' . $channel['channel_id']; + $profile['thumb'] = z_root() . '/photo/profile/m/' . $channel['channel_id']; - $arr = array( - 'guid' => $hubloc['hubloc_guid'], - 'guid_sig' => $hubloc['guid_sig'], - 'url' => $hubloc['hubloc_url'], - 'url_sig' => $hubloc['hubloc_url_sig'] - ); - if(($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize)) - $hubloc['hubloc_primary'] = 0; - if(! zot_gethub($arr)) { - unset($hubloc['hubloc_id']); - dbesc_array($hubloc); - - $r = dbq("INSERT INTO hubloc (`" - . implode("`, `", array_keys($hubloc)) + dbesc_array($profile); + $r = dbq("INSERT INTO profile (`" + . implode("`, `", array_keys($profile)) . "`) VALUES ('" - . implode("', '", array_values($hubloc)) + . implode("', '", array_values($profile)) . "')" ); - } - } + logger('import step 3'); + $_SESSION['import_step'] = 3; + ref_session_write(session_id(), serialize($_SESSION)); } - // 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_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']), - dbesc($channel['channel_guid_sig']), - dbesc($channel['channel_hash']), - dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()), - dbesc('zot'), - intval(($seize) ? 1 : 0), - dbesc(z_root()), - dbesc(base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))), - dbesc(get_app()->get_hostname()), - dbesc(z_root() . '/post'), - dbesc(get_config('system','pubkey')) - ); - - // reset the original primary hubloc if it is being seized - - if($seize) - $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()) - ); - - // import xchans and contact photos - if($seize) { + if($completed < 4) { + $hublocs = $data['hubloc']; + if($hublocs) { + foreach($hublocs as $hubloc) { - // replace any existing xchan we may have on this site if we're seizing control + if(! array_key_exists('hubloc_primary',$hublocs)) { + $hubloc['hubloc_primary'] = (($hubloc['hubloc_flags'] & 0x0001) ? 1 : 0); + $hubloc['hubloc_orphancheck'] = (($hubloc['hubloc_flags'] & 0x0004) ? 1 : 0); + $hubloc['hubloc_error'] = (($hubloc['hubloc_status'] & 0x0003) ? 1 : 0); + $hubloc['hubloc_deleted'] = (($hubloc['hubloc_flags'] & 0x1000) ? 1 : 0); + } - $r = q("delete from xchan where xchan_hash = '%s'", - dbesc($channel['channel_hash']) - ); + $arr = array( + 'guid' => $hubloc['hubloc_guid'], + 'guid_sig' => $hubloc['guid_sig'], + 'url' => $hubloc['hubloc_url'], + 'url_sig' => $hubloc['hubloc_url_sig'] + ); + if(($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize)) + $hubloc['hubloc_primary'] = 0; - $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_hidden, xchan_orphan, xchan_censored, xchan_selfcensored, xchan_system, xchan_pubforum, xchan_deleted ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, %d )", - dbesc($channel['channel_hash']), + if(! zot_gethub($arr)) { + unset($hubloc['hubloc_id']); + dbesc_array($hubloc); + + $r = dbq("INSERT INTO hubloc (`" + . implode("`, `", array_keys($hubloc)) + . "`) VALUES ('" + . implode("', '", array_values($hubloc)) + . "')" ); + } + } + } + logger('import step 4'); + $_SESSION['import_step'] = 4; + ref_session_write(session_id(), serialize($_SESSION)); + } + + if($completed < 5) { + // 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_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']), dbesc($channel['channel_guid_sig']), - dbesc($channel['channel_pubkey']), - dbesc($a->get_baseurl() . "/photo/profile/l/" . $channel['channel_id']), - dbesc($a->get_baseurl() . "/photo/profile/m/" . $channel['channel_id']), - dbesc($a->get_baseurl() . "/photo/profile/s/" . $channel['channel_id']), + dbesc($channel['channel_hash']), dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()), - dbesc(z_root() . '/channel/' . $channel['channel_address']), - dbesc(z_root() . '/follow?f=&url=%s'), - dbesc(z_root() . '/poco/' . $channel['channel_address']), - dbesc($channel['channel_name']), dbesc('zot'), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - 0,0,0,0,0,0,0 + intval(($seize) ? 1 : 0), + dbesc(z_root()), + dbesc(base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))), + dbesc(get_app()->get_hostname()), + dbesc(z_root() . '/post'), + dbesc(get_config('system','pubkey')) ); + + // reset the original primary hubloc if it is being seized + + if($seize) { + $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()) + ); + } + logger('import step 5'); + $_SESSION['import_step'] = 5; + ref_session_write(session_id(), serialize($_SESSION)); } + - $xchans = $data['xchan']; - if($xchans) { - foreach($xchans as $xchan) { - if(! array_key_exists('xchan_hidden',$xchan)) { - $xchan['xchan_hidden'] = (($xchan['xchan_flags'] & 0x0001) ? 1 : 0); - $xchan['xchan_orphan'] = (($xchan['xchan_flags'] & 0x0002) ? 1 : 0); - $xchan['xchan_censored'] = (($xchan['xchan_flags'] & 0x0004) ? 1 : 0); - $xchan['xchan_selfcensored'] = (($xchan['xchan_flags'] & 0x0008) ? 1 : 0); - $xchan['xchan_system'] = (($xchan['xchan_flags'] & 0x0010) ? 1 : 0); - $xchan['xchan_pubforum'] = (($xchan['xchan_flags'] & 0x0020) ? 1 : 0); - $xchan['xchan_deleted'] = (($xchan['xchan_flags'] & 0x1000) ? 1 : 0); - } + if($completed < 6) { + + // import xchans and contact photos + + if($seize) { - $r = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1", - dbesc($xchan['xchan_hash']) + // replace any existing xchan we may have on this site if we're seizing control + + $r = q("delete from xchan where xchan_hash = '%s'", + dbesc($channel['channel_hash']) ); - if($r) - continue; - dbesc_array($xchan); + $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_hidden, xchan_orphan, xchan_censored, xchan_selfcensored, xchan_system, xchan_pubforum, xchan_deleted ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, %d )", + dbesc($channel['channel_hash']), + dbesc($channel['channel_guid']), + dbesc($channel['channel_guid_sig']), + dbesc($channel['channel_pubkey']), + dbesc($a->get_baseurl() . "/photo/profile/l/" . $channel['channel_id']), + dbesc($a->get_baseurl() . "/photo/profile/m/" . $channel['channel_id']), + dbesc($a->get_baseurl() . "/photo/profile/s/" . $channel['channel_id']), + dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()), + dbesc(z_root() . '/channel/' . $channel['channel_address']), + dbesc(z_root() . '/follow?f=&url=%s'), + dbesc(z_root() . '/poco/' . $channel['channel_address']), + dbesc($channel['channel_name']), + dbesc('zot'), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + 0,0,0,0,0,0,0 + ); + } + logger('import step 6'); + $_SESSION['import_step'] = 6; + ref_session_write(session_id(), serialize($_SESSION)); + } + + if($completed < 7) { + + $xchans = $data['xchan']; + if($xchans) { + foreach($xchans as $xchan) { + if(! array_key_exists('xchan_hidden',$xchan)) { + $xchan['xchan_hidden'] = (($xchan['xchan_flags'] & 0x0001) ? 1 : 0); + $xchan['xchan_orphan'] = (($xchan['xchan_flags'] & 0x0002) ? 1 : 0); + $xchan['xchan_censored'] = (($xchan['xchan_flags'] & 0x0004) ? 1 : 0); + $xchan['xchan_selfcensored'] = (($xchan['xchan_flags'] & 0x0008) ? 1 : 0); + $xchan['xchan_system'] = (($xchan['xchan_flags'] & 0x0010) ? 1 : 0); + $xchan['xchan_pubforum'] = (($xchan['xchan_flags'] & 0x0020) ? 1 : 0); + $xchan['xchan_deleted'] = (($xchan['xchan_flags'] & 0x1000) ? 1 : 0); + } + + $r = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1", + dbesc($xchan['xchan_hash']) + ); + if($r) + continue; + + dbesc_array($xchan); - $r = dbq("INSERT INTO xchan (`" - . implode("`, `", array_keys($xchan)) - . "`) VALUES ('" - . implode("', '", array_values($xchan)) - . "')" ); + $r = dbq("INSERT INTO xchan (`" + . implode("`, `", array_keys($xchan)) + . "`) VALUES ('" + . implode("', '", array_values($xchan)) + . "')" ); - require_once('include/photo/photo_driver.php'); - $photos = import_profile_photo($xchan['xchan_photo_l'],$xchan['xchan_hash']); - if($photos[4]) - $photodate = NULL_DATE; - else - $photodate = $xchan['xchan_photo_date']; - - $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s', xchan_photo_date = '%s' - where xchan_hash = '%s'", - dbesc($photos[0]), - dbesc($photos[1]), - dbesc($photos[2]), - dbesc($photos[3]), - dbesc($photodate), - dbesc($xchan['xchan_hash']) - ); + require_once('include/photo/photo_driver.php'); + $photos = import_profile_photo($xchan['xchan_photo_l'],$xchan['xchan_hash']); + if($photos[4]) + $photodate = NULL_DATE; + else + $photodate = $xchan['xchan_photo_date']; + + $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s', xchan_photo_date = '%s' + where xchan_hash = '%s'", + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + dbesc($photos[3]), + dbesc($photodate), + dbesc($xchan['xchan_hash']) + ); + } } + logger('import step 7'); + $_SESSION['import_step'] = 7; + ref_session_write(session_id(), serialize($_SESSION)); } + + // FIXME - ensure we have an xchan if somebody is trying to pull a fast one - - $friends = 0; - $feeds = 0; - - // import contacts - $abooks = $data['abook']; - if($abooks) { - foreach($abooks as $abook) { - if($max_friends !== false && $friends > $max_friends) - continue; - if($max_feeds !== false && intval($abook['abook_feed']) && ($feeds > $max_feeds)) - continue; - unset($abook['abook_id']); - $abook['abook_account'] = get_account_id(); - $abook['abook_channel'] = $channel['channel_id']; - if(! array_key_exists('abook_blocked',$abook)) { - $abook['abook_blocked'] = (($abook['abook_flags'] & 0x0001 ) ? 1 : 0); - $abook['abook_ignored'] = (($abook['abook_flags'] & 0x0002 ) ? 1 : 0); - $abook['abook_hidden'] = (($abook['abook_flags'] & 0x0004 ) ? 1 : 0); - $abook['abook_archived'] = (($abook['abook_flags'] & 0x0008 ) ? 1 : 0); - $abook['abook_pending'] = (($abook['abook_flags'] & 0x0010 ) ? 1 : 0); - $abook['abook_unconnected'] = (($abook['abook_flags'] & 0x0020 ) ? 1 : 0); - $abook['abook_self'] = (($abook['abook_flags'] & 0x0080 ) ? 1 : 0); - $abook['abook_feed'] = (($abook['abook_flags'] & 0x0100 ) ? 1 : 0); - } + if($completed < 8) { + $friends = 0; + $feeds = 0; + + // import contacts + $abooks = $data['abook']; + if($abooks) { + foreach($abooks as $abook) { + if($max_friends !== false && $friends > $max_friends) + continue; + if($max_feeds !== false && intval($abook['abook_feed']) && ($feeds > $max_feeds)) + continue; - if($abook['abook_self']) { - $role = get_pconfig($channel['channel_id'],'system','permissions_role'); - if(($role === 'forum') || ($abook['abook_my_perms'] & PERMS_W_TAGWALL)) { - q("update xchan set xchan_pubforum = 1 where xchan_hash = '%s' ", - dbesc($abook['abook_xchan']) - ); + unset($abook['abook_id']); + unset($abook['abook_rating']); + unset($abook['abook_rating_text']); + $abook['abook_account'] = get_account_id(); + $abook['abook_channel'] = $channel['channel_id']; + if(! array_key_exists('abook_blocked',$abook)) { + $abook['abook_blocked'] = (($abook['abook_flags'] & 0x0001 ) ? 1 : 0); + $abook['abook_ignored'] = (($abook['abook_flags'] & 0x0002 ) ? 1 : 0); + $abook['abook_hidden'] = (($abook['abook_flags'] & 0x0004 ) ? 1 : 0); + $abook['abook_archived'] = (($abook['abook_flags'] & 0x0008 ) ? 1 : 0); + $abook['abook_pending'] = (($abook['abook_flags'] & 0x0010 ) ? 1 : 0); + $abook['abook_unconnected'] = (($abook['abook_flags'] & 0x0020 ) ? 1 : 0); + $abook['abook_self'] = (($abook['abook_flags'] & 0x0080 ) ? 1 : 0); + $abook['abook_feed'] = (($abook['abook_flags'] & 0x0100 ) ? 1 : 0); } - } - dbesc_array($abook); - $r = dbq("INSERT INTO abook (`" - . implode("`, `", array_keys($abook)) - . "`) VALUES ('" - . implode("', '", array_values($abook)) - . "')" ); + if($abook['abook_self']) { + $role = get_pconfig($channel['channel_id'],'system','permissions_role'); + if(($role === 'forum') || ($abook['abook_my_perms'] & PERMS_W_TAGWALL)) { + q("update xchan set xchan_pubforum = 1 where xchan_hash = '%s' ", + dbesc($abook['abook_xchan']) + ); + } + } + + dbesc_array($abook); + $r = dbq("INSERT INTO abook (`" + . implode("`, `", array_keys($abook)) + . "`) VALUES ('" + . implode("', '", array_values($abook)) + . "')" ); - $friends ++; - if(intval($abook['abook_feed'])) - $feeds ++; + $friends ++; + if(intval($abook['abook_feed'])) + $feeds ++; + } } + logger('import step 8'); + $_SESSION['import_step'] = 8; + ref_session_write(session_id(), serialize($_SESSION)); } - $groups = $data['group']; - if($groups) { - $saved = array(); - foreach($groups as $group) { - $saved[$group['hash']] = array('old' => $group['id']); - unset($group['id']); - $group['uid'] = $channel['channel_id']; - dbesc_array($group); - $r = dbq("INSERT INTO groups (`" - . implode("`, `", array_keys($group)) - . "`) VALUES ('" - . implode("', '", array_values($group)) - . "')" ); - } - $r = q("select * from `groups` where uid = %d", - intval($channel['channel_id']) - ); - if($r) { - foreach($r as $rr) { - $saved[$rr['hash']]['new'] = $rr['id']; + if($completed < 9) { + $groups = $data['group']; + if($groups) { + $saved = array(); + foreach($groups as $group) { + $saved[$group['hash']] = array('old' => $group['id']); + unset($group['id']); + $group['uid'] = $channel['channel_id']; + dbesc_array($group); + $r = dbq("INSERT INTO groups (`" + . implode("`, `", array_keys($group)) + . "`) VALUES ('" + . implode("', '", array_values($group)) + . "')" ); } - } - } + $r = q("select * from `groups` where uid = %d", + intval($channel['channel_id']) + ); + if($r) { + foreach($r as $rr) { + $saved[$rr['hash']]['new'] = $rr['id']; + } + } + } + - $group_members = $data['group_member']; - if($groups_members) { - foreach($group_members as $group_member) { - unset($group_member['id']); - $group_member['uid'] = $channel['channel_id']; - foreach($saved as $x) { - if($x['old'] == $group_member['gid']) - $group_member['gid'] = $x['new']; + $group_members = $data['group_member']; + if($group_members) { + foreach($group_members as $group_member) { + unset($group_member['id']); + $group_member['uid'] = $channel['channel_id']; + foreach($saved as $x) { + if($x['old'] == $group_member['gid']) + $group_member['gid'] = $x['new']; + } + dbesc_array($group_member); + $r = dbq("INSERT INTO group_member (`" + . implode("`, `", array_keys($group_member)) + . "`) VALUES ('" + . implode("', '", array_values($group_member)) + . "')" ); } - dbesc_array($group_member); - $r = dbq("INSERT INTO group_member (`" - . implode("`, `", array_keys($group_member)) - . "`) VALUES ('" - . implode("', '", array_values($group_member)) - . "')" ); } + logger('import step 9'); + $_SESSION['import_step'] = 9; + ref_session_write(session_id(), serialize($_SESSION)); } $saved_notification_flags = notifications_off($channel['channel_id']); @@ -544,6 +617,7 @@ function import_post(&$a) { change_channel($channel['channel_id']); + unset($_SESSION['import_step']); goaway(z_root() . '/network' ); } diff --git a/mod/like.php b/mod/like.php index ffd302efa..9077adbda 100755 --- a/mod/like.php +++ b/mod/like.php @@ -242,8 +242,8 @@ 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_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", + and item_type = 0 and item_deleted = 0 and item_unpublished = 0 + and item_delayed = 0 and item_pending_remove = 0 and item_blocked = 0 LIMIT 1", intval($item_id) ); diff --git a/mod/menu.php b/mod/menu.php index f46dc9471..7763c4ed1 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -137,7 +137,9 @@ function menu_content(&$a) { $o = replace_macros(get_markup_template('menuedit.tpl'), array( '$header' => t('Edit Menu'), + '$sys' => $a->is_sys, '$menu_id' => intval(argv(1)), + '$menu_edit_link' => 'mitem/' . intval(argv(1)) . (($a->is_sys) ? '?f=&sys=1' : ''), '$hintedit' => t('Add or remove entries to this menu'), '$editcontents' => t('Edit menu contents'), '$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'), diff --git a/mod/mitem.php b/mod/mitem.php index c4c293d1e..bc93165ac 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -44,9 +44,6 @@ function mitem_post(&$a) { if(! $a->data['menu']) return; - - $channel = $a->get_channel(); - if(!$_REQUEST['mitem_desc'] || !$_REQUEST['mitem_link']) { notice( t('Unable to create element.') . EOL); return; @@ -90,9 +87,6 @@ function mitem_post(&$a) { } - - - } @@ -167,7 +161,8 @@ function mitem_content(&$a) { '$submit_more' => t('Submit and continue'), '$display' => $display, '$lockstate' => $lockstate, - '$menu_names' => $menu_names + '$menu_names' => $menu_names, + '$sys' => $a->is_sys )); $o .= replace_macros(get_markup_template('mitemlist.tpl'),array( diff --git a/mod/photo.php b/mod/photo.php index 2e16fc1d9..e8cd95f1c 100644 --- a/mod/photo.php +++ b/mod/photo.php @@ -123,7 +123,7 @@ function photo_init(&$a) { ); if($r) { - $allowed = (($r[0]['uid']) ? perm_is_allowed($r[0]['uid'],$observer_xchan,'view_photos') : true); + $allowed = (($r[0]['uid']) ? perm_is_allowed($r[0]['uid'],$observer_xchan,'view_storage') : true); $sql_extra = permissions_sql($r[0]['uid']); diff --git a/mod/photos.php b/mod/photos.php index c65c87c27..b65218e94 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -63,7 +63,7 @@ function photos_post(&$a) { $page_owner_uid = $a->data['channel']['channel_id']; - if(perm_is_allowed($page_owner_uid,get_observer_hash(),'post_photos')) + if(perm_is_allowed($page_owner_uid,get_observer_hash(),'write_storage')) $can_post = true; if(! $can_post) { @@ -495,8 +495,8 @@ function photos_content(&$a) { $observer = $a->get_observer(); - $can_post = perm_is_allowed($owner_uid,$observer['xchan_hash'],'post_photos'); - $can_view = perm_is_allowed($owner_uid,$observer['xchan_hash'],'view_photos'); + $can_post = perm_is_allowed($owner_uid,$observer['xchan_hash'],'write_storage'); + $can_view = perm_is_allowed($owner_uid,$observer['xchan_hash'],'view_storage'); if(! $can_view) { notice( t('Access to this item is restricted.') . EOL); diff --git a/mod/profile_photo.php b/mod/profile_photo.php index de2a538f1..13923a655 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -135,7 +135,7 @@ function profile_photo_post(&$a) { $im = photo_factory($base_image['data'], $base_image['type']); if($im->is_valid()) { - $im->cropImage(175,$srcX,$srcY,$srcW,$srcH); + $im->cropImage(300,$srcX,$srcY,$srcW,$srcH); $aid = get_account_id(); @@ -412,7 +412,7 @@ function profile_photo_crop_ui_head(&$a, $ph, $hash, $smallest){ $width = $ph->getWidth(); $height = $ph->getHeight(); - if($width < 175 || $height < 175) { + if($width < 300 || $height < 300) { $ph->scaleImageUp(200); $width = $ph->getWidth(); $height = $ph->getHeight(); diff --git a/mod/setup.php b/mod/setup.php index d88cf73f1..bba29921e 100755 --- a/mod/setup.php +++ b/mod/setup.php @@ -729,6 +729,6 @@ function what_next() { ."<p>".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.') .t('Please see the file "install/INSTALL.txt".') ."</p><p>" - .t("Go to your new Red node <a href='$baseurl/register'>registration page</a> and register as new user. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.") + .t("Go to your new hub <a href='$baseurl/register'>registration page</a> and register as new member. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.") ."</p>"; } diff --git a/mod/uexport.php b/mod/uexport.php index edcb2fa84..8217a17c4 100644 --- a/mod/uexport.php +++ b/mod/uexport.php @@ -9,9 +9,17 @@ function uexport_init(&$a) { require_once('include/identity.php'); + if(argc() > 1 && intval(argv(1)) > 1900) { + $year = intval(argv(1)); + } + header('content-type: application/octet_stream'); - header('content-disposition: attachment; filename="' . $channel['channel_address'] . '.json"' ); + header('content-disposition: attachment; filename="' . $channel['channel_address'] . (($year) ? '-' . $year : '') . '.json"' ); + if($year) { + echo json_encode(identity_export_year(local_channel(),$year)); + killme(); + } if(argc() > 1 && argv(1) === 'basic') { echo json_encode(identity_basic_export(local_channel())); @@ -34,7 +42,9 @@ function uexport_content(&$a) { '$basictitle' => t('Export Channel'), '$basic' => t('Export your basic channel information to a small file. This acts as a backup of your connections, permissions, profile and basic data, which can be used to import your data to a new hub, but does not contain your content.'), '$fulltitle' => t('Export Content'), - '$full' => t('Export your channel information and all the content to a JSON backup. This backs up all of your connections, permissions, profile data and all of your content, but is generally not suitable for importing a channel to a new hub as this file may be VERY large. Please be patient - it may take several minutes for this download to begin.') + '$full' => t('Export your channel information and all the content to a JSON backup. This backs up all of your connections, permissions, profile data and the last year of posts. This file may be VERY large. Please be patient - it may take several minutes for this download to begin.'), + '$by_year' => t('Export your posts from a given year.'), + )); return $o; } |