<?php
/*
This file is part of Thomas Bley's moregroupware webmail2/calendar2/admin2 module. (tb-mgw)

More information:
-----------------

Simple Groupware Solutions Thomas Bley
Fichtenstr. 23
Germany, 85640 Putzbrunn

Contact:
--------

info@simple-groupware.de

http://www.simple-groupware.de


Copyright 2002-2003 Thomas Bley
tb-mgw is distributed under the terms of the GNU General Public License 

tb-mgw is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

tb-mgw is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with tb-mgw; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// Accounts-inc
// Moregroupware.org


function getallusers() {
  global $conn;
  $sql = "select username,id from mgw_users order by username";
  if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
  $users = array();
  while ($row = $res->FetchRow()) {
    $users[] = array($row["id"],$row["username"]);
  }
  return $users;
}

function get_myusername($userid) {
  global $conn;
  $sql = "select username from mgw_users where id=".(int)$userid;
  if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
  $row = $res->FetchRow();
  $result = $row["username"];
  if ($result == "") {$result = "unknown";}
  return $result;
}
      
function get_myuseremail($userid) {
  global $conn;
  $sql = "select email from mgw_users where id=".(int)$userid;
  if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
  $row = $res->FetchRow();
  $result = $row["email"];
  if ($result == "") {$result = "";}
  return $result;
}
      
function get_myfullusername($userid) {
  global $conn;
  $sql = "select firstname,lastname from mgw_users where id=".(int)$userid;
  if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
  $row = $res->FetchRow();
  $result = $row["firstname"]." ".$row["lastname"];
  if ($result == " ") {$result = "";}
  return $result;
}
      
function get_folders2($sql) {
  global $conn,$messagecount,$tree,$folders;
  if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));

  while($row = $res->FetchRow()) {
	if ($row["user_id"]==0 and !has_read_rights_mbox($row["mbox_id"],$_SESSION["MGW"]->userid)) continue;
    $thiscount = getmessagecount($row["mbox_id"]);
    $messagecount = $messagecount + $thiscount;
   
    $thiscount_unread = getmessagecount_unread($row["mbox_id"]);
    if ($thiscount_unread!=0) {$thiscount_unread = "<b>".$thiscount_unread."</b> / ";} else {$thiscount_unread="";}
    if ($row["mbox_protect"]==1) { $row["mboxname"] = mboxname_replace($row["mboxname"]); }
  
    addtotree($row["mboxparent"],$tree,$row["mbox_id"],0);
    if ($row["isintrash"]==1) { $confirm="true"; } else { $confirm=""; }
 
    $folders[$row["mbox_id"]] = array($row["mbox_id"],$row["mboxname"],$thiscount,$row["mbox_protect"],"",$row["mboxname"],$thiscount_unread,$confirm);
  }
}



?>