use Friendica\BaseObject;
use Friendica\Content\Feature;
-use Friendica\Core\Addon;
use Friendica\Core\Config;
+use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\PConfig;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
-require_once 'include/text.php';
require_once 'mod/share.php';
-require_once 'include/enotify.php';
-
function add_page_info_data(array $data, $no_photos = false)
{
- Addon::callHooks('page_info_data', $data);
+ Hook::callAll('page_info_data', $data);
if (empty($data['type'])) {
return '';
/// @TODO make a positive list of allowed characters
$hashtag = str_replace([" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"],
["", "", "", "", "", "", "", "", "", "", "", ""], $keyword);
- $hashtags .= "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url] ";
+ $hashtags .= "#[url=" . System::baseUrl() . "/search?tag=" . $hashtag . "]" . $hashtag . "[/url] ";
}
}
$tags .= ", ";
}
- $tags .= "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url]";
+ $tags .= "#[url=" . System::baseUrl() . "/search?tag=" . $hashtag . "]" . $hashtag . "[/url]";
}
}
$body = $removedlink;
}
- $url = str_replace(['/', '.'], ['\/', '\.'], $matches[1]);
- $removedlink = preg_replace("/\[url\=" . $url . "\](.*?)\[\/url\]/ism", '', $body);
+ $removedlink = preg_replace("/\[url\=" . preg_quote($matches[1], '/') . "\](.*?)\[\/url\]/ism", '', $body);
if (($removedlink == "") || strstr($body, $removedlink)) {
$body = $removedlink;
}
* model where comments can have sub-threads. That would require some massive sorting
* to get all the feed items into a mostly linear ordering, and might still require
* recursion.
+ *
+ * @param $xml
+ * @param array $importer
+ * @param array $contact
+ * @param $hub
+ * @throws ImagickException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
-function consume_feed($xml, array $importer, array $contact, &$hub, $datedir = 0, $pass = 0)
+function consume_feed($xml, array $importer, array $contact, &$hub)
{
if ($contact['network'] === Protocol::OSTATUS) {
- if ($pass < 2) {
- // Test - remove before flight
- //$tempfile = tempnam(get_temppath(), "ostatus2");
- //file_put_contents($tempfile, $xml);
- Logger::log("Consume OStatus messages ", Logger::DEBUG);
- OStatus::import($xml, $importer, $contact, $hub);
- }
+ Logger::log("Consume OStatus messages ", Logger::DEBUG);
+ OStatus::import($xml, $importer, $contact, $hub);
return;
}
if ($contact['network'] === Protocol::FEED) {
- if ($pass < 2) {
- Logger::log("Consume feeds", Logger::DEBUG);
- Feed::import($xml, $importer, $contact, $hub);
- }
+ Logger::log("Consume feeds", Logger::DEBUG);
+ Feed::import($xml, $importer, $contact, $hub);
return;
}
return;
}
- $a = BaseObject::getApp();
-
$user = DBA::selectFirst('user', ['nickname'], ['uid' => $importer['uid']]);
// No user, no nickname, we quit
// 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);