ajax_taglookup($_REQUEST['taglookup']);
}elseif($_REQUEST['addnote']){
ajax_addnote($_REQUEST['addnote'],$_REQUEST['note']);
+}elseif($_REQUEST['settags']){
+ ajax_settags($_REQUEST['settags'],$_REQUEST['tags']);
}
/**
print smarty_modifier_noteparser($note);
}
+/**
+ * Sett tags for a contact
+ */
+function ajax_settags($dn,$tags){
+ global $conf;
+ global $LDAP_CON;
+ if(!$conf[extended]) return;
+
+ $tags = explode(',',$tags);
+ $tags = array_map('trim',$tags);
+ $tags = array_unique($tags);
+
+ $entry['marker'] = $tags;
+ ldap_modify($LDAP_CON,$dn,$entry);
+
+ foreach ($tags as $tag){
+ print '<a href="index.php?marker=';
+ print rawurlencode($tag);
+ print '" class="tag">';
+ print htmlspecialchars($tag);
+ print '</a> ';
+ }
+}
+
/**
* Find all tags (markers) starting with the given
* string
+function tedit_showEditor(dn){
+ // if the editor already exists cancel it
+ if($('tedit_editor') !== null){
+ tedit_cleanUp();
+ return;
+ }
-/**
- * Note Editor Class
- */
+ var tags = $('tedit_out').innerHTML;
+ tags = tags.replace(/>[ \n\r]+<a/g,'>, <a');
+ tags = tags.stripTags();
+ tags = tags.replace(/[ \n\r]{2,}/g,' ');
+ tags = tags.replace(/^ /,'');
+ tags = tags.replace(/ $/,'');
+
+ var editor = '<div id="tedit_editor"><form accept-charset="utf-8">';
+ editor += '<textarea id="tedit_edit">'+tags+'</textarea>';
+ editor += '<div id="tedit_completion" class="autocomplete"></div>';
+ editor += '<img src="pix/accept.png" width="16" height="16" id="tedit_save" class="click" alt="save" /><br />';
+ editor += '<img src="pix/cancel.png" width="16" height="16" id="tedit_cancel" class="click" alt="cancel" />';
+ editor += '</form></div>';
+
+ Element.hide('tedit_out');
+ new Insertion.Top($('tedit_insert'), editor);
+
+ new Ajax.Autocompleter('tedit_edit','tedit_completion', 'ajax.php', {paramName: 'taglookup', tokens: ','});
+
+ Event.observe('tedit_save', 'click', function(){ tedit_saveChanges(dn) }, false);
+ Event.observe('tedit_cancel', 'click', tedit_cleanUp, false);
+ $('tedit_edit').focus();
+}
+
+function tedit_cleanUp(){
+ Element.remove('tedit_editor');
+ Element.show('tedit_out');
+}
+
+function tedit_saveChanges(dn){
+ var content = encodeURI($F('tedit_edit'));
+ dn = encodeURI(dn);
-/*
-NoteEditor.prototype = {
+ $('tedit_editor').innerHTML = "Saving...";
- initialize: function(ident,type,controlId){
- this.type = type;
- this.ident = ident;
- this.ctl = $(controlId);
- // add click handler to control
- Event.observe(controlId, 'click', this.edit, false);
- },
-*/
+ var success = function(resp){tedit_complete(resp)};
+ var failure = function(resp){tedit_failed(resp)};
+ var pars = 'settags='+dn+'&tags='+content;
+ var ajax = new Ajax.Request('ajax.php', {method:'post',postBody:pars,onSuccess:success,onFailure:failure});
+}
+
+function tedit_complete(resp){
+ $('tedit_out').innerHTML = resp.responseText;
+ tedit_cleanUp();
+}
+
+function tedit_failed(resp){
+ tedit_cleanUp();
+ alert("Saving failed.");
+}
+
+
+
+// --------------------------------------------------------------------
/**
* Create the editor component
*/
-
function nedit_showEditor(type,dn,name){
// if the editor already exists cancel it
if($('nedit_editor') !== null){
var dt = new Date();
editor += '//'+dt.formatDate('j. M y H:i')+' '+name+'//: ';
- editor += '</textarea><br />';
+ editor += '</textarea>';
- editor += '<input id="nedit_save" type="button" value="SAVE" />';
- editor += '<input id="nedit_cancel" type="button" value="CANCEL" />';
+ editor += '<img src="pix/accept.png" width="16" height="16" id="nedit_save" class="click" alt="save" /><br />';
+ editor += '<img src="pix/cancel.png" width="16" height="16" id="nedit_cancel" class="click" alt="cancel" />';
editor += '</form></div>';
new Insertion.Top($('nedit_insert'), editor);
Event.observe('nedit_save', 'click', function(){ nedit_saveChanges(dn) }, false);
Event.observe('nedit_cancel', 'click', nedit_cleanUp, false);
-
-// $('nedit_edit').scrollIntoView();
$('nedit_edit').focus();
};
<b>{$lang.note}</b>
{if $user}
- <img src="pix/phone.png" width="16" height="16" onclick="nedit_showEditor('call','{$entry.dn}','{$user|escape:javascript}');" />
- <img src="pix/email.png" width="16" height="16" onclick="nedit_showEditor('mail','{$entry.dn}','{$user|escape:javascript}');" />
- <img src="pix/arrow_right.png" width="16" height="16" onclick="nedit_showEditor('todo','{$entry.dn}','{$user|escape:javascript}');" />
- <img src="pix/note.png" width="16" height="16" onclick="nedit_showEditor('note','{$entry.dn}','{$user|escape:javascript}');" />
+ <img src="pix/phone.png" width="16" height="16" onclick="nedit_showEditor('call','{$entry.dn}','{$user|escape:javascript}');" class="click" />
+ <img src="pix/email.png" width="16" height="16" onclick="nedit_showEditor('mail','{$entry.dn}','{$user|escape:javascript}');" class="click" />
+ <img src="pix/arrow_right.png" width="16" height="16" onclick="nedit_showEditor('todo','{$entry.dn}','{$user|escape:javascript}');" class="click" />
+ <img src="pix/note.png" width="16" height="16" onclick="nedit_showEditor('note','{$entry.dn}','{$user|escape:javascript}');" class="click" />
{/if}
-<dl><dd id="nedit_insert">
+<dl class="notes"><dd id="nedit_insert">
{$entry.note|noteparser}
</dd></dl>