* posting categories go through item_store() instead of this function.
*/
+use Friendica\App;
+
require_once 'include/crypto.php';
require_once 'include/enotify.php';
require_once 'include/email.php';
require_once 'include/threads.php';
require_once 'include/text.php';
require_once 'include/items.php';
-require_once 'include/Scrape.php';
+require_once 'include/probe.php';
require_once 'include/diaspora.php';
require_once 'include/Contact.php';
function item_post(App $a) {
- if ((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter'))) {
+ if ((! local_user()) && (! remote_user()) && (! x($_REQUEST, 'commenter'))) {
return;
}
- require_once('include/security.php');
+ require_once 'include/security.php';
$uid = local_user();
}
// Is this a reply to something?
- $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0);
- $parent_uri = ((x($_REQUEST,'parent_uri')) ? trim($_REQUEST['parent_uri']) : '');
+ $parent = ((x($_REQUEST, 'parent')) ? intval($_REQUEST['parent']) : 0);
+ $parent_uri = ((x($_REQUEST, 'parent_uri')) ? trim($_REQUEST['parent_uri']) : '');
$parent_item = null;
$parent_contact = null;
$objecttype = ACTIVITY_OBJ_COMMENT;
- if (! x($_REQUEST,'type')) {
+ if (! x($_REQUEST, 'type')) {
$_REQUEST['type'] = 'net-comment';
}
if (! dbm::is_result($r)) {
notice( t('Unable to locate original post.') . EOL);
- if (x($_REQUEST,'return')) {
+ if (x($_REQUEST, 'return')) {
goaway($return_path);
}
killme();
$parent_contact = get_contact_details_by_url($thrparent[0]["author-link"]);
if (!isset($parent_contact["nick"])) {
- require_once("include/Scrape.php");
$probed_contact = probe_url($thrparent[0]["author-link"]);
if ($probed_contact["network"] != NETWORK_FEED) {
$parent_contact = $probed_contact;
logger('mod_item: item_post parent=' . $parent);
}
- $profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0);
- $post_id = ((x($_REQUEST,'post_id')) ? intval($_REQUEST['post_id']) : 0);
- $app = ((x($_REQUEST,'source')) ? strip_tags($_REQUEST['source']) : '');
- $extid = ((x($_REQUEST,'extid')) ? strip_tags($_REQUEST['extid']) : '');
- $object = ((x($_REQUEST,'object')) ? $_REQUEST['object'] : '');
+ $profile_uid = ((x($_REQUEST, 'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0);
+ $post_id = ((x($_REQUEST, 'post_id')) ? intval($_REQUEST['post_id']) : 0);
+ $app = ((x($_REQUEST, 'source')) ? strip_tags($_REQUEST['source']) : '');
+ $extid = ((x($_REQUEST, 'extid')) ? strip_tags($_REQUEST['extid']) : '');
+ $object = ((x($_REQUEST, 'object')) ? $_REQUEST['object'] : '');
// Check for multiple posts with the same message id (when the post was created via API)
if (($message_id != '') AND ($profile_uid != 0)) {
* use the user default permissions - as they won't have
* been supplied via a form.
*/
-
+ /// @TODO use x($_REQUEST, 'foo') here
if (($api_source)
- && (! array_key_exists('contact_allow',$_REQUEST))
- && (! array_key_exists('group_allow',$_REQUEST))
- && (! array_key_exists('contact_deny',$_REQUEST))
- && (! array_key_exists('group_deny',$_REQUEST))) {
+ && (! array_key_exists('contact_allow', $_REQUEST))
+ && (! array_key_exists('group_allow', $_REQUEST))
+ && (! array_key_exists('contact_deny', $_REQUEST))
+ && (! array_key_exists('group_deny', $_REQUEST))) {
$str_group_allow = $user['allow_gid'];
$str_contact_allow = $user['allow_cid'];
$str_group_deny = $user['deny_gid'];
// if using the API, we won't see pubmail_enable - figure out if it should be set
if ($api_source && $profile_uid && $profile_uid == local_user() && (! $private)) {
- $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
+ $mail_disabled = ((function_exists('imap_open') && (! get_config('system', 'imap_disabled'))) ? 0 : 1);
if (! $mail_disabled) {
+ /// @TODO Check if only pubmail is loaded, * loads all columns
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user())
);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval($_SESSION['uid']));
} elseif(remote_user()) {
- if (is_array($_SESSION['remote'])) {
+ if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $v) {
if ($v['uid'] == $profile_uid) {
$contact_id = $v['cid'];
// Fold multi-line [code] sequences
$body = preg_replace('/\[\/code\]\s*\[code\]/ism', "\n", $body);
- $body = scale_external_images($body,false);
+ $body = scale_external_images($body, false);
// Setting the object type if not defined before
if (!$objecttype) {
$objecttype = ACTIVITY_OBJ_NOTE; // Default value
- require_once("include/plaintext.php");
+ require_once 'include/plaintext.php';
$objectdata = get_attached_data($body);
if ($post["type"] == "link") {
if ($parent AND ($parent_contact['network'] == NETWORK_OSTATUS)) {
$contact = '@[url=' . $parent_contact['url'] . ']' . $parent_contact['nick'] . '[/url]';
- if (!in_array($contact,$tags)) {
- $body = $contact.' '.$body;
+ if (!in_array($contact, $tags)) {
+ $body = $contact . ' ' . $body;
$tags[] = $contact;
}
$toplevel_contact = '@' . $toplevel_parent[0]['nick'] . '+' . $toplevel_parent[0]['id'];
} else {
$toplevel_parent = q("SELECT `author-link`, `author-name` FROM `item` WHERE `id` = `parent` AND `parent` = %d", intval($parent));
- $toplevel_contact = '@[url='.$toplevel_parent[0]['author-link'].']'.$toplevel_parent[0]['author-name'].'[/url]';
+ $toplevel_contact = '@[url=' . $toplevel_parent[0]['author-link'] . ']' . $toplevel_parent[0]['author-name'] . '[/url]';
}
- if (!in_array($toplevel_contact, $tags)) [
+ if (!in_array($toplevel_contact, $tags)) {
$tags[] = $toplevel_contact;
}
}
* Robert Johnson should be first in the $tags array
*/
$fullnametagged = false;
- for ($x = 0; $x < count($tagged); $x ++) {
- if (stristr($tagged[$x],$tag . ' ')) {
+ /// @TODO $tagged is initialized above if() block and is not filled, maybe old-lost code?
+ foreach ($tagged as $nextTag) {
+ if (stristr($nextTag, $tag . ' ')) {
$fullnametagged = true;
break;
}
// even if the post arrived via API we are considering that it
// originated on this site by default for determining relayability.
- $origin = ((x($_REQUEST,'origin')) ? intval($_REQUEST['origin']) : 1);
+ $origin = ((x($_REQUEST, 'origin')) ? intval($_REQUEST['origin']) : 1);
$notify_type = (($parent) ? 'comment-new' : 'wall-new' );
$datarray['last-child'] = 1;
$datarray['visible'] = 1;
+ $datarray['protocol'] = PROTOCOL_DFRN;
+
+ $r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $datarray['parent-uri']);
+ if (dbm::is_result($r)) {
+ if ($r['conversation-uri'] != '') {
+ $datarray['conversation-uri'] = $r['conversation-uri'];
+ }
+ if ($r['conversation-href'] != '') {
+ $datarray['conversation-href'] = $r['conversation-href'];
+ }
+ }
+
if ($orig_post) {
$datarray['edit'] = true;
}
// preview mode - prepare the body for display and send it via json
if ($preview) {
- require_once('include/conversation.php');
+ require_once 'include/conversation.php';
// We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID.
$datarray["id"] = -1;
}
$json = array('cancel' => 1);
- if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) {
+ if (x($_REQUEST, 'jsreload') && strlen($_REQUEST['jsreload'])) {
$json['reload'] = App::get_baseurl() . '/' . $_REQUEST['jsreload'];
}
// Fill the cache field
put_item_in_cache($datarray);
+ $datarray = store_conversation($datarray);
+
if ($orig_post) {
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($datarray['title']),
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
proc_run(PRIORITY_HIGH, "include/notifier.php", 'edit_post', $post_id);
- if ((x($_REQUEST,'return')) && strlen($return_path)) {
+ if ((x($_REQUEST, 'return')) && strlen($return_path)) {
logger('return: ' . $return_path);
goaway($return_path);
}
$post_id = 0;
}
- q("COMMIT");
- q("START TRANSACTION;");
+ dba::transaction();
$r = q("INSERT INTO `item` (`guid`, `extid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,
`owner-name`,`owner-link`,`owner-avatar`, `owner-id`,
}
if ($post_id == 0) {
- q("COMMIT");
+ dba::commit();
logger('mod_item: unable to retrieve post that was just stored.');
notice(t('System error. Post not saved.') . EOL);
goaway($return_path);
if (! strlen($addr)) {
continue;
}
- $disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
+ $disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'), $a->user['username'])
. '<br />';
$disclaimer .= sprintf( t('You may visit them online at %s'), App::get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
$disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
$link = '<a href="' . App::get_baseurl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
$html = prepare_body($datarray);
$message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';
- include_once('include/html2plain.php');
+ include_once 'include/html2plain.php';
$params = array (
'fromName' => $a->user['username'],
'fromEmail' => $a->user['email'],
update_thread($parent, true);
}
- q("COMMIT");
+ dba::commit();
create_tags_from_item($post_id);
create_files_from_item($post_id);
}
$json = array('success' => 1);
- if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) {
+ if (x($_REQUEST, 'jsreload') && strlen($_REQUEST['jsreload'])) {
$json['reload'] = $baseurl . '/' . $_REQUEST['jsreload'];
}
return;
}
- require_once('include/security.php');
+ require_once 'include/security.php';
$o = '';
if (($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
*
* @return boolean true if replaced, false if not replaced
*/
-function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $network = "") {
- require_once("include/Scrape.php");
- require_once("include/socgraph.php");
+function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $network = "") {
+ require_once 'include/socgraph.php';
$replaced = false;
$r = null;
//is it already replaced?
if (strpos($tag, '[url=')) {
//append tag to str_tags
- if (!stristr($str_tags,$tag)) {
+ if (!stristr($str_tags, $tag)) {
if (strlen($str_tags)) {
$str_tags .= ',';
}
}
} else {
$r = false;
- if (strrpos($name,'+')) {
+ if (strrpos($name, '+')) {
// Is it in format @nick+number?
- $tagcid = intval(substr($name,strrpos($name,'+') + 1));
+ $tagcid = intval(substr($name, strrpos($name, '+') + 1));
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($tagcid),
$replaced = true;
// create profile link
- $profile = str_replace(',','%2c',$profile);
- $newtag = '@[url='.$profile.']'.$newname.'[/url]';
- $body = str_replace('@'.$name, $newtag, $body);
+ $profile = str_replace(',', '%2c', $profile);
+ $newtag = '@[url=' . $profile . ']' . $newname . '[/url]';
+ $body = str_replace('@' . $name, $newtag, $body);
// append tag to str_tags
- if (! stristr($str_tags,$newtag)) {
+ if (! stristr($str_tags, $newtag)) {
if (strlen($str_tags)) {
$str_tags .= ',';
}
$str_tags .= $newtag;
}
- // Status.Net seems to require the numeric ID URL in a mention if the person isn't
- // subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both.
+ /*
+ * Status.Net seems to require the numeric ID URL in a mention if the person isn't
+ * subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both.
+ */
if (strlen($alias)) {
- $newtag = '@[url='.$alias.']'.$newname.'[/url]';
- if (! stristr($str_tags,$newtag)) {
+ $newtag = '@[url=' . $alias . ']' . $newname . '[/url]';
+ if (! stristr($str_tags, $newtag)) {
if (strlen($str_tags)) {
$str_tags .= ',';
}