Update deprecated classes

This commit is contained in:
Romain Neutron
2012-09-21 15:01:26 +02:00
parent 8ff146b215
commit 6f30b71f8e
2 changed files with 46 additions and 57 deletions

View File

@@ -9,15 +9,17 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
function giveMeBases($usr = null) function giveMeBases(Application $app, $usr = null)
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $conn = $app['phraseanet.appbox']->get_connection();
$conn = $appbox->get_connection();
$inscriptions = null; $inscriptions = null;
@@ -68,7 +70,7 @@ function giveMeBases($usr = null)
} }
} }
foreach ($appbox->get_databoxes() as $databox) { foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
$collname = $basname = null; $collname = $basname = null;
$sbas_id = $databox->get_sbas_id(); $sbas_id = $databox->get_sbas_id();
$inscriptions[$sbas_id] = array(); $inscriptions[$sbas_id] = array();
@@ -169,11 +171,9 @@ function giveMeBases($usr = null)
return $inscriptions; return $inscriptions;
} }
function giveMeBaseUsr($usr, $lng) function giveMeBaseUsr(Application $app, $usr, $lng)
{ {
$noDemand = true; $noDemand = true;
$appbox = appbox::get_instance(\bootstrap::getCore());
$out = '<table border="0" style="table-layout:fixed;font-size:11px;" cellspacing=0 width="100%">' . $out = '<table border="0" style="table-layout:fixed;font-size:11px;" cellspacing=0 width="100%">' .
'<tr>' . '<tr>' .
@@ -182,16 +182,16 @@ function giveMeBaseUsr($usr, $lng)
'<td style="width:180px;">&nbsp;</td>' . '<td style="width:180px;">&nbsp;</td>' .
'</tr>'; '</tr>';
$inscriptions = giveMeBases($usr); $inscriptions = giveMeBases($app, $usr);
foreach ($inscriptions as $sbasId => $baseInsc) { foreach ($inscriptions as $sbasId => $baseInsc) {
//je presente la base //je presente la base
if (($baseInsc['CollsRegistered'] || $baseInsc['CollsRefuse'] || $baseInsc['CollsWait'] || $baseInsc['CollsIntime'] || $baseInsc['CollsOuttime'] || $baseInsc['CollsNonactif'] || $baseInsc['CollsCGU'] || $baseInsc['Colls']))//&& $baseInsc['inscript']) 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>'; $out .= '<tr><td colspan="3" style="text-align:center;"><h3>' . phrasea::sbas_names($sbasId, $app) . '</h3></td></tr>';
if ($baseInsc['CollsRegistered']) { if ($baseInsc['CollsRegistered']) {
foreach ($baseInsc['CollsRegistered'] as $collId => $isTrue) { foreach ($baseInsc['CollsRegistered'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId); $base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces authorise sur la collection ') . phrasea::bas_names($base_id); $out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces authorise sur la collection ') . phrasea::bas_names($base_id, $app);
if (trim($isTrue) != '') 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 .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>'; $out .= '</td></tr>';
@@ -200,8 +200,8 @@ function giveMeBaseUsr($usr, $lng)
} }
if ($baseInsc['CollsRefuse']) { if ($baseInsc['CollsRefuse']) {
foreach ($baseInsc['CollsRefuse'] as $collId => $isTrue) { foreach ($baseInsc['CollsRefuse'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId); $base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$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>'; $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, $app) . '</span>';
if (trim($isTrue) != '') 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 .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>'; $out .= '</td></tr>';
@@ -210,8 +210,8 @@ function giveMeBaseUsr($usr, $lng)
} }
if ($baseInsc['CollsWait']) { if ($baseInsc['CollsWait']) {
foreach ($baseInsc['CollsWait'] as $collId => $isTrue) { foreach ($baseInsc['CollsWait'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId); $base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$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>'; $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, $app) . '</span>';
if (trim($isTrue) != '') 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 .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>'; $out .= '</td></tr>';
@@ -220,8 +220,8 @@ function giveMeBaseUsr($usr, $lng)
} }
if ($baseInsc['CollsIntime']) { if ($baseInsc['CollsIntime']) {
foreach ($baseInsc['CollsIntime'] as $collId => $isTrue) { foreach ($baseInsc['CollsIntime'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId); $base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces temporaire sur') . phrasea::bas_names($base_id) . '</span>'; $out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces temporaire sur') . phrasea::bas_names($base_id, $app) . '</span>';
if (trim($isTrue) != '') 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 .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>'; $out .= '</td></tr>';
@@ -230,8 +230,8 @@ function giveMeBaseUsr($usr, $lng)
} }
if ($baseInsc['CollsOuttime']) { if ($baseInsc['CollsOuttime']) {
foreach ($baseInsc['CollsOuttime'] as $collId => $isTrue) { foreach ($baseInsc['CollsOuttime'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId); $base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$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>'; $out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces temporaire termine sur ') . phrasea::bas_names($base_id, $app) . '</span>';
if (trim($isTrue) != '') 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 .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>'; $out .= '</td></tr>';
@@ -240,8 +240,8 @@ function giveMeBaseUsr($usr, $lng)
} }
if ($baseInsc['CollsNonactif']) { if ($baseInsc['CollsNonactif']) {
foreach ($baseInsc['CollsNonactif'] as $collId => $isTrue) { foreach ($baseInsc['CollsNonactif'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId); $base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces supendu sur') . phrasea::bas_names($base_id) . '</span>'; $out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces supendu sur') . phrasea::bas_names($base_id, $app) . '</span>';
if (trim($isTrue) != '') 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 .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>'; $out .= '</td></tr>';
@@ -260,7 +260,7 @@ function giveMeBaseUsr($usr, $lng)
$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>'; $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) { foreach ($baseInsc['Colls'] as $collId => $collName) {
$base_id = phrasea::baseFromColl($sbasId, $collId); $base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr>' . $out .= '<tr>' .
'<td style="text-align:right;">' . $collName . '</td>' . '<td style="text-align:right;">' . $collName . '</td>' .
'<td></td>' . '<td></td>' .
@@ -273,7 +273,7 @@ function giveMeBaseUsr($usr, $lng)
} }
if ($baseInsc['CollsCGU']) { if ($baseInsc['CollsCGU']) {
foreach ($baseInsc['CollsCGU'] as $collId => $collDesc) { foreach ($baseInsc['CollsCGU'] as $collId => $collDesc) {
$base_id = phrasea::baseFromColl($sbasId, $collId); $base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr><td colspan="3" style="text-align:center;"><hr style="width:80%"/></td></tr>' . $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;">' . _('login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes') . '</td></tr>' .
'<tr>' . '<tr>' .
@@ -301,9 +301,7 @@ function giveMeBaseUsr($usr, $lng)
function giveModInscript($usr, $lng) function giveModInscript($usr, $lng)
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $out = '<html lang="' . $app['session.I18n'] . '">' .
$session = $appbox->get_session();
$out = '<html lang="' . $session->get_I18n() . '">' .
'<head>' . '<head>' .
'</head>' . '</head>' .
'<body>' . '<body>' .
@@ -311,7 +309,7 @@ function giveModInscript($usr, $lng)
'<form id="conf_mod" target="_self" action="mod_inscript.php" method="post">' . '<form id="conf_mod" target="_self" action="mod_inscript.php" method="post">' .
'<div style="width:400px;center;margin:0 100px;">'; '<div style="width:400px;center;margin:0 100px;">';
$demandes = giveMeBaseUsr($usr, $lng); $demandes = giveMeBaseUsr($app, $usr, $lng);
$out .= $demandes['tab']; $out .= $demandes['tab'];
@@ -335,10 +333,8 @@ function giveModInscript($usr, $lng)
return $out; return $out;
} }
function giveInscript($lng, $demandes = null) function giveInscript(Application $app, $lng, $demandes = null)
{ {
$appbox = appbox::get_instance(\bootstrap::getCore());
$out = '<table border="0" style="table-layout:fixed" cellspacing=0 width="590">' . $out = '<table border="0" style="table-layout:fixed" cellspacing=0 width="590">' .
'<tr>' . '<tr>' .
'<td style="width:240px; text-align:right">&nbsp;</td>' . '<td style="width:240px; text-align:right">&nbsp;</td>' .
@@ -346,13 +342,13 @@ function giveInscript($lng, $demandes = null)
'<td style="width:325px;">&nbsp;</td>' . '<td style="width:325px;">&nbsp;</td>' .
'</tr>'; '</tr>';
$inscriptions = giveMeBases(); $inscriptions = giveMeBases($app);
foreach ($inscriptions as $sbasId => $baseInsc) { foreach ($inscriptions as $sbasId => $baseInsc) {
if (($baseInsc['CollsCGU'] || $baseInsc['Colls']) && $baseInsc['inscript']) {// il y a des coll ou s'inscrire ! if (($baseInsc['CollsCGU'] || $baseInsc['Colls']) && $baseInsc['inscript']) {// il y a des coll ou s'inscrire !
//je pr<70>sente la base //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>'; $out .= '<tr><td colspan="3" style="text-align:center;"><h3 style="margin: 15px 0pt 2px;" class="inscriptbase">' . phrasea::sbas_names($sbasId, $app) . '</h3></td></tr>';
if ($baseInsc['Colls']) {//des coll ou on peut s'inscrire sans cgu specifiques if ($baseInsc['Colls']) {//des coll ou on peut s'inscrire sans cgu specifiques
//je check si ya des cgu pour la base //je check si ya des cgu pour la base
@@ -362,7 +358,7 @@ function giveInscript($lng, $demandes = null)
} }
foreach ($baseInsc['Colls'] as $collId => $collName) { foreach ($baseInsc['Colls'] as $collId => $collName) {
$baseId = phrasea::baseFromColl($sbasId, $collId); $baseId = phrasea::baseFromColl($sbasId, $collId, $app);
$ch = "checked"; $ch = "checked";
if (( ! is_null($demandes) && ! isset($demandes[$baseId]))) if (( ! is_null($demandes) && ! isset($demandes[$baseId])))
$ch = ""; $ch = "";
@@ -379,7 +375,7 @@ function giveInscript($lng, $demandes = null)
if ($baseInsc['CollsCGU']) { if ($baseInsc['CollsCGU']) {
foreach ($baseInsc['CollsCGU'] as $collId => $collDesc) { foreach ($baseInsc['CollsCGU'] as $collId => $collDesc) {
$baseId = phrasea::baseFromColl($sbasId, $collId); $baseId = phrasea::baseFromColl($sbasId, $collId, $app);
$ch = "checked"; $ch = "checked";
if ( ! is_null($demandes) && ! isset($demandes[$baseId])) if ( ! is_null($demandes) && ! isset($demandes[$baseId]))

View File

@@ -9,22 +9,19 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
function deleteRecord($lst, $del_children) function deleteRecord(Application $app, $lst, $del_children)
{ {
$Core = bootstrap::getCore(); $BE_repository = $app['EM']->getRepository('\Entities\BasketElement');
$em = $Core->getEntityManager();
$BE_repository = $em->getRepository('\Entities\BasketElement');
$appbox = appbox::get_instance(\bootstrap::getCore()); $user = $app['phraseanet.user'];
$session = $appbox->get_session();
$registry = $Core->getRegistry();
$user = $Core->getAuthenticatedUser();
$ACL = $user->ACL(); $ACL = $user->ACL();
$lst = explode(";", $lst); $lst = explode(";", $lst);
@@ -32,20 +29,18 @@ function deleteRecord($lst, $del_children)
$tcoll = array(); $tcoll = array();
$tbase = array(); $tbase = array();
$conn = $appbox->get_connection();
foreach ($lst as $basrec) { foreach ($lst as $basrec) {
$basrec = explode("_", $basrec); $basrec = explode("_", $basrec);
if ( ! $basrec || count($basrec) !== 2) if ( ! $basrec || count($basrec) !== 2)
continue; continue;
$record = new record_adapter($basrec[0], $basrec[1]); $record = new record_adapter($app, $basrec[0], $basrec[1]);
$base_id = $record->get_base_id(); $base_id = $record->get_base_id();
if ( ! isset($tcoll["c" . $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 ($app['phraseanet.appbox']->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) { foreach ($databox->get_collections() as $collection) {
if ($collection->get_base_id() == $base_id) { if ($collection->get_base_id() == $base_id) {
$tcoll["c" . $base_id] = array("base_id" => $databox->get_sbas_id(), "id" => $base_id); $tcoll["c" . $base_id] = array("base_id" => $databox->get_sbas_id(), "id" => $base_id);
@@ -70,7 +65,7 @@ function deleteRecord($lst, $del_children)
foreach ($tbase as $base) { foreach ($tbase as $base) {
try { try {
foreach ($base["rids"] as $rid) { foreach ($base["rids"] as $rid) {
$record = new record_adapter($rid[0], $rid[1]); $record = new record_adapter($app, $rid[0], $rid[1]);
if ( ! $ACL->has_right_on_base($record->get_base_id(), 'candeleterecord')) if ( ! $ACL->has_right_on_base($record->get_base_id(), 'candeleterecord'))
continue; continue;
if ($del_children == "1") { if ($del_children == "1") {
@@ -87,7 +82,7 @@ function deleteRecord($lst, $del_children)
$basket_elements = $BE_repository->findElementsByRecord($record); $basket_elements = $BE_repository->findElementsByRecord($record);
foreach ($basket_elements as $basket_element) { foreach ($basket_elements as $basket_element) {
$em->remove($basket_element); $app['EM']->remove($basket_element);
} }
$record->delete(); $record->delete();
@@ -98,18 +93,16 @@ function deleteRecord($lst, $del_children)
} }
} }
$em->flush(); $app['EM']->flush();
return p4string::jsonencode($ret); return p4string::jsonencode($ret);
} }
function whatCanIDelete($lst) function whatCanIDelete(Application $app, $lst)
{ {
$appbox = $app['phraseanet.appbox'];
$appbox = appbox::get_instance(\bootstrap::getCore()); $usr_id = $app['phraseanet.user']->get_id();
$session = $appbox->get_session();
$usr_id = $session->get_usr_id();
$conn = $appbox->get_connection(); $conn = $appbox->get_connection();
@@ -129,7 +122,7 @@ function whatCanIDelete($lst)
if (count($exp) !== 2) if (count($exp) !== 2)
continue; continue;
$record = new record_adapter($exp[0], $exp[1]); $record = new record_adapter($app, $exp[0], $exp[1]);
$sqlV = 'SELECT mask_and, mask_xor, sb.* $sqlV = 'SELECT mask_and, mask_xor, sb.*
FROM (sbas sb, bas b, usr u) FROM (sbas sb, bas b, usr u)
LEFT JOIN basusr bu ON LEFT JOIN basusr bu ON
@@ -150,7 +143,7 @@ function whatCanIDelete($lst)
if ($rowV && $rowV['mask_and'] != '' && $rowV['mask_xor'] != '') { if ($rowV && $rowV['mask_and'] != '' && $rowV['mask_xor'] != '') {
try { try {
$connbas = connection::getPDOConnection($rowV['sbas_id']); $connbas = connection::getPDOConnection($app, $rowV['sbas_id']);
$sqlS2 = 'SELECT record_id FROM record $sqlS2 = 'SELECT record_id FROM record
WHERE ((status ^ ' . $rowV['mask_xor'] . ') & ' . $rowV['mask_and'] . ')=0 WHERE ((status ^ ' . $rowV['mask_xor'] . ') & ' . $rowV['mask_and'] . ')=0
AND record_id = :record_id'; AND record_id = :record_id';