Example #1
0
function deleteShortcutApps($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials)
{
    $error = "";
    $continue = true;
    $success = false;
    $idShortcutApps = getParameter("id");
    //obtenemos la informacion del ring_group por el id dado, sino existe el ring_group mostramos un mensaje de error
    if (!isset($idShortcutApps)) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("Invalid ShortcutApps ID"));
        return reportShortcutApps($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    $domain = getParameter('organization');
    //este parametro solo es selecionable cuando es el superadmin quien hace la accion
    if ($credentials['userlevel'] != 'superadmin') {
        $domain = $credentials['domain'];
    }
    $pShortcutApps = new paloSantoShortcutApps($pDB, $domain);
    $arrShortcutApps = $pShortcutApps->getShortcutAppsById($idShortcutApps);
    if ($arrShortcutApps === false) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr($pShortcutApps->errMsg));
        return reportShortcutApps($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    } else {
        if (count($arrShortcutApps) == 0) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("ShortcutApps doesn't exist"));
            return reportShortcutApps($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
    }
    $pDB->beginTransaction();
    $success = $pShortcutApps->deleteShortcutApps($idShortcutApps);
    if ($success) {
        $pDB->commit();
    } else {
        $pDB->rollBack();
    }
    $error .= $pShortcutApps->errMsg;
    if ($success) {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("ShortcutApps was deleted successfully"));
        //mostramos el mensaje para crear los archivos de ocnfiguracion
        $pAstConf = new paloSantoASteriskConfig($pDB);
        $pAstConf->setReloadDialplan($domain, true);
    } else {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr($error));
    }
    return reportShortcutApps($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
}