Merge pull request #6694 from Quix0r/rewrites/added-missing-var-init
Some rewrites
This commit is contained in:
commit
182058943f
8 changed files with 33 additions and 15 deletions
|
@ -1528,7 +1528,9 @@ function api_search($type)
|
|||
|
||||
if (api_user() === false || $user_info === false) { throw new ForbiddenException(); }
|
||||
|
||||
if (empty($_REQUEST['q'])) { throw new BadRequestException('q parameter is required.'); }
|
||||
if (empty($_REQUEST['q'])) {
|
||||
throw new BadRequestException('q parameter is required.');
|
||||
}
|
||||
|
||||
$searchTerm = trim(rawurldecode($_REQUEST['q']));
|
||||
|
||||
|
@ -4399,6 +4401,7 @@ function api_fr_photo_delete($type)
|
|||
if (api_user() === false) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
|
||||
// input params
|
||||
$photo_id = defaults($_REQUEST, 'photo_id', null);
|
||||
|
||||
|
@ -4407,11 +4410,12 @@ function api_fr_photo_delete($type)
|
|||
if ($photo_id == null) {
|
||||
throw new BadRequestException("no photo_id specified");
|
||||
}
|
||||
|
||||
// check if photo is existing in database
|
||||
$r = Photo::exists(['resource-id' => $photo_id, 'uid' => api_user()]);
|
||||
if (!$r) {
|
||||
if (!Photo::exists(['resource-id' => $photo_id, 'uid' => api_user()])) {
|
||||
throw new BadRequestException("photo not available");
|
||||
}
|
||||
|
||||
// now we can perform on the deletion of the photo
|
||||
$result = Photo::delete(['uid' => api_user(), 'resource-id' => $photo_id]);
|
||||
|
||||
|
|
|
@ -15,3 +15,4 @@ require __DIR__ . '/vendor/autoload.php';
|
|||
$a = Factory\DependencyFactory::setUp('index', __DIR__, false);
|
||||
|
||||
$a->runFrontend();
|
||||
|
||||
|
|
|
@ -1565,7 +1565,7 @@ function admin_page_site(App $a)
|
|||
|
||||
$storage_form = [];
|
||||
if (!is_null($storage_current_backend) && $storage_current_backend != "") {
|
||||
foreach($storage_current_backend::getOptions() as $name => $info) {
|
||||
foreach ($storage_current_backend::getOptions() as $name => $info) {
|
||||
$type = $info[0];
|
||||
$info[0] = $storage_form_prefix . '_' . $name;
|
||||
$info['type'] = $type;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use \BadMethodCallException;
|
||||
|
||||
class ItemDeliveryData
|
||||
{
|
||||
|
@ -71,7 +72,7 @@ class ItemDeliveryData
|
|||
public static function insert($item_id, array $fields)
|
||||
{
|
||||
if (empty($item_id)) {
|
||||
throw new \BadMethodCallException('Empty item_id');
|
||||
throw new BadMethodCallException('Empty item_id');
|
||||
}
|
||||
|
||||
$fields['iid'] = $item_id;
|
||||
|
@ -92,7 +93,7 @@ class ItemDeliveryData
|
|||
public static function update($item_id, array $fields)
|
||||
{
|
||||
if (empty($item_id)) {
|
||||
throw new \BadMethodCallException('Empty item_id');
|
||||
throw new BadMethodCallException('Empty item_id');
|
||||
}
|
||||
|
||||
if (empty($fields)) {
|
||||
|
@ -113,7 +114,7 @@ class ItemDeliveryData
|
|||
public static function delete($item_id)
|
||||
{
|
||||
if (empty($item_id)) {
|
||||
throw new \BadMethodCallException('Empty item_id');
|
||||
throw new BadMethodCallException('Empty item_id');
|
||||
}
|
||||
|
||||
return DBA::delete('item-delivery-data', ['iid' => $item_id]);
|
||||
|
|
|
@ -173,6 +173,8 @@ class Photo extends BaseObject
|
|||
*/
|
||||
public static function getImageForPhoto(array $photo)
|
||||
{
|
||||
$data = "";
|
||||
|
||||
if ($photo["backend-class"] == "") {
|
||||
// legacy data storage in "data" column
|
||||
$i = self::selectFirst(["data"], ["id" => $photo["id"]]);
|
||||
|
@ -189,6 +191,7 @@ class Photo extends BaseObject
|
|||
if ($data === "") {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Image($data, $photo["type"]);
|
||||
}
|
||||
|
||||
|
@ -219,11 +222,13 @@ class Photo extends BaseObject
|
|||
{
|
||||
$fields = self::getFields();
|
||||
$values = array_fill(0, count($fields), "");
|
||||
|
||||
$photo = array_combine($fields, $values);
|
||||
$photo["backend-class"] = Storage\SystemResource::class;
|
||||
$photo["backend-ref"] = $filename;
|
||||
$photo["type"] = $mimetype;
|
||||
$photo["cacheable"] = false;
|
||||
|
||||
return $photo;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,13 @@ class Database implements IStorage
|
|||
return DBA::delete('storage', ['id' => $ref]);
|
||||
}
|
||||
|
||||
public static function getOptions() { return []; }
|
||||
public static function getOptions()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function saveOptions($data) { return []; }
|
||||
public static function saveOptions($data)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
namespace Friendica\Model\Storage;
|
||||
|
||||
use \BadMethodCallException;
|
||||
|
||||
/**
|
||||
* @brief System resource storage class
|
||||
*
|
||||
|
@ -32,12 +34,12 @@ class SystemResource implements IStorage
|
|||
|
||||
public static function put($data, $filename = "")
|
||||
{
|
||||
throw new \BadMethodCallException();
|
||||
throw new BadMethodCallException();
|
||||
}
|
||||
|
||||
public static function delete($filename)
|
||||
{
|
||||
throw new \BadMethodCallException();
|
||||
throw new BadMethodCallException();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
|
|
|
@ -498,7 +498,6 @@ class Notifier
|
|||
}
|
||||
DBA::close($delivery_contacts_stmt);
|
||||
|
||||
|
||||
$url_recipients = array_filter($url_recipients);
|
||||
// send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts
|
||||
// They are especially used for notifications to OStatus users that don't follow us.
|
||||
|
|
Loading…
Reference in a new issue