Removed ORM table drop proposal

This commit is contained in:
Romain Neutron
2012-02-28 15:28:56 +01:00
parent 150ab811cd
commit daf4fe2a03

View File

@@ -15,295 +15,295 @@
* @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
*/ */
$Core = \bootstrap::getCore(); //$Core = \bootstrap::getCore();
$appbox = appbox::get_instance($Core); //$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); //$session = $appbox->get_session();
//
$th_size = $user->getPrefs('images_size'); //$th_size = $user->getPrefs('images_size');
//
$user = $Core->getAuthenticatedUser(); //$user = $Core->getAuthenticatedUser();
//
$RN = array("\r\n", "\n", "\r"); //$RN = array("\r\n", "\n", "\r");
//
$conn = $appbox->get_connection(); //$conn = $appbox->get_connection();
//
$sql = 'SELECT s.public, s.pub_restrict,c.sselcont_id, c.base_id, sb.*, c.record_id, s.ssel_id, s.name, s.descript, c.ord, ' . //$sql = 'SELECT s.public, s.pub_restrict,c.sselcont_id, c.base_id, sb.*, c.record_id, s.ssel_id, s.name, s.descript, c.ord, ' .
'DATE_FORMAT(s.pub_date,"' . _('phraseanet::technique::datetime') . '") AS pub_date, ' . // 'DATE_FORMAT(s.pub_date,"' . _('phraseanet::technique::datetime') . '") AS pub_date, ' .
'DATE_FORMAT(s.updater,"' . _('phraseanet::technique::date') . '") AS updater, ' . // 'DATE_FORMAT(s.updater,"' . _('phraseanet::technique::date') . '") AS updater, ' .
's.updater as dateC1, s.pub_date as dateC2,' . // 's.updater as dateC1, s.pub_date as dateC2,' .
' n.id, u.usr_nom, u.usr_prenom, u.usr_login, u.usr_mail ' . // ' n.id, u.usr_nom, u.usr_prenom, u.usr_login, u.usr_mail ' .
', bu.mask_and ' . // ', bu.mask_and ' .
', bu.mask_xor ' . // ', bu.mask_xor ' .
'FROM (sselcont c, ssel s, usr u, bas b, sbas sb) ' . // 'FROM (sselcont c, ssel s, usr u, bas b, sbas sb) ' .
'LEFT JOIN sselnew n ' . // 'LEFT JOIN sselnew n ' .
'ON (n.ssel_id = s.ssel_id AND n.usr_id = :usr_id) ' . // 'ON (n.ssel_id = s.ssel_id AND n.usr_id = :usr_id) ' .
' LEFT JOIN basusr bu ON (bu.base_id = b.base_id AND bu.usr_id = :usr_id_bis)' . // ' LEFT JOIN basusr bu ON (bu.base_id = b.base_id AND bu.usr_id = :usr_id_bis)' .
'WHERE s.ssel_id = c.ssel_id AND s.public="1" ' . // 'WHERE s.ssel_id = c.ssel_id AND s.public="1" ' .
'AND (s.pub_restrict="0" ' . // 'AND (s.pub_restrict="0" ' .
'OR (s.pub_restrict="1" AND c.base_id IN ' . // 'OR (s.pub_restrict="1" AND c.base_id IN ' .
' (SELECT base_id FROM basusr WHERE usr_id = :usr_id_sub AND actif = "1")))' . // ' (SELECT base_id FROM basusr WHERE usr_id = :usr_id_sub AND actif = "1")))' .
' AND u.usr_id = s.usr_id AND temporaryType=0 ' . // ' AND u.usr_id = s.usr_id AND temporaryType=0 ' .
' AND b.sbas_id = sb.sbas_id' . // ' AND b.sbas_id = sb.sbas_id' .
' AND b.base_id = c.base_id' . // ' AND b.base_id = c.base_id' .
' ORDER BY s.pub_date DESC, c.ord ASC'; // ' ORDER BY s.pub_date DESC, c.ord ASC';
//
$sqlMe = 'SELECT usr_login, usr_password FROM usr WHERE usr_id = :usr_id'; //$sqlMe = 'SELECT usr_login, usr_password FROM usr WHERE usr_id = :usr_id';
//
$stmt = $conn->prepare($sqlMe); //$stmt = $conn->prepare($sqlMe);
$stmt->execute(array(':usr_id' => $session->get_usr_id())); //$stmt->execute(array(':usr_id' => $session->get_usr_id()));
$rawMe = $stmt->fetch(PDO::FETCH_ASSOC); //$rawMe = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); //$stmt->closeCursor();
//
$info_usr = null; //$info_usr = null;
//
if ($rawMe) //if ($rawMe)
{ //{
$info_usr = $rawMe; // $info_usr = $rawMe;
} //}
//
$core = \bootstrap::getCore(); //$core = \bootstrap::getCore();
$twig = $core->getTwig(); //$twig = $core->getTwig();
//
$stmt = $conn->prepare($sql); //$stmt = $conn->prepare($sql);
$usr_id = $session->get_usr_id(); //$usr_id = $session->get_usr_id();
$stmt->execute(array(':usr_id' => $usr_id, ':usr_id_bis' => $usr_id, ':usr_id_sub' => $usr_id)); //$stmt->execute(array(':usr_id' => $usr_id, ':usr_id_bis' => $usr_id, ':usr_id_sub' => $usr_id));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); //$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); //$stmt->closeCursor();
//
$sselid = null; //$sselid = null;
$o = 0; //$o = 0;
$out = ''; //$out = '';
//
$feed = ''; //$feed = '';
$feed .= '<div style="height:50px;" class="homePubTitleBox">' . //$feed .= '<div style="height:50px;" class="homePubTitleBox">' .
'<div style="float:left;width:350px;"><h1 style="font-size:20px;margin-top:15px;">' . _('publications:: dernieres publications') . '</h1></div>' . // '<div style="float:left;width:350px;"><h1 style="font-size:20px;margin-top:15px;">' . _('publications:: dernieres publications') . '</h1></div>' .
'<div style="float:right;width:160px;text-align:right;cursor:pointer;" class="subscribe_my_rss"> // '<div style="float:right;width:160px;text-align:right;cursor:pointer;" class="subscribe_my_rss">
<h1 style="font-size:17px;margin-top:19px;"> ' . // <h1 style="font-size:17px;margin-top:19px;"> ' .
_('publications:: s\'abonner aux publications') . ' ' . // _('publications:: s\'abonner aux publications') . ' ' .
'<img style="border:none;" src="/skins/icons/rss16.png" /> // '<img style="border:none;" src="/skins/icons/rss16.png" />
</h1>' . // </h1>' .
'</div></div>'; // '</div></div>';
//
foreach ($rs as $row) //foreach ($rs as $row)
{ //{
if ($row['ssel_id'] != $sselid) // if ($row['ssel_id'] != $sselid)
{ // {
if ($sselid !== null) // if ($sselid !== null)
{ // {
//
//
//
$item .= '<div style="width:100%;position:relative;float:left;" id="PUBLICONT' . $sselid . '">' . $out; // $item .= '<div style="width:100%;position:relative;float:left;" id="PUBLICONT' . $sselid . '">' . $out;
$item .= '</div>' . // $item .= '</div>' .
'</div></div>'; // '</div></div>';
//
if ($itemIsOk) // if ($itemIsOk)
$feed .= $item; // $feed .= $item;
} // }
//
$itemIsOk = false; // $itemIsOk = false;
//
$sselid = $row['ssel_id']; // $sselid = $row['ssel_id'];
$ord = $row['ord']; // $ord = $row['ord'];
$o = 0; // $o = 0;
$out = ''; // $out = '';
$neverSeen = ''; // $neverSeen = '';
$publisher = $row['usr_prenom'] . ' ' . $row['usr_nom']; // $publisher = $row['usr_prenom'] . ' ' . $row['usr_nom'];
if ($publisher == ' ') // if ($publisher == ' ')
$publisher = $row['usr_mail']; // $publisher = $row['usr_mail'];
if ($publisher == '') // if ($publisher == '')
$publisher = 'Unreferenced user'; // $publisher = 'Unreferenced user';
//
if ($row['id'] != '') // if ($row['id'] != '')
$neverSeen = _('publications:: publication non lue'); // $neverSeen = _('publications:: publication non lue');
//
$item = ''; // $item = '';
$item .= '<div class="boxPubli">' . // $item .= '<div class="boxPubli">' .
'<div class="titlePubli">' . // '<div class="titlePubli">' .
'<h2 class="htitlePubli">' . // '<h2 class="htitlePubli">' .
'<a class="homePubTitle" onclick="openCompare(\'' . $sselid . '\');">' . $row['name'] . // '<a class="homePubTitle" onclick="openCompare(\'' . $sselid . '\');">' . $row['name'] .
'</a> <span style="font-size:12px;color:red;">' . $neverSeen . '</span></h2>' . // '</a> <span style="font-size:12px;color:red;">' . $neverSeen . '</span></h2>' .
'<span class="publiInfos">' . // '<span class="publiInfos">' .
' ' . $row['pub_date'] . // ' ' . $row['pub_date'] .
' '; // ' ';
//
if ($row['usr_mail'] != '') // if ($row['usr_mail'] != '')
$item .= '<a class="homePubLink" href="mailto:' . $row['usr_mail'] . '">'; // $item .= '<a class="homePubLink" href="mailto:' . $row['usr_mail'] . '">';
//
$item .= $publisher; // $item .= $publisher;
//
if ($row['usr_mail'] != '') // if ($row['usr_mail'] != '')
$item .= '</a>'; // $item .= '</a>';
//
if ($row['dateC1'] != $row['dateC2']) // if ($row['dateC1'] != $row['dateC2'])
$item .= '<br/><span style="font-style:italic;">' . _('publications:: derniere mise a jour') . ' ' . $row['updater'] . '</span><br/><br/>'; // $item .= '<br/><span style="font-style:italic;">' . _('publications:: derniere mise a jour') . ' ' . $row['updater'] . '</span><br/><br/>';
//
$item .= '</span></div><div class="descPubli"><div style="margin:10px 0 10px 20px;width:80%;">'; // $item .= '</span></div><div class="descPubli"><div style="margin:10px 0 10px 20px;width:80%;">';
//
//
if (trim(str_replace($RN, '', $row['descript'])) != '') // if (trim(str_replace($RN, '', $row['descript'])) != '')
{ // {
$row['descript'] = str_replace($RN, '<br/>', $row['descript']); // $row['descript'] = str_replace($RN, '<br/>', $row['descript']);
$item .= '' . $row['descript']; // $item .= '' . $row['descript'];
} // }
$item .= '</div>'; // $item .= '</div>';
} // }
//
//
//
//
//
$ord = $row['ord']; // $ord = $row['ord'];
$statOk = true; // $statOk = true;
if ($row['public'] == 1 && $row['pub_restrict'] == 1) // if ($row['public'] == 1 && $row['pub_restrict'] == 1)
{ // {
$statOk = false; // $statOk = false;
//
try // try
{ // {
$connsbas = connection::getPDOConnection($row['sbas_id']); // $connsbas = connection::getPDOConnection($row['sbas_id']);
//
$sql = 'SELECT record_id FROM record WHERE ((status ^ ' . $row['mask_xor'] . ') & ' . $row['mask_and'] . ')=0 // $sql = 'SELECT record_id FROM record WHERE ((status ^ ' . $row['mask_xor'] . ') & ' . $row['mask_and'] . ')=0
AND record_id = :record_id'; // AND record_id = :record_id';
$stmt = $connsbas->prepare($sql); // $stmt = $connsbas->prepare($sql);
$stmt->execute(array(':record_id' => $row['record_id'])); // $stmt->execute(array(':record_id' => $row['record_id']));
$statOk = ($stmt->rowCount() > 0); // $statOk = ($stmt->rowCount() > 0);
$stmt->closeCursor(); // $stmt->closeCursor();
} // }
catch (Exception $e) // catch (Exception $e)
{ // {
//
} // }
} // }
//
//
$layoutmode = $user->getPrefs('view'); // $layoutmode = $user->getPrefs('view');
//
if ($statOk) // if ($statOk)
{ // {
$record = new record_adapter($row["sbas_id"], $row["record_id"]); // $record = new record_adapter($row["sbas_id"], $row["record_id"]);
$sbas_id = phrasea::sbasFromBas($row['base_id']); // $sbas_id = phrasea::sbasFromBas($row['base_id']);
//
$captionXML = $record->get_xml(); // $captionXML = $record->get_xml();
//
$thumbnail = $record->get_thumbnail(); // $thumbnail = $record->get_thumbnail();
//
$title = $record->get_title(); // $title = $record->get_title();
$exifinfos = $record->get_technical_infos(); // $exifinfos = $record->get_technical_infos();
$caption = $twig->render('common/caption.html', array('view' => 'internal_publi', 'record' => $record)); // $caption = $twig->render('common/caption.html', array('view' => 'internal_publi', 'record' => $record));
//
$o++; // $o++;
$itemIsOk = true; // $itemIsOk = true;
$bottom = 0; // $bottom = 0;
$right = 10; // $right = 10;
$left = 0; // $left = 0;
$top = 10; // $top = 10;
//
//
if (trim($preview) != '') // if (trim($preview) != '')
$preview = "<div tooltipsrc='/prod/tooltip/preview/" . phrasea::sbasFromBas($row["base_id"]) . "/" . $row["record_id"] . "/' class=\"previewTips\"></div>&nbsp;"; // $preview = "<div tooltipsrc='/prod/tooltip/preview/" . phrasea::sbasFromBas($row["base_id"]) . "/" . $row["record_id"] . "/' class=\"previewTips\"></div>&nbsp;";
//
$docType = $record->get_type(); // $docType = $record->get_type();
$isVideo = ($docType == 'video'); // $isVideo = ($docType == 'video');
$isAudio = ($docType == 'audio'); // $isAudio = ($docType == 'audio');
$isImage = ($docType == 'image'); // $isImage = ($docType == 'image');
$isDocument = ($docType == 'document'); // $isDocument = ($docType == 'document');
//
$duration = ''; // $duration = '';
//
if (!$isVideo && !$isAudio) // if (!$isVideo && !$isAudio)
$isImage = true; // $isImage = true;
//
if ($isVideo) // if ($isVideo)
{ // {
$duration = $record->get_formated_duration(); // $duration = $record->get_formated_duration();
if ($duration != '') // if ($duration != '')
$duration = '<div class="duration">' . $duration . '</div>'; // $duration = '<div class="duration">' . $duration . '</div>';
} // }
if ($isAudio) // if ($isAudio)
{ // {
$duration = $record->get_formated_duration(); // $duration = $record->get_formated_duration();
if ($duration != '') // if ($duration != '')
$duration = '<div class="duration">' . $duration . '</div>'; // $duration = '<div class="duration">' . $duration . '</div>';
} // }
//
//
$ratio = $thumbnail->get_width() / $thumbnail->get_height(); // $ratio = $thumbnail->get_width() / $thumbnail->get_height();
//
if ($ratio > 1) // if ($ratio > 1)
{ // {
$cw = min(((int) $th_size - 30), $thumbnail->get_width()); // $cw = min(((int) $th_size - 30), $thumbnail->get_width());
$ch = $cw / $ratio; // $ch = $cw / $ratio;
$pv = floor(($th_size - $ch) / 2); // $pv = floor(($th_size - $ch) / 2);
$ph = floor(($th_size - $cw) / 2); // $ph = floor(($th_size - $cw) / 2);
$imgStyle = 'xwidth:' . $cw . 'px;xpadding:' . $pv . 'px ' . $ph . 'px;'; // $imgStyle = 'xwidth:' . $cw . 'px;xpadding:' . $pv . 'px ' . $ph . 'px;';
} // }
else // else
{ // {
$ch = min(((int) $th_size - 30), $thumbnail->get_height()); // $ch = min(((int) $th_size - 30), $thumbnail->get_height());
$cw = $ch * $ratio; // $cw = $ch * $ratio;
//
$pv = floor(($th_size - $ch) / 2); // $pv = floor(($th_size - $ch) / 2);
$ph = floor(($th_size - $cw) / 2); // $ph = floor(($th_size - $cw) / 2);
//
$imgStyle = 'xheight:' . $ch . 'px;xpadding:' . $pv . 'px ' . $ph . 'px;'; // $imgStyle = 'xheight:' . $ch . 'px;xpadding:' . $pv . 'px ' . $ph . 'px;';
} // }
//
//
//
$ident = $row["base_id"] . "_" . $row["record_id"]; // $ident = $row["base_id"] . "_" . $row["record_id"];
//
//
$out .= "<div style='width:" . ($th_size + 30) . "px;' sbas=\"" . $row['sbas_id'] . "\" id='IMGT_" . $row['base_id'] . "_" . $row['record_id'] . "_PUB_" . $sselid . "' class='IMGT diapo' onclick=\"openPreview('BASK','" . $ord . "','" . $sselid . "');\">"; // $out .= "<div style='width:" . ($th_size + 30) . "px;' sbas=\"" . $row['sbas_id'] . "\" id='IMGT_" . $row['base_id'] . "_" . $row['record_id'] . "_PUB_" . $sselid . "' class='IMGT diapo' onclick=\"openPreview('BASK','" . $ord . "','" . $sselid . "');\">";
//
$out .= '<div>'; // $out .= '<div>';
$out .= "<div class=\"title\" style=\"height:40px;\">"; // $out .= "<div class=\"title\" style=\"height:40px;\">";
//
$out .= $title; //$data['title']; // $out .= $title; //$data['title'];
//
$out .= "</div>\n"; // $out .= "</div>\n";
//
$out .= '</div>'; // $out .= '</div>';
//
$out .= "<table class=\"thumb w160px h160px\" style=\"xheight:" . (int) $th_size . "px;\" cellspacing='0' cellpadding='0' valign='middle'>\n<tr><td>"; // $out .= "<table class=\"thumb w160px h160px\" style=\"xheight:" . (int) $th_size . "px;\" cellspacing='0' cellpadding='0' valign='middle'>\n<tr><td>";
//
$out .= $duration . "<img title=\"" . str_replace('"', '&quot;', $caption) . "\" class=\" captionTips\" src=\"" . $thumbnail->get_url() . "\" style=\"" . $imgStyle . "\" />"; // $out .= $duration . "<img title=\"" . str_replace('"', '&quot;', $caption) . "\" class=\" captionTips\" src=\"" . $thumbnail->get_url() . "\" style=\"" . $imgStyle . "\" />";
//
$out .= "</td></tr></table>"; // $out .= "</td></tr></table>";
//
$out .= '<div style="height: 25px;position:relative;">'; // $out .= '<div style="height: 25px;position:relative;">';
$out .= '<table class="bottom">'; // $out .= '<table class="bottom">';
$out .= '<tr>'; // $out .= '<tr>';
$out .= '<td>'; // $out .= '<td>';
//
$out .= "</td>\n"; // $out .= "</td>\n";
//
$out .= "<td style='text-align:right;' valign='bottom' nowrap>\n"; // $out .= "<td style='text-align:right;' valign='bottom' nowrap>\n";
//
$out .= $preview; // $out .= $preview;
//
$out .= "</td>"; // $out .= "</td>";
$out .= "</tr>"; // $out .= "</tr>";
$out .= "</table>"; // $out .= "</table>";
$out .= "</div>"; // $out .= "</div>";
//
//
$out .= "</div>"; // $out .= "</div>";
} // }
} //}
//
if (isset($item)) //if (isset($item))
{ //{
$item .= ' <br/><div style="width:100%;position:relative;float:left;" id="PUBLICONT' . $sselid . '">' . $out; // $item .= ' <br/><div style="width:100%;position:relative;float:left;" id="PUBLICONT' . $sselid . '">' . $out;
$item .= '</div>' . // $item .= '</div>' .
'</div></div>'; // '</div></div>';
if ($itemIsOk) // if ($itemIsOk)
$feed .= $item; // $feed .= $item;
} //}
//
echo '<div>' . $feed . '</div>'; //echo '<div>' . $feed . '</div>';
//
$sql = 'DELETE FROM sselnew WHERE usr_id = :usr_id AND ssel_id IN (SELECT ssel_id FROM ssel WHERE public="1")'; //$sql = 'DELETE FROM sselnew WHERE usr_id = :usr_id AND ssel_id IN (SELECT ssel_id FROM ssel WHERE public="1")';
$stmt = $conn->prepare($sql); //$stmt = $conn->prepare($sql);
$stmt->execute(array(':usr_id' => $usr_id)); //$stmt->execute(array(':usr_id' => $usr_id));
$stmt->closeCursor(); //$stmt->closeCursor();