<?php 
// version 1.0
require_once(dirname(__FILE__)."/functions.php");
require_once(dirname(__FILE__)."/actions.php");
require_once(dirname(__FILE__)."/do-action.php");
require_once(dirname(__FILE__)."/filters.php");
require_once(dirname(__FILE__)."/table-functions.php");
require_once(dirname(__FILE__)."/query-functions.php");

class eedu_portal {

	public static $plugin_name = "eedu_portal";
	public static $plugin_root = 'contents\plugins\eedu_portal';
	public static $plugin_ref = "E-Edu Portal";

	public function __construct () {
		
	}

	public static function install() {
		if(VERSION === "delux") {
			remove_option("stop_update_menu");
		}
		if(VERSION === "delux") {
			unregister_admin_page([
				"master-sheets",
				"master-sheet2",
				"master-sheet3",
				"master-sheet1",
				"standard-broadsheet",
				"broadsheet2",
				"our-academic-staff",
				"our-students",
				"our-courses",
				"add-staff",
				"our-admin-staff",
				"work-result",
				"verify-result",
				"results-for-verification",
				"verified-results",
				"curriculum",
				"master-sheet",
				"apply-minimum-subject",
				"apply_minimum_subject",
				"compiled-results",
				"master-results",
				"master-result",
				'ft-comment'
			]);

			unregister_admin_submenu([
				'curriculum',
				'work_result',
				'verify_result',
				'verified_results',
				'our_students',
				'staff',
				'withdrawn_staff',
				'withdrawn_student',
				'add_staff',
				'my_results',
				"ft_comment",
				"master_results",
				"compiled_results",
				"apply_minimum_subject"
			]);
			$database = new database;
			$sql = "ALTER TABLE records MODIFY record_value LONGTEXT";
			if (! mysqli_query($database->connection, $sql)) {
				die ('Unable to create records table');
			}
			$sql = "ALTER TABLE options MODIFY option_value LONGTEXT";
			if (! mysqli_query($database->connection, $sql)) {
				die ('Unable to create records table');
			}
			$sql = "ALTER TABLE invoice MODIFY items LONGTEXT";
			if (! mysqli_query($database->connection, $sql)) {
				die ('Unable to create records table');
			}
			$sql = "ALTER TABLE notification MODIFY action TEXT";
			if (! mysqli_query($database->connection, $sql)) {
				die ('Unable to create records table');
			}
			remove_action('rotate_element', 'get_rotate_element');
			remove_action('get_broadsheet', 'display_broadsheet');
			remove_action('get_broadsheet2', 'display_broadsheet2');
			remove_action('students_not_promoted', 'display_students_not_promoted');
			remove_action('close_academic_term', 'close_term_button');
			remove_action('dashboard_row', 'eedu_portal_latest_students_staff');
			remove_action('dashboard_row', 'eedu_portal_student_attendance_dashboard');
			remove_action('dashboard_row', 'eedu_portal_profile_calendar_dashboard');
			remove_action('get_master_sheet', 'display_master_sheet');
			remove_action('get_master_sheet2', 'display_master_sheet2');
			remove_action('get_master_sheet3', 'display_master_sheet3');
			remove_action('result_comments', 'display_result_comments');
			remove_action('get_paperhead', 'display_paperhead');
			remove_action('get_results_button_set', 'display_results_button_set');
			remove_action('get_teacher_stats', 'display_teacher_stats');
		}
		$common_access = ['academic_session', 'all_academic_session', 'academic_session_menu', 'view_timetable', 'timetable_menu', 'eedu_portal_dashboard'];
		add_common_access($common_access);
		$super_admin = ['add_student', 'structure_menu', 'assign_courses', 'assign_teachers', 'assign_form_teachers', 'admin_buttons', 'academic_session', 'all_academic_session', 'academic_session_menu', 'schedule_school_event', 'edit_event', 'academic_term', 'edit_timetable', 'view_timetable', 'my_timetable', 'work_result', 'edit_student', 'student_profile', 'edit_psychometrics', 'performance_menu', 'view_result_sheet', 'students', 'see_curriculum', 'edit_curriculum', 'view_student', 'broadsheet', 'ft_comment', 'compiled_results', 'teacher', 'admin', 'change_password', 'profile', 'switch_user_role', 'my_students', 'manage_my_classes', 'mark_attendance', 'attendance_report', 'master_sheet', 'upload_signature', 'super_admin', 'result_sheet', 'promote_students', 'new_academic_session', 'add_new_term', 'login_as_user', 'timetable_menu', 'my_results', 'apply_minimum_subject', 'all_cumulative_results', 'master_result', 'update_all_result', 'staff_profile', 'reassign_students', 'analytics', 'school_population', 'maintain_class_list', "access_others_result_sheet", "edit_form_teacher_comment", "gradebook", "print_results", "print_broadsheet", "print_annual_broadsheet", "print_results_without_pin", "edit_others_signature", 'manage_students_in_class'];
		$admin = ['add_student', 'all_academic_session', 'structure_menu', 'academic_session_menu', 'assign_courses', 'assign_teachers', 'assign_form_teachers', 'academic_session', 'academic_term', 'edit_timetable', 'view_timetable', 'my_timetable', 'work_result', 'edit_student', 'student_profile', 'edit_psychometrics', 'performance_menu', 'view_result_sheet', 'students', 'see_curriculum', 'edit_curriculum', 'view_student', 'broadsheet', 'ft_comment', 'compiled_results', 'teacher', 'admin', 'admin_only', 'change_password', 'profile', 'my_students', 'manage_my_classes', 'mark_attendance', 'attendance_report', 'master_sheet', 'upload_signature', 'result_sheet', 'promote_students', 'timetable_menu', 'my_results', 'all_cumulative_results', 'master_result', 'update_all_result', 'staff_profile', 'reassign_students', 'analytics', 'school_population', 'maintain_class_list', "access_others_result_sheet", "edit_form_teacher_comment", "gradebook", "print_results", "print_broadsheet", "print_annual_broadsheet", "print_results_without_pin"];
		$bursar = ['bursar_only', 'all_academic_session', 'structure_menu', 'academic_session_menu', 'academic_session', 'academic_term', 'student_profile', 'students', 'view_student', 'admin', 'bursar_only', 'change_password', 'profile', 'upload_signature', 'analytics', 'school_population', 'manage_students_in_class'];
		$teacher = ['teacher_only', 'structure_menu', 'our_academic_staff', 'academic_session', 'all_academic_session', 'academic_session_menu', 'view_timetable', 'my_timetable', 'work_result', 'student_profile', 'edit_psychometrics', 'performance_menu', 'students', 'see_curriculum', 'view_student', 'broadsheet', 'ft_comment', 'compiled_results', 'teacher', 'change_password', 'profile', 'my_students', 'manage_my_classes', 'mark_attendance', 'attendance_report', 'master_sheet', 'upload_signature', 'edit_timetable', 'result_sheet', 'teacher_only', 'timetable_menu', "access_others_result_sheet", "gradebook", "print_results", "print_broadsheet", "print_annual_broadsheet"];
		$student = ['student_only', 'academic_session', 'all_academic_session', 'academic_session_menu', 'view_timetable', 'timetable_menu', 'student_profile', 'performance_menu', 'see_curriculum', 'my_results', 'result_sheet', 'student', 'change_password', 'student_profile', 'my_profile', 'attendance_report', 'attendance_report_submenu', 'master_result', "print_results"];
		$se = ['update_software', 'add_class', 'add_courses', 'add_subject_branch', 'delete_class', 'edit_class', 'edit_category', 'delete_course', 'edit_course', 'school_settings', 'generate_result_pins', 'generated_pins', 'pins_by_batch', 'promotion_order', 'plugins_settings', 'more_logo', 'add_db_section', 'manage_students_in_class', 'edit_subject_branch', 'eedu_portal_remove_student_from_class', 'maintain_students_in_class'];
		
		update_role('software_engineer', array_unique(array_merge($super_admin, $admin, $teacher, $student, $bursar, $se)));
		update_role('super_admin', $super_admin);
		update_role('admin', $admin);
		update_role('teacher', $teacher);
		update_role('student', $student);
		update_role('bursar', $bursar);
		unset($teacher[0]);
		unset($bursar[0]);
		unset($student[0]);
		$post = new post;

		register_admin_page(array(
					'title' => 'Dashboard',
					'callback' => 'eedu_portal_dashboard_cb',
					'access' => 'eedu_portal_dashboard',
					'permalink' => 'eedu-portal-dashboard'
				));
		register_admin_page(array(
					'title' => 'Add Class',
					'callback' => 'add_class_cb',
					'access' => 'add_class',
					'permalink' => 'add-class'
				));
		register_admin_page(array(
					'title' => 'Add Student',
					'callback' => 'add_student_cb',
					'access' => 'add_student',
					'permalink' => 'add-student'
				));
		register_admin_page(array(
					'title' => 'Add Courses',
					'callback' => 'add_courses_cb',
					'access' => 'add_courses',
					'permalink' => 'add-courses'
				));
		register_admin_page(array(
					'title' => 'Assign Courses',
					'callback' => 'assign_courses_cb',
					'access' => 'assign_courses',
					'permalink' => 'assign-courses'
				));
		register_admin_page(array(
					'title' => 'Assign Teachers',
					'callback' => 'assign_teachers_cb',
					'access' => 'assign_teachers',
					'permalink' => 'assign-teachers'
				));
		register_admin_page(array(
					'title' => 'Assign Form Teachers',
					'callback' => 'assign_form_teachers_cb',
					'access' => 'assign_form_teachers',
					'permalink' => 'assign-form-teachers'
				));
		register_admin_page(array(
					'title' => 'Academic Session',
					'callback' => 'academic_session_cb',
					'access' => 'academic_session',
					'permalink' => 'academic-session'
				));
		register_admin_page(array(
					'title' => 'Academic Term',
					'callback' => 'academic_term_cb',
					'access' => 'academic_term',
					'permalink' => 'academic-term'
				));
		register_admin_page(array(
					'title' => 'All Academic Session',
					'callback' => 'all_academic_session_cb',
					'access' => 'all_academic_session',
					'permalink' => 'all-academic-session'
				));
		register_admin_page(array(
					'title' => 'Schedule School Event',
					'callback' => 'schedule_school_event_cb',
					'access' => 'schedule_school_event',
					'permalink' => 'schedule-school-event'
				));
		register_admin_page(array(
					'title' => 'Edit Event',
					'callback' => 'edit_event_cb',
					'access' => 'edit_event',
					'permalink' => 'edit-event'
				));
		register_admin_page(array(
					'title' => 'Edit Timetable',
					'callback' => 'edit_timetable_cb',
					'access' => 'edit_timetable',
					'permalink' => 'edit-timetable'
				));
		register_admin_page(array(
					'title' => 'Class Timetable',
					'callback' => 'class_timetable_cb',
					'access' => 'view_timetable',
					'permalink' => 'class-timetable'
				));
		register_admin_page(array(
					'title' => 'My Timetable',
					'callback' => 'my_timetable_cb',
					'access' => 'my_timetable',
					'permalink' => 'my-timetable'
				));
		register_admin_page(array(
					'title' => 'Student Profile',
					'callback' => 'student_profile_cb',
					'access' => 'student_profile',
					'permalink' => 'student-profile'
				));

		register_admin_page(array(
					'title' => 'Edit Psychometrics',
					'callback' => 'edit_psychometrics_cb',
					'access' => 'edit_psychometrics',
					'permalink' => 'edit-psychometrics'
				));
		register_admin_page(array(
					'title' => 'View Result Sheet',
					'callback' => 'view_result_sheet_cb',
					'access' => 'view_result_sheet',
					'permalink' => 'view-result-sheet'
				));
		register_admin_page(array(
					'title' => 'Broadsheet',
					'callback' => 'broadsheet_cb',
					'access' => 'broadsheet',
					'permalink' => 'broadsheet'
				));
		register_admin_page(array(
					'title' => 'My Results',
					'callback' => 'my_results_cb',
					'access' => 'my_results',
					'permalink' => 'my-results'
				));
		register_admin_page(array(
					'title' => 'Result Sheet',
					'callback' => 'result_sheet_cb',
					'access' => 'result_sheet',
					'permalink' => 'result-sheet'
				));
		// register_admin_page(array(
		// 			'title' => 'Form Teacher Comment',
		// 			'callback' => 'ft_comment_cb',
		// 			'access' => 'ft_comment',
		// 			'permalink' => 'ft-comment'
		// 		));
		// register_admin_page(array(
		// 			'title' => 'Compiled Results',
		// 			'callback' => 'compiled_results_cb',
		// 			'access' => 'compiled_results',
		// 			'permalink' => 'compiled-results'
		// 		));
		register_admin_page(array(
					'title' => 'Generated Pins',
					'callback' => 'generated_pins_cb',
					'access' => 'generated_pins',
					'permalink' => 'generated-pins'
				));
		register_admin_page(array(
					'title' => 'Pins By Batch',
					'callback' => 'pins_by_batch_cb',
					'access' => 'pins_by_batch',
					'permalink' => 'pins-by-batch'
				));
		register_admin_page(array(
					'title' => 'My Students',
					'callback' => 'my_students_cb',
					'access' => 'my_students',
					'permalink' => 'my-students'
				));
		register_admin_page(array(
					'title' => 'Manage My Classes',
					'callback' => 'manage_my_classes_cb',
					'access' => 'manage_my_classes',
					'permalink' => 'manage-my-classes'
				));
		register_admin_page(array(
					'title' => 'Mark Attendance',
					'callback' => 'mark_attendance_cb',
					'access' => 'mark_attendance',
					'permalink' => 'mark-attendance'
				));
		register_admin_page(array(
					'title' => 'Attendance Report',
					'callback' => 'attendance_report_cb',
					'access' => 'attendance_report',
					'permalink' => 'attendance-report'
				));
		register_admin_page(array(
					'title' => 'Annual Broadsheet',
					'callback' => 'master_sheet_cb',
					'access' => 'master_sheet',
					'permalink' => 'master-sheet'
				));
		register_admin_page(array(
					'title' => 'Promotion Order',
					'callback' => 'promotion_order_cb',
					'access' => 'promotion_order',
					'permalink' => 'promotion-order'
				));
		register_admin_page(array(
					'title' => 'Upload Signature',
					'callback' => 'upload_signature_cb',
					'access' => 'upload_signature',
					'permalink' => 'upload-signature'
				));
		register_admin_page(array(
					'title' => 'Annual Result',
					'callback' => 'master_result_cb',
					'access' => 'master_result',
					'permalink' => 'master-result'
				));
		register_admin_page(array(
					'title' => 'Edit Class',
					'callback' => 'edit_class_cb',
					'access' => 'edit_class',
					'permalink' => 'edit-class'
				));
		register_admin_page(array(
					'title' => 'Edit Category',
					'callback' => 'edit_category_cb',
					'access' => 'edit_category',
					'permalink' => 'edit-category'
				));
		register_admin_page(array(
					'title' => 'Edit Course',
					'callback' => 'edit_course_cb',
					'access' => 'edit_course',
					'permalink' => 'edit-course'
				));

		register_admin_page(array(
					'title' => 'More Logo',
					'callback' => 'more_logo_cb',
					'access' => 'more_logo',
					'permalink' => 'more-logo'
				));
		register_admin_page(array(
					'title' => 'Add New Term',
					'callback' => 'add_new_term_cb',
					'access' => 'add_new_term',
					'permalink' => 'add-new-term'
				));
		register_admin_page(array(
			'title' => 'Class List Archive',
			'callback' => 'manage_students_in_class_cb',
			'access' => 'manage_students_in_class',
			'permalink' => 'manage-students-in-class'
		));
		register_admin_page(array(
			'title' => 'Maintain List',
			'callback' => 'maintain_students_in_class_cb',
			'access' => 'maintain_students_in_class',
			'permalink' => 'maintain-students-in-class'
		));
		register_admin_page(array(
			'title' => 'Re-Assign Students to Classes',
			'callback' => 'reassign_students_cb',
			'access' => 'reassign_students',
			'permalink' => 'reassign-students'
		));
		register_admin_page(array(
			'title' => 'School Settings',
			'callback' => 'school_settings_cb',
			'access' => 'school_settings',
			'permalink' => 'school-settings'
		));
		register_admin_page(array(
			'title' => 'School Population',
			'callback' => 'school_population_cb',
			'access' => 'school_population',
			'permalink' => 'school-population'
		));
		register_admin_page(array(
			'title' => 'Result Checker',
			'callback' => 'result_checker_cb',
			'access' => 'result_checker',
			'permalink' => 'result-checker',
			'availability' => 'public'
		));
		register_admin_page(array(
			'title' => 'Add Subject/Course Branch',
			'callback' => 'add_subject_branch_cb',
			'access' => 'add_subject_branch',
			'permalink' => 'add-subject-branch'
		));

		register_admin_page(array(
			'title' => 'Edit Subject/Course Branch',
			'callback' => 'edit_subject_branch_cb',
			'access' => 'edit_subject_branch',
			'permalink' => 'edit-subject-branch'
		));

		register_admin_page(array(
			'title' => 'Gradebook',
			'callback' => 'gradebook_cb',
			'access' => 'gradebook',
			'permalink' => 'gradebook'
		));

		register_admin_page(array(
			'title' => 'Print Results',
			'callback' => 'print_results_cb',
			'access' => 'print_results',
			'permalink' => 'print-results'
		));

		register_admin_page(array(
			'title' => 'Print Broadsheet',
			'callback' => 'print_broadsheet_cb',
			'access' => 'print_broadsheet',
			'permalink' => 'print-broadsheet'
		));

		register_admin_page(array(
			'title' => 'Print Annual Broadsheet',
			'callback' => 'print_annual_broadsheet_cb',
			'access' => 'print_annual_broadsheet',
			'permalink' => 'print-annual-broadsheet'
		));



		register_admin_menu(array(
			'id' => 'academic-operations',
			'title' => 'Academic Operations',
			'icon' => 'fas fa-graduation-cap',
			'page' => '',
			'access' => 'academic_session_menu',
			'order' => 2
		));

		register_admin_submenu(array(
			'mm_id' => 'academic-operations',
			'id' => 'all_academic_session',
			'title' => 'Academic Sessions',
			'icon' => '',
			'page' => 'all-academic-session',
			'access' => 'all_academic_session'
		));

		register_admin_submenu(array(
			'mm_id' => 'academic-operations',
			'id' => 'class_timetable',
			'title' => 'Timetable',
			'icon' => '',
			'page' => 'class-timetable',
			'access' => 'timetable_menu'
		));

		register_admin_submenu(array(
			'mm_id' => 'academic-operations',
			'id' => 'my_timetable',
			'title' => 'My Timetable',
			'icon' => '',
			'page' => 'my-timetable',
			'access' => 'my_timetable'
		));

		register_admin_submenu(array(
			'mm_id' => 'academic-operations',
			'id' => 'manage_my_classes',
			'title' => 'Manage My Classes',
			'icon' => '',
			'page' => 'manage-my-classes',
			'access' => 'manage_my_classes'
		));






		register_admin_menu(array(
			'id' => 'performance',
			'title' => 'Exams & Records',
			'icon' => 'fas fa-file-signature',
			'page' => '',
			'access' => 'performance_menu',
			'condition' => get_option("current_academic_term"),
			'order' => 3
		));

		register_admin_submenu(array(
			'mm_id' => 'performance',
			'id' => 'gradebook',
			'title' => 'Gradebook',
			'icon' => '',
			'page' => 'gradebook',
			'access' => 'gradebook'
		));

		register_admin_submenu(array(
			'mm_id' => 'performance',
			'id' => 'broadsheet',
			'title' => 'Broadsheet',
			'icon' => '',
			'page' => 'broadsheet',
			'access' => 'broadsheet'
		));

		register_admin_submenu(array(
			'mm_id' => 'performance',
			'id' => 'master_sheet',
			'title' => 'Annual Broadsheet',
			'icon' => '',
			'page' => 'master-sheet',
			'access' => 'master_sheet'
		));

		register_admin_submenu(array(
			'mm_id' => 'performance',
			'id' => 'print_results',
			'title' => 'Print Results',
			'icon' => '',
			'page' => 'print-results',
			'access' => 'print_results'
		));

		register_admin_submenu(array(
			'mm_id' => 'performance',
			'id' => 'edit-psychometrics',
			'title' => 'Edit Psychometrics',
			'icon' => '',
			'page' => 'edit-psychometrics',
			'access' => 'edit_psychometrics'
		));

		// register_admin_submenu(array(
		// 	'mm_id' => 'performance',
		// 	'id' => 'ft_comment',
		// 	'title' => 'Form Teacher Comment',
		// 	'icon' => '',
		// 	'page' => 'ft-comment',
		// 	'access' => 'ft_comment'
		// ));

		// register_admin_submenu(array(
		// 	'mm_id' => 'performance',
		// 	'id' => 'my_results',
		// 	'title' => 'My Results',
		// 	'icon' => '',
		// 	'page' => 'my-results',
		// 	'access' => 'my_results'
		// ));

		// register_admin_submenu(array(
		// 	'mm_id' => 'performance',
		// 	'id' => 'master_results',
		// 	'title' => 'Cumulative Results',
		// 	'icon' => '',
		// 	'page' => 'master-results',
		// 	'access' => 'master_results'
		// ));

		// register_admin_submenu(array(
		// 	'mm_id' => 'performance',
		// 	'id' => 'compiled_results',
		// 	'title' => 'Print Results',
		// 	'icon' => '',
		// 	'page' => 'compiled-results',
		// 	'access' => 'compiled_results'
		// ));

		register_admin_submenu(array(
			'mm_id' => 'performance',
			'id' => 'attendance_report',
			'title' => 'Attendance Report',
			'icon' => '',
			'page' => 'attendance-report',
			'access' => 'attendance_report_submenu'
		));





		register_admin_menu(array(
			'id' => 'school-mgt',
			'title' => 'School MGT',
			'icon' => 'far fa-building',
			'page' => '',
			'access' => 'structure_menu',
			'order' => 2
		));

		register_admin_submenu(array(
			'mm_id' => 'school-mgt',
			'id' => 'reassign_students',
			'title' => 'Reassign Students',
			'icon' => '',
			'page' => 'reassign-students',
			'access' => 'reassign_students'
		));

		register_admin_submenu(array(
			'mm_id' => 'school-mgt',
			'id' => 'manage_students_in_class',
			'title' => 'Students in Class',
			'icon' => '',
			'page' => 'manage-students-in-class',
			'access' => 'manage_students_in_class'
		));

		register_admin_submenu(array(
			'mm_id' => 'school-mgt',
			'id' => 'schedule_school_event',
			'title' => 'Schedule School Event',
			'icon' => '',
			'page' => 'schedule-school-event',
			'access' => 'schedule_school_event'
		));



		register_admin_menu(array(
			'id' => 'analytics',
			'title' => 'Analytics',
			'icon' => 'fas fa-chart-pie',
			'page' => '',
			'access' => 'analytics',
			'order' => 2
		));

		register_admin_submenu(array(
			'mm_id' => 'analytics',
			'id' => 'school_population',
			'title' => 'School Population',
			'icon' => '',
			'page' => 'school-population',
			'access' => 'school_population'
		));



		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'school_settings',
			'title' => 'School Settings',
			'icon' => '',
			'page' => 'school-settings',
			'access' => 'school_settings'
		));

		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'promotion_order',
			'title' => 'Promotion Order',
			'icon' => '',
			'page' => 'promotion-order',
			'access' => 'promotion_order'
		));

		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'add_class',
			'title' => 'Add Class',
			'icon' => '',
			'page' => 'add-class',
			'access' => 'add_class'
		));

		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'add_courses',
			'title' => 'Add Courses',
			'icon' => '',
			'page' => 'add-courses',
			'access' => 'add_courses'
		));

		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'add_subject_branch',
			'title' => 'Add Subject/Course Branch',
			'icon' => '',
			'page' => 'add-subject-branch',
			'access' => 'add_subject_branch'
		));

		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'add_student',
			'title' => 'Add Student',
			'icon' => '',
			'page' => 'add-student',
			'access' => 'add_student'
		));

		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'assign_courses',
			'title' => 'Assign Courses',
			'icon' => '',
			'page' => 'assign-courses',
			'access' => 'assign_courses'
		));

		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'assign_teachers',
			'title' => 'Assign Teachers',
			'icon' => '',
			'page' => 'assign-teachers',
			'access' => 'assign_teachers'
		));

		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'assign_form_teachers',
			'title' => 'Assign Form Teachers',
			'icon' => '',
			'page' => 'assign-form-teachers',
			'access' => 'assign_form_teachers'
		));

		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'upload_signature',
			'title' => 'Upload Signature',
			'icon' => '',
			'page' => 'upload-signature',
			'access' => 'upload_signature'
		));

		register_admin_submenu(array(
			'mm_id' => 'settings',
			'id' => 'student_profile',
			'title' => 'Student Profile',
			'icon' => '',
			'page' => 'student-profile',
			'access' => 'my_profile'
		));



		register_admin_menu(array(
			'id' => 'generated_pins',
			'title' => 'Generated Pins',
			'icon' => 'far fa-code-fork',
			'page' => 'generated-pins',
			'access' => 'generated_pins',
			'condition' => get_option('use_pins_to_access_results')
		));

		
		add_action('course_result_sheet', 'display_course_result_sheet');
		add_action('get_result_card', 'show_result_card');
		add_action('get_master_result_card', 'show_master_result_card');
		add_action('get_curriculum', 'display_curriculum');
		add_action('student_profile', 'display_student_profile');
		add_action('get_psychometrics', 'display_psychometrics');
		add_action('get_calendar', 'display_calendar');
		add_action("get_class_attendance_summary", "display_class_attendance_summary");
		add_action('class_timetable', 'display_class_timetable');
		add_action('dashboard_additional_panels', 'display_my_courses');
		add_action('class_category_filter', 'class_category_filter');
		add_action('school_population', 'school_population');
		add_action('display_student_list_filter', 'display_student_list_filter');
		add_action('display_student_list_filter2', 'display_student_list_filter2');
		add_action('display_student_list_filter3', 'display_student_list_filter3');
		add_action('display_broadsheet_filter', 'display_broadsheet_filter');
		add_action('display_staff_filter', 'display_staff_filter');
		add_action('_after_student_profile_more_info', 'student_result_to_profile');
		add_action('_after_student_profile_more_info_link', 'student_result_to_profile_link');
		add_action('compile_result_button', 'compile_result_button');
		add_action('performance_filter', 'performance_filter');
		add_action('performance_filter_broadsheet', 'performance_filter_broadsheet');
		add_action('performance_filter2', 'performance_filter2');
		add_action('performance_filter3', 'performance_filter3');
		add_action('all_cumulative_results', 'all_cumulative_results');
		add_action('cumulative_results_filter', 'cumulative_results_filter');
		add_action('load_other_dependencies', 'eedu_portal_dependencies');
		add_action('dashboard_row', 'eedu_portal_dashboard_row');	
		add_action("users_columns_after", "eedu_portal_users_columns_after");
		add_action('class_list_filter', 'class_list_filter');
		add_action("eedu_portal_display_ft_comment", "eedu_portal_display_ft_comment");
		add_action("before_display_user_profile", "eedu_portal_before_display_user_profile");
		add_action("users_filter_after", "eedu_portal_users_filter_after");
		add_action("eedu_portal_class_filter", "eedu_portal_class_filter");
		add_action("eedu_portal_class_course_filter", "eedu_portal_class_course_filter");
		add_action("eedu_portal_term_filter", "eedu_portal_term_filter");
		add_action("search_query_filter_broadsheet", "eedu_portal_class_filter", 1);
		add_action("search_query_filter_broadsheet", "eedu_portal_term_filter", 2);
		add_action("search_query_filter_broadsheet", "eedu_portal_broadsheet_filter", 3);
		add_action("search_query_filter_gradebook", "eedu_portal_class_course_filter", 1);
		add_action("search_query_filter_gradebook", "eedu_portal_term_filter", 2);
		add_action("search_query_filter_annual_broadsheet", "eedu_portal_annual_broadsheet_filter", 3);
		add_action("search_query_qf_filter_eedu_portal_print_results", "eedu_portal_class_filter", 1);
		add_action("search_query_qf_filter_eedu_portal_print_results", "eedu_portal_term_filter", 2);
		add_action("search_query_qf_filter_eedu_portal_print_results", "eedu_portal_print_results_filter", 3);
		add_action("search_query_filter_promotion_order", "eedu_portal_class_only_filter");
		add_action("search_query_filter_stud_in_class", "eedu_portal_class_filter", 1);
		add_action("search_query_filter_stud_in_class", "eedu_portal_term_filter", 2);
		add_action("before_add_user", "eedu_before_add_user");
		add_action("users_filter_after_after", "eedu_users_filter_after_after");
		add_action("profile_right_column", "eedu_portal_profile_right_column");
		add_action("promote_students_term", "promote_students_button");

		add_filter("email_exists", "eedu_portal_email_validation_filter");
		add_filter('qf_get_users_filter_response', 'qf_get_users_filter_response_eedu_portal', 3);
		add_filter('users_filter_system_roles_filter', 'eedu_portal_users_filter_system_roles_filter');
		add_filter("before_users_table_display", "eedu_portal_before_users_table_display");
		add_filter("filter_user_args", "eedu_portal_filter_user_args");
		add_filter("users_columns_filter", "eedu_portal_users_columns_filter");

		self::setup_default_list();
	}

	public static function uninstall() {

	}

	public static function setup_default_list() {
		$msg = MessagingOps::getInstance();
		// Add Roles
		$category_mapping = get_option("category_mapping");
		if($category_mapping && _count($category_mapping)) {
			foreach ($category_mapping as $class_id => $cats) {
				$msg->add_to_list("All ".get_class_name($class_id)." Students", "get_class_students", ["class_id" => $class_id]);
				if(_count($cats)) {
					foreach ($cats as $category_id) {
						$msg->add_to_list("All ".get_class_name($class_id, $category_id)." Students", "get_class_students", ["class_id" => $class_id, "category_id" => $category_id]);
					}
				}
			}
		}
	}

}