<?PHP
class DAOSaveFileProp
{
var $db;
var $db_table;
var $db_field;
function DAOSaveFileProp()
{
global $db, $db_table, $db_field;
$this->db = $db;
$this->db_table = $db_table;
$this->db_field = $db_field;
}
function getownerfileaccess($_filedb_id, $_ownerid)
{
$sqlq= new SQLSelect();
$sqlq->setSelect($this->db_field['userfileparamattr'],
$this->db_table['userfileparamattr']);
$sqlq->setWhere($this->db_table['userfileparamattr'].
".user_id=".$this->db_table['userfileparamattr'].
".owner");
$sqlq->setWhere($this->db_table['userfileparamattr'].
".filedb_id=".$_filedb_id);
$sqlq->setWhere($this->db_table['userfileparamattr'].
".owner=".$_ownerid);
//echo($sqlq->SQLReturn(). "<br />");
$result = ($sqlq->getRow($this->db, $sqlq->SQLReturn()));
if (isset($result['userfileparamattr']) && (count($result['userfileparamattr'])>0))
return true;
else
return false;
}
function getpublicfileaccess($_filedb_id, $_ownerid)
{
$sqlq= new SQLSelect();
$sqlq->setSelect($this->db_field['userfileparamattr'],
$this->db_table['userfileparamattr']);
$sqlq->setWhere($this->db_table['userfileparamattr'].
".user_id=".ANONYMOUS);
$sqlq->setWhere($this->db_table['userfileparamattr'].
".filedb_id=".$_filedb_id);
$sqlq->setWhere($this->db_table['userfileparamattr'].
".owner=".$_ownerid);
//echo($sqlq->SQLReturn(). "<br />");
$result = ($sqlq->getRow($this->db, $sqlq->SQLReturn()));
if (isset($result['userfileparamattr']) && (count($result['userfileparamattr'])>0))
return true;
else
return false;
}
function updateownerfileaccess($_filedb_id, $_ownerid, $_ownerwriteaccess)
{
$sqlq = "UPDATE ".$this->db_table['userfileparamattr']." SET".
" allowread='Y', allowwrite='";
if ($_ownerwriteaccess=="Y")
$sqlq.="Y'";
else
$sqlq.="N'";
$sqlq.=" WHERE filedb_id=".$_filedb_id." AND user_id=owner".
" AND owner=".$_ownerid;
//echo($sqlq. "<br />");
if ($this->db->sql_query($sqlq, BEGIN_TRANSACTION))
{
return true;
}
else
return false;
}
function updatepublicfileaccess($_filedb_id, $_ownerid, $_publicreadaccess)
{
$sqlq = "UPDATE ".$this->db_table['userfileparamattr']." SET".
" allowwrite='N', allowread='";
if ($_publicreadaccess=="Y")
$sqlq.="Y'";
else
$sqlq.="N'";
$sqlq.=" WHERE filedb_id=".$_filedb_id." AND user_id=".ANONYMOUS.
" AND owner=".$_ownerid;
//echo($sqlq. "<br />");
if ($this->db->sql_query($sqlq))
{
return true;
}
else
return false;
}
function insertownerfileaccess($_filedb_id, $_ownerid, $_ownerwriteaccess)
{
$sqlq = "INSERT INTO ".$this->db_table['userfileparamattr']." (filedb_id,".
" user_id, owner, allowread, allowwrite) VALUES ($_filedb_id,".
"$_ownerid, $_ownerid, 'Y', '$_ownerwriteaccess')";
//echo($sqlq. "<br />");
if ($this->db->sql_query($sqlq, BEGIN_TRANSACTION))
{
return true;
}
else
return false;
}
function insertpublicfileaccess($_filedb_id, $_ownerid, $_publicreadaccess)
{
$sqlq = "INSERT INTO ".$this->db_table['userfileparamattr']." (filedb_id,".
" user_id, owner, allowread, allowwrite) VALUES ($_filedb_id,".
ANONYMOUS.", $_ownerid, '$_publicreadaccess', 'N')";
//echo($sqlq. "<br />");
if ($this->db->sql_query($sqlq))
{
return true;
}
else
return false;
}
function deluseraccess($_filedb_id, $_userid, $_owner)
{
for ($i=0; $i<count($_userid); $i++)
{
if (!is_numeric($_userid[$i]))
continue;
$sqlq="DELETE FROM ".$this->db_table['userfileparamattr'].
" WHERE filedb_id=".$_filedb_id. " AND user_id=".
$_userid[$i]." AND owner=".$_owner;
//echo($sqlq. "<br />");
if ($this->db->sql_query($sqlq)==false)
return false;
}
return true;
}
function getuserfileaccess($_filedb_id, $_userid, $_ownerid)
{
$sqlq= new SQLSelect();
$sqlq->setSelect($this->db_field['userfileparamattr'],
$this->db_table['userfileparamattr']);
$sqlq->setWhere($this->db_table['userfileparamattr'].
".user_id=".$_userid);
$sqlq->setWhere($this->db_table['userfileparamattr'].
".filedb_id=".$_filedb_id);
$sqlq->setWhere($this->db_table['userfileparamattr'].
".owner=".$_ownerid);
//echo($sqlq->SQLReturn(). "<br />");
$result = ($sqlq->getRow($this->db, $sqlq->SQLReturn()));
if (isset($result['userfileparamattr']) && (count($result['userfileparamattr'])>0))
return true;
else
return false;
}
function updateuserfileaccess($_filedb_id, $_userid, $_ownerid, $_read)
{
$sqlq = "UPDATE ".$this->db_table['userfileparamattr']." SET".
" allowwrite='N', allowread='";
if ($_read=="Y")
$sqlq.="Y'";
else
$sqlq.="N'";
$sqlq.=" WHERE filedb_id=".$_filedb_id." AND user_id=$_userid".
" AND owner=".$_ownerid;
//echo($sqlq. "<br />");
if ($this->db->sql_query($sqlq))
{
return true;
}
else
return false;
}
function insertuserfileaccess($_filedb_id, $_userid, $_ownerid, $_read)
{
$sqlq = "INSERT INTO ".$this->db_table['userfileparamattr']." (filedb_id,".
" user_id, owner, allowread, allowwrite) VALUES ($_filedb_id,".
$_userid.", $_ownerid, '$_read', 'N')";
//echo($sqlq. "<br />");
if ($this->db->sql_query($sqlq))
{
return true;
}
else
return false;
}
function rollback()
{
$this->db->sql_query("", ROLLBACK);
}
function commit()
{
$this->db->sql_query("", END_TRANSACTION);
}
}
?>