Exemplo n.º 1
0
 function save()
 {
     $res = parent::save();
     if ($this->_readings != $this->_old_readings) {
         $this->__deleteBibleReadings();
         $this->__insertBibleReadings();
     }
     return $res;
 }
Exemplo n.º 2
0
 function save()
 {
     $res = parent::save();
     $this->_saveMemberRoles();
     return $res;
 }
Exemplo n.º 3
0
 /**
  * Save changes to an existing custom field to the DB
  * @return boolean
  */
 public function save()
 {
     $GLOBALS['system']->doTransaction('BEGIN');
     parent::save();
     $this->_saveOptions();
     $GLOBALS['system']->doTransaction('COMMIT');
 }
Exemplo n.º 4
0
 public function save()
 {
     $res = parent::save();
     if ($res) {
         $this->_saveCongregations(TRUE);
         $this->_saveTags(TRUE);
     }
     return $res;
 }
Exemplo n.º 5
0
 function save($update_members = TRUE)
 {
     $msg = '';
     if ($update_members) {
         if (!empty($this->_old_values['status'])) {
             if ($this->getValue('status') == 'archived') {
                 // Status has just been changed to 'archived' so archive members too
                 $members = $this->getMemberData();
                 if (!empty($members)) {
                     $GLOBALS['system']->includeDBClass('person');
                     $member = new Person();
                     $all_members_archived = TRUE;
                     foreach ($members as $id => $details) {
                         $member->populate($id, $details);
                         if ($member->canAcquireLock()) {
                             $member->acquireLock();
                             $member->setValue('status', 'archived');
                             $member->save(FALSE);
                             $member->releaseLock();
                         } else {
                             $all_members_archived = FALSE;
                         }
                     }
                     if ($all_members_archived) {
                         $msg = 'The ' . count($members) . ' members of the family have also been archived';
                     } else {
                         $msg = 'Not all members of the family could be accordingly archived because another user holds the lock';
                     }
                 }
             } else {
                 if ($this->_old_values['status'] == 'archived') {
                     // Status has just been changed from archived to something else
                     $msg = 'NB Members of the family will need to be de-archived separately';
                 }
             }
         }
         if (!empty($this->_old_values['family_name'])) {
             // Family name has changed
             // We update all the members' last names to match if
             // (a) there is only one member, or
             // (b) all members' current last name = the old family name
             $members = $this->getMemberData();
             if (count($members) == 1) {
                 $member = $GLOBALS['system']->getDBObject('person', key($members));
                 if ($member->canAcquireLock()) {
                     $member->acquireLock();
                     $member->setValue('last_name', $this->getValue('family_name'));
                     $member->save(FALSE);
                     $member->releaseLock();
                     $msg = 'The last name of the family\'s one member has also been set to "' . $this->getValue('family_name') . '"';
                 } else {
                     $msg = 'The family\'s one member could not be updated accordingly because another user holds the lock';
                 }
             } else {
                 if (!empty($members)) {
                     $members_all_have_family_name = TRUE;
                     foreach ($members as $id => $member) {
                         if ($member['last_name'] != $this->_old_values['family_name']) {
                             $members_all_have_family_name = FALSE;
                             break;
                         }
                     }
                     if ($members_all_have_family_name) {
                         $all_members_updated = TRUE;
                         $GLOBALS['system']->includeDBClass('person');
                         $member = new Person();
                         foreach ($members as $id => $details) {
                             $member->populate($id, $details);
                             if ($member->canAcquireLock()) {
                                 $member->acquireLock();
                                 $member->setValue('last_name', $this->getValue('family_name'));
                                 $member->save(FALSE);
                                 $member->releaseLock();
                             } else {
                                 $all_members_updated = FALSE;
                             }
                         }
                         if ($all_members_updated) {
                             $msg = 'Each family member\'s last name has also been set to "' . $this->getValue('family_name') . '"';
                         } else {
                             $msg = 'Not all family members could be updated with the new last name because another user holds the lock';
                         }
                     } else {
                         $msg = 'Family members have not been updated because they already have different last names';
                     }
                 }
             }
         }
     }
     $res = parent::save();
     if ($msg) {
         add_message($msg);
     }
     return $res;
 }
Exemplo n.º 6
0
 /**
  * Save changes to an existing note template to the DB
  * @return boolean
  */
 public function save()
 {
     $GLOBALS['system']->doTransaction('BEGIN');
     if (parent::save()) {
         $this->_saveFields();
         $GLOBALS['system']->doTransaction('COMMIT');
         return TRUE;
     }
     return FALSE;
 }