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