ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilLinkChecker Class Reference

class for checking external links in page objects Normally used in Cron jobs, but should be extensible for use in learning modules. More...

+ Collaboration diagram for ilLinkChecker:

Public Member Functions

 ilLinkChecker (&$db, $a_validate_all=true)
 
 setCheckPeriod ($a_period)
 
 getCheckPeriod ()
 
 setMailStatus ($a_status)
 
 getMailStatus ()
 
 __setType ($a_type)
 
 __getType ()
 
 setObjId ($a_page_id)
 
 getObjId ()
 
 getValidateAll ()
 
 getLogMessages ()
 
 getInvalidLinks ()
 
 getInvalidLinksFromDB ()
 
 getLastCheckTimestamp ()
 
 checkWebResourceLinks ()
 
 checkLinks ()
 
 checkPear ()
 
 __txt ($language, $key, $module='common')
 
 __fetchUserData ($a_usr_id)
 
 __getTitle ($a_lm_obj_id)
 
 __sendMail ()
 
 __getNotifyLinks ()
 
 __clearInvalidLinks ()
 
 __appendInvalidLink ($a_link)
 
 __appendLogMessage ($a_string)
 
 __clearLogMessages ()
 
 __getLinks ($a_page)
 
 __getWebResourceLinks ()
 
 __validateLinks ($a_links)
 
 __getObjIdByPageId ($a_page_id)
 
 __isInvalid ($a_page_id, $a_url)
 
 __saveInDB ()
 
 __checkNotify ()
 
 __clearDBData ()
 

Data Fields

 $db = null
 
 $log_messages = array()
 
 $invalid_links = array()
 
 $validate_all = true
 
 $mail_status = false
 
 $page_id = 0
 

Protected Member Functions

 createPermanentLink ($a_obj_id, $a_usr_id, $a_obj_type)
 creates a permanent link More...
 

Detailed Description

class for checking external links in page objects Normally used in Cron jobs, but should be extensible for use in learning modules.

In this case set second parameter of contructor = false, and use setPageObjectId()

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 12 of file class.ilLinkChecker.php.

Member Function Documentation

◆ __appendInvalidLink()

ilLinkChecker::__appendInvalidLink (   $a_link)

Definition at line 384 of file class.ilLinkChecker.php.

385 {
386 $this->invalid_links[] = $a_link;
387 }

Referenced by checkLinks(), and checkWebResourceLinks().

+ Here is the caller graph for this function:

◆ __appendLogMessage()

ilLinkChecker::__appendLogMessage (   $a_string)

Definition at line 390 of file class.ilLinkChecker.php.

391 {
392 $this->log_messages[] = $a_string;
393 }

Referenced by __sendMail(), __validateLinks(), checkLinks(), and checkWebResourceLinks().

+ Here is the caller graph for this function:

◆ __checkNotify()

ilLinkChecker::__checkNotify ( )

Definition at line 605 of file class.ilLinkChecker.php.

606 {
607 global $ilDB;
608
609 foreach($this->getInvalidLinks() as $link)
610 {
611 $query = "SELECT * FROM link_check ".
612 "WHERE page_id = ".$ilDB->quote($link['page_id'],'integer')." ".
613 "AND url = ".$ilDB->quote(substr($link['complete'],0,255),'text')." ";
614 $res = $ilDB->query($query);
615
616 if(!$res->numRows())
617 {
618 $this->notify[$link["obj_id"]][] = array('page_id' => $link['page_id'],
619 'url' => $link['complete']);
620 }
621 }
622 }
global $ilDB

References $ilDB, $query, $res, and getInvalidLinks().

Referenced by __saveInDB().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __clearDBData()

ilLinkChecker::__clearDBData ( )

Definition at line 625 of file class.ilLinkChecker.php.

626 {
627 global $ilDB;
628
629 if($this->getValidateAll())
630 {
631 $query = "DELETE FROM link_check";
632 }
633 else
634 {
635 $query = "DELETE FROM link_check ".
636 "WHERE obj_id = ".$ilDB->quote($this->getObjId(),'integer');
637 }
638 $res = $ilDB->manipulate($query);
639
640 return true;
641 }

