Changeset 27563 for extensions/rv_db_integrity/check_db.php
- Timestamp:
- Mar 5, 2014, 9:44:20 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rv_db_integrity/check_db.php
r20461 r27563 20 20 GROUP BY ref.'.$reff; 21 21 22 $result = pwg_query($query); 23 return pwg_db_num_rows($result); 22 return query2array($query,null,$reff); 24 23 } 25 24 … … 75 74 { 76 75 $err = check_table_ref($table, $field_name, $test[0], $test[1] ); 77 if ( $err)76 if (count($err)) 78 77 { 79 78 $failed++; 80 $tpl_var['errors'][]= $err.' error references; #'.$test[0].'.'.$test[1].' referring to #'.$table.'.'.$field_name; 79 $tpl_var['errors'][]= count($err).' error references; #'.$test[0].'.'.$test[1].' referring to #'.$table.'.'.$field_name; 80 $tpl_var['errors'][]= 'Offending '.$test[1].' '.implode(',',$err); 81 81 } 82 82 } … … 107 107 $template->append('reference_tests', $tpl_var); 108 108 109 // Status/visible tests 110 $tpl_var = array( 111 'ID' => 'status', 112 'LABEL' => 'Album status/visibility', 113 'CHECKED' => isset($_POST['status']) ? 'checked="checked"' : $default_checked, 114 'COUNT' => 1, 115 ); 116 if (isset($_POST['status'])) 117 { 118 $failed = 0; 119 $query = ' 120 SELECT id,name,id_uppercat,status,visible 121 FROM '.CATEGORIES_TABLE; 122 $cats = query2array($query,'id'); 123 foreach($cats as $cat) 124 { 125 if (!isset($cat['id_uppercat'])) continue; 126 if ('public'==$cat['status'] && 'public'!=$cats[$cat['id_uppercat']]['status']) 127 { 128 $failed++; 129 $tpl_var['errors'][] = 'Public album '.$cat['id'].' '.$cat['name'].' parent '.$cat['id_uppercat'].' is '.$cats[$cat['id_uppercat']]['status']; 130 } 131 if ('true'==$cat['visible'] && 'true'!=$cats[$cat['id_uppercat']]['visible']) 132 { 133 $failed++; 134 $tpl_var['errors'][] = 'Visible album '.$cat['id'].' '.$cat['name'].' parent '.$cat['id_uppercat'].' is '.$cats[$cat['id_uppercat']]['visible']; 135 } 136 } 137 $tpl_var['result'] = $failed; 138 } 139 $template->append('reference_tests', $tpl_var); 140 141 // Permissions 142 $tpl_var = array( 143 'ID' => 'permissions', 144 'LABEL' => 'Permissions', 145 'CHECKED' => isset($_POST['permissions']) ? 'checked="checked"' : $default_checked, 146 'COUNT' => 1, 147 ); 148 if (isset($_POST['permissions'])) 149 { 150 $query = ' 151 SELECT id,name,id_uppercat 152 FROM '.CATEGORIES_TABLE.' 153 WHERE status="private"'; 154 $cats = query2array($query,'id'); 155 156 $groups = array_fill_keys( array_keys($cats), array()); 157 $query = 'SELECT cat_id,group_id FROM '.GROUP_ACCESS_TABLE; 158 $result = pwg_query($query); 159 while ($row=pwg_db_fetch_assoc($result)) 160 $groups[$row['cat_id']][] = $row['group_id']; 161 162 $users = array_fill_keys( array_keys($cats), array()); 163 $query = 'SELECT cat_id,user_id FROM '.USER_ACCESS_TABLE; 164 $result = pwg_query($query); 165 while ($row=pwg_db_fetch_assoc($result)) 166 $users[$row['cat_id']][] = $row['user_id']; 167 168 $failed = 0; 169 foreach($cats as $cat) 170 { 171 if (!isset($cats[$cat['id_uppercat']])) continue; 172 foreach( array('users','groups') as $type) 173 { 174 $arr = $$type; 175 $me = $arr[$cat['id']]; 176 $dad = $arr[$cat['id_uppercat']]; 177 $delta = array_diff($me, $dad); 178 if (count($delta)) 179 { 180 $tpl_var['errors'][] = 'Album '.$cat['id'].' '.$cat['name'].' too many '.$type.' permissions '.implode(',',$delta); 181 $failed++; 182 } 183 } 184 } 185 $tpl_var['result'] = $failed; 186 } 187 $template->append('reference_tests', $tpl_var); 188 109 189 110 190 // #images(id,storage_category_id) vs. #image_category(image_id,category_id) --- … … 117 197 if (isset($_POST['id_storage_category_id'])) 118 198 { 119 199 $query = ' 120 200 SELECT i.id, i.storage_category_id, i.path 121 201 FROM '.IMAGES_TABLE.' i LEFT JOIN '.IMAGE_CATEGORY_TABLE.' ic ON ic.image_id=i.id AND ic.category_id=i.storage_category_id
Note: See TracChangeset
for help on using the changeset viewer.