Add hooks to support plugins interacting with sub domains

This commit is contained in:
Kienan Stewart 2018-12-23 23:47:21 -05:00
parent 28a9ea261c
commit 79597bc489
1 changed files with 31 additions and 9 deletions

View File

@ -25,22 +25,32 @@
require_once("../class/config.php"); require_once("../class/config.php");
$fields = array ( global $db, $hooks;
"domain" => array ("post", "string", ""),
"sub" => array ("post", "string", ""), // Do the type first so it can be used to retrieve dynamic fields.
"type" => array ("post", "string", $dom->type_local), $fields = array(
"sub_domain_id" => array ("post", "integer", 0), 'type' => array('post', 'string', $dom->type_local),
); );
getFields($fields); getFields($fields);
// here we get a dynamic-named value $fields = array();
foreach ($hooks->invoke('hook_dom_subdoedit_fields', array($type)) as $module => $extra_fields) {
$fields = array_merge($fields, $extra_fields);
}
$dynamicvar="t_$type"; $dynamicvar="t_$type";
$httpsvar="https_$type"; $httpsvar="https_$type";
$fields = array ( $default_fields = array (
"domain" => array ("post", "string", ""),
"sub" => array ("post", "string", ""),
"sub_domain_id" => array ("post", "integer", 0),
"$dynamicvar" => array ("post", "string", ""), "$dynamicvar" => array ("post", "string", ""),
"$httpsvar" => array ("post", "string", ""), "$httpsvar" => array ("post", "string", ""),
); );
$fields = array_merge($fields, $default_fields);
getFields($fields); getFields($fields);
// here we get a dynamic-named value
$value=$$dynamicvar; $value=$$dynamicvar;
$https=$$httpsvar; $https=$$httpsvar;
// The dynamic value is now in $value // The dynamic value is now in $value
@ -69,6 +79,18 @@ if (!$r) {
} }
exit(); exit();
} else { } else {
$db->query('SELECT id from sub_domaines where domaine = ? ORDER BY id DESC;',
array($domain));
$db->next_record();
$new_subdomain_id = $db->f('id');
$context = array();
foreach ($fields as $k => $v) {
$context[$k] = $$k;
}
$context['sub_domain_id'] = $new_subdomain_id;
$context['type'] = $type;
$hooks->invoke('hook_dom_subdoedit_set', array($context));
$t = time(); $t = time();
// TODO: we assume the cron job is at every 5 minutes // TODO: we assume the cron job is at every 5 minutes
$noread=false; $noread=false;