Ejemplo n.º 1
0
 public function doApprove()
 {
     $exist = Member::get()->filter(array('Email' => $this->Email))->first();
     if ($exist) {
         return false;
     }
     $member = new Member();
     $data = $this->toMap();
     unset($data['ID']);
     unset($data['ClassName']);
     unset($data['UnapprovedMember']);
     $member->update($data);
     $member->write();
     if ($this->MemberType === 'Organization') {
         $member->addToGroupByCode('organization');
         $organization = new Organization();
         $organization->AccountID = $member->ID;
         $organization->company_name = $this->OrganizationName;
         $organizationID = $organization->write();
         $member->OrganizationID = $organizationID;
         $member->write();
     } else {
         $member->addToGroupByCode('personal');
     }
     $this->setField('Approved', true);
     $this->write();
     return true;
 }
Ejemplo n.º 2
0
 public function findOrCreateOrganization()
 {
     $organization = $this->owner->Organization();
     if ($organization->ID) {
         return $organization;
     }
     $organization = new Organization();
     $organization->write();
     $organization->Members()->add($this->owner);
     return $organization;
 }