References $ilDB, $query, $res, getObjId(), and getValidateAll().

Referenced by __saveInDB().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __clearInvalidLinks()

ilLinkChecker::__clearInvalidLinks ( )

Definition at line 380 of file class.ilLinkChecker.php.

381 {
382 $this->invalid_links = array();
383 }

Referenced by checkLinks(), and checkWebResourceLinks().

+ Here is the caller graph for this function:

◆ __clearLogMessages()

ilLinkChecker::__clearLogMessages ( )

Definition at line 394 of file class.ilLinkChecker.php.

395 {
396 return $this->log_messages = array();
397 }

Referenced by checkLinks(), and checkWebResourceLinks().

+ Here is the caller graph for this function:

◆ __fetchUserData()

ilLinkChecker::__fetchUserData (   $a_usr_id)

Definition at line 236 of file class.ilLinkChecker.php.

237 {
238 global $ilDB;
239
240 $query = "SELECT email FROM usr_data WHERE usr_id = ".$ilDB->quote($a_usr_id)."";
241
242 $row = $this->db->getRow($query,DB_FETCHMODE_OBJECT);
243
244 $data['email'] = $row->email;
245
246 $set = $ilDB->query("SELECT * FROM usr_pref ".
247 "WHERE usr_id = ".$ilDB->quote($a_usr_id, "integer")." ".
248 "AND keyword = ".$ilDB->quote('language', "text"));
249
250 $row = $ilDB->fetchObject($set);
251
252 $data['lang'] = $row->value;
253
254 return $data;
255 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
$data

References $data, $ilDB, $query, $row, and DB_FETCHMODE_OBJECT.

◆ __getLinks()

ilLinkChecker::__getLinks (   $a_page)

Definition at line 399 of file class.ilLinkChecker.php.

400 {
401 $matches = array();
402
403 $pattern_complete = '/<ExtLink Href="([^"]*)">/';
404 if(preg_match_all($pattern_complete,$a_page['content'],$matches))
405 {
406 for($i = 0;$i < count($matches[0]); ++$i)
407 {
408 $url_data = @parse_url($matches[1][$i]);
409 // continue if mailto link
410 if($url_data['scheme'] == 'mailto')
411 {
412 continue;
413 }
414
415 // PUH, HTTP_REQUEST needs a beginning http://
416 if(!$url_data['scheme'])
417 {
418 $matches[1][$i] = 'http://'.$matches[1][$i];
419 }
420
421 $lm_id = $this->__getObjIdByPageId($a_page['page_id']);
422 $link[] = array('page_id' => $a_page['page_id'],
423 'obj_id' => $lm_id,
424 'type' => $a_page['type'],
425 'complete' => $matches[1][$i],
426 'scheme' => isset($url_data['scheme']) ? $url_data['scheme'] : 'http',
427 'host' => isset($url_data['host']) ? $url_data['host'] : $url_data['path']);
428 }
429 }
430
431 return $link ? $link : array();
432 }
__getObjIdByPageId($a_page_id)

References __getObjIdByPageId().

Referenced by checkLinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getNotifyLinks()

ilLinkChecker::__getNotifyLinks ( )

Definition at line 374 of file class.ilLinkChecker.php.

375 {
376 return $this->notify ? $this->notify : array();
377 }

Referenced by __sendMail().

+ Here is the caller graph for this function:

◆ __getObjIdByPageId()

ilLinkChecker::__getObjIdByPageId (   $a_page_id)

Definition at line 556 of file class.ilLinkChecker.php.

557 {
558 $query = "SELECT lm_id FROM lm_data ".
559 "WHERE obj_id = '".$a_page_id."'";
560
561 $row = $this->db->getRow($query,DB_FETCHMODE_OBJECT);
562
563 return $row->lm_id ? $row->lm_id : 0;
564 }

References $query, $row, and DB_FETCHMODE_OBJECT.

Referenced by __getLinks().

+ Here is the caller graph for this function:

◆ __getTitle()

ilLinkChecker::__getTitle (   $a_lm_obj_id)

Definition at line 257 of file class.ilLinkChecker.php.

258 {
259 global $ilDB;
260
261 $query = "SELECT title FROM object_data ".
262 "WHERE obj_id = ".$ilDB->quote($a_lm_obj_id ,'integer')." ";
263
264 $row = $this->db->getRow($query,DB_FETCHMODE_OBJECT);
265
266 return $row->title;
267 }

References $ilDB, $query, $row, and DB_FETCHMODE_OBJECT.

Referenced by __sendMail().

+ Here is the caller graph for this function:

◆ __getType()

ilLinkChecker::__getType ( )

Definition at line 60 of file class.ilLinkChecker.php.

61 {
62 return $this->type;
63 }

Referenced by __sendMail().

+ Here is the caller graph for this function:

◆ __getWebResourceLinks()

ilLinkChecker::__getWebResourceLinks ( )

Definition at line 434 of file class.ilLinkChecker.php.

435 {
436 global $objDefinition;
437
438 include_once 'Modules/WebResource/classes/class.ilLinkResourceItems.php';
439
440 $link_res_obj = new ilLinkResourceItems($this->getObjId());
441
442 foreach($check_links = $link_res_obj->getCheckItems($this->getCheckPeriod()) as $item_data)
443 {
444 // #10091 - internal
445 if(strpos($item_data['target'], '|'))
446 {
447 $parts = explode('|', $item_data['target']);
448 if(sizeof($parts) == 2 &&
449 is_numeric($parts[1]) &&
450 $objDefinition->isAllowedInRepository($parts[0]))
451 {
452 $link[] = array('page_id' => $item_data['link_id'],
453 'obj_id' => $this->getObjId(),
454 'type' => 'webr',
455 'complete' => $item_data['target'],
456 'scheme' => 'internal',
457 'obj_type' => $parts[0],
458 'ref_id' => $parts[1]);
459 continue;
460 }
461 }
462
463 // external
464 $url_data = @parse_url($item_data['target']);
465
466 // PUH, HTTP_REQUEST needs a beginning http://
467 if(!$url_data['scheme'])
468 {
469 $item_data['target'] = 'http://'.$item_data['target'];
470 }
471
472 $link[] = array('page_id' => $item_data['link_id'],
473 'obj_id' => $this->getObjId(),
474 'type' => 'webr',
475 'complete' => $item_data['target'],
476 'scheme' => isset($url_data['scheme']) ? $url_data['scheme'] : 'http',
477 'host' => isset($url_data['host']) ? $url_data['host'] : $url_data['path']);
478 }
479 return $link ? $link : array();
480 }
Class ilObjLinkResourceGUI.

References getObjId().

Referenced by checkWebResourceLinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __isInvalid()

ilLinkChecker::__isInvalid (   $a_page_id,
  $a_url 
)

Definition at line 566 of file class.ilLinkChecker.php.

567 {
568 foreach($this->getInvalidLinks() as $link)
569 {
570 if($link['page_id'] == $a_page_id and
571 substr($link['complete'],0,255) == $a_url)
572 {
573 return true;
574 }
575 }
576 return false;
577 }

References getInvalidLinks().

+ Here is the call graph for this function:

◆ __saveInDB()

ilLinkChecker::__saveInDB ( )

Definition at line 579 of file class.ilLinkChecker.php.

580 {
581 global $ilDB;
582
583 if($this->getMailStatus())
584 {
585 $this->__checkNotify();
586 }
587 $this->__clearDBData();
588
589
590 foreach($this->getInvalidLinks() as $link)
591 {
592 $query = "INSERT INTO link_check (obj_id,page_id,url,parent_type,http_status_code,last_check) ".
593 "VALUES ( ".
594 $ilDB->quote($link['obj_id'],'integer').", ".
595 $ilDB->quote($link['page_id'],'integer').", ".
596 $ilDB->quote(substr($link['complete'],0,255),'text').", ".
597 $ilDB->quote($link['type'],'text').", ".
598 $ilDB->quote($link['http_status_code'] ? $link['http_status_code'] : 0,'integer').", ".
599 $ilDB->quote(time(),'integer')." ".
600 ")";
601 $res = $ilDB->manipulate($query);
602 }
603 }

References $ilDB, $query, $res, __checkNotify(), __clearDBData(), getInvalidLinks(), and getMailStatus().

Referenced by checkLinks(), and checkWebResourceLinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __sendMail()

ilLinkChecker::__sendMail ( )

Definition at line 269 of file class.ilLinkChecker.php.

270 {
271 global $ilUser;
272
273
274 if(!count($notify = $this->__getNotifyLinks()))
275 {
276 // Nothing to do
277 return true;
278 }
279 if(!$this->getMailStatus())
280 {
281 return true;
282 }
283
284 include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
285 $body = "";
286 $obj_name = "";
287
288 foreach(ilLinkCheckNotify::_getAllNotifiers($this->db) as $usr_id => $obj_ids)
289 {
290 if(!is_object($tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id,false)))
291 {
292 $this->__appendLogMessage('LinkChecker: Cannot find user with id: '.$usr_id);
293 continue;
294 }
295
296 $counter = 0;
297 foreach($obj_ids as $obj_id)
298 {
299 if(!isset($notify[$obj_id]))
300 {
301 continue;
302 }
303 ++$counter;
304
305 switch($this->__getType())
306 {
307 case 'webr':
308 $obj_name = $this->__txt($tmp_user->getLanguage(),'obj_webr');
309 break;
310 case 'lm':
311 default:
312 $obj_name = $this->__txt($tmp_user->getLanguage(),'lo');
313 break;
314 }
315 $body .= $obj_name.': '.$this->__getTitle($obj_id)."\r\n";
316 $body .= $this->__txt($tmp_user->getLanguage(),'link_check_perma_link', "mail"). ": " .
317 $this->createPermanentLink($obj_id, $usr_id, $this->__getType())." \r\n";
318 $body .= $this->__txt($tmp_user->getLanguage(),"link_check_affected_links", "mail"). ":\r\n";
319
320 // Print all invalid
321 foreach($notify[$obj_id] as $data)
322 {
323 $body .= $data['url']."\r\n";
324 }
325 $body .= "\r\n";
326 }
327 if($counter)
328 {
329 include_once "./Services/Notification/classes/class.ilSystemNotification.php";
330 $ntf = new ilSystemNotification();
331 $ntf->setLangModules(array("mail", "common"));
332 $ntf->setSubjectLangId("link_check_subject");
333 $ntf->setIntroductionLangId("link_check_introduction");
334 $ntf->setReasonLangId("link_check_reason");
335 $ntf->addAdditionalInfo("additional_info", $body,true);
336 $ntf->sendMail(array($tmp_user->getId()));
337
338 $this->__appendLogMessage('LinkChecker: Sent mail to '.$tmp_user->getEmail());
339 }
340 $body = "";
341 }
342 }
__txt($language, $key, $module='common')
createPermanentLink($a_obj_id, $a_usr_id, $a_obj_type)
creates a permanent link
__getTitle($a_lm_obj_id)
__appendLogMessage($a_string)
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Wrapper classes for system notifications.
global $ilUser
Definition: imgupload.php:15

