Ejemplo 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;
             }
         }
     }
 }
Ejemplo n.º 2
0
 function action_update(&$errors)
 {
     global $data, $config;
     if (isset($_SESSION['apu_aliases']['ack'])) {
         $username = $_SESSION['apu_aliases']['ack']['vals']['new']['username'];
         $did = $_SESSION['apu_aliases']['ack']['vals']['new']['did'];
         $flags = $_SESSION['apu_aliases']['ack']['vals']['new']['flags'];
         unset($_SESSION['apu_aliases']['ack']);
     } else {
         $username = $_POST['al_username'];
         $did = $_POST['al_domain'];
         $flags = $this->get_flags_from_POSTs();
     }
     $uid = $this->user_id->get_uid();
     // Check if admin has parmission to update URI.
     // Domain should be chceke in method validate_form(), but check it
     // again to be sure.
     if (!$this->check_did($did)) {
         $errors[] = "Can not update URI, you have not access to selected domain";
         return false;
     }
     if (!$this->check_did($this->act_alias['did'])) {
         $errors[] = "Can not update, you have not access to this URI";
         return false;
     }
     $f =& $config->data_sql->uri->flag_values;
     $data->transaction_start();
     /* if flag 'IS_TO' is set in this URI, clear this flag in all other 
      * URIs with same username and did
      */
     if ($flags & $f['DB_IS_TO']) {
         if (false === $this->clear_is_to($username, $did)) {
             $data->transaction_rollback();
             return false;
         }
     }
     /* if flag 'IS_CANON' is set in this URI, clear this flag in all other 
      * URIs with same uid 
      */
     if ($flags & $f['DB_CANON']) {
         if ($flags & $f['DB_IS_TO']) {
             $uris_handler =& URIS::singleton($uid);
             $uris_handler->invalidate();
         }
         if (false === $this->clear_is_canon($uid)) {
             $data->transaction_rollback();
             return false;
         }
     }
     $old_v = array('uid' => $uid, 'did' => $this->act_alias['did'], 'username' => $this->act_alias['username'], 'flags' => $this->act_alias['flags']);
     $new_v = array('did' => $did, 'username' => $username, 'flags' => $flags);
     if (false === $data->update_uri($new_v, $old_v, null)) {
         $data->transaction_rollback();
         return false;
     }
     $data->transaction_commit();
     return array("m_al_updated=" . RawURLEncode($this->opt['instance_id']));
 }