/** * Called by {@link PluginManager} to append a user interface section to the edit contact form. * The result is delivered to the changedContactRecord() method in $_POST['PluginName'] * @return string XHTML content */ function editContactInterface(&$contact, $location) { //die("?????????????"); if ($location != 'ownFieldset') { return ""; } //if(!$_SESSION['user']->isAtLeast('manager')) // return ""; $content = '<fieldset class="edit-names">'; $content .= '<legend>Relationships</legend>'; // create dropdown selector box from all contacts (might be HUGE) global $CONFIG_DB_PREFIX; $db = DB::getSingleton(); // fetch dropdown $dropdown = $this->getDropdown($db); $id = $contact->contact['id']; $i = 0; // list existing relationships if not a new/added contact if (!empty($id)) { $db->query("SELECT r.* FROM `{$CONFIG_DB_PREFIX}Relationships` as r, `{$CONFIG_DB_PREFIX}contact` as c WHERE r.ownerId={$id} AND c.id=r.ownerId AND c.hidden=0", 'Relationships'); while ($r = $db->next('Relationships')) { $content .= '<div class="edit-line">'; $content .= HTMLHelper::createDropdown('Relationship[' . $i . '][relatedToId]', 'Relationship to', $dropdown, $r['relatedToId'], 'edit-input'); $content .= HTMLHelper::createTextField('Relationship[' . $i . '][relationship]', 'Relationship Type', $r['relationship'], 'edit-property-value', false); $content .= '</div>'; $i++; } } for ($k = $i; $k < $i + 2; $k++) { $content .= '<div class="edit-line">'; $content .= HTMLHelper::createDropdown('Relationship[' . $k . '][relatedToId]', 'Relationship to', $dropdown, ' ', 'edit-input'); $content .= HTMLHelper::createTextField('Relationship[' . $k . '][relationship]', 'Relationship Type', '', 'edit-property-value', false); $content .= '</div>'; } return $content . '</fieldset>'; }
/** * create the fieldset that allows user to the addresses of the contact * @global array list of country names and acronyms * @global Options used to determine the country default * @return string html-content */ function createAddressFieldset() { global $country, $options; $cont = '<fieldset class="edit-address">'; $cont .= '<legend>Addresses</legend>'; $cont .= '<div class="context-help" id="editHelp' . $this->htmlId . '"><a href="#" onclick="Element.hide(\'editHelp' . $this->htmlId . '\'); Effect.Appear(\'editHint' . $this->htmlId . '\',{duration:1.2}); return false;">?</a></div><div class="context-help" id="editHint' . $this->htmlId++ . '" style="display: none;">All fields are optional. An address will be saved if either of the following are provided: type, address lines, city, state, zip code, or a phone number. If Primary Address is selected, the address will be displayed in the contact list. To obtain more than 2 additional blank address sections, save this entry and edit it again.</div>'; $addr = $this->contact->getValueGroup('addresses'); $n = max(count($addr), 1); // initially 3 blank adresses // write out all existing addresses plus 2 blank address for ($i = 0; $i < $n + 2; $i++) { $a = array_key_exists($i, $addr) ? $addr[$i] : null; // generate additional blank entries if ($i >= $n) { // hide the blank addresses by default $cont .= '<div class="edit-single-address" id="anotherAddress' . $i . '" style="display: none;"><br>'; } else { $cont .= '<div class="edit-single-address">'; } if (!$this->add) { $cont .= '<input type="hidden" name="address[' . $i . '][refid]" value="' . $a['refid'] . '" />'; } $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][type]", 'Type', $a['type'], 'edit-input'); $cont .= HTMLHelper::createRadioButton("address_primary", 'Set as primary address', $i, isset($this->contact->contact['primaryAddress']) && $a['refid'] == $this->contact->contact['primaryAddress'], 'edit-input-radio'); if (!$i >= $n) { $cont .= '<div class="edit-input-link"><a href="javascript:deleteAddress(' . $i . ');">Delete this address</a></div>'; } $cont .= '</div>'; $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][line1]", 'Address (Line 1)', $a['line1'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][line2]", 'Address (Line 2)', $a['line2'], 'edit-input'); $cont .= '</div>'; $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][city]", 'City', $a['city'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][state]", 'State', $a['state'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][zip]", 'Zip-code', $a['zip'], 'edit-input'); $cont .= '</div>'; $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][phone1]", 'Phone 1', $a['phone1'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][phone2]", 'Phone 2', $a['phone2'], 'edit-input'); $cont .= HTMLHelper::createDropdown("address[{$i}][country]", 'Country', $country, $a === null ? $options->getOption('countryDefault') : $a['country'], 'edit-input'); $cont .= '</div>'; if ($i >= $n - 1 && $i != $n + 1) { // include the add more link in the previous div $cont .= "\n" . '<div id="addAddressLink' . ($i + 1) . '"><a href="#" onclick="Element.hide(\'addAddressLink' . ($i + 1) . '\'); Effect.SlideDown(\'anotherAddress' . ($i + 1) . '\',{duration:1.2}); return false;">add address</a></div>'; } $cont .= '</div>'; } $cont .= '</fieldset>'; return $cont; }
function editContactInterface(&$contact, $location) { if ($location != 'ownFieldset') { return ""; } //if(!$_SESSION['user']->isAtLeast('manager')) // return ""; global $CONFIG_DB_PREFIX; $db = DB::getSingleton(); // fetch dropdown $dropdown = $this->getDropdown($db, $contact->contact['id']); $db->query("SELECT partnerId,ouder1,ouder2,thuiswonend FROM " . $CONFIG_DB_PREFIX . "contact WHERE id = '" . $contact->contact['id'] . "'"); $r = $db->next(); $thuiswonend = false; if ($r['thuiswonend'] == 1) { $thuiswonend = true; } $content = '<fieldset class="edit-names">'; $content .= '<legend>Relatives</legend>'; $content .= '<div class="edit-line">'; $content .= HTMLHelper::createDropdown("partner", 'Getrouwd met', $dropdown, $r['partnerId'], 'edit-input'); $content .= HTMLHelper::createCheckbox("delpartner", 'Verwijder relatie', false, 'edit-input-checkbox'); $content .= '</div>'; $content .= '<hr />'; $content .= '<div class="edit-line">'; $content .= HTMLHelper::createDropdown("ouder1", 'Ouder 1', $dropdown, $r['ouder1'], 'edit-input'); $content .= HTMLHelper::createCheckbox("thuiswonend", 'Thuiswonend', $thuiswonend, 'edit-input-checkbox'); $content .= '</div>'; $content .= '<div class="edit-line">'; $content .= HTMLHelper::createDropdown("ouder2", 'Ouder 2', $dropdown, $r['ouder2'], 'edit-input'); $content .= HTMLHelper::createCheckbox("delouders", 'Verwijder ouderrelaties', false, 'edit-input-checkbox'); $content .= '</div>'; return $content . '</fieldset>'; }
/** * create the fieldset that allows user to the addresses of the contact * @global array list of country names and acronyms * @global Options used to determine the country default * @return string html-content * @TODO If a contact gets bounced (missing mandatory value) 2 additional unhidden blank addresses show. This is because in the previous step 3 blank addresses were created and by reediting the same contact without storing it the blank addresses are not removed. */ function createAddressFieldset() { global $country, $options; $cont = '<fieldset class="edit-address">'; $cont .= '<legend>Addresses</legend>'; $cont .= $this->contextHelp('address'); $addr = $this->contact->getValueGroup('addresses'); $n = max(count($addr), 1); // initially 3 blank adresses // write out all existing addresses plus 2 blank address for ($i = 0; $i < $n + 2; $i++) { $a = array_key_exists($i, $addr) ? $addr[$i] : null; // generate additional blank entries if (!isset($a['refid'])) { // if someone leaves the lastname blank we reedit the same contact - would cause tons of warnings $a = null; } if ($a !== null) { $this->valueGroups['phone'][$a['refid']] = $this->contact->getValueGroup('phone', $a['refid']); $this->valueGroups['email'][$a['refid']] = $this->contact->getValueGroup('email', $a['refid']); $this->valueGroups['chat'][$a['refid']] = $this->contact->getValueGroup('chat', $a['refid']); $this->valueGroups['www'][$a['refid']] = $this->contact->getValueGroup('www', $a['refid']); $this->valueGroups['other'][$a['refid']] = $this->contact->getValueGroup('other', $a['refid']); } if ($i >= $n) { // hide the blank addresses by default $cont .= '<div class="edit-single-address" id="anotherAddress' . $i . '" style="display: none;"><br>'; } else { $cont .= '<div class="edit-single-address">'; } if (!$this->add) { $cont .= '<input type="hidden" name="address[' . $i . '][refid]" value="' . $a['refid'] . '" />'; } $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][type]", 'Address type', $a['type'], 'edit-input'); $cont .= HTMLHelper::createRadioButton("address_primary", 'Set as primary address', $i, isset($this->contact->contact['primaryAddress']) && $a['refid'] == $this->contact->contact['primaryAddress'], 'edit-input-radio'); if ($i < $n) { $cont .= '<div class="edit-input-link"><a href="javascript:deleteAddress(' . $i . ');">Delete this address</a></div>'; } $cont .= '</div>'; $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][line1]", 'Address (Line 1)', $a['line1'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][line2]", 'Address (Line 2)', $a['line2'], 'edit-input'); $cont .= '</div>'; $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][city]", 'City', $a['city'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][state]", 'State', $a['state'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][zip]", 'Zip-code', $a['zip'], 'edit-input'); $cont .= '</div>'; $cont .= '<div class="edit-line">'; // $cont .= HTMLHelper::createTextField("address[$i][phone1]",'Phone 1',$a['phone1'],'edit-input'); // $cont .= HTMLHelper::createTextField("address[$i][phone2]",'Phone 2',$a['phone2'],'edit-input'); $cont .= HTMLHelper::createDropdown("address[{$i}][country]", 'Country', $country, $a === null ? $options->getOption('countryDefault') : $a['country'], 'edit-input'); $cont .= '</div>'; if ($a !== null) { $cont .= '<div><label>Communications</label>'; $opt = array('email' => 'email', 'phone' => 'phone', 'chat' => 'chat', 'other' => 'other', 'www' => 'url', ' ' => 'delete'); $cont .= $this->createNormalProperties($opt, 'email', $a['refid']); $cont .= $this->createNormalProperties($opt, 'phone', $a['refid']); $cont .= $this->createNormalProperties($opt, 'chat', $a['refid']); $cont .= $this->createNormalProperties($opt, 'www', $a['refid']); $cont .= $this->createNormalProperties($opt, 'other', $a['refid']); $cont .= '</div>'; } if ($i >= $n - 1 && $i != $n + 1) { // include the add more link in the previous div $cont .= "\n" . '<div id="addAddressLink' . ($i + 1) . '"><a href="#" onclick="Element.hide(\'addAddressLink' . ($i + 1) . '\'); Effect.SlideDown(\'anotherAddress' . ($i + 1) . '\',{duration:1.2}); return false;">add address</a></div>'; } $cont .= '</div>'; } $cont .= '</fieldset>'; return $cont; }
/** * STATIC method that creates a dropdown list from an array of options * * @param string $name which name is to be used for the dropdown * @param string $label label of the dropdown (null if none) * @param array $options normal array with displayed option text == option value (must be unique!) * @param string $selected option value of the item that should be pre-selected * @param boolean $insideDiv Is the box within its own div? default=true * @param array $extraAttributes = Javascript functions or style='...' could be placed here - placed in the <select ...> tag * @return string html-content * @static */ function createDropdownValuesAreKeys($name, $label, $options, $selected, $cssClass = null, $insideDiv = true, $extraAttributes = '') { $newOpt = array(); foreach ($options as $k => $s) { // automatically delete duplicates $newOpt[$s] = $s; } return HTMLHelper::createDropdown($name, $label, $newOpt, $selected, $cssClass, $insideDiv, $extraAttributes); }