]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
Use Model\Photo as much as possible
[friendica.git] / mod / item.php
index 507185e7c264ee04580818ad8977dde1541e36b2..cc9de0dd60bb114fc7d44f567d8260bfb8b8fb58 100644 (file)
@@ -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;
@@ -166,7 +163,7 @@ function item_post(App $a) {
 
        // Now check that valid personal details have been provided
        if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) {
-               notice(L10n::t('Permission denied.') . EOL) ;
+               notice(L10n::t('Permission denied.') . EOL);
 
                if (!empty($_REQUEST['return'])) {
                        $a->internalRedirect($return_path);
@@ -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' => '',
+                                       'uid' => $profile_uid
+                               ];
+                               if (!Photo::exists($image_uri, $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, 'album' => L10n::t('Wall Photos')];
-                               DBA::update('photo', $fields, $condition);
+                               $condition = ['resource-id' => $image_uri, 'uid' => $profile_uid];
+                               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;
@@ -690,7 +688,7 @@ function item_post(App $a) {
                }
 
                $json = ['cancel' => 1];
-               if (!empty($_REQUEST['jsreload']) && strlen($_REQUEST['jsreload'])) {
+               if (!empty($_REQUEST['jsreload'])) {
                        $json['reload'] = System::baseUrl() . '/' . $_REQUEST['jsreload'];
                }
 
@@ -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;
@@ -869,7 +867,7 @@ function item_post_return($baseurl, $api_source, $return_path)
        }
 
        $json = ['success' => 1];
-       if (!empty($_REQUEST['jsreload']) && strlen($_REQUEST['jsreload'])) {
+       if (!empty($_REQUEST['jsreload'])) {
                $json['reload'] = $baseurl . '/' . $_REQUEST['jsreload'];
        }