Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
test_orphan_assets.inc
1 <?php
28 {
29 
30 
37  public static function getName()
38  {
39  return 'Orphaned Assets Test';
40 
41  }//end getName()
42 
43 
50  public static function getDescription()
51  {
52  return 'A test to check for orphaned assets in Matrix';
53 
54  }//end getDescription()
55 
56 
66  public static function test(&$messages, &$errors)
67  {
68  $status = TRUE;
69  $sql = 'SELECT assetid FROM sq_ast WHERE assetid NOT IN (SELECT minorid AS assetid FROM sq_ast_lnk WHERE link_type < 8)';
70  $results = MatrixDAL::executeSqlAssoc($sql);
71  if (!empty($results)) {
72 
73  foreach ($results as $index => $result) {
74  $results[$index] = $result['assetid'];
75  }
76  $results = array_unique($results);
77 
78  $status = FALSE;
79  $messages[] = 'There are '.count($results).' orphaned asset(s) on the system';
80  foreach ($results as $asset) {
81  $errors[] = 'Asset #'.$asset.' is orphaned on the system';
82  }//end foreach
83  }//end if
84 
85  return $status;
86 
87  }//end test()
88 
89 }//end class
90 ?>