<commit_before><?php

class AdminPageController {
	static public function adminHandler($params) {
		$format = Utils::getFormat($params['args'], 0, 2);
		$app_url = Settings::getProtected('app_url');
		$db = Settings::getProtected('db');

		$user = User::getAuthenticatedUser();

		// Get the current user's role and make sure they're at least creator or admin
		$roleManager = new Role();
		$roleManager->forceClearance(array('role' => 'user:creator', 'user' => $user));

		// Get latest work for the user's projects
		$latestWorkList = $db->getAdminProjectsLatestWork($user->username, 5);
		$latestWork = array();
		foreach ($latestWorkList as $work) {
			$qn = $work['queue_name'];
			$type = substr($qn, strpos($qn, '.') + 1, strpos($qn, ':') - strpos($qn, '.') - 1);
			$username = substr($qn, strpos($qn, ':') + 1);

			$item = new Item($work['item_id'], $work['project_slug']);
			$project = new Project($work['project_slug']);

			if ($item->project_type == 'system') { 
				$transcriptURL = "$app_url/projects/" . $item->project_slug . "/items/" . $item->item_id . "/$type/$username";
				$editURL = "$app_url/projects/" . $item->project_slug . "/items/" . $item->item_id . "/edit";
			} else {<commit_msg>Added role check to admin page<commit_after><?php

class AdminPageController {
	static public function adminHandler($params) {
		$format = Utils::getFormat($params['args'], 0, 2);
		$app_url = Settings::getProtected('app_url');
		$db = Settings::getProtected('db');

		$user = User::getAuthenticatedUser();

		// Make sure the user is at least creator or admin
		RoleController::forceClearance(
			array('system.creator', 'system.admin'),
			$user
		);

		// Get latest work for the user's projects
		$latestWorkList = $db->getAdminProjectsLatestWork($user->username, 5);
		$latestWork = array();
		foreach ($latestWorkList as $work) {
			$qn = $work['queue_name'];
			$type = substr($qn, strpos($qn, '.') + 1, strpos($qn, ':') - strpos($qn, '.') - 1);
			$username = substr($qn, strpos($qn, ':') + 1);

			$item = new Item($work['item_id'], $work['project_slug']);
			$project = new Project($work['project_slug']);

			if ($item->project_type == 'system') { 
				$transcriptURL = "$app_url/projects/" . $item->project_slug . "/items/" . $item->item_id . "/$type/$username";
				$editURL = "$app_url/projects/" . $item->project_slug . "/items/" . $item->item_id . "/edit";
			} else {
{'fraction_non_alphanumeric': 0.20350291909924936, 'fraction_numerical': 0.0050041701417848205, 'mean_word_length': 4.307522123893805, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2481053', 'n_tokens_mistral': 897, 'n_tokens_neox': 798, 'n_words': 178}