function action_usage_query(&$errors) { global $data; $this->controler->disable_html_output(); header("Content-Type: text/plain"); $uname = $_GET['al_uname']; $did = $_GET['al_did']; // check whether user have access to the did of the uri if (!$this->check_did($did)) { return true; } //finish the action execution $uris_handler =& URIS::singleton_2($uname, $did); if (false === ($uris = $uris_handler->get_URIs())) { return false; } $response = new stdClass(); $response->uri_used = count($uris) > 0 ? true : false; echo my_JSON_encode($response); return true; }
function determine_action() { if ($this->opt['allow_edit']) { if ($this->was_form_submited()) { // Is there data to process? //check if alias exists $uris_handler =& URIS::singleton_2($_POST['al_username'], $_POST['al_domain']); if (false === ($uris = $uris_handler->get_URIs())) { return false; } $ack = false; if (count($uris) > 1) { $ack = true; } if (count($uris) == 1) { if (!($uris[0]->get_uid() == $this->user_id->get_uid() and $uris[0]->get_did() == $_POST['al_id_d'] and $uris[0]->get_username() == $_POST['al_id_u'] and $uris[0]->get_flags() == $_POST['al_id_f'])) { $ack = true; } } if ($_POST['al_id_u']) { $this->act_alias['username'] = $_POST['al_id_u']; $this->act_alias['did'] = $_POST['al_id_d']; $this->act_alias['flags'] = $_POST['al_id_f']; if ($ack) { $this->action = array('action' => "ack_update", 'validate_form' => true, 'reload' => false); } else { $this->action = array('action' => "update", 'validate_form' => true, 'reload' => true); } } else { if ($ack) { $this->action = array('action' => "ack_add", 'validate_form' => true, 'reload' => false); } else { $this->action = array('action' => "add", 'validate_form' => true, 'reload' => true); } } return; } if (!empty($_GET['al_ack_changes']) and isset($_SESSION['apu_aliases']['ack'])) { if ($_SESSION['apu_aliases']['ack']['action'] == 'update') { $this->act_alias['username'] = $_SESSION['apu_aliases']['ack']['vals']['old']['username']; $this->act_alias['did'] = $_SESSION['apu_aliases']['ack']['vals']['old']['did']; $this->act_alias['flags'] = $_SESSION['apu_aliases']['ack']['vals']['old']['flags']; $this->action = array('action' => "update", 'validate_form' => false, 'reload' => true); } else { $this->action = array('action' => "add", 'validate_form' => false, 'reload' => true); } return; } /* to be sure */ if (isset($_SESSION['apu_aliases']['ack'])) { unset($_SESSION['apu_aliases']['ack']); } if (isset($_GET['uri_insert'])) { $this->action = array('action' => "insert", 'validate_form' => false, 'reload' => false); return; } if (isset($_GET['uri_edit'])) { $this->act_alias['username'] = $_GET['al_un']; $this->act_alias['did'] = $_GET['al_did']; $this->act_alias['flags'] = $_GET['al_flags']; $this->action = array('action' => "edit", 'validate_form' => false, 'reload' => false); return; } if (isset($_GET['uri_dele'])) { $this->act_alias['username'] = $_GET['al_un']; $this->act_alias['did'] = $_GET['al_did']; $this->act_alias['flags'] = $_GET['al_flags']; $this->action = array('action' => "delete", 'validate_form' => false, 'reload' => true); return; } if (isset($_GET['uri_usage'])) { $this->action = array('action' => "usage_query", 'validate_form' => false, 'reload' => false, 'alone' => true); return; } if (isset($_GET['uri_suggest'])) { $this->action = array('action' => "suggest_query", 'validate_form' => false, 'reload' => false, 'alone' => true); return; } if (isset($_GET['uri_generate'])) { $this->action = array('action' => "generate_query", 'validate_form' => false, 'reload' => false, 'alone' => true); return; } } $this->action = array('action' => "default", 'validate_form' => false, 'reload' => false); }