method makeHotlink documentation in bbn\User\Manager
function(string $id_user, string $message = 'hotlink', $exp = NULL)
{
if (!isset($this->messages[$message]) || empty($this->messages[$message]['link'])) {
switch ($message)
{
case 'hotlink':
if ($path = bbn\Mvc::getPluginUrl('appui-usergroup')) {
$this->messages[$message]['link'] = BBN_URL.$path.'/main/profile';
}
break;
case 'creation':
if ($path = bbn\Mvc::getPluginUrl('appui-core')) {
$this->messages[$message]['link'] = BBN_URL.$path.'/login/%s';
}
break;
case 'password':
if ($path = bbn\Mvc::getPluginUrl('appui-core')) {
$this->messages[$message]['link'] = BBN_URL.$path.'/login/%s';
}
break;
}
if (empty($this->messages[$message]['link'])) {
throw new \Exception(X::_("Impossible to make hotlinks without a link configured"));
}
}
if ($usr = $this->getUser($id_user)) {
// Expiration date
if (!\is_int($exp) || ($exp < 1)) {
$exp = time() + $this->hotlink_length;
}
$hl =& $this->class_cfg['arch']['hotlinks'];
// Expire existing valid hotlinks
$this->db->update(
$this->class_cfg['tables']['hotlinks'], [
$hl['expire'] => date('Y-m-d H:i:s')
],[
[$hl['id_user'], '=', $id_user],
[$hl['expire'], '>', date('Y-m-d H:i:s')]
]
);
$magic = $this->usrcls->makeMagicString();
// Create hotlink
$this->db->insert(
$this->class_cfg['tables']['hotlinks'], [
$hl['magic'] => $magic['hash'],
$hl['id_user'] => $id_user,
$hl['expire'] => date('Y-m-d H:i:s', $exp)
]
);
$id_link = $this->db->lastId();
$link = "?id=$id_link&key=".$magic['key'];
$this->sendMail(
$id_user,
$this->messages[$message]['subject'],
sprintf($this->messages[$message]['text'], sprintf($this->messages[$message]['link'], $link))
);
}
else{
X::log("User $id_user not found");
throw new \Exception(X::_('User not found'));
}
return $this;
}
BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions