function hacked_calculate_project_data in Hacked! 5
Same name and namespace in other branches
- 6.2 hacked.module \hacked_calculate_project_data()
- 6 hacked.module \hacked_calculate_project_data()
- 7.2 hacked.module \hacked_calculate_project_data()
4 calls to hacked_calculate_project_data()
- drush_hacked_list_projects in ./
hacked.drush.inc - Drush command callback that shows the listing of changed/unchanged projects.
- hacked_project_load in ./
hacked.module - Menu loader for loading a project from its short name.
- hacked_reports_hacked in ./
hacked.module - hacked_reports_hacked_details in ./
hacked.details.inc
File
- ./
hacked.module, line 201 - The Hacked! module, shows which project have been changed since download.
Code
function hacked_calculate_project_data($projects, $ensure_downloaded = FALSE) {
foreach ($projects as $project_key => $project) {
//if ($project['install_type'] == 'official') {
$projects[$project_key]['hacked_status'] = HACKED_STATUS_UNCHECKED;
// Go get the hashes of the clean copy of the installed version:
$projects[$project_key]['clean_hashes'] = hacked_hash_project($project, $ensure_downloaded);
// If we got some hashes, let's compare it with the local copy:
if ($projects[$project_key]['clean_hashes']) {
hacked_hash_local($projects[$project_key]);
$hacked_count = 0;
$deleted_count = 0;
$unreadable_count = 0;
// Now do the comparison:
foreach ($projects[$project_key]['clean_hashes'] as $file => $hash) {
// Has the file been deleted:
if (!isset($projects[$project_key]['local_hashes'][$file])) {
$deleted_count++;
$projects[$project_key]['hacked_results'][$file] = HACKED_STATUS_DELETED;
}
else {
// If we can't read the file, mark it as permission denied
if (!is_readable(hacked_find_local_project_directory($projects[$project_key]) . '/' . $file)) {
$unreadable_count++;
$projects[$project_key]['hacked_results'][$file] = HACKED_STATUS_PERMISSION_DENIED;
}
elseif ($projects[$project_key]['local_hashes'][$file] != $hash) {
$hacked_count++;
$projects[$project_key]['hacked_results'][$file] = HACKED_STATUS_HACKED;
}
else {
$projects[$project_key]['hacked_results'][$file] = HACKED_STATUS_UNHACKED;
}
}
}
// Record aggregate stats
$projects[$project_key]['changed_count'] = $hacked_count;
$projects[$project_key]['deleted_count'] = $deleted_count;
$projects[$project_key]['unreadable_count'] = $unreadable_count;
if ($hacked_count) {
$projects[$project_key]['hacked_status'] = HACKED_STATUS_HACKED;
}
else {
$projects[$project_key]['hacked_status'] = HACKED_STATUS_UNHACKED;
}
}
//}
}
return $projects;
}