• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

cron/classes/class.ilCronWebResourceCheck.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00034 class ilCronWebResourceCheck
00035 {
00036         function ilCronWebResourceCheck()
00037         {
00038                 global $ilLog,$ilDB;
00039 
00040                 $this->log =& $ilLog;
00041                 $this->db =& $ilDB;
00042         }
00043 
00044         function check()
00045         {
00046                 include_once'./classes/class.ilLinkChecker.php';
00047 
00048 
00049                 foreach(ilUtil::getObjectsByOperations('webr','write',false) as $node)
00050                 {
00051                         if(!is_object($tmp_webr =& ilObjectFactory::getInstanceByRefId($node['ref_id'],false)))
00052                         {
00053                                 continue;
00054                         }
00055 
00056                         $tmp_webr->initLinkResourceItemsObject();
00057                         
00058                         // Set all link to valid. After check invalid links will be set to invalid
00059 
00060                         $link_checker =& new ilLinkChecker($this->db);
00061                         $link_checker->setMailStatus(true);
00062                         $link_checker->setCheckPeriod($this->__getCheckPeriod());
00063                         $link_checker->setObjId($node['obj_id']);
00064 
00065 
00066                         $tmp_webr->items_obj->updateValidByCheck($this->__getCheckPeriod());
00067                         foreach($link_checker->checkWebResourceLinks() as $invalid)
00068                         {
00069                                 $tmp_webr->items_obj->readItem($invalid['page_id']);
00070                                 $tmp_webr->items_obj->setActiveStatus(false);
00071                                 $tmp_webr->items_obj->setValidStatus(false);
00072                                 $tmp_webr->items_obj->setDisableCheckStatus(true);
00073                                 $tmp_webr->items_obj->setLastCheckDate(time());
00074                                 $tmp_webr->items_obj->update(false);
00075                         }
00076                         
00077                         $tmp_webr->items_obj->updateLastCheck($this->__getCheckPeriod());
00078 
00079                         foreach($link_checker->getLogMessages() as $message)
00080                         {
00081                                 $this->log->write($message);
00082                         }
00083                 }
00084                 return true;
00085         }
00086 
00087 
00088         function __getCheckPeriod()
00089         {
00090                 global $ilias;
00091 
00092                 return 10;
00093 
00094                 switch($ilias->getSetting('cron_web_resource_check'))
00095                 {
00096                         case 1:
00097                                 $period = 24 * 60 * 60;
00098                                 break;
00099 
00100                         case 2:
00101                                 $period = 7 * 24 * 60 * 60;
00102                                 break;
00103 
00104                         case 3:
00105                                 $period = 30 * 7 * 24 * 60 * 60;
00106                                 break;
00107 
00108                         case 4:
00109                                 $period = 4  * 30 * 7 * 24 * 60 * 60;
00110                                 break;
00111 
00112                         default:
00113                                 $period = 0;
00114                 }
00115                 return $period;
00116         }
00117 }
00118 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1