Example #1
0
 /**
  * Adds a Person to this Group as a Group Participation record.  Throws an exception
  * if the GroupRole doesn't exist in the Ministry that the group belongs to.
  * 
  * If StartDate is NULL, it will use Now()
  * 
  * @param Person $objPerson
  * @param integer $intGroupRoleId
  * @param QDateTime $dttDateStart
  * @param QDateTime $dttDateEnd
  * @return GroupParticipation
  */
 public function AddPerson(Person $objPerson, $intGroupRoleId, QDateTime $dttDateStart = null, QDateTime $dttDateEnd = null)
 {
     $objGroupParticipation = new GroupParticipation();
     $objGroupParticipation->Person = $objPerson;
     $objGroupParticipation->Group = $this;
     $objGroupParticipation->GroupRoleId = $intGroupRoleId;
     $objGroupParticipation->DateStart = $dttDateStart ? $dttDateStart : QDateTime::Now();
     $objGroupParticipation->DateEnd = $dttDateEnd;
     $objGroupParticipation->Save();
 }
Example #2
0
 public function SetUp()
 {
     $this->objMinistry = Ministry::LoadByToken('ert');
     if (!$this->objMinistry) {
         $this->objMinistry = new Ministry();
         $this->objMinistry->Token = 'ert';
     }
     $this->objMinistry->Name = 'Test Ministry';
     $this->objMinistry->ActiveFlag = true;
     $this->objMinistry->Save();
     if ($objGroupRoleArray = $this->objMinistry->GetGroupRoleArray()) {
         $this->objGroupRole = $objGroupRoleArray[0];
     } else {
         $this->objGroupRole = new GroupRole();
         $this->objGroupRole->Ministry = $this->objMinistry;
         $this->objGroupRole->Name = 'ERT';
         $this->objGroupRole->GroupRoleTypeId = GroupRoleType::Participant;
         $this->objGroupRole->Save();
     }
     $this->objLoginLeader = Login::LoadByUsername('ert1');
     if (!$this->objLoginLeader) {
         $this->objLoginLeader = new Login();
         $this->objLoginLeader->Username = '******';
     } else {
         $this->objLoginLeader->UnassociateAllMinistries();
     }
     $this->objLoginLeader->RoleTypeId = RoleType::StaffMember;
     $this->objLoginLeader->Email = '*****@*****.**';
     $this->objLoginLeader->Save();
     $this->objLoginLeader->AssociateMinistry($this->objMinistry);
     $this->objLoginNonLeader = Login::LoadByUsername('ert2');
     if (!$this->objLoginNonLeader) {
         $this->objLoginNonLeader = new Login();
         $this->objLoginNonLeader->Username = '******';
     } else {
         $this->objLoginNonLeader->UnassociateAllMinistries();
     }
     $this->objLoginNonLeader->RoleTypeId = RoleType::StaffMember;
     $this->objLoginNonLeader->Email = '*****@*****.**';
     $this->objLoginNonLeader->Save();
     $this->objPersonArray = array();
     $this->objPersonArray['ert1'] = Person::CreatePerson('Test', 'E', 'User', true, '*****@*****.**', null, null);
     $this->objPersonArray['ert2'] = Person::CreatePerson('Test', 'E', 'User', true, '*****@*****.**', null, null);
     $this->objPersonArray['ert3'] = Person::CreatePerson('Test', 'E', 'User', true, '*****@*****.**', null, null);
     $objPerson = Person::CreatePerson('Test', 'E', 'User', true, null, null, null);
     $objEmail = new Email();
     $objEmail->Address = '*****@*****.**';
     $objEmail->Person = $objPerson;
     $objEmail->Save();
     $this->objPersonArray['ert4'] = $objPerson;
     $objPerson = Person::CreatePerson('Test', 'E', 'User', true, null, null, null);
     $objEmail = new Email();
     $objEmail->Address = '*****@*****.**';
     $objEmail->Person = $objPerson;
     $objEmail->Save();
     $objEmail = new Email();
     $objEmail->Address = '*****@*****.**';
     $objEmail->Person = $objPerson;
     $objEmail->Save();
     $this->objPersonArray['ert5'] = $objPerson;
     $this->objGroup1 = Group::LoadByToken('ert1');
     if (!$this->objGroup1) {
         $this->objGroup1 = new Group();
         $this->objGroup1->Token = 'ert1';
     }
     $this->objGroup1->GroupTypeId = GroupType::RegularGroup;
     $this->objGroup1->Ministry = $this->objMinistry;
     $this->objGroup1->EmailBroadcastTypeId = EmailBroadcastType::PrivateList;
     $this->objGroup1->Name = 'ERT Test Group 1';
     $this->objGroup1->Save();
     $this->objGroup2 = Group::LoadByToken('ert2');
     if (!$this->objGroup2) {
         $this->objGroup2 = new Group();
         $this->objGroup2->Token = 'ert2';
     }
     $this->objGroup2->GroupTypeId = GroupType::RegularGroup;
     $this->objGroup2->Ministry = $this->objMinistry;
     $this->objGroup2->EmailBroadcastTypeId = EmailBroadcastType::AnnouncementOnly;
     $this->objGroup2->Name = 'ERT Test Group 2';
     $this->objGroup2->Save();
     $this->objGroup1->DeleteAllGroupParticipations();
     $this->objGroup2->DeleteAllGroupParticipations();
     $objParticipation = new GroupParticipation();
     $objParticipation->Person = $this->objPersonArray['ert1'];
     $objParticipation->Group = $this->objGroup1;
     $objParticipation->GroupRole = $this->objGroupRole;
     $objParticipation->DateStart = new QDateTime('2005-01-01');
     $objParticipation->Save();
     $objParticipation = new GroupParticipation();
     $objParticipation->Person = $this->objPersonArray['ert1'];
     $objParticipation->Group = $this->objGroup2;
     $objParticipation->GroupRole = $this->objGroupRole;
     $objParticipation->DateStart = new QDateTime('2005-01-01');
     $objParticipation->Save();
 }