コード例 #1
0
ファイル: member.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Save data
  *
  * @return  boolean
  */
 public function save()
 {
     if (is_array($this->get('params'))) {
         $params = new Registry($this->get('params'));
         $this->set('params', $params);
     }
     if (is_object($this->get('params'))) {
         $this->set('params', $this->get('params')->toString());
     }
     // Map set data to profile fields
     $attribs = $this->getAttributes();
     $columns = $this->getStructure()->getTableColumns($this->getTableName());
     $profile = null;
     foreach ($attribs as $key => $val) {
         if ($key == 'accessgroups') {
             continue;
         }
         if ($key == 'profile' || $key == 'profiles') {
             $profile = $val;
         }
         if (!isset($columns[$key])) {
             $this->removeAttribute($key);
         }
     }
     // Save record
     $result = parent::save();
     if ($result) {
         if ($profile) {
             $result = $this->saveProfile($profile);
         }
     }
     if (!$result) {
         // Reset the data to the way it was before save attempt
         $this->set($attribs);
     }
     return $result;
 }