12. At any hearing of an application under section 26(1), 26(4), 27(2) or 28(1), or on the application of any person affected by an order for continued or further detention, the court may, if it thinks fit, order that such a person be joined as a party to the proceedings and, if the court so orders, otherwise than at such a hearing, the clerk of petty sessions shall give notice to the other parties of the joinder.