References $data, $ilUser, __appendLogMessage(), __getNotifyLinks(), __getTitle(), __getType(), __txt(), ilLinkCheckNotify\_getAllNotifiers(), createPermanentLink(), ilObjectFactory\getInstanceByObjId(), and getMailStatus().

Referenced by checkLinks(), and checkWebResourceLinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __setType()

ilLinkChecker::__setType (   $a_type)

Definition at line 56 of file class.ilLinkChecker.php.

57 {
58 $this->type = $a_type;
59 }

Referenced by checkLinks(), and checkWebResourceLinks().

+ Here is the caller graph for this function:

◆ __txt()

ilLinkChecker::__txt (   $language,
  $key,
  $module = 'common' 
)

Definition at line 228 of file class.ilLinkChecker.php.

229 {
230 global $ilDB;
231
232 include_once './Services/Language/classes/class.ilLanguage.php';
233 return ilLanguage::_lookupEntry($language, $module, $key);
234 }
static _lookupEntry($a_lang_key, $a_mod, $a_id)

References $ilDB, and ilLanguage\_lookupEntry().

Referenced by __sendMail().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __validateLinks()

ilLinkChecker::__validateLinks (   $a_links)

Definition at line 484 of file class.ilLinkChecker.php.

485 {
486 global $tree;
487
488 if(!@include_once('HTTP/Request.php'))
489 {
490 $this->__appendLogMessage('LinkChecker: Pear HTTP_Request is not installed. Aborting');
491
492 return array();
493 }
494
495 foreach($a_links as $link)
496 {
497 // #10091 - internal
498 if($link['scheme'] == 'internal')
499 {
500 $obj_id = ilObject::_lookupObjId($link['ref_id']);
501 if(!$obj_id ||
502 ilObject::_lookupType($obj_id) != $link['obj_type'] ||
503 $tree->isDeleted($link['ref_id']))
504 {
505 $invalid[] = $link;
506 }
507 }
508 // external
509 else
510 {
511 if(gethostbyname($link['host']) == $link['host'])
512 {
513 $invalid[] = $link;
514 continue;
515 }
516
517 if($link['scheme'] !== 'http' and $link['scheme'] !== 'https')
518 {
519 continue;
520 }
521
522 require_once './Services/Http/classes/class.ilProxySettings.php';
523
524 if(ilProxySettings::_getInstance()->isActive())
525 {
526 $options = array('proxy_host' => ilProxySettings::_getInstance()->getHost(),
527 'proxy_port' => ilProxySettings::_getInstance()->getPort());
528 }
529 else
530 {
531 $options = array();
532 }
533
534 $req = new HTTP_Request($link['complete'], $options);
535 $req->sendRequest();
536
537 switch($req->getResponseCode())
538 {
539 // EVERYTHING OK
540 case '200':
541 // In the moment 301 will be handled as ok
542 case '301':
543 case '302':
544 break;
545
546 default:
547 $link['http_status_code'] = $req->getResponseCode();
548 $invalid[] = $link;
549 break;
550 }
551 }
552 }
553 return $invalid ? $invalid : array();
554 }
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getInstance()
Getter for unique instance.
if(!is_array($argv)) $options

References $options, __appendLogMessage(), ilProxySettings\_getInstance(), ilObject\_lookupObjId(), and ilObject\_lookupType().

Referenced by checkLinks(), and checkWebResourceLinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkLinks()

ilLinkChecker::checkLinks ( )

Definition at line 151 of file class.ilLinkChecker.php.

152 {
153 global $ilDB;
154
155 $pages = array();
156
157 $this->__setType('lm');
158 $this->__clearLogMessages();
159 $this->__clearInvalidLinks();
160 $this->__appendLogMessage('LinkChecker: Start checkLinks()');
161
162 if(!$this->getValidateAll() and !$this->getObjId())
163 {
164 echo "ilLinkChecker::checkLinks() No Page id given";
165
166 return false;
167 }
168 elseif(!$this->getValidateAll() and $this->getObjId())
169 {
170 $query = "SELECT * FROM page_object ".
171 "WHERE parent_id = ".$ilDB->quote($this->getObjId())." ".
172 "AND parent_type = 'lm'";
173
174 $res = $this->db->query($query);
175 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
176 {
177 $pages[] = array('page_id' => $row->page_id,
178 'content' => $row->content,
179 'type' => $row->parent_type);
180 }
181 }
182 elseif($this->getValidateAll())
183 {
184 $query = "SELECT * FROM page_object ".
185 "WHERE parent_type = 'lm'";
186
187 $res = $this->db->query($query);
188 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
189 {
190 $pages[] = array('page_id' => $row->page_id,
191 'content' => $row->content,
192 'type' => $row->parent_type);
193 }
194 }
195
196 // VALIDATE
197 foreach($pages as $page)
198 {
199 if(count($invalid = $this->__validateLinks($this->__getLinks($page))))
200 {
201 foreach($invalid as $invalid_item)
202 {
203 $this->__appendLogMessage('LinkChecker: found invalid link: '.$invalid_item['complete']);
204 $this->__appendInvalidLink($invalid_item);
205 }
206 }
207 }
208
209 $this->__appendLogMessage('LinkChecker: End checkLinks()');
210 $this->__saveInDB();
211
212 $this->__sendMail();
213
214 return $this->getInvalidLinks();
215 }
__appendInvalidLink($a_link)

References $ilDB, $query, $res, $row, __appendInvalidLink(), __appendLogMessage(), __clearInvalidLinks(), __clearLogMessages(), __getLinks(), __saveInDB(), __sendMail(), __setType(), __validateLinks(), DB_FETCHMODE_OBJECT, getInvalidLinks(), getObjId(), and getValidateAll().

+ Here is the call graph for this function:

◆ checkPear()

ilLinkChecker::checkPear ( )

Definition at line 217 of file class.ilLinkChecker.php.

218 {
219 if(!@include_once('HTTP/Request.php'))
220 {
221 return false;
222 }
223 return true;
224 }

◆ checkWebResourceLinks()

ilLinkChecker::checkWebResourceLinks ( )

Definition at line 125 of file class.ilLinkChecker.php.

126 {
127 $pages = array();
128
129 $this->__setType('webr');
130 $this->__clearLogMessages();
131 $this->__clearInvalidLinks();
132 $this->__appendLogMessage('LinkChecker: Start checkLinks()');
133
134 if(count($invalid = $this->__validateLinks($this->__getWebResourceLinks())))
135 {
136 foreach($invalid as $invalid_item)
137 {
138 $this->__appendLogMessage('LinkChecker: found invalid link: '.$invalid_item['complete']);
139 $this->__appendInvalidLink($invalid_item);
140 }
141 }
142
143 $this->__appendLogMessage('LinkChecker: End checkLinks()');
144 $this->__saveInDB();
145
146 $this->__sendMail();
147
148 return $this->getInvalidLinks();
149 }

References __appendInvalidLink(), __appendLogMessage(), __clearInvalidLinks(), __clearLogMessages(), __getWebResourceLinks(), __saveInDB(), __sendMail(), __setType(), __validateLinks(), and getInvalidLinks().

+ Here is the call graph for this function:

◆ createPermanentLink()

ilLinkChecker::createPermanentLink (   $a_obj_id,
  $a_usr_id,
  $a_obj_type 
)
protected

creates a permanent link

Parameters
$a_obj_id
$a_usr_id
$a_obj_type
Returns
string goto link

Definition at line 351 of file class.ilLinkChecker.php.

352 {
353 global $ilAccess;
354 $ref_ids = ilObject::_getAllReferences($a_obj_id);
355 $ref_id = null;
356
357 foreach((array) $ref_ids as $id)
358 {
359 if($ilAccess->checkAccessOfUser($a_usr_id, "read", "", $id, $a_obj_type, $a_obj_id))
360 {
361 $ref_id = $id;
362 }
363 }
364
365 if($ref_id === null)
366 {
367 return false;
368 }
369
370 include_once './Services/Link/classes/class.ilLink.php';
371 return ilLink::_getLink($ref_id, $a_obj_type);
372 }
static _getAllReferences($a_id)
get all reference ids of object
$ref_id
Definition: sahs_server.php:39

References $ref_id, ilObject\_getAllReferences(), and ilLink\_getLink().

Referenced by __sendMail().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCheckPeriod()

ilLinkChecker::getCheckPeriod ( )

Definition at line 42 of file class.ilLinkChecker.php.

43 {
44 return $this->period;
45 }

◆ getInvalidLinks()

ilLinkChecker::getInvalidLinks ( )

Definition at line 84 of file class.ilLinkChecker.php.

85 {
86 return $this->invalid_links ? $this->invalid_links : array();
87 }

Referenced by __checkNotify(), __isInvalid(), __saveInDB(), checkLinks(), and checkWebResourceLinks().

+ Here is the caller graph for this function:

◆ getInvalidLinksFromDB()

ilLinkChecker::getInvalidLinksFromDB ( )

Definition at line 89 of file class.ilLinkChecker.php.

90 {
91 global $ilDB;
92
93 $query = "SELECT * FROM link_check ".
94 "WHERE obj_id = ".$ilDB->quote($this->getObjId(),'integer')." ";
95
96 $res = $this->db->query($query);
97 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
98 {
99 $invalid[] = array('page_id' => $row->page_id,
100 'url' => $row->url);
101 }
102
103 return $invalid ? $invalid : array();
104 }

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, and getObjId().

