This commit is contained in:
2020-03-28 08:00:35 +06:00
3 changed files with 24 additions and 15 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
Библиотека для работы с базой данных через JavaScript.

View File

@ -306,44 +306,49 @@
if ($currNode!=null) if ($currNode!=null)
{ {
//Вернём значение прав доступа для запрошенного объекта //Вернём значение прав доступа для запрошенного объекта
$allow=true; //$allow=true;
/*$allow=false; $allow=false;
//$res = $db->query('select a.*,at.name from "_Access" a, "_Actions" at where a.del=false and at.id=a.action_id and at.name=\'Insert_'.$name.'\' and a.group_id in (select group_id from "_UsersGroups" where user_id='.$_SESSION['USER_ID'].');'); //$sql_query='select a.*,at.name from "_Access" a, "_Actions" at where a.del=false and at.id=a.action_id and at.name=\'Insert_'.$name.'\' and a.group_id in (select group_id from "_UsersGroups" where user_id='.$_SESSION['USER_ID'].');'
$res = $db->query('select "getAccess"('.getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID']).',\'Insert_'.$name.'\') as allow;'); $sql_query='select main.p_getaccess('.getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID']).',\'Insert_'.$name.'\') as allow;';
$res = $db->query($sql_query);
while ($row = $res->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов while ($row = $res->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
{ {
$allow=$allow || ($row['allow'] == 't'); $allow=$allow || ($row['allow'] == 't');
}*/ }
$xmlAttr = $objXMLDocument->createAttribute("ins"); //insert $xmlAttr = $objXMLDocument->createAttribute("ins"); //insert
$xmlAttr->nodeValue = $allow ? "1" : "0"; $xmlAttr->nodeValue = $allow ? "1" : "0";
$currNode->setAttributeNode($xmlAttr); $currNode->setAttributeNode($xmlAttr);
/*$allow=false; $allow=false;
//$res = $db->query('select a.*,at.name from "_Access" a, "_Actions" at where a.del=false and at.id=a.action_id and at.name=\'Update_'.$name.'\' and a.group_id in (select group_id from "_UsersGroups" where user_id='.$_SESSION['USER_ID'].');'); //$sql_query='select a.*,at.name from "_Access" a, "_Actions" at where a.del=false and at.id=a.action_id and at.name=\'Update_'.$name.'\' and a.group_id in (select group_id from "_UsersGroups" where user_id='.$_SESSION['USER_ID'].');';
$res = $db->query('select "getAccess"('.getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID']).',\'Update_'.$name.'\') as allow;'); $sql_query='select main.p_getaccess('.getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID']).',\'Update_'.$name.'\') as allow;';
$res = $db->query($sql_query);
while ($row = $res->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов while ($row = $res->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
{ {
$allow=$allow || ($row['allow'] == 't'); $allow=$allow || ($row['allow'] == 't');
}*/ }
$xmlAttr = $objXMLDocument->createAttribute("upd"); //insert $xmlAttr = $objXMLDocument->createAttribute("upd"); //insert
$xmlAttr->nodeValue = $allow ? "1" : "0"; $xmlAttr->nodeValue = $allow ? "1" : "0";
$currNode->setAttributeNode($xmlAttr); $currNode->setAttributeNode($xmlAttr);
/*$allow=false; $allow=false;
//$res = $db->query('select a.*,at.name from "_Access" a, "_Actions" at where a.del=false and at.id=a.action_id and at.name=\'Delete_'.$name.'\' and a.group_id in (select group_id from "_UsersGroups" where user_id='.$_SESSION['USER_ID'].');'); //$sql_query='select a.*,at.name from "_Access" a, "_Actions" at where a.del=false and at.id=a.action_id and at.name=\'Delete_'.$name.'\' and a.group_id in (select group_id from "_UsersGroups" where user_id='.$_SESSION['USER_ID'].');';
$res = $db->query('select "getAccess"('.getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID']).',\'Delete_'.$name.'\') as allow;'); $sql_query='select main.p_getaccess('.getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID']).',\'Delete_'.$name.'\') as allow;';
$res = $db->query($sql_query);
while ($row = $res->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов while ($row = $res->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
{ {
$allow=$allow || ($row['allow'] == 't'); $allow=$allow || ($row['allow'] == 't');
}*/ }
$xmlAttr = $objXMLDocument->createAttribute("del"); //delete $xmlAttr = $objXMLDocument->createAttribute("del"); //delete
$xmlAttr->nodeValue = $allow ? "1" : "0"; $xmlAttr->nodeValue = $allow ? "1" : "0";
$currNode->setAttributeNode($xmlAttr); $currNode->setAttributeNode($xmlAttr);
$allow=true;
$xmlAttr = $objXMLDocument->createAttribute("sel"); //select $xmlAttr = $objXMLDocument->createAttribute("sel"); //select
$xmlAttr->nodeValue = $allow ? "1" : "0"; $xmlAttr->nodeValue = $allow ? "1" : "0";
$currNode->setAttributeNode($xmlAttr); $currNode->setAttributeNode($xmlAttr);
//Удаляем все запросы из узла //Удаляем все запросы из узла
for($i=0;$i<5;$i++) for($i=0;$i<5;$i++)
{ $nsql=findFirstNode($currNode, "sql-query"); { $nsql=findFirstNode($currNode, "sql-query");

View File

@ -892,7 +892,10 @@ class TRequest
//загрузился xml документ начинаем его разбирать (по id функции в документе) //загрузился xml документ начинаем его разбирать (по id функции в документе)
var xmldoc = xmlHttpRequest.responseXML; var xmldoc = xmlHttpRequest.responseXML;
if(xmldoc==null) alert(_('Wrong_XML_document')+"!\nXML=("+xmlHttpRequest.responseText+')\nURL=('+url+')\nxmlString=('+xmlString+')'); if(xmldoc==null){
alert(_('Wrong_XML_document')+"!\nXML=("+xmlHttpRequest.responseText+')\nURL=('+url+')\nxmlString=('+xmlString+')');
return;
}
var node = xmldoc.documentElement; var node = xmldoc.documentElement;
if((node==null)||(node.getAttribute("fn")==null)) alert(_('Error')+"\n"+_('No_data')+"!\n"+xmlHttpRequest.responseText); if((node==null)||(node.getAttribute("fn")==null)) alert(_('Error')+"\n"+_('No_data')+"!\n"+xmlHttpRequest.responseText);