Exemple #1
0
function delete_org_2($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    $jsonObject = new PaloSantoJSON();
    $idOrgs = getParameter("idOrgs");
    //el susperadmin es el unico autorizado a borrar una organizacion
    if ($credentials['userlevel'] != "superadmin") {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("You are not authorized to perform this action"));
        return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    $arrOrgs = array_diff(explode(",", $idOrgs), array(""));
    if (!is_array($arrOrgs) || count($arrOrgs) == 0) {
        $jsonObject->set_error(_tr("Err: Any valid organization has been selected"));
        return $jsonObject->createJSON();
    }
    $pOrg = new paloSantoOrganization($pDB);
    if ($pOrg->deleteOrganization($arrOrgs)) {
        $jsonObject->set_message($pOrg->errMsg);
    } else {
        $jsonObject->set_error($pOrg->errMsg);
    }
    return $jsonObject->createJSON();
}