function update_password($host, $username, $password)
{
global $GO_CRYPTO;
$sql = "UPDATE emAccounts SET password='".$GO_CRYPTO->encrypt($password)."' WHERE username='$username' AND host='$host'";
return $this->query($sql);
}
function update_folders($account_id, $sent, $spam, $trash)
{
$sql = "UPDATE emAccounts SET sent='".smart_addslashes($sent)."', spam='".smart_addslashes($spam)."',trash='".smart_addslashes($trash)."' WHERE id='$account_id'";
return $this->query($sql);
}
function get_account($id = 0)
{
global $GO_CRYPTO;
if ($id == 0)
{
$sql = "SELECT * FROM emAccounts WHERE standard='1' AND user_id='".$_SESSION['GO_SESSION']['user_id']."'";
}else
{
$sql = "SELECT * FROM emAccounts WHERE id='$id'";
}
$this->query($sql);
if ($this->next_record())
{
return $this->Record;
}else
{
return false;
}
}
function is_default_account($id)
{
$sql = "SELECT * FROM emAccounts WHERE id='$id' AND standard='1'";
$this->query($sql);
if ($this->num_rows() == 1)
{
return true;
}else
{
return false;
}
}
function delete_account($user_id, $id)
{
$default = $this->is_default_account($id);
$sql = "DELETE FROM emAccounts WHERE id='$id' AND user_id='$user_id'";
if ($this->query($sql))
{
$sql = "DELETE FROM emFolders WHERE account_id='$id'";
$this->query($sql);
$sql = "DELETE FROM emFilters WHERE account_id='$id'";
$this->query($sql);
}
if ($default)
{
$this->get_accounts($user_id);
$this->next_record();
$this->set_as_default($this->f("id"), $user_id);
}
return true;
}
function set_as_default($account_id, $user_id)
{
$sql = "UPDATE emAccounts SET standard='0' WHERE user_id='$user_id' AND standard='1'";
$this->query($sql);
$sql = "UPDATE emAccounts SET standard='1' WHERE id='$account_id'";
$this->query($sql);
}
/*
gets the subfolder of a folder id. Account id is only usefull for the root level where all folders have parent 0
*/
function get_folders($account_id, $folder_id=-1)
{
$sql = "SELECT * FROM emFolders WHERE account_id='$account_id' AND subscribed='1' ";
if ($folder_id > -1)
{
$sql .= "AND parent_id='$folder_id' ";
}
$sql .= "ORDER BY NAME ASC";
$this->query($sql);
return $this->num_rows();
}
function get_all_folders($account_id, $subscribed_only=false)
{
if ($subscribed_only)
{
$sql = "SELECT * FROM emFolders WHERE account_id='$account_id' AND subscribed='1' ORDER BY NAME ASC";
}else
{
$sql = "SELECT * FROM emFolders WHERE account_id='$account_id' ORDER BY NAME ASC";
}
$this->query($sql);
return $this->num_rows();
}
function add_folder($account_id, $name, $parent_id=0, $subscribed=1, $delimiter='/', $attributes=0)