query('
SELECT ?status_id WHERE {
<'.$uri.'> rdf:type ca:Scenario .
<'.$uri.'> pmb:status ?status_id
}
');
$rows = self::$graphstore->get_result();
return $rows[0]->status_id;
}
public static function get_entity_type($id) {
$id += 0;
$uri = onto_common_uri::get_uri($id);
self::get_graphstore();
$result = self::$graphstore->query('
SELECT ?entity_type WHERE {
<'.$uri.'> rdf:type ca:Scenario .
<'.$uri.'> pmb:entity ?entity_type
}
');
$rows = self::$graphstore->get_result();
return $rows[0]->entity_type;
}
public static function save_rights($update, $id) {
global $gestion_acces_active, $gestion_acces_empr_contribution_scenario;
global $res_prf, $chk_rights, $prf_rad, $r_rad;
// traitement des droits acces user_contribution_area
if ($gestion_acces_active == 1 && $gestion_acces_empr_contribution_scenario == 1) {
$ac = new acces();
$dom_5 = $ac->setDomain(5);
if ($update) {
$dom_5->storeUserRights(1, $id, $res_prf, $chk_rights, $prf_rad, $r_rad);
} else {
$dom_5->storeUserRights(0, $id, $res_prf, $chk_rights, $prf_rad, $r_rad);
}
}
}
public static function get_rights_form($id = 0) {
global $msg, $charset;
global $gestion_acces_active, $gestion_acces_empr_contribution_scenario;
global $gestion_acces_empr_contribution_scenario_def;
if ($gestion_acces_active != 1)
return '';
$ac = new acces();
$form = '';
$c_form = "
" . htmlentities($msg['dom_cur_prf'], ENT_QUOTES, $charset) . "
" . htmlentities($msg['dom_cur_rights'], ENT_QUOTES, $charset) . "
";
if ($gestion_acces_empr_contribution_scenario == 1) {
$r_form = $c_form;
$dom_5 = $ac->setDomain(5);
$r_form = str_replace('', htmlentities($dom_5->getComment('long_name'), ENT_QUOTES, $charset), $r_form);
if ($id) {
// profil ressource
$def_prf = $dom_5->getComment('res_prf_def_lib');
$res_prf = $dom_5->getResourceProfile($id);
$q = $dom_5->loadUsedResourceProfiles();
// Recuperation droits generiques utilisateur
$user_rights = $dom_5->getDomainRights(0, $res_prf);
if ($user_rights & 2) {
$p_sel = gen_liste($q, 'prf_id', 'prf_name', 'res_prf[5]', '', $res_prf, '0', $def_prf, '0', $def_prf);
$p_rad = "";
$r_form = str_replace('', $p_rad, $r_form);
} else {
$r_form = str_replace('', htmlentities($dom_5->getResourceProfileName($res_prf), ENT_QUOTES, $charset), $r_form);
}
// droits/profils utilisateurs
if ($user_rights & 1) {
$r_rad = "";
$r_form = str_replace('', $r_rad, $r_form);
}
// recuperation profils utilisateurs
$t_u = array();
$t_u[0] = $dom_5->getComment('user_prf_def_lib'); // niveau par defaut
$qu = $dom_5->loadUsedUserProfiles();
$ru = pmb_mysql_query($qu);
if (pmb_mysql_num_rows($ru)) {
while ( ($row = pmb_mysql_fetch_object($ru)) ) {
$t_u[$row->prf_id] = $row->prf_name;
}
}
// recuperation des controles dependants de l'utilisateur
$t_ctl = $dom_5->getControls(0);
// recuperation des droits
$t_rights = $dom_5->getResourceRights($id);
if (count($t_u)) {
$h_tab = "";
foreach ( $t_u as $k => $v ) {
$h_tab .= "" . htmlentities($v, ENT_QUOTES, $charset) . " | ";
}
$h_tab .= "
";
$c_tab = '';
foreach ( $t_u as $k => $v ) {
$c_tab .= " | ";
$t_rows = "";
foreach ( $t_ctl as $k2 => $v2 ) {
$t_rows .= "
|
";
} else {
$t_rows .= "/>
|
";
}
}
$c_tab = str_replace('', $t_rows, $c_tab);
}
$c_tab .= "";
}
$h_tab = str_replace('', $c_tab, $h_tab);
;
$r_form = str_replace('', $h_tab, $r_form);
} else {
$r_form = str_replace('', htmlentities($msg['dom_prf_unknown'], ENT_QUOTES, $charset), $r_form);
$r_form = str_replace('', htmlentities($msg['dom_rights_unknown'], ENT_QUOTES, $charset), $r_form);
}
$form .= $r_form;
}
return $form;
}
public static function save_current_scenario($current_scenario) {
if (!empty($current_scenario)) {
//on stocke pour l'uri du scenario pour calculer les droits
$uri = 'http://www.pmbservices.fr/ca/Scenario#'.$current_scenario;
$scenario_uri_id = onto_common_uri::set_new_uri($uri);
contribution_area_scenario::save_rights(true, $scenario_uri_id);
}
}
public static function delete($id) {
self::get_graphstore();
$id = intval($id);
$uri = onto_common_uri::get_uri($id);
$succes = self::$graphstore->query('
delete {
<'.$uri.'> ?p ?o
}
');
if (!$succes) {
var_dump(self::$graphstore->get_errors());
}
$succes = self::$graphstore->query('
delete {
?s ?p <'.$uri.'>
}
');
if (!$succes) {
var_dump(self::$graphstore->get_errors());
}
pmb_mysql_query('delete from onto_uri where uri_id = '.$id);
//suppression des droits d'acces empr_contribution_area_scenario
$query_acces = "show tables like 'acces_res_5'";
$result_acces = pmb_mysql_query($query_acces);
if($result_acces && pmb_mysql_num_rows($result_acces)) {
$requete = "delete from acces_res_5 where res_num=".$id;
@pmb_mysql_query($requete);
}
}
} // end of contribution_area_scenario