Source of file ScoutRole.php
Size: 2,324 Bytes - Last Modified: 2021-12-23T10:09:55+00:00
/var/www/docs.ssmods.com/process/src/code/model/ScoutRole.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | <?php /** * ScoutRole - code/model/ScoutRole.php * * @link http://github.com/zucchi/Silverstripe-ScoutDistrict for the canonical source repository * @copyright Copyright (c) 2005-2013 Zucchi Limited. (http://zucchi.co.uk) * @license http://zucchi.co.uk/legals/bsd-license New BSD License */ /** * ScoutRole Model * * Class to provide model the different Roles in Scouting * * @author Matt Cockayne <matt@zucchi.co.uk> */ class ScoutRole extends DataObject { private static $db = array( 'Title' => 'varchar', 'Acronym' => 'varchar', ); private static $has_one = array(); private static $has_many = array( 'Members' => 'Member' ); private $roles = array( array('Title' => 'Group Scout Leader', 'Acronym' => 'GSL'), array('Title' => 'Beaver Scout Leader', 'Acronym' => 'BSL'), array('Title' => 'Assistant Beaver Scout Leader', 'Acronym' => 'ABSL'), array('Title' => 'Cub Scout Leader', 'Acronym' => 'CSL'), array('Title' => 'Assistant Cub Scout Leader', 'Acronym' => 'ACSL'), array('Title' => 'Scout Leader', 'Acronym' => 'SL'), array('Title' => 'Assistant Scout Leader', 'Acronym' => 'ASL'), array('Title' => 'Explorer Scout Leader', 'Acronym' => 'ESL'), array('Title' => 'Assistant Explorer Scout Leader', 'Acronym' => 'AESL'), array('Title' => 'Section Assistant', 'Acronym' => 'SA'), array('Title' => 'Occasional Helper', 'Acronym' => 'OH'), array('Title' => 'Group Chairman', 'Acronym' => 'Chair'), array('Title' => 'Group Treasurer', 'Acronym' => 'Treasurer'), array('Title' => 'Group Secretary', 'Acronym' => 'Secretary'), ); public function requireDefaultRecords() { parent::requireDefaultRecords(); foreach ($this->roles as $role) { $ScoutRole = DataObject::get_one('ScoutRole', "Title = '" . $role['Title'] . "'"); if (!$ScoutRole) { $ScoutRole = new ScoutRole(); $ScoutRole->Title = $role['Title']; $ScoutRole->Acronym = $role['Acronym']; $ScoutRole->write(); DB::alteration_message($ScoutRole->Title . ' (' . $ScoutRole->Acronym . ') Scout Role created', 'created'); } } } } |