Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
test_user_permissions.inc
1 <?php
28 {
29 
30 
37  public static function getName()
38  {
39  return 'User Permissions Test';
40 
41  }//end getName()
42 
43 
50  public static function getDescription()
51  {
52  return 'A test to check for invalid users on the permission table in Matrix';
53 
54  }//end getDescription()
55 
56 
66  public static function test(&$messages, &$errors)
67  {
68  $status = TRUE;
69  $count = 0;
70  $am = $GLOBALS['SQ_SYSTEM']->am;
71  $sql = 'SELECT DISTINCT userid FROM sq_ast_perm ORDER BY userid';
72  $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db');
73  $assetids = MatrixDAL::executeSqlAssoc($sql, 0);
74 
75  foreach ($assetids as $assetid) {
76  // Does the user exist?
77  $asset = $am->getAsset($assetid, '', TRUE);
78  if (is_null($asset)) {
79  $status=FALSE;
80  $count++;
81  $errors[] = 'User #'.$assetid.' does not exist';
82  } else {
83  $am->forgetAsset($asset, TRUE);
84  }//end if
85  unset($asset);
86  }//end foreach
87 
88  if (!$status && !empty($count)) {
89  $messages[] = 'There are '.$count.' users on the permissions table that do not exist';
90  }//end if
91 
92  return $status;
93 
94  }//end test()
95 
96 }//end class
97 ?>