Example #1
0
function List_Permissions($perm_id, $master_id, $group_id, $category_id, $slave_id, $role, $bd)
{
    if (!empty($perm_id)) {
        $condition .= " AND (rel_id='{$perm_id}')";
    }
    if (!empty($master_id)) {
        $condition .= " AND (master_id = '{$master_id}')";
    }
    if (!empty($group_id)) {
        $condition .= " AND (master_group = {$group_id})";
    }
    if (!empty($category_id)) {
        $condition .= " AND (master_category = '{$category_id}')";
    }
    if (!empty($slave_id)) {
        $condition .= " AND (slave_id = '{$slave_id}')";
    }
    if (!empty($role)) {
        $condition .= " AND (rel_type = '{$role}')";
    }
    $query = "SELECT * FROM relationships WHERE (rel_id IS NOT NULL){$condition}";
    $result = $bd->Query($query);
    $permissions = "";
    $num_permissions = $bd->NumberOfRows($result);
    if ($num_permissions) {
        for ($i = 0; $i < $num_permissions; $i++) {
            $permissions[$i][0] = $bd->FetchResult($result, $i, 'rel_id');
            $permissions[$i][1] = $bd->FetchResult($result, $i, 'master_id');
            if ($permissions[$i][1]) {
                $person = List_People($permissions[$i][1], '', '', '', '', $bd);
                $permissions[$i][2] = $person[0][1];
            } else {
                $permissions[$i][2] = '';
            }
            $permissions[$i][3] = $bd->FetchResult($result, $i, 'master_group');
            if ($permissions[$i][3] > 0) {
                $group = $permissions[$i][3];
                $query1 = "SELECT name FROM groups WHERE group_id = {$group}";
                $result1 = $bd->Query($query1);
                $permissions[$i][4] = $bd->FetchResult($result1, 0, 'name');
            } else {
                $permissions[$i][3] = '';
                $permissions[$i][4] = '';
            }
            $permissions[$i][5] = $bd->FetchResult($result, $i, 'master_category');
            if ($permissions[$i][5]) {
                $cat = List_Categories($permissions[$i][5], '', $bd);
                $result1 = $bd->Query($query1);
                $permissions[$i][6] = $cat[0][1];
            } else {
                $permissions[$i][6] = '';
            }
            $permissions[$i][7] = $bd->FetchResult($result, $i, 'slave_id');
            $permissions[$i][9] = $bd->FetchResult($result, $i, 'rel_type');
            $role = $permissions[$i][9];
            if ($role == 'course') {
                $course = List_Courses($permissions[$i][7], '', '', '', '', '', '', $bd);
                $permissions[$i][8] = $course[0][1];
            } else {
                $room = List_Rooms($permissions[$i][7], '', '', '', '', $bd);
                $permissions[$i][8] = $room[0][1];
            }
        }
    }
    return $permissions;
}
        include "logout.php";
        exit;
    }
    if (!empty($_POST['submit_conf_yes']) || !empty($_POST['submit_conf_no'])) {
        if (!empty($_POST['submit_conf_yes'])) {
            if (Delete_Person($_POST['account_id'], $bd) == 1) {
                $alert[$num_alerts++] = 'Person deleted successfully';
            }
        } else {
            $alert[$num_alerts++] = 'Person deletion cancelled';
        }
        include "adm_acc_people.php";
        exit;
    } else {
        if (!empty($_GET['account_id'])) {
            $people = List_People($_GET['account_id'], '', '', '', '', $bd);
        }
    }
    $result_xsl = "xsl/" . $default_xsl . "/adm_acc_people_remove.xsl";
} else {
    $error[$num_errors++] = "Invalid Session ID";
    include "logout.php";
    exit;
}
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpSchErrors", $error);
$smarty->assign("nrpSchAlerts", $alert);
$smarty->assign("nrpSessId", $complete_sess_id);
$smarty->assign("nrpPeople", $people);
$result_xml = $smarty->fetch("xml/adm_acc_people.xml");
require "./inc/proc_transform.php";
                break;
        }
        $current = List_Courses('', '', $courses[0][3], $courses[0][4], '', $courses[5], $courses[0][6], $bd);
        if ($current) {
            $error[$num_errors++] = 'This course already exists';
        }
        if (empty($error)) {
            Insert_Course($courses[0][0], $courses[0][1], $courses[0][2], $courses[0][3], $courses[0][4], $courses[0][6], $courses[0][5], $courses[0][7], $bd);
            $alert[$num_alerts++] = "New Course Inserted Successfully";
            include "adm_acc_courses.php";
            exit;
        }
    }
    $result_xsl = "xsl/" . $default_xsl . "/adm_acc_courses_new.xsl";
    $category = List_Categories('', $cfg['professor_category'], $bd);
    $people = List_People('', '', '', '', $category[0][0], $bd);
} else {
    $error[$num_errors++] = "Invalid Session ID";
    include "logout.php";
    exit;
}
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpSchErrors", $error);
$smarty->assign("nrpSchAlerts", $alert);
$smarty->assign("nrpSessId", $complete_sess_id);
$smarty->assign("nrpUserId", $account_id);
$smarty->assign("nrpCourses", $courses);
$smarty->assign("nrpPeople", $people);
$result_xml = $smarty->fetch("xml/adm_acc_courses.xml");
require "./inc/proc_transform.php";
// Calls the commands do procede the XSLT transformation
Example #4
0
     case 0:
         $error[$num_errors++] = "The name is blank";
         break;
     case -1:
         $error[$num_errors++] = "The name length is more than 50 characters";
         break;
 }
 switch (User_Validate_Email($email, 70)) {
     case 0:
         $error[$num_errors++] = "The e-mail is invalid";
         break;
     case -1:
         $error[$num_errors++] = "The e-mail length is more than 70 characters";
         break;
     case 1:
         $person = List_People('', '', $email, '', '', $bd);
         if ($person) {
             if ($person[0][0] != $account_id) {
                 $error[$num_errors++] = "This E-mail is already in use";
             }
         }
         break;
 }
 if ($_POST['new_password'] != $_POST['conf_new_password']) {
     $error[$num_errors++] = "The confirmation of the new password is not equal to the new password";
 }
 if (!empty($_POST['new_pasword'])) {
     switch (User_Validate_Password($_POST['new_passord'])) {
         case 0:
             $error[$num_errors++] = "The New Password is blank";
             break;
                $result_xsl = "xsl/" . $cfg['default_xsl'] . "/groups_members_mod.xsl";
                break;
            case 'M':
                $result_xsl = "xsl/" . $cfg['default_xsl'] . "/groups_members_mod.xsl";
                break;
            case 'C':
                $result_xsl = "xsl/" . $cfg['default_xsl'] . "/groups_members.xsl";
                break;
            case 'I':
                $result_xsl = "xsl/" . $cfg['default_xsl'] . "/groups_members.xsl";
                break;
        }
    }
    $people = array();
    for ($i = 0; $groups[0][5][$i]; $i++) {
        $people = array_merge($people, List_People($groups[0][5][$i][0], '', '', '', '', $bd));
    }
} else {
    $error[$num_errors++] = "Invalid Session ID";
    include "logout.php";
    exit;
}
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpSchedErrors", $error);
$smarty->assign("nrpSchedAlerts", $alert);
$smarty->assign("nrpSessId", $complete_sess_id);
$smarty->assign("nrpPeople", $people);
$smarty->assign("nrpGroups", $groups);
$result_xml = $smarty->fetch("xml/groups.xml");
require "./inc/proc_transform.php";
// Calls the commands do procede the XSLT transformation
require_once "./inc/config.inc.php";
require_once "./inc/database_handler.php";
require_once "./inc/nrp_api.php";
$account_id = $_GET['account_id'];
$space = $cfg['space'];
$query = "SELECT * FROM accounts WHERE account_id = '{$account_id}'";
$result = $bd->Query($query);
$role = $bd->FetchResult($result, 0, 'role');
$var_type = $role . '_type';
$var_color = $role . '_color';
$var_image = $role . '_icon';
$array_type = $cfg[$var_type];
$array_color = $cfg[$var_color];
$array_image = $cfg[$var_image];
if ($role == 'user') {
    $person = List_People($account_id, '', '', '', '', $bd);
}
$num_blocks = count($cfg['time']);
$block_size = intval((600 - $num_blocks * $space) / $num_blocks);
$max_text_factor = (int) ($block_size / 7);
Get_Span_Limits(date('d'), date('m'), date('Y'), 'week', 0, $span_start_day, $span_start_month, $span_start_year, $span_end_day, $span_end_month, $span_end_year);
function locate($vector, $element, $n_elem)
{
    $found = 0;
    for ($i = 1; $i <= $n_elem and !$found; $i++) {
        if ($vector[$i] == $element) {
            $found = 1;
        }
    }
    if (!$found) {
        return -1;
            if ($current) {
                $error[$num_errors++] = 'This permition already exists';
            }
        } else {
            $error[$num_errors++] = "One (and only one) option of master must be chosen";
        }
        if (empty($error)) {
            Insert_Permission($permissions[0][1], $permissions[0][3], $permissions[0][5], $permissions[0][7], 'room', $bd);
            $alert[$num_alerts++] = "New Permision to Room Inserted Successfully";
            include "adm_permissions.php";
            exit;
        }
    }
    $result_xsl = "xsl/" . $default_xsl . "/adm_permissions_room_new.xsl";
    $categories = List_Categories('', '', $bd);
    $people = List_People('', '', '', '', '', $bd);
    $groups = List_Groups('', '', '', '', '', $bd);
    $rooms = List_Rooms('', '', '', '', '', $bd);
} else {
    $error[$num_errors++] = "Invalid Session ID";
    include "logout.php";
    exit;
}
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpSchErrors", $error);
$smarty->assign("nrpSchAlerts", $alert);
$smarty->assign("nrpSessId", $complete_sess_id);
$smarty->assign("nrpUserId", $account_id);
$smarty->assign("nrpCourses", $courses);
$smarty->assign("nrpRooms", $rooms);
$smarty->assign("nrpPeople", $people);
         break;
 }
 switch (User_Validate_Simple_Field($people[0][2], 256)) {
     case -2:
         $error[$num_errors++] = "There are invalid characteres at the comments";
         break;
 }
 switch (User_Validate_Simple_Field($people[0][5], 100)) {
     case 0:
         $error[$num_errors++] = "The E-mail must be filled";
         break;
     case -2:
         $error[$num_errors++] = "There are invalid characteres at the e-mail";
         break;
     case 1:
         $current = List_People('', '', $people[0][5], '', '', $bd);
         if ($current) {
             $error[$num_errors++] = "This e-mail is already in use";
         }
         break;
 }
 switch (User_Validate_Simple_Field($people[0][6], 100)) {
     case -2:
         $error[$num_errors++] = "There are invalid characteres at the url";
         break;
 }
 if (empty($error)) {
     srand((double) microtime() * 1000000);
     $password = rand(00, 999999);
     $passwordmd5 = md5($password);
     $id = $people[0][0];
                Group_Change_Membership($group_id, $account_id, 'C', $bd);
                $alert[$num_alerts++] = 'You were included in the group.';
                include "groups_enter.php";
            } else {
                // Removes the invitation
                Group_Remove_Member($group_id, $account_id, $bd);
                $alert[$num_alerts++] = 'Your invitation to the group was cancelled.';
                include "groups.php";
            }
            exit;
        } else {
            $error[$num_errors++] = "Invalid confirmation code.";
        }
        $groups = List_Groups($group_id, '', '', '', 1, $bd);
    }
    $people = List_People($account_id, '', '', '', '', $bd);
} else {
    $error[$num_errors++] = "Invalid Session ID";
    include "logout.php";
    exit;
}
$result_xsl = "xsl/" . $cfg['default_xsl'] . "/groups_members_confirmation.xsl";
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpSchedErrors", $error);
$smarty->assign("nrpSchedAlerts", $alert);
$smarty->assign("nrpSessId", $complete_sess_id);
$smarty->assign("nrpPeople", $people);
$smarty->assign("nrpGroups", $groups);
$result_xml = $smarty->fetch("xml/groups.xml");
require "./inc/proc_transform.php";
// Calls the commands do procede the XSLT transformation