PageRenderTime 52ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/webEdition/we/include/we_widgets/dlg/mfd/mfd.inc.php

https://github.com/drietsch/newcms
PHP | 214 lines | 182 code | 13 blank | 19 comment | 36 complexity | bda640dd6217e2bc1ee065d07d497418 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * webEdition CMS
  4. *
  5. * This source is part of webEdition CMS. webEdition CMS is
  6. * free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * any later version.
  10. *
  11. * The GNU General Public License can be found at
  12. * http://www.gnu.org/copyleft/gpl.html.
  13. * A copy is found in the textfile
  14. * webEdition/licenses/webEditionCMS/License.txt
  15. *
  16. * @category webEdition
  17. * @package webEdition_base
  18. * @copyright Copyright (c) 2008 living-e AG (http://www.living-e.com)
  19. * @license http://www.gnu.org/copyleft/gpl.html GPL
  20. */
  21. include_once ($_SERVER["DOCUMENT_ROOT"] . "/webEdition/we/include/we.inc.php");
  22. include_once ($_SERVER["DOCUMENT_ROOT"] . "/webEdition/we/include/we_language/" . $GLOBALS["WE_LANGUAGE"] . "/cockpit.inc.php");
  23. include_once ($_SERVER["DOCUMENT_ROOT"] . "/webEdition/we/include/we_language/" . $GLOBALS["WE_LANGUAGE"] . "/date.inc.php");
  24. include_once ($_SERVER["DOCUMENT_ROOT"] . "/webEdition/we/include/we_classes/we_history.class.php");
  25. protect();
  26. $sTypeBinary = $_REQUEST["we_cmd"][0];
  27. $bTypeDoc = (bool)$sTypeBinary{0};
  28. $bTypeTpl = (bool)$sTypeBinary{1};
  29. $bTypeObj = (bool)$sTypeBinary{2};
  30. $bTypeCls = (bool)$sTypeBinary{3};
  31. $iDate = $_REQUEST["we_cmd"][1];
  32. switch ($iDate) {
  33. case 1 :
  34. $timestamp = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
  35. break;
  36. case 2 :
  37. $iTime = time() - (7 * 24 * 60 * 60);
  38. $timestamp = mktime(
  39. date('H', $iTime),
  40. date('i', $iTime),
  41. date('s', $iTime),
  42. date('m', $iTime),
  43. date('d', $iTime),
  44. date('Y', $iTime));
  45. break;
  46. case 3 :
  47. $iTime = time() - (30 * 24 * 60 * 60);
  48. $timestamp = mktime(
  49. date('H', $iTime),
  50. date('i', $iTime),
  51. date('s', $iTime),
  52. date('m', $iTime),
  53. date('d', $iTime),
  54. date('Y', $iTime));
  55. break;
  56. case 4 :
  57. $iTime = time() - (365 * 24 * 60 * 60);
  58. $timestamp = mktime(
  59. date('H', $iTime),
  60. date('i', $iTime),
  61. date('s', $iTime),
  62. date('m', $iTime),
  63. date('d', $iTime),
  64. date('Y', $iTime));
  65. break;
  66. }
  67. $iNumItems = $_REQUEST["we_cmd"][2];
  68. switch ($iNumItems) {
  69. case 0 :
  70. $iMaxItems = 200;
  71. break;
  72. case 11 :
  73. $iMaxItems = 15;
  74. break;
  75. case 12 :
  76. $iMaxItems = 20;
  77. break;
  78. case 13 :
  79. $iMaxItems = 25;
  80. break;
  81. case 14 :
  82. $iMaxItems = 50;
  83. break;
  84. default :
  85. $iMaxItems = $iNumItems;
  86. }
  87. $sDisplayOpt = $_REQUEST["we_cmd"][3];
  88. $bMfdBy = $sDisplayOpt{0};
  89. $bDateLastMfd = $sDisplayOpt{1};
  90. $aUsers = makeArrayFromCSV($_REQUEST["we_cmd"][4]);
  91. $sJsCode = "
  92. var _sObjId='" . $_REQUEST["we_cmd"][5] . "';
  93. var _sType='mfd';
  94. var _sTb='" . $l_cockpit['last_modified'] . "';
  95. function init(){
  96. parent.rpcHandleResponse(_sType,_sObjId,document.getElementById(_sType),_sTb);
  97. }
  98. ";
  99. $_where = array();
  100. $_ws = array();
  101. $_users_where = array();
  102. foreach ($aUsers as $uid) {
  103. $_users_where[] = '"' . basename(id_to_path($uid, USER_TABLE)) . '"';
  104. }
  105. if ($bTypeDoc && we_hasPerm('CAN_SEE_DOCUMENTS')) {
  106. $_where[] = '"' . str_replace(TBL_PREFIX, '', FILE_TABLE) . '"';
  107. $_ws[FILE_TABLE] = get_ws(FILE_TABLE);
  108. }
  109. if ($bTypeObj && we_hasPerm('CAN_SEE_OBJECTS')) {
  110. $_where[] = '"' . str_replace(TBL_PREFIX, '', OBJECT_FILES_TABLE) . '"';
  111. $_ws[OBJECT_FILES_TABLE] = get_ws(OBJECT_FILES_TABLE);
  112. }
  113. if ($bTypeTpl && we_hasPerm('CAN_SEE_TEMPLATES') && $_SESSION["we_mode"] != "seem") {
  114. $_where[] = '"' . str_replace(TBL_PREFIX, '', TEMPLATES_TABLE) . '"';
  115. }
  116. if ($bTypeCls && we_hasPerm('CAN_SEE_CLASSES') && $_SESSION["we_mode"] != "seem") {
  117. $_where[] = '"' . str_replace(TBL_PREFIX, '', OBJECT_TABLE) . '"';
  118. }
  119. $lastModified = '';
  120. $lastModified .= "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
  121. $_count = 10;
  122. $i = $j = $k = 0;
  123. while ($j < $iMaxItems) {
  124. $_query = "SELECT * FROM " . HISTORY_TABLE . (!empty($_where) ? (' WHERE ' . ((count($_users_where) > 0) ? 'UserName IN (' . implode(
  125. ',',
  126. $_users_where) . ') AND ' : '') . 'DocumentTable IN(' . implode(',', $_where) . ')') : '') . (($iDate) ? ' AND ModDate >' . abs($timestamp) : '') . ' ORDER BY ModDate DESC LIMIT ' . abs($k * $_count) . " , " . abs($_count) . ";";
  127. $k++;
  128. $DB_WE->query($_query);
  129. $_db = new DB_WE();
  130. $num_rows = $DB_WE->num_rows();
  131. if ($num_rows == 0) {
  132. break;
  133. }
  134. while ($DB_WE->next_record()) {
  135. $_table = TBL_PREFIX . $DB_WE->f("DocumentTable");
  136. $_paths = array();
  137. $_bool_ot = (defined("OBJECT_TABLE")) ? (($_table != OBJECT_TABLE) ? true : false) : true;
  138. if (!we_hasPerm('ADMINISTRATOR') || ($_table != TEMPLATES_TABLE && $_bool_ot)) {
  139. if (isset($_ws[$_table])) {
  140. $_wsa = makeArrayFromCSV($_ws[$_table]);
  141. foreach ($_wsa as $_id) {
  142. $_paths[] = 'Path LIKE ("' . id_to_path($_id, $_table) . '%")';
  143. }
  144. }
  145. }
  146. $_hash = getHash(
  147. "SELECT ID,Path,Icon,Text,ContentType,ModDate,CreatorID,Owners,RestrictOwners FROM " . mysql_real_escape_string($_table) . " WHERE ID = '" . abs($DB_WE->f(
  148. "DID")) . "'" . (!empty($_paths) ? (' AND (' . implode(' OR ', $_paths) . ')') : '') . ";",
  149. $_db);
  150. if (!empty($_hash)) {
  151. $_show = true;
  152. $_bool_oft = (defined("OBJECT_FILES_TABLE")) ? (($_table == OBJECT_FILES_TABLE) ? true : false) : true;
  153. if ($_table == FILE_TABLE || $_bool_oft) {
  154. $_show = we_history::userHasPerms($_hash['CreatorID'], $_hash['Owners'], $_hash['RestrictOwners']);
  155. }
  156. if ($_show) {
  157. if ($i + 1 <= $iMaxItems) {
  158. $i++;
  159. $j++;
  160. $lastModified .= '<tr>';
  161. $lastModified .= '<td width="20" height="20" valign="middle" nowrap><img src="' . ICON_DIR . $_hash['Icon'] . '">' . getpixel(
  162. 4,
  163. 1) . '</td>';
  164. $lastModified .= '<td valign="middle" class="middlefont">';
  165. $lastModified .= '<a href="' . 'javascript:top.weEditorFrameController.openDocument(\'' . $_table . '\',\'' . $_hash['ID'] . '\',\'' . $_hash['ContentType'] . '\');"' . ' title="' . $_hash['Path'] . '" style="color:#000000;text-decoration:none;">' . $_hash['Path'] . "</a></td>";
  166. if ($bMfdBy)
  167. $lastModified .= '<td>' . getpixel(5, 1) . '</td><td class="middlefont" nowrap>' . $DB_WE->f(
  168. "UserName") . (($bDateLastMfd) ? ',' : '') . '</td>';
  169. if ($bDateLastMfd)
  170. $lastModified .= '<td>' . getpixel(5, 1) . '</td><td class="middlefont" nowrap>' . date(
  171. $GLOBALS["l_global"]["date_format"],
  172. $_hash['ModDate']) . '</td>';
  173. $lastModified .= "</tr>\n";
  174. } else {
  175. break;
  176. }
  177. } else {
  178. $j++;
  179. }
  180. } else {
  181. break;
  182. }
  183. }
  184. }
  185. $lastModified .= "</table>\n";
  186. print
  187. we_htmlElement::htmlHtml(
  188. we_htmlElement::htmlHead(
  189. we_htmlElement::htmlTitle($l_cockpit['last_modified']) . STYLESHEET . we_htmlElement::jsElement(
  190. $sJsCode)) . we_htmlElement::htmlBody(
  191. array(
  192. "marginwidth" => "15",
  193. "marginheight" => "10",
  194. "leftmargin" => "15",
  195. "topmargin" => "10",
  196. "onload" => "if(parent!=self)init();"
  197. ),
  198. we_htmlElement::htmlDiv(array(
  199. "id" => "mfd"
  200. ), $lastModified)));
  201. ?>