[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/administrator/components/com_checkin/ -> admin.checkin.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @subpackage Checkin
   5  * @author Mambo Foundation Inc see README.php
   6  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   7  * See COPYRIGHT.php for copyright notices and details.
   8  * @license GNU/GPL Version 2, see LICENSE.php
   9  *
  10  * Redistributions of files must retain the above copyright notice.
  11  *
  12  * Mambo is free software; you can redistribute it and/or
  13  * modify it under the terms of the GNU General Public License
  14  * as published by the Free Software Foundation; version 2 of the License.
  15  */
  16  
  17  /** ensure this file is being included by a parent file */
  18  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  19  
  20  if (!$acl->acl_check( 'administration', 'config', 'users', $my->usertype )) {
  21      mosRedirect( 'index2.php', T_('You are not authorized to view this resource.') );
  22  }
  23  ?>
  24  <table class="adminheading">
  25  <tr>
  26  <th class="checkin"><?php echo T_('Global Check-in') ?></th>
  27  </tr>
  28  </table>
  29  <table class="adminform">
  30  <tr>
  31      <th class="title"><?php echo T_('Database Table') ?></th>
  32      <th class="title"><?php echo T_('# of Items') ?></th>
  33      <th class="title"><?php echo T_('Checked-In') ?></th>
  34      <th class="title">&nbsp;</th>
  35  </tr>
  36  <?php
  37  $lt = mysql_list_tables($mosConfig_db);
  38  $k = 0;
  39  while (list($tn) = mysql_fetch_array( $lt )) {
  40      // make sure we get the right tables based on prefix
  41      if (!preg_match( "/^".$mosConfig_dbprefix."/i", $tn )) {
  42          continue;
  43      }
  44      $lf = mysql_list_fields($mosConfig_db, "$tn");
  45      $nf = mysql_num_fields($lf);
  46  
  47      $foundCO = false;
  48      $foundCOT = false;
  49      $foundE = false;
  50      for ($i = 0; $i < $nf; $i++) {
  51          $fname = mysql_field_name($lf, $i);
  52          if ( $fname == 'checked_out') {
  53              $foundCO = true;
  54          } else if ( $fname == 'checked_out_time') {
  55              $foundCOT = true;
  56          } else if ( $fname == 'editor') {
  57              $foundE = true;
  58          }
  59      }
  60  
  61      if ($foundCO && $foundCOT) {
  62          if ($foundE) {
  63              $database->setQuery( "SELECT checked_out, editor FROM $tn WHERE checked_out > 0" );
  64          } else {
  65              $database->setQuery( "SELECT checked_out FROM $tn WHERE checked_out > 0" );
  66          }
  67          $res = $database->query();
  68          $num = $database->getNumRows( $res );
  69  
  70          if ($foundE) {
  71              $database->setQuery( "UPDATE $tn SET checked_out=0, checked_out_time='00:00:00', editor=NULL WHERE checked_out > 0" );
  72          } else {
  73              $database->setQuery( "UPDATE $tn SET checked_out=0, checked_out_time='0000-00-00 00:00:00' WHERE checked_out > 0" );
  74          }
  75          $res = $database->query();
  76  
  77          if ($res == 1) {
  78              if ($num > 0) {
  79                  echo "<tr class=\"row$k\">";
  80                  echo "\n    <td width=\"350\">".T_('Checking table')." - $tn</td>";
  81                  echo "\n    <td width=\"150\">".sprintf(Tn_('Checked in <strong>%d</strong> item','Checked in <strong>%d</strong> items', $num), $num)."</td>";
  82                  echo "\n    <td width=\"100\" align=\"center\"><img src=\"images/tick.png\" border=\"0\" alt=\"tick\" /></td>";
  83                  echo "\n    <td>&nbsp;</td>";
  84                  echo "\n</tr>";
  85              } else {
  86                  echo "<tr class=\"row$k\">";
  87                  echo "\n    <td width=\"350\">".T_('Checking table')." - $tn</td>";
  88                  echo "\n    <td width=\"150\">".sprintf(Tn_('Checked in <strong>%d</strong> item','Checked in <strong>%d</strong> items', $num), $num)."</td>";
  89                  echo "\n    <td width=\"100\">&nbsp;</td>";
  90                  echo "\n    <td>&nbsp;</td>";
  91                  echo "\n</tr>";
  92              }
  93              $k = 1 - $k;
  94          }
  95      }
  96  }
  97  ?>
  98  <tr>
  99      <td colspan="4"><strong><?php echo T_('Checked out items have now been all checked in') ?></strong></td>
 100  </tr>
 101  </table>