public function insert($pa_options = null)
 {
     if (!trim($this->get('surname')) && !trim($this->get('forename'))) {
         // auto-split entity name if displayname is set
         if ($vs_display_name = trim($this->get('displayname'))) {
             $va_label = DataMigrationUtils::splitEntityName($vs_display_name);
             if (is_array($va_label)) {
                 unset($va_label['displayname']);
                 // just make sure we don't mangle the user-entered displayname
                 foreach ($va_label as $vs_fld => $vs_val) {
                     $this->set($vs_fld, $vs_val);
                 }
             } else {
                 $this->postError(1100, _t('Something went wrong when splitting displayname'), 'ca_entity_labels->insert()');
                 return false;
             }
         } else {
             $this->postError(1100, _t('Surname, forename or displayname must be set'), 'ca_entity_labels->insert()');
             return false;
         }
     }
     if (!$this->get('displayname')) {
         $this->set('displayname', trim(preg_replace('![ ]+!', ' ', $this->get('forename') . ' ' . $this->get('middlename') . ' ' . $this->get('surname'))));
     }
     return parent::insert($pa_options);
 }
Example #2
0
 public function insert($pa_options = null)
 {
     if (!trim($this->get('surname')) && !trim($this->get('forename'))) {
         $this->postError(1100, _t('Surname or forename must be set'), 'ca_entity_labels->insert()');
         return false;
     }
     if (!$this->get('displayname')) {
         $this->set('displayname', trim(preg_replace('![ ]+!', ' ', $this->get('forename') . ' ' . $this->get('middlename') . ' ' . $this->get('surname'))));
     }
     return parent::insert($pa_options);
 }
Example #3
0
 public function insert($pa_options = null)
 {
     if (!$this->get('displayname')) {
         $this->set('displayname', trim(preg_replace('![ ]+!', ' ', $this->get('forename') . ' ' . $this->get('middlename') . ' ' . $this->get('surname'))));
     }
     return parent::insert($pa_options);
 }