streams/Zotlabs/Module/Wall_upload.php

63 lines
1.3 KiB
PHP
Raw Normal View History

2016-04-19 03:38:38 +00:00
<?php
2021-12-03 03:01:39 +00:00
2016-04-19 03:38:38 +00:00
namespace Zotlabs\Module;
2021-12-02 22:33:36 +00:00
use App;
use Zotlabs\Web\Controller;
2019-04-16 06:43:06 +00:00
require_once('include/photo_factory.php');
require_once('include/channel.php');
2016-04-19 03:38:38 +00:00
require_once('include/photos.php');
2021-12-02 23:02:31 +00:00
class Wall_upload extends Controller
{
2016-04-19 03:38:38 +00:00
2021-12-02 23:02:31 +00:00
public function post()
{
$using_api = ((x($_FILES, 'media')) ? true : false);
if ($using_api) {
require_once('include/api.php');
2021-12-03 03:01:39 +00:00
if (api_user()) {
2021-12-02 23:02:31 +00:00
$channel = channelx_by_n(api_user());
2021-12-03 03:01:39 +00:00
}
2021-12-02 23:02:31 +00:00
} else {
2021-12-03 03:01:39 +00:00
if (argc() > 1) {
2021-12-02 23:02:31 +00:00
$channel = channelx_by_nick(argv(1));
2021-12-03 03:01:39 +00:00
}
2021-12-02 23:02:31 +00:00
}
if (!$channel) {
2021-12-03 03:01:39 +00:00
if ($using_api) {
2021-12-02 23:02:31 +00:00
return;
2021-12-03 03:01:39 +00:00
}
2021-12-02 23:02:31 +00:00
notice(t('Channel not found.') . EOL);
killme();
}
$observer = App::get_observer();
$args = array('source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash']));
$ret = photo_upload($channel, $observer, $args);
if (!$ret['success']) {
2021-12-03 03:01:39 +00:00
if ($using_api) {
2021-12-02 23:02:31 +00:00
return;
2021-12-03 03:01:39 +00:00
}
2021-12-02 23:02:31 +00:00
notice($ret['message']);
killme();
}
2021-12-03 03:01:39 +00:00
if ($using_api) {
2021-12-02 23:02:31 +00:00
return ("\n\n" . $ret['body'] . "\n\n");
2021-12-03 03:01:39 +00:00
} else {
2021-12-02 23:02:31 +00:00
echo "\n\n" . $ret['body'] . "\n\n";
2021-12-03 03:01:39 +00:00
}
2021-12-02 23:02:31 +00:00
killme();
}
2016-04-19 03:38:38 +00:00
}