+ Here is the call graph for this function:

◆ getLastCheckTimestamp()

ilLinkChecker::getLastCheckTimestamp ( )

Definition at line 106 of file class.ilLinkChecker.php.

107 {
108 global $ilDB;
109
110 if($this->getValidateAll())
111 {
112 $query = "SELECT MAX(last_check) last_check FROM link_check ";
113 }
114 else
115 {
116 $query = "SELECT MAX(last_check) last_check FROM link_check ".
117 "WHERE obj_id = ".$ilDB->quote($this->getObjId(),'integer')." ";
118 }
119 $res = $ilDB->query($query);
120 $row = $ilDB->fetchObject($res);
121
122 return $row->last_check ? $row->last_check : 0;
123 }

References $ilDB, $query, $res, $row, getObjId(), and getValidateAll().

+ Here is the call graph for this function:

◆ getLogMessages()

ilLinkChecker::getLogMessages ( )

Definition at line 79 of file class.ilLinkChecker.php.

80 {
81 return $this->log_messages ? $this->log_messages : array();
82 }

◆ getMailStatus()

ilLinkChecker::getMailStatus ( )

Definition at line 51 of file class.ilLinkChecker.php.

52 {
53 return (bool) $this->mail_status;
54 }

References $mail_status.

Referenced by __saveInDB(), and __sendMail().

+ Here is the caller graph for this function:

◆ getObjId()

ilLinkChecker::getObjId ( )

Definition at line 69 of file class.ilLinkChecker.php.

70 {
71 return $this->page_id;
72 }

References $page_id.

Referenced by __clearDBData(), __getWebResourceLinks(), checkLinks(), getInvalidLinksFromDB(), and getLastCheckTimestamp().

+ Here is the caller graph for this function:

◆ getValidateAll()

ilLinkChecker::getValidateAll ( )

Definition at line 74 of file class.ilLinkChecker.php.

75 {
76 return $this->validate_all ? true : false;
77 }

Referenced by __clearDBData(), checkLinks(), and getLastCheckTimestamp().

+ Here is the caller graph for this function:

◆ ilLinkChecker()

ilLinkChecker::ilLinkChecker ( $db,
  $a_validate_all = true 
)

Definition at line 23 of file class.ilLinkChecker.php.

24 {
25 global $ilDB;
26
27 define('DEBUG',1);
28 define('SOCKET_TIMEOUT',5);
29
30 $this->db =& $db;
31
32 // SET GLOBAL DB HANDLER FOR STATIC METHODS OTHER CLASSES
33 $ilDB =& $db;
34
35 $this->validate_all = $a_validate_all;
36 }

References $db, and $ilDB.

◆ setCheckPeriod()

ilLinkChecker::setCheckPeriod (   $a_period)

Definition at line 38 of file class.ilLinkChecker.php.

39 {
40 $this->period = $a_period;
41 }

◆ setMailStatus()

ilLinkChecker::setMailStatus (   $a_status)

Definition at line 47 of file class.ilLinkChecker.php.

48 {
49 $this->mail_status = (bool) $a_status;
50 }

◆ setObjId()

ilLinkChecker::setObjId (   $a_page_id)

Definition at line 65 of file class.ilLinkChecker.php.

66 {
67 return $this->page_id = $a_page_id;
68 }

Field Documentation

◆ $db

ilLinkChecker::$db = null

Definition at line 14 of file class.ilLinkChecker.php.

Referenced by ilLinkChecker().

◆ $invalid_links

ilLinkChecker::$invalid_links = array()

Definition at line 16 of file class.ilLinkChecker.php.

◆ $log_messages

ilLinkChecker::$log_messages = array()

Definition at line 15 of file class.ilLinkChecker.php.

◆ $mail_status

ilLinkChecker::$mail_status = false

Definition at line 19 of file class.ilLinkChecker.php.

Referenced by getMailStatus().

◆ $page_id

ilLinkChecker::$page_id = 0

Definition at line 20 of file class.ilLinkChecker.php.

Referenced by getObjId().

◆ $validate_all

ilLinkChecker::$validate_all = true

Definition at line 18 of file class.ilLinkChecker.php.


The documentation for this class was generated from the following file: