diff --git a/action/ajax.php b/action/ajax.php --- a/action/ajax.php +++ b/action/ajax.php @@ -1,236 +1,241 @@ hlp =& plugin_load('helper','davcard'); } function register(Doku_Event_Handler $controller) { $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call_unknown'); } function handle_ajax_call_unknown(&$event, $param) { if($event->data != 'plugin_davcard') return; $event->preventDefault(); $event->stopPropagation(); global $INPUT; $action = trim($INPUT->post->str('action')); $id = trim($INPUT->post->str('id')); $page = trim($INPUT->post->str('page')); $params = $INPUT->post->arr('params'); if(isset($_SERVER['REMOTE_USER']) && !is_null($_SERVER['REMOTE_USER'])) $user = $_SERVER['REMOTE_USER']; else $user = null; if(!checkSecurityToken()) { echo "CSRF Attack."; return; } $data = array(); $data['result'] = false; $data['html'] = $this->getLang('unknown_error'); // Parse the requested action switch($action) { // Add a new Contact case 'newContact': if($this->hlp->addContactEntryToAddressbookForPage($id, $user, $params) === true) { $data['result'] = true; } else { $data['result'] = false; $data['html'] = $this->getLang('error_adding'); } break; // Retrieve contact details case 'getContactDetails': $contactdata = $this->hlp->getContactByUri($id, $params['uri']); if($contactdata['result'] === true) { + // When we support pictures for editing contacts, + // we need to use the following line: + // $contactdata['photo'] = base64_encode($contactdata['photo']); + // For now, we just save bandwidth :) + unset($contactdata['photo']); $data['result'] = true; $data['contactdata'] = $contactdata; } else { $data['result'] = false; $data['html'] = $this->getLang('contact_not_found'); } break; // Edit a contact case 'editContact': if($this->hlp->editContactEntryToAddressbookForPage($id, $user, $params['uri'], $params) === true) { $data['result'] = true; } else { $data['result'] = false; $data['html'] = $this->getLang('error_editing'); } break; // Delete a Contact case 'deleteContact': if($this->hlp->deleteContactEntryToAddressbookForPage($id, $user, $params['uri']) === true) { $data['result'] = true; } else { $data['result'] = false; $data['html'] = $this->getLang('error_deleting'); } break; // Get AJAX popup case 'getContactAjax': $contactdata = $this->hlp->getContactByUri($id, $params['uri']); $cardpattern = $this->getConf('popup_content'); echo '