*/ class ParTCP_Admins_Checker { static function is_authorized( $ptcpId, $messageType, $object ){ global $Admins; if ( empty( $object['dir'] ) ){ return NULL; } $specialTypes = [ // message types where only parent admins are relevant 'admin-appointment', 'admin-dismissal', 'root-appointment', 'root-dismissal' ]; if ( ! in_array( $messageType, $specialTypes ) ){ $adminList = $Admins->get_list( $object['dir'] ); if ( $adminList ){ return ptcp_is_in_list( $ptcpId, $adminList ); } } // object admins not specified or irrelevant, so check parent admins $dir = $object['dir']; while ( ! in_array( $dir, [ '/', '.' ] ) ){ $dir = dirname( $dir ); $adminList = $Admins->get_list( $dir ); if ( $adminList ){ break; } } // if no parent admins are specified, check root admins if ( empty( $adminList ) ){ $adminList = $Admins->get_list( 0 ); } return $adminList && ptcp_is_in_list( $ptcpId, $adminList ) ? TRUE : NULL; } } // end of file lib/admins_checker.class.php