public function addAction()
 {
     // Handle edit vocabulary form.
     $profileType = new UserProfilesType();
     $this->_profileType = $profileType;
     $this->view->profileType = $profileType;
     if ($this->_getParam('submit')) {
         $profileType->label = $this->_getParam('name');
         $profileType->description = $this->_getParam('description');
         $profileType->public = $this->_getParam('public');
         $profileType->required = $this->_getParam('required');
         $elementSet = new ElementSet();
         $elementSet->name = $profileType->label . " Elements";
         $elementSet->description = "Elements for " . $profileType->label;
         $elementSet->record_type = 'UserProfilesType';
         $elementSet->save();
         $this->_elementSet = $elementSet;
         $profileType->element_set_id = $elementSet->id;
         $elementInfos = $this->_getElementInfos();
         $profileType->setElementInfos($elementInfos);
         $multiInfos = $this->_getMultiElementInfos();
         $profileType->setMultiElementInfos($multiInfos);
         if ($profileType->save(false)) {
             $this->_helper->flashMessenger(__('The profile type was successfully added.'), 'success');
             $this->redirect('user-profiles');
         } else {
             $elementSet->delete();
             $errors = $profileType->getErrors();
             $this->_helper->flashMessenger($errors, 'error');
         }
     }
 }
 public function _setupType()
 {
     $type = new UserProfilesType();
     $type->description = "Type Description";
     $fields = array(array('label' => 'Text Field', 'type' => 'text', 'order' => 0), array('label' => 'Int Field', 'type' => 'int', 'order' => 1));
     $type->fields = $fields;
     $type->save();
 }
 private function _importContributorFields($elementSet)
 {
     $db = get_db();
     //create the ProfileType
     $contribFieldElementMap = $this->_contributorFieldsToElements($elementSet->id);
     $profileType = new UserProfilesType();
     $profileType->label = "Contributor Info";
     $profileType->description = "Contributor Info";
     $profileType->element_set_id = $elementSet->id;
     $profileType->public = true;
     $profileType->required = false;
     $profileType->setElementInfos(array());
     $profileType->setMultiElementInfos(array());
     $profileType->save();
     set_option('contribution_user_profile_type', $profileType->id);
     return array('type_id' => $profileType->id, 'contribFieldElementMap' => $contribFieldElementMap);
 }
 protected function getUserProfilesType()
 {
     if ($this->userProfilesType) {
         return $this->userProfilesType;
     }
     $types = get_db()->getTable('UserProfilesType')->findBy(array('label' => 'Imported Contributor Information'));
     if (count($types) != 0) {
         $userProfilesType = $types[0];
     } else {
         $userProfilesType = new UserProfilesType();
         $userProfilesType->required_element_ids = serialize(array());
         $userProfilesType->required_multielement_ids = serialize(array());
         $userProfilesType->label = 'Imported Contributor Information';
         $userProfilesType->description = "Contributor information imported from {$this->endpointUri}";
         $userProfilesType->public = 0;
         $userProfilesType->required = 0;
         $userProfilesType->element_set_id = $this->elementSet->id;
         $userProfilesType->save();
     }
     $this->userProfilesType = $userProfilesType;
     return $this->userProfilesType;
 }