]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
Replace deprecated Addon::callHooks with Hook::callAll
[friendica.git] / mod / item.php
index cc801df57c1b62ce0d0878332807c3449c9109b2..3d6d886eeb33042f05457529edf9bc0cb150fd56 100644 (file)
@@ -19,8 +19,8 @@ use Friendica\App;
 use Friendica\Content\Pager;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
-use Friendica\Core\Addon;
 use Friendica\Core\Config;
+use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
@@ -31,6 +31,7 @@ use Friendica\Model\Contact;
 use Friendica\Model\Conversation;
 use Friendica\Model\FileTag;
 use Friendica\Model\Item;
+use Friendica\Model\Photo;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\Email;
 use Friendica\Util\DateTimeFormat;
@@ -38,10 +39,6 @@ use Friendica\Util\Emailer;
 use Friendica\Util\Security;
 use Friendica\Util\Strings;
 
-require_once 'include/enotify.php';
-require_once 'include/text.php';
-require_once 'include/items.php';
-
 function item_post(App $a) {
        if (!local_user() && !remote_user()) {
                return 0;
@@ -54,10 +51,10 @@ function item_post(App $a) {
                drop_items($arr_drop);
                $json = ['success' => 1];
                echo json_encode($json);
-               killme();
+               exit();
        }
 
-       Addon::callHooks('post_local_start', $_REQUEST);
+       Hook::callAll('post_local_start', $_REQUEST);
 
        Logger::log('postvars ' . print_r($_REQUEST, true), Logger::DATA);
 
@@ -121,7 +118,7 @@ function item_post(App $a) {
                        if (!empty($_REQUEST['return'])) {
                                $a->internalRedirect($return_path);
                        }
-                       killme();
+                       exit();
                }
 
                $parent = $parent_item['id'];
@@ -172,7 +169,7 @@ function item_post(App $a) {
                        $a->internalRedirect($return_path);
                }
 
-               killme();
+               exit();
        }
 
        // Init post instance
@@ -283,13 +280,13 @@ function item_post(App $a) {
 
                if (!strlen($body)) {
                        if ($preview) {
-                               killme();
+                               exit();
                        }
                        info(L10n::t('Empty post discarded.') . EOL);
                        if (!empty($_REQUEST['return'])) {
                                $a->internalRedirect($return_path);
                        }
-                       killme();
+                       exit();
                }
        }
 
@@ -460,16 +457,18 @@ function item_post(App $a) {
                                // Ensure to only modify photos that you own
                                $srch = '<' . intval($original_contact_id) . '>';
 
-                               $condition = ['allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '',
-                                               'resource-id' => $image_uri, 'uid' => $profile_uid];
-                               if (!DBA::exists('photo', $condition)) {
+                               $condition = [
+                                       'allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '',
+                                       'resource-id' => $image_uri, 'uid' => $profile_uid
+                               ];
+                               if (!Photo::exists($condition)) {
                                        continue;
                                }
 
                                $fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
                                                'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny];
                                $condition = ['resource-id' => $image_uri, 'uid' => $profile_uid];
-                               DBA::update('photo', $fields, $condition);
+                               Photo::update($fields, $condition);
                        }
                }
        }
@@ -668,7 +667,6 @@ function item_post(App $a) {
 
        // preview mode - prepare the body for display and send it via json
        if ($preview) {
-               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;
@@ -681,7 +679,7 @@ function item_post(App $a) {
                exit();
        }
 
-       Addon::callHooks('post_local',$datarray);
+       Hook::callAll('post_local',$datarray);
 
        if (!empty($datarray['cancel'])) {
                Logger::log('mod_item: post cancelled by addon.');
@@ -695,7 +693,7 @@ function item_post(App $a) {
                }
 
                echo json_encode($json);
-               killme();
+               exit();
        }
 
        if ($orig_post) {
@@ -723,7 +721,7 @@ function item_post(App $a) {
                        Logger::log('return: ' . $return_path);
                        $a->internalRedirect($return_path);
                }
-               killme();
+               exit();
        } else {
                $post_id = 0;
        }
@@ -797,7 +795,7 @@ function item_post(App $a) {
                }
        }
 
-       Addon::callHooks('post_local_end', $datarray);
+       Hook::callAll('post_local_end', $datarray);
 
        if (strlen($emailcc) && $profile_uid == local_user()) {
                $erecips = explode(',', $emailcc);
@@ -858,7 +856,7 @@ function item_post(App $a) {
 function item_post_return($baseurl, $api_source, $return_path)
 {
        // figure out how to return, depending on from whence we came
-    $a = get_app();
+    $a = \get_app();
 
        if ($api_source) {
                return;
@@ -876,7 +874,7 @@ function item_post_return($baseurl, $api_source, $return_path)
        Logger::log('post_json: ' . print_r($json, true), Logger::DEBUG);
 
        echo json_encode($json);
-       killme();
+       exit();
 }
 
 function item_content(App $a)
@@ -902,7 +900,7 @@ function item_content(App $a)
                if ($a->isAjax()) {
                        // ajax return: [<item id>, 0 (no perm) | <owner id>]
                        echo json_encode([intval($a->argv[2]), intval($o)]);
-                       killme();
+                       exit();
                }
        }
 
@@ -914,7 +912,7 @@ function item_content(App $a)
  * the appropiate link.
  *
  * @param App $a Application instance @TODO is unused in this function's scope (excluding included files)
- * @param unknown_type $body the text to replace the tag in
+ * @param string $body the text to replace the tag in
  * @param string $inform a comma-seperated string containing everybody to inform
  * @param string $str_tags string to add the tag to
  * @param integer $profile_uid