예제 #1
0
 public static function logout($session_id)
 {
     $session = session::get_session($session_id);
     $session->activ = "0";
     $session->update();
     return true;
 }
예제 #2
0
 public static function get_list_with_session($session_id)
 {
     $session = session::get_session($session_id);
     if ($session->is_valid()) {
         $user = ormlib::get_from_instance(new user(), array("id"), array($session->user_id));
         if ($user !== null && $user->id !== null && $user->id !== "") {
             if ($user->has_group(session::GROUP_METADATA) === true) {
                 $metadata_list = ormlib::get_list_from_instance(new metadata());
                 $mw_list = array();
                 for ($i = 0; $i < count($metadata_list); $i++) {
                     $md = $metadata_list[$i];
                     $mw = new metadata_wrapper($md);
                     $mw->metadata_field_list = ormlib::get_list_from_instance(new metadata_field(), array("metadata_id"), array($md->id));
                     for ($j = 0; $j < count($mv->metadata_field_list); $j++) {
                         $mw->metadata_field_selection[] = ormlib::get_list_from_instance(new metadata_field_selection(), array("metadata_field_id"), array($mv->metadata_field_list[$j]->id));
                     }
                     $mw->metadata_table_list = ormlib::get_list_from_instance(new metadata_table(), array("metadata_id"), array($md->id));
                     $mw->metadata_table_relation = ormlib::get_list_from_instance(new metadata_table_relation(), array("metadata_id"), array($md->id));
                     $mw->metadata_relation = array_merge($mv->metadata_relation, ormlib::get_list_from_instance(new metadata_table_relation(), array("metadata_id1"), array($md->id)));
                     $mw->metadata_relation = array_merge($mv->metadata_relation, ormlib::get_list_from_instance(new metadata_table_relation(), array("metadata_id2"), array($md->id)));
                     $mw_list[] = $mw;
                 }
                 return $mw_list;
             }
         }
     }
     return null;
 }
예제 #3
0
 public static function check_and_remove($session_id, $user_id, $group_id)
 {
     $session = session::get_session($session_id);
     if ($session != null && $session->is_valid()) {
         $user = ormlib::get_from_instance(new user(), array("id"), array($session->user_id));
         if ($user->has_group(session::GROUP_METADATA) === true) {
             if ($user_id != "" && $group_id != "" && $user_id * 1 > 0 && $group_id * 1 > 0) {
                 ormlib::remove_from_instance(new user_group(), "`user_id` = {$user_id} and `group_id` = {$group_id}");
                 return array("response" => "OK");
             } else {
                 return array("response" => "error", "message" => "user_id or group_id is empty or zero.");
             }
         }
     }
     return array("response" => "error", "message" => "no privileg");
 }
예제 #4
0
 public static function get_list_with_session($session_id)
 {
     $session = session::get_session($session_id);
     if ($session != null && $session->is_valid()) {
         $user_group = new user_group();
         $report_privileg_list = array();
         $user_group_list = $user_group->get_list(array("user_id"), array($session->user_id));
         for ($i = 0; $i < count($user_group_list); $i++) {
             $report_privileg = new report_privileg();
             $report_privileg_list = array_merge($report_privileg_list, $report_privileg->get_list(array("group_id", "privileg_id"), array($user_group_list[$i]->group_id, report_privileg::PRIVILEG_ID_ACCESS)));
         }
         $report_list = array();
         $report = new report();
         for ($i = 0; $i < count($report_privileg_list); $i++) {
             array_push($report_list, $report->get($report_privileg_list[$i]->report_id));
         }
         $session->update();
         return $report_list;
     }
     return array();
 }
<?php

if (!defined('INTERFACE_ACCESS')) {
    die('Direct access not premitted');
}
$session_id = $_REQUEST["session_id"];
$session = session::get_session($session_id);
$user = ormlib::get_from_instance(new user(), array("id"), array($session->user_id));
if ($session->is_valid() === true && $user->has_group(session::GROUP_METADATA) === true) {
    $metadata_table = ormlib::get_from_instance(new metadata_table(), array("id"), array($_REQUEST["table_id"]));
    $metadata_table->remove();
    //TODO Remove more elements
    echo "true";
} else {
    echo "no privileg";
}