예제 #1
0
파일: viewer.php 프로젝트: nemein/openpsa
 /**
  * Helper function to create account based on data from DM2
  *
  * @param midcom_db_person $person The person we're working on
  * @param midcom_helper_datamanager2_formmanager $formmanager The formmanager instance to use
  */
 public function create_account(midcom_db_person $person, midcom_helper_datamanager2_formmanager $formmanager)
 {
     if (empty($formmanager->_types['username'])) {
         return;
     }
     $account_helper = new org_openpsa_user_accounthelper();
     $formdata = $formmanager->get_submit_values();
     $password = "";
     //take user password?
     if ((int) $formdata['org_openpsa_user_person_account_password_switch'] > 0) {
         $password = $formmanager->_types['password']->value;
     }
     $account_helper->create_account($person->guid, $formmanager->_types["username"]->value, $person->email, $password, $formmanager->_types["send_welcome_mail"]->value);
 }
예제 #2
0
 /**
  * This function invokes the display_form() hook on the form manager class.
  */
 function display_form()
 {
     // Prevent temporary objects from failing
     if ($this->lock_object && isset($this->datamanager->storage) && isset($this->datamanager->storage->object) && isset($this->datamanager->storage->object->guid)) {
         // Get the metadata object
         $metadata = $this->datamanager->storage->object->metadata;
         if ($metadata->is_locked()) {
             // Drop us to uncached state when locked
             midcom::get('cache')->content->uncached();
             $this->show_unlock();
             return;
         }
     }
     $this->formmanager->display_form();
 }
예제 #3
0
파일: ajax.php 프로젝트: nemein/openpsa
 /**
  * ...
  *
  * @return string One of 'editing', 'save', 'next', 'previous' and 'cancel'
  */
 function process_form($ajax_mode = true)
 {
     $this->_exitcode = parent::process_form(true);
     // Process next/previous
     return $this->_exitcode;
 }
예제 #4
0
 /**
  * This function displays a quick view of the record, using some simple div based layout,
  * which can be formatted using CSS.
  *
  * Be aware that this is only geared for simple administration interfaces, it will provide
  * *no* editing capabilities (like AJAX) etc. If you want that to work, you need a formmanger
  * instance instead.
  *
  * @param boolean $skip_empty Should empty fields be rendered or not
  */
 function display_view($skip_empty = false)
 {
     if (is_null($this->formmanager)) {
         $this->formmanager = new midcom_helper_datamanager2_formmanager($this->schema, $this->types);
         $this->formmanager->initialize();
     }
     // iterate over all types so that they can add their piece to the form
     echo "<div class=\"midcom_helper_datamanager2_view\">\n";
     $fieldset_count = 0;
     foreach ($this->schema->field_order as $name) {
         if ($this->_schema_field_is_broken($name)) {
             continue;
         }
         $config =& $this->schema->fields[$name];
         if (!empty($config['hidden'])) {
             continue;
         }
         $field_value = $this->formmanager->widgets[$name]->render_content();
         if (trim($field_value) == '' && $skip_empty) {
             continue;
         }
         if (isset($config['start_fieldset'])) {
             if (isset($config['start_fieldset']['title'])) {
                 $fieldsets = array();
                 $fieldsets[] = $config['start_fieldset'];
             } else {
                 $fieldsets = $config['start_fieldset'];
             }
             foreach ($fieldsets as $key => $fieldset) {
                 if (isset($fieldset['css_group'])) {
                     $class = $fieldset['css_group'];
                 } else {
                     $class = $name;
                 }
             }
             echo "<div class=\"fieldset {$class}\">\n";
             if (isset($fieldset['title'])) {
                 if (isset($fieldset['css_title'])) {
                     $class = " class=\"{$fieldset['css_title']}\"";
                 } else {
                     $class = " class=\"{$name}\"";
                 }
                 echo "    <h2{$class}>\n";
                 echo "        " . $this->schema->translate_schema_string($fieldset['title']) . "\n";
                 echo "    </h2>\n";
             }
             if (isset($fieldset['description'])) {
                 echo "<p>" . $this->schema->translate_schema_string($fieldset['description']) . "</p>\n";
             }
             $fieldset_count++;
         }
         echo "<div class=\"field\">\n";
         echo '<div class="title">' . $this->schema->translate_schema_string($this->schema->fields[$name]['title']) . "</div>\n";
         echo '<div class="value">';
         echo $field_value;
         echo "</div>\n";
         echo "</div>\n";
         if (!isset($config['end_fieldset']) || $fieldset_count <= 0) {
             // No more fieldsets to close
             continue;
         }
         if (is_numeric($config['end_fieldset'])) {
             for ($i = 0; $i < $config['end_fieldset']; $i++) {
                 echo "</div>\n";
                 $fieldset_count--;
                 if ($fieldset_count <= 0) {
                     break;
                 }
             }
         } else {
             echo "</div>\n";
             $fieldset_count--;
         }
     }
     echo "</div>\n";
 }