Esempio n. 1
0
 function clear_canon_flag()
 {
     global $data, $config, $lang_str;
     $f =& $config->data_sql->uri->flag_values;
     $uid = $this->controler->user_id->get_uid();
     $uris_handler =& URIS::singleton($uid);
     if (false === ($uris = $uris_handler->get_URIs())) {
         return false;
     }
     foreach ($uris as $k => $v) {
         if ($v->is_canonical()) {
             /* do not affect URI which is currently changed */
             if ($this->action['action'] == 'update' and $uris[$k]->get_scheme() == 'sip' and $uris[$k]->get_did() == $this->edit['did'] and $uris[$k]->get_username() == $this->edit['un']) {
                 continue;
             }
             if (!$this->is_edit_allowed($v->get_username(), $v->get_did())) {
                 ErrorHandler::add_error($lang_str['err_canon_uri_exists']);
                 return false;
             }
             $old_v = array('uid' => $v->get_uid(), 'did' => $v->get_did(), 'username' => $v->get_username(), 'flags' => $v->get_flags());
             $new_v = array('flags' => $v->get_flags() & ~$f['DB_CANON']);
             if (false === $data->update_uri($new_v, $old_v, null)) {
                 return false;
             }
         }
     }
 }
Esempio n. 2
0
 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);
 }