[Doc] Rearranged and wrote some parts new and more coherent.
// locate item to be deleted
- $fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity'];
+ $fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', parent];
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $id]);
if (!DBA::isResult($item)) {
}
$is_comment = ($item['gravity'] == GRAVITY_COMMENT) ? true : false;
+ $parentitem = null;
+ if (!empty($item['parent'])){
+ $fields = ['guid'];
+ $parentitem = Item::selectFirstForUser(local_user(), $fields, ['id' => $item['parent']]);
+ }
// delete the item
Item::deleteForUser(['id' => $item['id']], local_user());
// removes update_* from return_url to ignore Ajax refresh
$return_url = str_replace("update_", "", $return_url);
- // if unknown location or top level post called from display
- if (empty($return_url) || ((strpos($return_url, 'display') !== false) AND (!$is_comment))) {
- $a->internalRedirect('network');
- //NOTREACHED
+ // Check if delete a comment
+ if ($is_comment) {
+ // Return to parent guid
+ if (!empty($parentitem)) {
+ $a->internalRedirect('display/' . $parentitem['guid']);
+ //NOTREACHED
+ }
+ // In case something goes wrong
+ else {
+ $a->internalRedirect('network');
+ //NOTREACHED
+ }
}
else {
- $a->internalRedirect($return_url);
- //NOTREACHED
+ // if unknown location or deleting top level post called from display
+ if (empty($return_url) || strpos($return_url, 'display') !== false) {
+ $a->internalRedirect('network');
+ //NOTREACHED
+ } else {
+ $a->internalRedirect($return_url);
+ //NOTREACHED
+ }
}
} else {
notice(L10n::t('Permission denied.') . EOL);
public static function networkToName($network, $profile = "")
{
$nets = [
- Protocol::DFRN => L10n::t('Friendica'),
+ Protocol::DFRN => L10n::t('DFRN'),
Protocol::OSTATUS => L10n::t('OStatus'),
Protocol::FEED => L10n::t('RSS/Atom'),
Protocol::MAIL => L10n::t('Email'),
['archives', L10n::t('Archives'), L10n::t('Ability to select posts by date ranges'), false, Config::get('feature_lock', 'archives', false)],
['forumlist_widget', L10n::t('List Forums'), L10n::t('Enable widget to display the forums your are connected with'), true, Config::get('feature_lock', 'forumlist_widget', false)],
['groups', L10n::t('Group Filter'), L10n::t('Enable widget to display Network posts only from selected group'), false, Config::get('feature_lock', 'groups', false)],
- ['networks', L10n::t('Network Filter'), L10n::t('Enable widget to display Network posts only from selected network'), false, Config::get('feature_lock', 'networks', false)],
+ ['networks', L10n::t('Protocol Filter'), L10n::t('Enable widget to display Network posts only from selected protocols'), false, Config::get('feature_lock', 'networks', false)],
['savedsearch', L10n::t('Saved Searches'), L10n::t('Save search terms for re-use'), false, Config::get('feature_lock', 'savedsearch', false)],
],
}
return Renderer::replaceMacros(Renderer::getMarkupTemplate('nets.tpl'), array(
- '$title' => L10n::t('Networks'),
+ '$title' => L10n::t('Protocols'),
'$desc' => '',
'$sel_all' => (($selected == '') ? 'selected' : ''),
- '$all' => L10n::t('All Networks'),
+ '$all' => L10n::t('All Protocols'),
'$nets' => $nets,
'$base' => $baseurl,
));
* @param object $doc XML document
* @param array $owner Contact data of the poster
* @param string $filter The related feed filter (activity, posts or comments)
+ * @param bool $feed_mode Behave like a regular feed for users if true
*
* @return object header root element
*/
- private static function addHeader(DOMDocument $doc, array $owner, $filter)
+ private static function addHeader(DOMDocument $doc, array $owner, $filter, $feed_mode = false)
{
$a = get_app();
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
$title = '';
+ $selfUri = '/feed/' . $owner["nick"] . '/';
switch ($filter) {
- case 'activity': $title = L10n::t('%s\'s timeline', $owner['name']); break;
- case 'posts' : $title = L10n::t('%s\'s posts' , $owner['name']); break;
- case 'comments': $title = L10n::t('%s\'s comments', $owner['name']); break;
+ case 'activity':
+ $title = L10n::t('%s\'s timeline', $owner['name']);
+ $selfUri .= $filter;
+ break;
+ case 'posts':
+ $title = L10n::t('%s\'s posts', $owner['name']);
+ break;
+ case 'comments':
+ $title = L10n::t('%s\'s comments', $owner['name']);
+ $selfUri .= $filter;
+ break;
+ }
+
+ if (!$feed_mode) {
+ $selfUri = "/dfrn_poll/" . $owner["nick"];
}
$attributes = ["uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION];
$attributes = ["href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-mention"];
XML::addElement($doc, $root, "link", "", $attributes);
- $attributes = ["href" => System::baseUrl() . "/dfrn_poll/" . $owner["nick"],
- "rel" => "self", "type" => "application/atom+xml"];
+ $attributes = ["href" => System::baseUrl() . $selfUri, "rel" => "self", "type" => "application/atom+xml"];
XML::addElement($doc, $root, "link", "", $attributes);
if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
- $root = self::addHeader($doc, $owner, $filter);
+ $root = self::addHeader($doc, $owner, $filter, $feed_mode);
foreach ($items as $item) {
if (Config::get('system', 'ostatus_debug')) {