Auto update call recording settings to all extensions in asterisk-freepbx

I have 150 extensions in my asterisk-freepbx setup, which are broadly divided into following two classes :-

  1. Record Incoming Call On Demand. Record Outgoing Call On Demand
    Extensions in this class:  8001, 8002, 8003, 8004, 8005 (total 5 in number)
  2. Record All Incoming Call. Record All Outgoing Call
    Extensions in this class:  9001, 9002, … , 9145 (total 145 in number)

To avoid manual configuration of each extension, I had taken following steps:-

  1. Execute following queries on asterisk database (mysql):
    UPDATE asterisk.users SET recording='out=Adhoc|in=Adhoc' WHERE extension IN (8001, 8002, 8003, 8004, 8005)
    UPDATE asterisk.users SET recording='out=Always|in=Always' WHERE extension >= 9001 AND extension <= 9145

    The above queries updates the recording setting for extensions in database. The effect for extension 8001 may be seen at http://Your-Asterisk-Freepbx-Server-Domain-Name/admin/config.php?type=setup&display=extensions&extdisplay=8001

  2. Open each extension page and press the submit button. Finally click “Apply Configuration Changes” so that the changes may be propagated in running asterisk server