]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Remove library/jgrowl
[friendica.git] / include / api.php
index 21db40433a88fe1ab46ed1ed30979e33cbd67a5f..8579d2d185b9a6b2c81bbb4a88acb3a4b2160c5a 100644 (file)
@@ -8,9 +8,12 @@
 use Friendica\App;
 use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
+use Friendica\Content\Text\BBCode;
+use Friendica\Core\Addon;
 use Friendica\Core\System;
 use Friendica\Core\Config;
 use Friendica\Core\NotificationsManager;
+use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
@@ -19,6 +22,7 @@ use Friendica\Model\Group;
 use Friendica\Model\Mail;
 use Friendica\Model\Photo;
 use Friendica\Model\User;
+use Friendica\Model\Item;
 use Friendica\Network\FKOAuth1;
 use Friendica\Network\HTTPException;
 use Friendica\Network\HTTPException\BadRequestException;
@@ -44,7 +48,6 @@ require_once 'include/html2bbcode.php';
 require_once 'mod/wall_upload.php';
 require_once 'mod/proxy.php';
 require_once 'include/like.php';
-require_once 'include/plaintext.php';
 
 define('API_METHOD_ANY', '*');
 define('API_METHOD_GET', 'GET');
@@ -165,7 +168,7 @@ function api_login(App $a)
                list($consumer, $token) = $oauth1->verify_request(OAuthRequest::from_request());
                if (!is_null($token)) {
                        $oauth1->loginUser($token->uid);
-                       call_hooks('logged_in', $a->user);
+                       Addon::callHooks('logged_in', $a->user);
                        return;
                }
                echo __FILE__.__LINE__.__FUNCTION__ . "<pre>";
@@ -211,11 +214,11 @@ function api_login(App $a)
        ];
 
        /*
-               * A plugin indicates successful login by setting 'authenticated' to non-zero value and returning a user record
-               * Plugins should never set 'authenticated' except to indicate success - as hooks may be chained
-               * and later plugins should not interfere with an earlier one that succeeded.
-               */
-       call_hooks('authenticate', $addon_auth);
+       * An addon indicates successful login by setting 'authenticated' to non-zero value and returning a user record
+       * Addons should never set 'authenticated' except to indicate success - as hooks may be chained
+       * and later addons should not interfere with an earlier one that succeeded.
+       */
+       Addon::callHooks('authenticate', $addon_auth);
 
        if ($addon_auth['authenticated'] && count($addon_auth['user_record'])) {
                $record = $addon_auth['user_record'];
@@ -238,7 +241,7 @@ function api_login(App $a)
 
        $_SESSION["allow_api"] = true;
 
-       call_hooks('logged_in', $a->user);
+       Addon::callHooks('logged_in', $a->user);
 }
 
 /**
@@ -1174,8 +1177,8 @@ function api_statuses_update($type)
 
                        if ($posts_day > $throttle_day) {
                                logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG);
-                               // die(api_error($type, sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day)));
-                               throw new TooManyRequestsException(sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day));
+                               // die(api_error($type, L10n::t("Daily posting limit of %d posts reached. The post was rejected.", $throttle_day));
+                               throw new TooManyRequestsException(L10n::tt("Daily posting limit of %d post reached. The post was rejected.", "Daily posting limit of %d posts reached. The post was rejected.", $throttle_day));
                        }
                }
 
@@ -1198,8 +1201,8 @@ function api_statuses_update($type)
 
                        if ($posts_week > $throttle_week) {
                                logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG);
-                               // die(api_error($type, sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week)));
-                               throw new TooManyRequestsException(sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week));
+                               // die(api_error($type, L10n::t("Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week)));
+                               throw new TooManyRequestsException(L10n::tt("Weekly posting limit of %d post reached. The post was rejected.", "Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week));
                        }
                }
 
@@ -1222,8 +1225,8 @@ function api_statuses_update($type)
 
                        if ($posts_month > $throttle_month) {
                                logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG);
-                               // die(api_error($type, sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month)));
-                               throw new TooManyRequestsException(sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month));
+                               // die(api_error($type, L10n::t("Monthly posting limit of %d posts reached. The post was rejected.", $throttle_month));
+                               throw new TooManyRequestsException(L10n::t("Monthly posting limit of %d post reached. The post was rejected.", "Monthly posting limit of %d posts reached. The post was rejected.", $throttle_month));
                        }
                }
 
@@ -2214,7 +2217,7 @@ function api_statuses_destroy($type)
 
        $ret = api_statuses_show($type);
 
-       drop_item($id, false);
+       Item::delete($id);
 
        return $ret;
 }
@@ -3987,7 +3990,7 @@ function api_fr_photoalbum_delete($type)
                if (!DBM::is_result($photo_item)) {
                        throw new InternalServerErrorException("problem with deleting items occured");
                }
-               drop_item($photo_item[0]['id'], false);
+               Item::delete($photo_item[0]['id']);
        }
 
        // now let's delete all photos from the album
@@ -4290,7 +4293,7 @@ function api_fr_photo_delete($type)
                }
                // function for setting the items to "deleted = 1" which ensures that comments, likes etc. are not shown anymore
                // to the user and the contacts of the users (drop_items() do all the necessary magic to avoid orphans in database and federate deletion)
-               drop_item($photo_item[0]['id'], false);
+               Item::delete($photo_item[0]['id']);
 
                $answer = ['result' => 'deleted', 'message' => 'photo with id `' . $photo_id . '` has been deleted from server.'];
                return api_format_data("photo_delete", $type, ['$result' => $answer]);
@@ -4372,7 +4375,7 @@ function api_account_update_profile_image($type)
                $media = $_FILES['media'];
        }
        // save new profile image
-       $data = save_media_to_database("profileimage", $media, $type, t('Profile Photos'), "", "", "", "", "", $is_default_profile);
+       $data = save_media_to_database("profileimage", $media, $type, L10n::t('Profile Photos'), "", "", "", "", "", $is_default_profile);
 
        // get filetype
        if (is_array($media['type'])) {
@@ -4712,7 +4715,6 @@ function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $f
        $arr['allow_gid']     = $allow_gid;
        $arr['deny_cid']      = $deny_cid;
        $arr['deny_gid']      = $deny_gid;
-       $arr['last-child']    = 1;
        $arr['visible']       = $visibility;
        $arr['origin']        = 1;
 
@@ -5194,7 +5196,7 @@ function api_clean_plain_items($Text)
  */
 function api_clean_attachments($body)
 {
-       $data = get_attachment_data($body);
+       $data = BBCode::getAttachmentData($body);
 
        if (!$data) {
                return $body;