Ejemplo n.º 1
0
<?php

if ($already_initialized != 1) {
    require "./inc/script_inicialization.php";
    require "./inc/nrp_api.php";
}
if (!isset($num_errors)) {
    $num_errors = 0;
}
if (!isset($num_alerts)) {
    $num_alerts = 0;
}
if (Validate_Session($complete_sess_id, $_SERVER['REMOTE_ADDR'], $bd)) {
    Get_Account_Id($sess_id, $account_id, $bd);
    if ($account_id != 'admin') {
        $error[$num_errors++] = "You are not the administrator";
        include "logout.php";
        exit;
    }
} else {
    $error[$num_errors++] = "Invalid Session ID";
    include "logout.php";
    exit;
}
$result_xsl = "xsl/" . $default_xsl . "/adm_accounts.xsl";
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpSchErrors", $error);
$smarty->assign("nrpSchAlerts", $alert);
$smarty->assign("nrpMasterSessId", $master_session);
$smarty->assign("nrpSessId", $complete_sess_id);
$smarty->assign("nrpUserId", $account_id);
Ejemplo n.º 2
0
function listAppointments($complete_sess_id, $beg_date, $end_date, $beg_time, $end_time, $type)
{
    // Validate user session code
    if (!Validate_Session($complete_sess_id, $_SERVER['REMOTE_ADDR'], $GLOBALS['bd'])) {
        return "Invalid session ID!";
    }
    // Get the user account ID
    $sess_id = substr($complete_sess_id, 32);
    Get_Account_Id($sess_id, $account_id, $GLOBALS['bd']);
    // Get information about appointments types available
    $query = "SELECT * FROM accounts WHERE account_id = '{$account_id}'";
    $result = $GLOBALS['bd']->Query($query);
    $role = $GLOBALS['bd']->FetchResult($result, 0, 'role');
    $var_type = $role . '_type';
    // Set app types, times and days of week (see inc/config.inc.php)
    $app_times = $GLOBALS['cfg']['time'];
    $app_types = $GLOBALS['cfg'][$var_type];
    $days_of_week = $GLOBALS['cfg']['days'];
    // Convert $beg_time and $end_time to NoRisk values
    // see (inc/config.inc.php to see how norisk store this values
    // XXX Check if value is between first_time and last_time?
    $aux = split(":", $beg_time);
    $nrp_beg_time = $aux[0] - $GLOBALS['cfg']['first_time'];
    $aux = split(":", $end_time);
    $nrp_end_time = $aux[0] - $GLOBALS['cfg']['first_time'];
    // Get the list of appointments for this user
    // (does not include the weekly ones)
    $apps = List_Appointments($account_id, '', '', '', $beg_date, $end_date, $nrp_beg_time, $nrp_end_time, '', '', $app_times, $app_types, '', '', $days_of_week, $GLOBALS['bd']);
    // If there are no results, return an empty array instead of a null
    if ($apps == null) {
        return array();
    }
    // Make the returning array
    $apps_list = array();
    foreach ($apps as $app) {
        $aux = array('app_id' => $app['0'], 'description' => $app['2'], 'beg_time' => $app['8'], 'end_time' => $app['10'], 'date' => $app['16'], 'type' => $app['12'], 'url' => $app['17'], 'owner' => $app['18']);
        array_push($apps_list, $aux);
    }
    // Return the appotinments list
    return $apps_list;
}