This commit is contained in:
Romain Neutron
2012-04-26 00:55:53 +02:00
parent edbfff226e
commit ade22295ad
631 changed files with 92375 additions and 101763 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -15,19 +15,18 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
function giveMeBases($usr=null)
function giveMeBases($usr = null)
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$conn = $appbox->get_connection();
$appbox = appbox::get_instance(\bootstrap::getCore());
$conn = $appbox->get_connection();
$inscriptions = null;
$inscriptions = null;
$usrerRegis = null;
$usrerRegis = null;
if ($usr != null)
{
if ($usr != null) {
$sqlU = 'SELECT sbas.dbname, time_limited, UNIX_TIMESTAMP( limited_from ) AS limited_from,
$sqlU = 'SELECT sbas.dbname, time_limited, UNIX_TIMESTAMP( limited_from ) AS limited_from,
UNIX_TIMESTAMP( limited_to ) AS limited_to, bas.server_coll_id,
usr.usr_id, basusr.actif, demand.en_cours, demand.refuser
FROM (usr, bas, sbas)
@@ -40,426 +39,374 @@ function giveMeBases($usr=null)
WHERE bas.active >0 AND bas.sbas_id = sbas.sbas_id
AND usr.usr_id = :usr_id AND model_of = 0';
$stmt = $conn->prepare($sqlU);
$stmt->execute(array(':usr_id' => $usr));
$rsU = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $conn->prepare($sqlU);
$stmt->execute(array(':usr_id' => $usr));
$rsU = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (count($rsU) == 0)
if (count($rsU) == 0)
return null;
return null;
foreach ($rsU as $rowU) {
if ( ! isset($usrerRegis[$rowU['dbname']]))
$usrerRegis[$rowU['dbname']] = null;
foreach ($rsU as $rowU)
{
if (!isset($usrerRegis[$rowU['dbname']]))
$usrerRegis[$rowU['dbname']] = null;
if ( ! is_null($rowU['actif']) || ! is_null($rowU['en_cours'])) {
if (!is_null($rowU['actif']) || !is_null($rowU['en_cours']))
{
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = true;
if ($rowU['actif'] == '0')
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = 'NONACTIF';
elseif ($rowU['time_limited'] == '1' && !($rowU['limited_from'] >= time() && $rowU['limited_to'] <= time()))
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = 'OUTTIME';
elseif ($rowU['time_limited'] == '1' && ($rowU['limited_from'] > time() && $rowU['limited_to'] < time()))
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = 'INTIME';
elseif ($rowU['en_cours'] == '1')
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = 'WAIT';
elseif ($rowU['refuser'] == '1')
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = 'REFUSE';
}
}
}
foreach ($appbox->get_databoxes() as $databox)
{
$collname = $basname = null;
$sbas_id = $databox->get_sbas_id();
$inscriptions[$sbas_id] = array();
$inscriptions[$sbas_id]['CGU'] = false;
$inscriptions[$sbas_id]['CGUrelease'] = false;
$inscriptions[$sbas_id]['inscript'] = false;
$inscriptions[$sbas_id]['CollsCGU'] = null;
$inscriptions[$sbas_id]['Colls'] = null;
$inscriptions[$sbas_id]['CollsRegistered'] = null;
$inscriptions[$sbas_id]['CollsWait'] = null;
$inscriptions[$sbas_id]['CollsRefuse'] = null;
$inscriptions[$sbas_id]['CollsIntime'] = null;
$inscriptions[$sbas_id]['CollsOuttime'] = null;
$inscriptions[$sbas_id]['CollsNonactif'] = null;
foreach ($databox->get_collections() as $key => $coll)
{
$collname[$key] = $coll->get_name();
$basname[$key] = $coll->get_coll_id();
}
$sbpcgu = '';
$xml = $databox->get_sxml_structure();
if ($xml)
{
foreach ($xml->xpath('/record/caninscript') as $caninscript)
{
if ($inscriptions[$sbas_id]['inscript'] === false)
$inscriptions[$sbas_id]['inscript'] = ((string) $caninscript == "1");
}
foreach ($xml->xpath('/record/cgu') as $sbpcgu)
{
foreach ($sbpcgu->attributes() as $a => $b)
{
if ($a == "release")
$inscriptions[$sbas_id]['CGUrelease'] = (string) $b;
}
$inscriptions[$sbas_id]['CGU'] = (string) $sbpcgu->saveXML();
}
}
$baseInscript = $inscriptions[$sbas_id]['inscript'];
foreach ($databox->get_collections() as $collection)
{
$cguColl = false;
$collInscript = $baseInscript;
$defined = false;
$cguSpec = false;
if ($xml = simplexml_load_string($collection->get_prefs()))
{
$defined = true;
foreach ($xml->xpath('/baseprefs/caninscript') as $caninscript)
{
$tmp = (string) $caninscript;
if ($tmp === "1")
$collInscript = true;
elseif ($tmp === "0")
$collInscript = false;
}
if ($collInscript)
{
$cguCollRelease = false;
if ($inscriptions[$sbas_id]['inscript'] === false)
$inscriptions[$sbas_id]['inscript'] = !!$collInscript;
foreach ($xml->xpath('/baseprefs/cgu') as $bpcgu)
{
foreach ($bpcgu->attributes() as $a => $b)
{
if ($a == "release")
$cguCollRelease = (string) $b;
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = true;
if ($rowU['actif'] == '0')
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = 'NONACTIF';
elseif ($rowU['time_limited'] == '1' && ! ($rowU['limited_from'] >= time() && $rowU['limited_to'] <= time()))
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = 'OUTTIME';
elseif ($rowU['time_limited'] == '1' && ($rowU['limited_from'] > time() && $rowU['limited_to'] < time()))
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = 'INTIME';
elseif ($rowU['en_cours'] == '1')
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = 'WAIT';
elseif ($rowU['refuser'] == '1')
$usrerRegis[$rowU['dbname']][$rowU['server_coll_id']] = 'REFUSE';
}
$cguColl = (string) $bpcgu->saveXML();
}
if ($cguColl)
{
$cguSpec = true;
}
else
{
if (!isset($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()]))
$inscriptions[$sbas_id]['Colls'][$collection->get_coll_id()] = $collection->get_name();
}
}
}
$lacgu = $cguColl ? $cguColl : (string) $sbpcgu;
if (isset($usrerRegis[$databox->get_dbname()]) && isset($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()]))
{
if ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === "WAIT")
$inscriptions[$sbas_id]['CollsWait'][$collection->get_coll_id()] = $lacgu;
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === "REFUSE")
$inscriptions[$sbas_id]['CollsRefuse'][$collection->get_coll_id()] = $lacgu;
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === "INTIME")
$inscriptions[$sbas_id]['CollsIntime'][$collection->get_coll_id()] = $lacgu;
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === "OUTTIME")
$inscriptions[$sbas_id]['CollsOuttime'][$collection->get_coll_id()] = $lacgu;
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === "NONACTIF")
$inscriptions[$sbas_id]['CollsNonactif'][$collection->get_coll_id()] = $lacgu;
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === true)
$inscriptions[$sbas_id]['CollsRegistered'][$collection->get_coll_id()] = $lacgu;
}
elseif (!$cguSpec && $collInscript)//ne va pas.. si l'inscriptio na la coll est explicitement non autorise, je refuse'
{
$inscriptions[$sbas_id]['Colls'][$collection->get_coll_id()] = $collection->get_name();
}
elseif ($cguSpec)
{
$inscriptions[$sbas_id]['CollsCGU'][$collection->get_coll_id()]['name'] = $collection->get_name();
$inscriptions[$sbas_id]['CollsCGU'][$collection->get_coll_id()]['CGU'] = $cguColl;
$inscriptions[$sbas_id]['CollsCGU'][$collection->get_coll_id()]['CGUrelease'] = $cguCollRelease;
}
}
}
return $inscriptions;
foreach ($appbox->get_databoxes() as $databox) {
$collname = $basname = null;
$sbas_id = $databox->get_sbas_id();
$inscriptions[$sbas_id] = array();
$inscriptions[$sbas_id]['CGU'] = false;
$inscriptions[$sbas_id]['CGUrelease'] = false;
$inscriptions[$sbas_id]['inscript'] = false;
$inscriptions[$sbas_id]['CollsCGU'] = null;
$inscriptions[$sbas_id]['Colls'] = null;
$inscriptions[$sbas_id]['CollsRegistered'] = null;
$inscriptions[$sbas_id]['CollsWait'] = null;
$inscriptions[$sbas_id]['CollsRefuse'] = null;
$inscriptions[$sbas_id]['CollsIntime'] = null;
$inscriptions[$sbas_id]['CollsOuttime'] = null;
$inscriptions[$sbas_id]['CollsNonactif'] = null;
foreach ($databox->get_collections() as $key => $coll) {
$collname[$key] = $coll->get_name();
$basname[$key] = $coll->get_coll_id();
}
$sbpcgu = '';
$xml = $databox->get_sxml_structure();
if ($xml) {
foreach ($xml->xpath('/record/caninscript') as $caninscript) {
if ($inscriptions[$sbas_id]['inscript'] === false)
$inscriptions[$sbas_id]['inscript'] = ((string) $caninscript == "1");
}
foreach ($xml->xpath('/record/cgu') as $sbpcgu) {
foreach ($sbpcgu->attributes() as $a => $b) {
if ($a == "release")
$inscriptions[$sbas_id]['CGUrelease'] = (string) $b;
}
$inscriptions[$sbas_id]['CGU'] = (string) $sbpcgu->saveXML();
}
}
$baseInscript = $inscriptions[$sbas_id]['inscript'];
foreach ($databox->get_collections() as $collection) {
$cguColl = false;
$collInscript = $baseInscript;
$defined = false;
$cguSpec = false;
if ($xml = simplexml_load_string($collection->get_prefs())) {
$defined = true;
foreach ($xml->xpath('/baseprefs/caninscript') as $caninscript) {
$tmp = (string) $caninscript;
if ($tmp === "1")
$collInscript = true;
elseif ($tmp === "0")
$collInscript = false;
}
if ($collInscript) {
$cguCollRelease = false;
if ($inscriptions[$sbas_id]['inscript'] === false)
$inscriptions[$sbas_id]['inscript'] = ! ! $collInscript;
foreach ($xml->xpath('/baseprefs/cgu') as $bpcgu) {
foreach ($bpcgu->attributes() as $a => $b) {
if ($a == "release")
$cguCollRelease = (string) $b;
}
$cguColl = (string) $bpcgu->saveXML();
}
if ($cguColl) {
$cguSpec = true;
} else {
if ( ! isset($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()]))
$inscriptions[$sbas_id]['Colls'][$collection->get_coll_id()] = $collection->get_name();
}
}
}
$lacgu = $cguColl ? $cguColl : (string) $sbpcgu;
if (isset($usrerRegis[$databox->get_dbname()]) && isset($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()])) {
if ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === "WAIT")
$inscriptions[$sbas_id]['CollsWait'][$collection->get_coll_id()] = $lacgu;
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === "REFUSE")
$inscriptions[$sbas_id]['CollsRefuse'][$collection->get_coll_id()] = $lacgu;
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === "INTIME")
$inscriptions[$sbas_id]['CollsIntime'][$collection->get_coll_id()] = $lacgu;
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === "OUTTIME")
$inscriptions[$sbas_id]['CollsOuttime'][$collection->get_coll_id()] = $lacgu;
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === "NONACTIF")
$inscriptions[$sbas_id]['CollsNonactif'][$collection->get_coll_id()] = $lacgu;
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === true)
$inscriptions[$sbas_id]['CollsRegistered'][$collection->get_coll_id()] = $lacgu;
}
elseif ( ! $cguSpec && $collInscript) {//ne va pas.. si l'inscriptio na la coll est explicitement non autorise, je refuse'
$inscriptions[$sbas_id]['Colls'][$collection->get_coll_id()] = $collection->get_name();
} elseif ($cguSpec) {
$inscriptions[$sbas_id]['CollsCGU'][$collection->get_coll_id()]['name'] = $collection->get_name();
$inscriptions[$sbas_id]['CollsCGU'][$collection->get_coll_id()]['CGU'] = $cguColl;
$inscriptions[$sbas_id]['CollsCGU'][$collection->get_coll_id()]['CGUrelease'] = $cguCollRelease;
}
}
}
return $inscriptions;
}
function giveMeBaseUsr($usr, $lng)
{
$noDemand = true;
$appbox = appbox::get_instance(\bootstrap::getCore());
$noDemand = true;
$appbox = appbox::get_instance(\bootstrap::getCore());
$out = '<table border="0" style="table-layout:fixed;font-size:11px;" cellspacing=0 width="100%">' .
'<tr>' .
'<td style="width:180px; text-align:right">&nbsp;</td>' .
'<td width="15px" style="width:15px">&nbsp;</td>' .
'<td style="width:180px;">&nbsp;</td>' .
'</tr>';
$out = '<table border="0" style="table-layout:fixed;font-size:11px;" cellspacing=0 width="100%">' .
'<tr>' .
'<td style="width:180px; text-align:right">&nbsp;</td>' .
'<td width="15px" style="width:15px">&nbsp;</td>' .
'<td style="width:180px;">&nbsp;</td>' .
'</tr>';
$inscriptions = giveMeBases($usr);
foreach ($inscriptions as $sbasId => $baseInsc)
{
//je presente la base
if (($baseInsc['CollsRegistered'] || $baseInsc['CollsRefuse'] || $baseInsc['CollsWait'] || $baseInsc['CollsIntime'] || $baseInsc['CollsOuttime'] || $baseInsc['CollsNonactif'] || $baseInsc['CollsCGU'] || $baseInsc['Colls']))//&& $baseInsc['inscript'])
$out .= '<tr><td colspan="3" style="text-align:center;"><h3>' . phrasea::sbas_names ($sbasId) . '</h3></td></tr>';
$inscriptions = giveMeBases($usr);
foreach ($inscriptions as $sbasId => $baseInsc) {
//je presente la base
if (($baseInsc['CollsRegistered'] || $baseInsc['CollsRefuse'] || $baseInsc['CollsWait'] || $baseInsc['CollsIntime'] || $baseInsc['CollsOuttime'] || $baseInsc['CollsNonactif'] || $baseInsc['CollsCGU'] || $baseInsc['Colls']))//&& $baseInsc['inscript'])
$out .= '<tr><td colspan="3" style="text-align:center;"><h3>' . phrasea::sbas_names($sbasId) . '</h3></td></tr>';
if ($baseInsc['CollsRegistered'])
{
foreach ($baseInsc['CollsRegistered'] as $collId => $isTrue)
{
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces authorise sur la collection ') . phrasea::bas_names($base_id);
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
if ($baseInsc['CollsRefuse'])
{
foreach ($baseInsc['CollsRefuse'] as $collId => $isTrue)
{
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces refuse sur la collection ') . phrasea::bas_names($base_id) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
if ($baseInsc['CollsWait'])
{
foreach ($baseInsc['CollsWait'] as $collId => $isTrue)
{
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:orange;">' . _('login::register: en attente d\'acces sur') .' '. phrasea::bas_names($base_id) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
if ($baseInsc['CollsIntime'])
{
foreach ($baseInsc['CollsIntime'] as $collId => $isTrue)
{
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces temporaire sur') . phrasea::bas_names($base_id) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
if ($baseInsc['CollsOuttime'])
{
foreach ($baseInsc['CollsOuttime'] as $collId => $isTrue)
{
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces temporaire termine sur ') . phrasea::bas_names($base_id) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
if ($baseInsc['CollsNonactif'])
{
foreach ($baseInsc['CollsNonactif'] as $collId => $isTrue)
{
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces supendu sur') . phrasea::bas_names($base_id) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
if (($baseInsc['CollsCGU'] || $baseInsc['Colls']) && $baseInsc['inscript'])// il y a des coll ou s'inscrire !
{
$noDemand = false;
if ($baseInsc['Colls'])//des coll ou on peut s'inscrire sans cgu specifiques
{
//je check si ya des cgu pour la base
if ($baseInsc['CGU'])
{
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes') . '</td></tr>';
$out .= '<tr><td colspan="3" style="text-align:center;"><div style="width:90%;height:120px;text-align:left;overflow:auto;">' . $baseInsc['CGU'] . '</div></td></tr>';
if ($baseInsc['CollsRegistered']) {
foreach ($baseInsc['CollsRegistered'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces authorise sur la collection ') . phrasea::bas_names($base_id);
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
foreach ($baseInsc['Colls'] as $collId => $collName)
{
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr>' .
'<td style="text-align:right;">' . $collName . '</td>' .
'<td></td>' .
'<td class="TD_R" style="width:200px;">' .
'<input style="width:15px;" class="checkbox" type="checkbox" name="demand[]" value="' . $base_id . '" >' .
'<span>' . _('login::register: Faire une demande d\'acces') . '</span>' .
'</td>' .
'</tr>';
if ($baseInsc['CollsRefuse']) {
foreach ($baseInsc['CollsRefuse'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces refuse sur la collection ') . phrasea::bas_names($base_id) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
}
if ($baseInsc['CollsCGU'])
{
foreach ($baseInsc['CollsCGU'] as $collId => $collDesc)
{
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;"><hr style="width:80%"/></td></tr>' .
'<tr><td colspan="3" style="text-align:center;">' . _('login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes') . '</td></tr>' .
'<tr>' .
'<td colspan="3" style="text-align:center;">' .
'<div style="width:90%;height:120px;text-align:left;overflow:auto;">' . $collDesc['CGU'] . '</div>' .
'</td>' .
'</tr>' .
'<tr >' .
'<td style="text-align:right;">' . $collDesc['name'] . '</td>' .
'<td></td>' .
'<td class="TD_R" style="width:200px;">' .
'<input style="width:15px;" class="checkbox" type="checkbox" name="demand[]" value="' . $base_id . '" >' .
'<span>' . _('login::register: Faire une demande d\'acces') . '</span>' .
'</td>' .
'</tr>';
if ($baseInsc['CollsWait']) {
foreach ($baseInsc['CollsWait'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:orange;">' . _('login::register: en attente d\'acces sur') . ' ' . phrasea::bas_names($base_id) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
if ($baseInsc['CollsIntime']) {
foreach ($baseInsc['CollsIntime'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces temporaire sur') . phrasea::bas_names($base_id) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
if ($baseInsc['CollsOuttime']) {
foreach ($baseInsc['CollsOuttime'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces temporaire termine sur ') . phrasea::bas_names($base_id) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
if ($baseInsc['CollsNonactif']) {
foreach ($baseInsc['CollsNonactif'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces supendu sur') . phrasea::bas_names($base_id) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
}
$out .= '<tr style="height:5px;"><td></td></tr>';
if (($baseInsc['CollsCGU'] || $baseInsc['Colls']) && $baseInsc['inscript']) {// il y a des coll ou s'inscrire !
$noDemand = false;
if ($baseInsc['Colls']) {//des coll ou on peut s'inscrire sans cgu specifiques
//je check si ya des cgu pour la base
if ($baseInsc['CGU']) {
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes') . '</td></tr>';
$out .= '<tr><td colspan="3" style="text-align:center;"><div style="width:90%;height:120px;text-align:left;overflow:auto;">' . $baseInsc['CGU'] . '</div></td></tr>';
}
foreach ($baseInsc['Colls'] as $collId => $collName) {
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr>' .
'<td style="text-align:right;">' . $collName . '</td>' .
'<td></td>' .
'<td class="TD_R" style="width:200px;">' .
'<input style="width:15px;" class="checkbox" type="checkbox" name="demand[]" value="' . $base_id . '" >' .
'<span>' . _('login::register: Faire une demande d\'acces') . '</span>' .
'</td>' .
'</tr>';
}
}
if ($baseInsc['CollsCGU']) {
foreach ($baseInsc['CollsCGU'] as $collId => $collDesc) {
$base_id = phrasea::baseFromColl($sbasId, $collId);
$out .= '<tr><td colspan="3" style="text-align:center;"><hr style="width:80%"/></td></tr>' .
'<tr><td colspan="3" style="text-align:center;">' . _('login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes') . '</td></tr>' .
'<tr>' .
'<td colspan="3" style="text-align:center;">' .
'<div style="width:90%;height:120px;text-align:left;overflow:auto;">' . $collDesc['CGU'] . '</div>' .
'</td>' .
'</tr>' .
'<tr >' .
'<td style="text-align:right;">' . $collDesc['name'] . '</td>' .
'<td></td>' .
'<td class="TD_R" style="width:200px;">' .
'<input style="width:15px;" class="checkbox" type="checkbox" name="demand[]" value="' . $base_id . '" >' .
'<span>' . _('login::register: Faire une demande d\'acces') . '</span>' .
'</td>' .
'</tr>';
}
}
}
}
}
}
$out .= '</table>';
$out .= '</table>';
return array('tab' => $out, 'demandes' => $noDemand);
return array('tab' => $out, 'demandes' => $noDemand);
}
function giveModInscript($usr, $lng)
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$out = '<html lang="' . $session->get_I18n() . '">' .
'<head>' .
'</head>' .
'<body>' .
'<div style="width:600px;height:20px;text-align:center;margin:0">' . _('admin::compte-utilisateur actuellement, acces aux bases suivantes : ') . ' :</div>' .
'<form id="conf_mod" target="_self" action="mod_inscript.php" method="post">' .
'<div style="width:400px;center;margin:0 100px;">';
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$out = '<html lang="' . $session->get_I18n() . '">' .
'<head>' .
'</head>' .
'<body>' .
'<div style="width:600px;height:20px;text-align:center;margin:0">' . _('admin::compte-utilisateur actuellement, acces aux bases suivantes : ') . ' :</div>' .
'<form id="conf_mod" target="_self" action="mod_inscript.php" method="post">' .
'<div style="width:400px;center;margin:0 100px;">';
$demandes = giveMeBaseUsr($usr, $lng);
$demandes = giveMeBaseUsr($usr, $lng);
$out .= $demandes['tab'];
$out .= $demandes['tab'];
$noDemand = $demandes['demandes'];
$out .= '</div>' .
'<input type="hidden" value="' . $lng . '" name="lng">' .
'<input type="hidden" value="SEND" name="act">' .
'<input type="hidden" value="' . $usr . '" name="usrid">' .
'</form>';
$noDemand = $demandes['demandes'];
$out .= '</div>' .
'<input type="hidden" value="' . $lng . '" name="lng">' .
'<input type="hidden" value="SEND" name="act">' .
'<input type="hidden" value="' . $usr . '" name="usrid">' .
'</form>';
if ($noDemand)
{
$out .= '<div style="margin:10px 0;width:600px;text-align:center;">' . _('login::register: Vous avez acces a toutes les collections de toutes les bases') . '</div>';
}
else
{
$out .= '<div style="margin:10px 0;width:600px;text-align:center;"><input type="button" value="' . _('login::register: confirmer la demande') . '" onclick="document.getElementById(\'conf_mod\').submit();" /></a></div>';
}
$out .= '</div>' .
'</body>' .
'</html>';
return $out;
}
function giveInscript($lng, $demandes=null)
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$out = '<table border="0" style="table-layout:fixed" cellspacing=0 width="590">' .
'<tr>' .
'<td style="width:240px; text-align:right">&nbsp;</td>' .
'<td width="25px" style="width:25px">&nbsp;</td>' .
'<td style="width:325px;">&nbsp;</td>' .
'</tr>';
$inscriptions = giveMeBases();
foreach ($inscriptions as $sbasId => $baseInsc)
{
if (($baseInsc['CollsCGU'] || $baseInsc['Colls']) && $baseInsc['inscript'])// il y a des coll ou s'inscrire !
{
//je pr<70>sente la base
$out .= '<tr><td colspan="3" style="text-align:center;"><h3 style="margin: 15px 0pt 2px;" class="inscriptbase">' . phrasea::sbas_names($sbasId) . '</h3></td></tr>';
if ($baseInsc['Colls'])//des coll ou on peut s'inscrire sans cgu specifiques
{
//je check si ya des cgu pour la base
if ($baseInsc['CGU'])
{
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes') . '<br/><a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '">' . _('login::register::CGU: ouvrir dans une nouvelle fenetre') . '</a></td></tr>';
//$out .= '<tr><td colspan="3" style="text-align:center;"><div id="CGUTXT'.$sbasId.'" style="width:90%;height:120px;text-align:left;overflow:auto;">'.(string)$baseInsc['CGU'].'</div></td></tr>';
}
foreach ($baseInsc['Colls'] as $collId => $collName)
{
$baseId = phrasea::baseFromColl($sbasId, $collId);
$ch = "checked";
if ((!is_null($demandes) && !isset($demandes[$baseId])))
$ch = "";
$out .= '<tr>' .
'<td style="text-align:right;">' . $collName . '</td>' .
'<td></td>' .
'<td class="TD_R" style="width:200px;">' .
'<input style="width:15px;" class="checkbox" type="checkbox" ' . $ch . ' name="demand[]" value="' . $baseId . '" >' .
'<span>' . _('login::register: Faire une demande d\'acces') . '</span>' .
'</td>' .
'</tr>';
}
}
if ($baseInsc['CollsCGU'])
{
foreach ($baseInsc['CollsCGU'] as $collId => $collDesc)
{
$baseId = phrasea::baseFromColl($sbasId, $collId);
$ch = "checked";
if (!is_null($demandes) && !isset($demandes[$baseId]))
$ch = "";
$out .= '<tr><td colspan="3" style="text-align:center;"><hr style="width:80%"/></td></tr>' .
'<tr><td colspan="3" style="text-align:center;">' . _('login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes') .
'<br/><a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: ouvrir dans une nouvelle fenetre') . '</a></td></tr>' .
// '<tr >' .
// '<td colspan="3" style="text-align:center;"><div style="height:120px;text-align:left;overflow:auto;">' .
// ''.(string)$collDesc['CGU'].'' .
// '</div></td>' .
// '</tr>' .
'<tr >' .
'<td style="text-align:right;">' . $collDesc['name'] . '</td>' .
'<td></td>' .
'<td class="TD_R" style="width:200px;">' .
'<input style="width:15px;" class="checkbox" type="checkbox" ' . $ch . ' name="demand[]" value="' . $baseId . '" >' .
'<span>' . _('login::register: Faire une demande d\'acces') . '</span>' .
'</td>' .
'</tr>';
}
}
if ($noDemand) {
$out .= '<div style="margin:10px 0;width:600px;text-align:center;">' . _('login::register: Vous avez acces a toutes les collections de toutes les bases') . '</div>';
} else {
$out .= '<div style="margin:10px 0;width:600px;text-align:center;"><input type="button" value="' . _('login::register: confirmer la demande') . '" onclick="document.getElementById(\'conf_mod\').submit();" /></a></div>';
}
}
$out .= '</table>';
return $out;
$out .= '</div>' .
'</body>' .
'</html>';
return $out;
}
function giveInscript($lng, $demandes = null)
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$out = '<table border="0" style="table-layout:fixed" cellspacing=0 width="590">' .
'<tr>' .
'<td style="width:240px; text-align:right">&nbsp;</td>' .
'<td width="25px" style="width:25px">&nbsp;</td>' .
'<td style="width:325px;">&nbsp;</td>' .
'</tr>';
$inscriptions = giveMeBases();
foreach ($inscriptions as $sbasId => $baseInsc) {
if (($baseInsc['CollsCGU'] || $baseInsc['Colls']) && $baseInsc['inscript']) {// il y a des coll ou s'inscrire !
//je pr<70>sente la base
$out .= '<tr><td colspan="3" style="text-align:center;"><h3 style="margin: 15px 0pt 2px;" class="inscriptbase">' . phrasea::sbas_names($sbasId) . '</h3></td></tr>';
if ($baseInsc['Colls']) {//des coll ou on peut s'inscrire sans cgu specifiques
//je check si ya des cgu pour la base
if ($baseInsc['CGU']) {
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes') . '<br/><a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '">' . _('login::register::CGU: ouvrir dans une nouvelle fenetre') . '</a></td></tr>';
//$out .= '<tr><td colspan="3" style="text-align:center;"><div id="CGUTXT'.$sbasId.'" style="width:90%;height:120px;text-align:left;overflow:auto;">'.(string)$baseInsc['CGU'].'</div></td></tr>';
}
foreach ($baseInsc['Colls'] as $collId => $collName) {
$baseId = phrasea::baseFromColl($sbasId, $collId);
$ch = "checked";
if (( ! is_null($demandes) && ! isset($demandes[$baseId])))
$ch = "";
$out .= '<tr>' .
'<td style="text-align:right;">' . $collName . '</td>' .
'<td></td>' .
'<td class="TD_R" style="width:200px;">' .
'<input style="width:15px;" class="checkbox" type="checkbox" ' . $ch . ' name="demand[]" value="' . $baseId . '" >' .
'<span>' . _('login::register: Faire une demande d\'acces') . '</span>' .
'</td>' .
'</tr>';
}
}
if ($baseInsc['CollsCGU']) {
foreach ($baseInsc['CollsCGU'] as $collId => $collDesc) {
$baseId = phrasea::baseFromColl($sbasId, $collId);
$ch = "checked";
if ( ! is_null($demandes) && ! isset($demandes[$baseId]))
$ch = "";
$out .= '<tr><td colspan="3" style="text-align:center;"><hr style="width:80%"/></td></tr>' .
'<tr><td colspan="3" style="text-align:center;">' . _('login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes') .
'<br/><a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: ouvrir dans une nouvelle fenetre') . '</a></td></tr>' .
// '<tr >' .
// '<td colspan="3" style="text-align:center;"><div style="height:120px;text-align:left;overflow:auto;">' .
// ''.(string)$collDesc['CGU'].'' .
// '</div></td>' .
// '</tr>' .
'<tr >' .
'<td style="text-align:right;">' . $collDesc['name'] . '</td>' .
'<td></td>' .
'<td class="TD_R" style="width:200px;">' .
'<input style="width:15px;" class="checkbox" type="checkbox" ' . $ch . ' name="demand[]" value="' . $baseId . '" >' .
'<span>' . _('login::register: Faire une demande d\'acces') . '</span>' .
'</td>' .
'</tr>';
}
}
}
}
$out .= '</table>';
return $out;
}
?>

View File

@@ -1,173 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
//if (!function_exists('phrasea_list_bases'))
//{
//
// function phrasea_list_bases()
// {
//
// $conn = connection::getPDOConnection();
// $sql = "SELECT base_id, host, port, dbname, user, pwd, server_coll_id, sbas.sbas_id, viewname
// FROM (sbas INNER JOIN bas ON bas.sbas_id=sbas.sbas_id)
// WHERE active>0
// ORDER BY sbas.ord, sbas.sbas_id, bas.ord";
// $stmt = $conn->prepare($sql);
// $stmt->execute();
// $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
// $stmt->closeCursor();
//
// $last_sbas_id = false;
//
// $list = array('bases' => array());
//
// foreach ($rs as $row)
// {
// $basid = $row['base_id'];
// $sbas_id = $row['sbas_id'];
// $viewname = (trim($row['viewname']) !== '') ? $row['viewname'] : $row['dbname'];
//
// try
// {
// $connbas = connection::getPDOConnection($sbas_id);
//
//
// $list['bases'][$sbas_id] = array(
// 'sbas_id' => $sbas_id,
// 'host' => $row['host'],
// 'port' => $row['port'],
// 'dbname' => $row['dbname'],
// 'user' => $row['user'],
// 'pwd' => $row['pwd'],
// 'online' => false,
// 'collections' => array(),
// );
//
// $sql = "SELECT asciiname, prefs FROM coll WHERE coll_id = :coll_id";
// $stmt = $connbas->prepare($sql);
// $stmt->execute(array(':coll_id' => $row['coll_id']));
// $row2 = $stmt->fetch(PDO::FETCH_ASSOC);
//
// $list['bases'][$sbas_id]['collections'][$row['coll_id']] =
// array('asciiname' => $row2['asciiname'], 'prefs' => $row2['prefs']);
//
//
// if ($last_sbas_id == $sbas_id)
// continue;
//
// $list['bases'][$sbas_id]['online'] = true;
// $last_sbas_id = $sbas_id;
// }
// catch (Exception $e)
// {
//
// }
// }
// }
//
//}
if (!function_exists('phrasea_open_session'))
{
function phrasea_open_session($ses_id, $usr_id)
{
$conn = connection::getPDOConnection();
$sql = "UPDATE cache SET nact=nact+1, lastaccess=NOW()
WHERE session_id = :session_id AND usr_id = :usr_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':session_id' => $ses_id, ':usr_id' => $usr_id));
return;
}
}
if (!function_exists('phrasea_clear_cache'))
{
function phrasea_clear_cache()
{
$registry = registry::get_instance();
$filename = $registry->get('GV_RootPath') . '_phrasea_' . $registry->get('GV_sit') . '.answers.' . $ses_id . '';
unlink($filename);
$filename = $registry->get('GV_RootPath') . '_phrasea_' . $registry->get('GV_sit') . '.spots.' . $ses_id . '';
unlink($filename);
}
}
if (!function_exists('phrasea_create_session'))
{
function phrasea_create_session($usr_id)
{
try
{
$conn = connection::getPDOConnection();
$sql = "INSERT INTO cache (session_id, nact, lastaccess, answers, spots, session, usr_id)
VALUES (null, 0, NOW(), '', '', '', :usr_id)";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':usr_id', $usr_id));
$ses_id = $conn->lastInsertId();
return $ses_id;
}
catch (Exception $e)
{
return false;
}
}
}
if (!function_exists('phrasea_register_base'))
{
function phrasea_register_base($ses_id, $base_id)
{
$registered[$base_id] = true;
}
}
if (!function_exists('phrasea_close_session'))
{
function phrasea_close_session($ses_id)
{
try
{
$conn = connection::getPDOConnection();
$sql = "DELETE FROM cache WHERE session_id= :session_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':session_id', $ses_id));
return true;
}
catch (Exception $e)
{
return false;
}
}
}

View File

@@ -17,136 +17,121 @@
*/
function deleteRecord($lst, $del_children)
{
$Core = bootstrap::getCore();
$em = $Core->getEntityManager();
$BE_repository = $em->getRepository('\Entities\BasketElement');
$Core = bootstrap::getCore();
$em = $Core->getEntityManager();
$BE_repository = $em->getRepository('\Entities\BasketElement');
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $Core->getRegistry();
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $Core->getRegistry();
$user = $Core->getAuthenticatedUser();
$ACL = $user->ACL();
$user = $Core->getAuthenticatedUser();
$ACL = $user->ACL();
$lst = explode(";", $lst);
$lst = explode(";", $lst);
$tcoll = array();
$tbase = array();
$tcoll = array();
$tbase = array();
$conn = $appbox->get_connection();
$conn = $appbox->get_connection();
foreach ($lst as $basrec)
{
$basrec = explode("_", $basrec);
if (!$basrec || count($basrec) !== 2)
continue;
foreach ($lst as $basrec) {
$basrec = explode("_", $basrec);
if ( ! $basrec || count($basrec) !== 2)
continue;
$record = new record_adapter($basrec[0], $basrec[1]);
$base_id = $record->get_base_id();
if (!isset($tcoll["c" . $base_id]))
{
$record = new record_adapter($basrec[0], $basrec[1]);
$base_id = $record->get_base_id();
if ( ! isset($tcoll["c" . $base_id])) {
$tcoll["c" . $base_id] = null;
$tcoll["c" . $base_id] = null;
foreach ($appbox->get_databoxes() as $databox)
{
foreach ($databox->get_collections() as $collection)
{
if ($collection->get_base_id() == $base_id)
{
$tcoll["c" . $base_id] = array("base_id" => $databox->get_sbas_id(), "id" => $base_id);
if (!isset($tbase["b" . $base_id]))
{
$x = $databox->get_structure();
$tbase["b" . $collection->get_base_id()] = array("id" => $collection->get_base_id(), "rids" => array());
foreach ($appbox->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
if ($collection->get_base_id() == $base_id) {
$tcoll["c" . $base_id] = array("base_id" => $databox->get_sbas_id(), "id" => $base_id);
if ( ! isset($tbase["b" . $base_id])) {
$x = $databox->get_structure();
$tbase["b" . $collection->get_base_id()] = array("id" => $collection->get_base_id(), "rids" => array());
}
break;
}
}
}
break;
}
}
}
}
$temp = null;
$temp[0] = $basrec[0];
$temp[1] = $basrec[1];
$tbase["b" . $tcoll["c" . $base_id]["base_id"]]["rids"][] = $temp;
}
$ret = array();
foreach ($tbase as $base)
{
try
{
foreach ($base["rids"] as $rid)
{
$record = new record_adapter($rid[0], $rid[1]);
if (!$ACL->has_right_on_base($record->get_base_id(), 'candeleterecord'))
continue;
if ($del_children == "1")
{
foreach ($record->get_children() as $oneson)
{
if (!$ACL->has_right_on_base($oneson->get_base_id(), 'candeleterecord'))
continue;
$oneson->delete();
$ret[] = $oneson->get_serialize_key();
}
}
$ret[] = $record->get_serialize_key();
$basket_elements = $BE_repository->findElementsByRecord($record);
foreach($basket_elements as $basket_element)
{
$em->remove($basket_element);
}
$record->delete();
unset($record);
}
$temp = null;
$temp[0] = $basrec[0];
$temp[1] = $basrec[1];
$tbase["b" . $tcoll["c" . $base_id]["base_id"]]["rids"][] = $temp;
}
catch (Exception $e)
{
$ret = array();
foreach ($tbase as $base) {
try {
foreach ($base["rids"] as $rid) {
$record = new record_adapter($rid[0], $rid[1]);
if ( ! $ACL->has_right_on_base($record->get_base_id(), 'candeleterecord'))
continue;
if ($del_children == "1") {
foreach ($record->get_children() as $oneson) {
if ( ! $ACL->has_right_on_base($oneson->get_base_id(), 'candeleterecord'))
continue;
$oneson->delete();
$ret[] = $oneson->get_serialize_key();
}
}
$ret[] = $record->get_serialize_key();
$basket_elements = $BE_repository->findElementsByRecord($record);
foreach ($basket_elements as $basket_element) {
$em->remove($basket_element);
}
$record->delete();
unset($record);
}
} catch (Exception $e) {
}
}
}
$em->flush();
$em->flush();
return p4string::jsonencode($ret);
return p4string::jsonencode($ret);
}
function whatCanIDelete($lst)
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$usr_id = $session->get_usr_id();
$usr_id = $session->get_usr_id();
$conn = $appbox->get_connection();
$conn = $appbox->get_connection();
$nbdocsel = 0;
$nbgrp = 0;
$oksel = array();
$arrSel = explode(";", $lst);
$nbdocsel = 0;
$nbgrp = 0;
$oksel = array();
$arrSel = explode(";", $lst);
if (!is_array($lst))
$lst = explode(';', $lst);
if ( ! is_array($lst))
$lst = explode(';', $lst);
foreach ($lst as $sel)
{
if ($sel == "")
continue;
$exp = explode("_", $sel);
foreach ($lst as $sel) {
if ($sel == "")
continue;
$exp = explode("_", $sel);
if (count($exp) !== 2)
continue;
if (count($exp) !== 2)
continue;
$record = new record_adapter($exp[0], $exp[1]);
$sqlV = 'SELECT mask_and, mask_xor, sb.*
$record = new record_adapter($exp[0], $exp[1]);
$sqlV = 'SELECT mask_and, mask_xor, sb.*
FROM (sbas sb, bas b, usr u)
LEFT JOIN basusr bu ON
(bu.base_id = b.base_id AND bu.candeleterecord = "1"
@@ -154,46 +139,41 @@ function whatCanIDelete($lst)
WHERE u.usr_id = :usr_id AND b.base_id = :base_id
AND b.sbas_id = sb.sbas_id';
$params = array(
':base_id' => $record->get_base_id()
, ':usr_id' => $usr_id
);
$params = array(
':base_id' => $record->get_base_id()
, ':usr_id' => $usr_id
);
$stmt = $conn->prepare($sqlV);
$stmt->execute($params);
$rowV = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $conn->prepare($sqlV);
$stmt->execute($params);
$rowV = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($rowV && $rowV['mask_and'] != '' && $rowV['mask_xor'] != '')
{
try
{
$connbas = connection::getPDOConnection($rowV['sbas_id']);
$sqlS2 = 'SELECT record_id FROM record
if ($rowV && $rowV['mask_and'] != '' && $rowV['mask_xor'] != '') {
try {
$connbas = connection::getPDOConnection($rowV['sbas_id']);
$sqlS2 = 'SELECT record_id FROM record
WHERE ((status ^ ' . $rowV['mask_xor'] . ') & ' . $rowV['mask_and'] . ')=0
AND record_id = :record_id';
$stmt = $connbas->prepare($sqlS2);
$stmt->execute(array(':record_id' => $exp[1]));
$num_rows = $stmt->rowCount();
$stmt->closeCursor();
$stmt = $connbas->prepare($sqlS2);
$stmt->execute(array(':record_id' => $exp[1]));
$num_rows = $stmt->rowCount();
$stmt->closeCursor();
if ($num_rows > 0)
{
$oksel[] = implode('_', $exp);
$nbdocsel++;
if ($record->is_grouping())
$nbgrp++;
if ($num_rows > 0) {
$oksel[] = implode('_', $exp);
$nbdocsel ++;
if ($record->is_grouping())
$nbgrp ++;
}
} catch (Exception $e) {
}
}
}
catch (Exception $e)
{
}
}
}
$ret = array('lst' => $oksel, 'groupings' => $nbgrp);
$ret = array('lst' => $oksel, 'groupings' => $nbgrp);
return p4string::jsonencode($ret);
return p4string::jsonencode($ret);
}