Example #1
0
  function mailbox_exists ($mailbox) {
    global $log; 
    if (!$mailbox) { 
      return false; 
    } 
    $voicemail_db = get_voicemail_db($this->db, $this->udomain);
    change_db($this->db, $voicemail_db);
    $q = "SELECT count(extension) " . 
         " FROM VM_Users  WHERE extension = " . $mailbox;
                                                                                                                                               
     $res = $this->db->query($q);
                                                                                                                                               
     if (DB::isError($res)) {
          $log->log("FAILED QUERY : $q",LOG_ERR);
          change_to_default_db($this->db);
           
          return false;
     }
     $row =  $res->fetchRow(DB_FETCHMODE_ORDERED) ;
     $res->free();
     change_to_default_db($this->db);

     $count = $row[0]; 
     if ($count == 1)  {
       return true; 
     } else {
       return false; 
     } 
  } 
Example #2
0
  function savePerm($new_perm) {
    global $log ;
    if ($this->mailbox && preg_match("/SUPER|ADMIN|USER/", $new_perm))  {
       if (!$this->voicemail_db ) {
         $this->voicemail_db = get_voicemail_db($this->udomain);
       }
       change_db($this->db,$this->voicemail_db );

       $q="UPDATE VM_Users SET permission_id = '$new_perm' WHERE "
          . " extension=  ". $this->mailbox;
       $res=$this->db->query($q);
       if (DB::isError($res)) {
         $log->log("QUERY FAILED $q " . $res->getMessage());
       }
       change_to_default_db($this->db);

    } else {
      $log->log("ERRROR: Tried to savePerm with no extension " . $this->mailbox . " or invalid perm $new_perm");
    }
  }