Settings.php 3.62 KB
Newer Older
jaapjansma's avatar
jaapjansma committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<?php

use CRM_Sharepoint_ExtensionUtil as E;

/**
 * Form controller class
 *
 * @see https://wiki.civicrm.org/confluence/display/CRMDOC/QuickForm+Reference
 */
class CRM_Sharepoint_Form_Settings extends CRM_Admin_Form {
  public function buildQuickForm() {

    // add form elements
    $this->add(
      'text', // field type
      'url', // field name
jaapjansma's avatar
jaapjansma committed
17
      ts('Url', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
18 19 20 21 22 23 24 25 26
      array(
        'class' => 'huge40',
      ),
      TRUE // is required,
    );

    $this->add(
      'text', // field type
      'site', // field name
jaapjansma's avatar
jaapjansma committed
27
      ts('Site', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
28 29 30
      array(
        'class' => 'huge40',
      ),
JonGold's avatar
JonGold committed
31
      FALSE // is required,
jaapjansma's avatar
jaapjansma committed
32 33 34 35 36
    );

    $this->add(
      'text', // field type
      'username', // field name
jaapjansma's avatar
jaapjansma committed
37
      ts('Username', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
38 39 40 41 42 43 44 45 46
      array(
        'class' => 'huge40',
      ),
      TRUE // is required,
    );

    $this->add(
      'password', // field type
      'password', // field name
jaapjansma's avatar
jaapjansma committed
47
      ts('Password', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
48 49 50 51 52 53 54 55 56
      array(
        'class' => 'huge40',
      ),
      TRUE // is required,
    );

    $this->add(
      'text', // field type
      'library', // field name
jaapjansma's avatar
jaapjansma committed
57
      ts('Library name', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
58 59 60 61 62 63 64 65 66
      array(
        'class' => 'huge40',
      ),
      TRUE // is required,
    );

    $this->add(
      'text', // field type
      'contact_id_field_name', // field name
jaapjansma's avatar
jaapjansma committed
67
      ts('Contact ID field name', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
68 69 70 71 72 73 74 75 76
      array(
        'class' => 'huge40',
      ),
      TRUE // is required,
    );

    $this->add(
      'text', // field type
      'case_id_field_name', // field name
jaapjansma's avatar
jaapjansma committed
77
      ts('Case ID field name', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
78 79 80 81 82 83 84 85 86
      array(
        'class' => 'huge40',
      ),
      TRUE // is required,
    );

    $this->add(
      'text', // field type
      'civicrm_link_field_name', // field name
jaapjansma's avatar
jaapjansma committed
87
      ts('Link To CiviCRM field name', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
88 89 90 91 92 93 94 95 96
      array(
        'class' => 'huge40',
      ),
      TRUE // is required,
    );

    $this->add(
      'text', // field type
      'title_field', // field name
jaapjansma's avatar
jaapjansma committed
97
      ts('Title field name', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
98 99 100 101 102 103 104 105 106
      array(
        'class' => 'huge40',
      ),
      TRUE // is required,
    );

    $this->add(
      'text', // field type
      'contact_documentset_contenttype_id', // field name
jaapjansma's avatar
jaapjansma committed
107
      ts('Content Type ID for the contact documentset', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
108 109 110 111 112 113 114 115 116
      array(
        'class' => 'huge40',
      ),
      TRUE // is required,
    );

    $this->add(
      'text', // field type
      'case_documentset_contenttype_id', // field name
jaapjansma's avatar
jaapjansma committed
117
      ts('Content Type ID for the case documentset', array('domain' => 'sharepoint')), // field label
jaapjansma's avatar
jaapjansma committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
      array(
        'class' => 'huge40',
      ),
      TRUE // is required,
    );
    parent::buildQuickForm();
  }

  public function setDefaultValues() {
    $defaults = parent::setDefaultValues();
    $settings = _sharepoint_settings();
    return array_merge($defaults, $settings);
  }

  public function postProcess() {
    $values = $this->exportValues();
    $settings = _sharepoint_settings();
    foreach($settings as $setting_name => $old_value) {
      if (isset($values[$setting_name])) {
        CRM_Core_BAO_Setting::setItem($values[$setting_name], 'sharepoint', $setting_name);
      }
    }

jaapjansma's avatar
jaapjansma committed
141
    CRM_Core_Session::setStatus(ts('Saved sharepoint settings', array('domain' => 'sharepoint')), '', 'success');
jaapjansma's avatar
jaapjansma committed
142 143 144 145 146 147

    parent::postProcess();
  }


}