Пример #1
0
  function is_conference_owner($conference_id, $username) {
    global $log; 
    $log->log("is_conference_owner $conference_id, $username "); 

    if ($conference_id && $username){ 
      change_to_conference_db($this->db);

      $q=" select owner_flag FROM invitees WHERE conference_id=$conference_id AND invitee_username='******'";
      $res=$this->db->query($q);

      if (DB::isError($res)) {
        $log->log("QUERY FAILED $q " . $res->getMessage());
      }
      $owner_flag = FALSE;

      $row = $res->fetchRow() ; 
      if ($row[0]) { 
        $owner_flag = TRUE;
      }

      $res->free();
      change_to_default_db($this->db);
      return $owner_flag; 
    }
  }  
Пример #2
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; 
     } 
  } 
Пример #3
0
  function get_conference_name($domain) { 
    global $config,$log ; 

    if ($domain)  { 
       change_to_conference_db($this->db); 
       $q="SELECT count(*),com.company_name FROM companies com,conferences con " 
         . " WHERE com.domain='$domain' " 
         . " AND com.company_id = con.company_id GROUP BY com.company_name"; 

       $res=$this->db->query($q);
       if (DB::isError($res)) {
         $log->log("QUERY FAILED $q " . $res->getMessage());
       } 

       $row  = $res->fetchRow() ; 
       $count = $row[0] ; 
       $company_name = $row[1]; 
       $res->free(); 

       if (!$count) {
          $q = "SELECT company_name FROM companies WHERE domain='$domain' "  ; 
          $res=$this->db->query($q);
          $row = $res->fetchRow() ;
          $company_name = $row[0];
          $count  =0; 
       } 
       $count++;
       $conf_name = "$company_name Conference #$count" ; 
       $log->log("count = $count $conf_name "); 
  
       change_to_default_db($this->db);
       return $conf_name ; 
    } 
  }
Пример #4
0
  function get_user_conferences($conf_ids) {
    global $log ; 
    $id_array = array(); 
    $id_to_index_map = array(); 
    for ($i = 0; $i < count($conf_ids); $i++) {
       $id_array[] = $conf_ids[$i][conference_id] ; 
       $id_to_index_map[$conf_ids[$i][conference_id]] = $i; 
       $log->log(" $i " . $conf_ids[$i][conference_id] ); 
    }
   #    for ($i  ( $conf_ids as $h) {
   #    }  

    $ids = implode(',',$id_array); 
    $q = "SELECT c.conference_id, i.invitee_id, i.invitee_email, i.invitee_code, i.invitee_name,i.invitee_username  FROM conferences c, invitees i WHERE c.conference_id = i.conference_id AND c.conference_id in ($ids) ";
    $log->log($q); 
    change_to_conference_db($this->db); 

    $res=$this->db->query($q);
    if (DB::isError($res)) {
       $log->log("QUERY FAILED $q " . $res->getMessage());
    }

    $data =array();

    while ($row= $res->fetchRow(DB_FETCHMODE_ASSOC) ) {
        $index = $id_to_index_map[$row[conference_id]] ; 
        $conf_ids[$index]["invitees"][] = $row; 
    }
    change_to_default_db($this->db);
    return $conf_ids ; 

   
       
  } 
Пример #5
0
  function get_user_conference($conf_id,$username) {
    global $log ; 

    $q = "SELECT c.conference_id, c.conference_name, "
         ." date_format(c.conference_date,'%m-%d-%Y') conference_date,"
         ." time_format(c.begin_time,'%l:%i %p' ) begin_time,"
         ." time_format(c.end_time,'%l:%i %p' ) end_time,"
         ." i.owner_flag, i.invitee_id, i.invitee_email, "
         ."  i.invitee_code, i.invitee_name,i.invitee_username  "
         ."  FROM conferences c, invitees i "
         ." WHERE c.conference_id = i.conference_id AND c.conference_id = $conf_id ";
    $log->log($q); 
    change_to_conference_db($this->db); 

    $res=$this->db->query($q);
    if (DB::isError($res)) {
       $log->log("QUERY FAILED $q " . $res->getMessage());
    }

    $data =array();
    $user_conf = array();
    $row= $res->fetchRow(DB_FETCHMODE_ASSOC) ;
    $user_conf['conference_id']=$conf_id;
    $user_conf['conference_name']=$row['conference_name'] ;
    $user_conf['conference_date']=$row['conference_date'] ;
    $user_conf['begin_time']=$row['begin_time'] ;
    $user_conf['end_time']=$row['end_time'] ;
     
    do {
       $user_conf["invitees"][] = $row; 
       $log->log($row["invitee_username"] ."== $username");
       if ($row["owner_flag"] && ( $row["invitee_username"] == $username ) ) { 
         $log->log("owner_flag found");
         $user_conf['owner_flag']=1;
       } 
       $log->log("invitee_email = " . $row['invitee_email']);
       $log->log("owner_flag = " . $row['owner_flag']);
    } while ($row= $res->fetchRow(DB_FETCHMODE_ASSOC) ); 
    change_to_default_db($this->db);
    return $user_conf ; 

   
       
  } 
Пример #6
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");
    }
  }