2017-12-04 23:14:58 +00:00
|
|
|
<?php
|
|
|
|
namespace Zotlabs\Module;
|
|
|
|
|
2019-04-15 05:31:07 +00:00
|
|
|
/*
|
|
|
|
* Update
|
|
|
|
* Performs AJAX liveUpdate of conversational content by calling the appropriate
|
|
|
|
* controller (passed as argv(1)) and passing the profile_uid (passed as $_GET['p'])
|
|
|
|
* and load flag (argv(2) === 'load') to the get() function of the controller.
|
|
|
|
* Conversational controllers have been written to expect this input. Other controllers
|
|
|
|
* have not.
|
|
|
|
*/
|
2021-10-15 21:19:20 +00:00
|
|
|
|
|
|
|
use App;
|
2019-04-15 05:31:07 +00:00
|
|
|
use Zotlabs\Web\Controller;
|
|
|
|
|
|
|
|
class Update extends Controller {
|
2017-12-04 23:14:58 +00:00
|
|
|
|
|
|
|
function get() {
|
2021-04-06 00:57:39 +00:00
|
|
|
|
2017-12-04 23:14:58 +00:00
|
|
|
$profile_uid = intval($_GET['p']);
|
|
|
|
|
2019-04-15 05:31:07 +00:00
|
|
|
// Change a profile_uid of 0 (not logged in) to (-1) for selected controllers
|
|
|
|
// as they only respond to liveUpdate with non-zero values
|
|
|
|
|
|
|
|
if ((! $profile_uid) && in_array(argv(1),[ 'display', 'search', 'pubstream', 'home' ])) {
|
2017-12-05 05:18:10 +00:00
|
|
|
$profile_uid = (-1);
|
2019-04-15 05:31:07 +00:00
|
|
|
}
|
2017-12-05 05:18:10 +00:00
|
|
|
|
2019-04-15 05:31:07 +00:00
|
|
|
if (argc() < 2) {
|
2017-12-04 23:14:58 +00:00
|
|
|
killme();
|
|
|
|
}
|
|
|
|
|
|
|
|
// These modules don't have a completely working liveUpdate implementation currently
|
|
|
|
|
2019-04-15 05:31:07 +00:00
|
|
|
if (in_array(strtolower(argv(1)),[ 'articles', 'cards' ])) {
|
2017-12-04 23:14:58 +00:00
|
|
|
killme();
|
2019-04-15 05:31:07 +00:00
|
|
|
}
|
2017-12-04 23:14:58 +00:00
|
|
|
|
|
|
|
$module = "\\Zotlabs\\Module\\" . ucfirst(argv(1));
|
|
|
|
$load = (((argc() > 2) && (argv(2) == 'load')) ? 1 : 0);
|
|
|
|
|
|
|
|
$mod = new $module;
|
|
|
|
|
2021-10-15 21:19:20 +00:00
|
|
|
// Set the state flags of the relevant module (only conversational
|
|
|
|
// modules support state flags
|
|
|
|
|
|
|
|
if (isset($mod->profile_uid)) {
|
|
|
|
$mod->profile_uid = $profile_uid;
|
|
|
|
}
|
|
|
|
if (isset($mod->updating)) {
|
|
|
|
$mod->updating = 1;
|
|
|
|
}
|
|
|
|
if (isset($mod->loading)) {
|
|
|
|
$mod->loading = 1;
|
|
|
|
}
|
|
|
|
|
2017-12-04 23:14:58 +00:00
|
|
|
header("Content-type: text/html");
|
|
|
|
|
2019-04-15 05:31:07 +00:00
|
|
|
// Modify the argument parameters to match what the new controller
|
|
|
|
// expects. They are currently set to what this controller expects.
|
|
|
|
|
2021-10-15 21:19:20 +00:00
|
|
|
App::$argv = [ argv(1) ];
|
|
|
|
App::$argc = 1;
|
2017-12-05 05:18:10 +00:00
|
|
|
|
2017-12-04 23:14:58 +00:00
|
|
|
echo "<!DOCTYPE html><html><body><section>\r\n";
|
2021-10-15 21:19:20 +00:00
|
|
|
echo $mod->get();
|
2017-12-04 23:14:58 +00:00
|
|
|
echo "</section></body></html>\r\n";
|
|
|
|
|
|
|
|
killme();
|
|
|
|
}
|
|
|
|
}
|