mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
Fixed a few problems with the result objects
This commit is contained in:
parent
1272648985
commit
31f38a5d8e
@ -25,6 +25,14 @@
|
||||
|
||||
class acl
|
||||
{
|
||||
var $db;
|
||||
|
||||
function acl()
|
||||
{
|
||||
global $phpgw;
|
||||
$this->db = $phpgw->db;
|
||||
}
|
||||
|
||||
/* This is a new class. These are sample table entries
|
||||
insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)
|
||||
values('filemanager', 'create', 1, 'u', 4);
|
||||
@ -38,6 +46,8 @@
|
||||
|
||||
function check($location, $required, $appname = False){
|
||||
global $phpgw, $phpgw_info;
|
||||
// $this->db = $phpgw->db;
|
||||
|
||||
if ($appname == False){
|
||||
$appname = $phpgw_info["flags"]["currentapp"];
|
||||
}
|
||||
@ -56,11 +66,11 @@
|
||||
}
|
||||
$sql .= ")))";
|
||||
$rights = 0;
|
||||
$phpgw->db->query($sql ,__LINE__,__FILE__);
|
||||
if ($phpgw->db->num_rows() == 0 && $phpgw_info["server"]["acl_default"] != "deny"){ return True; }
|
||||
while ($phpgw->db->next_record()) {
|
||||
if ($phpgw->db->f("acl_rights") == 0){ return False; }
|
||||
$rights |= $phpgw->db->f("acl_rights");
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
if ($this->db->num_rows() == 0 && $phpgw_info["server"]["acl_default"] != "deny"){ return True; }
|
||||
while ($this->db->next_record()) {
|
||||
if ($this->db->f("acl_rights") == 0){ return False; }
|
||||
$rights |= $this->db->f("acl_rights");
|
||||
}
|
||||
return !!($rights & $required);
|
||||
}
|
||||
@ -68,7 +78,7 @@
|
||||
function add($app, $location, $id, $id_type, $rights){
|
||||
$sql = "insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)";
|
||||
$sql .= " values('".$app."', '".$location."', ".$id.", '".$id_type."', ".$rights.")";
|
||||
$phpgw->db->query($sql ,__LINE__,__FILE__);
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -76,7 +86,7 @@
|
||||
$sql = "delete from phpgw_acl where acl_appname='".$app."'";
|
||||
$sql .= " and acl_location ='".$location."' and ";
|
||||
$sql .= " acl_account_type = '".$id_type."' and acl_account = ".$id.")";
|
||||
$phpgw->db->query($sql ,__LINE__,__FILE__);
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -84,4 +94,4 @@
|
||||
}
|
||||
|
||||
} //end of acl class
|
||||
?>
|
||||
?>
|
||||
|
@ -29,7 +29,36 @@
|
||||
var $app_name;
|
||||
var $cats;
|
||||
var $db;
|
||||
|
||||
|
||||
function filter($type)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case "subs": $s = " and cat_parent != '0'"; break;
|
||||
case "mains": $s = " and cat_parent = '0'"; break;
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
function return_array($type = "all")
|
||||
{
|
||||
$filter = $this->filter($type);
|
||||
|
||||
$this->db->query("select * from phpgw_categories where cat_owner='"
|
||||
. $this->account_id . "' and cat_appname='"
|
||||
. $this->app_name . "' $filter",__LINE__,__FILE__);
|
||||
$i = 0;
|
||||
while ($this->db->next_record()) {
|
||||
$cats[$i]["id"] = $this->db->f("cat_id");
|
||||
$cats[$i]["parent"] = $this->db->f("cat_parent");
|
||||
$cats[$i]["name"] = $this->db->f("cat_name");
|
||||
$cats[$i]["description"] = $this->db->f("cat_description");
|
||||
$cats[$i]["data"] = $this->db->f("cat_data");
|
||||
$i++;
|
||||
}
|
||||
return $cats;
|
||||
}
|
||||
|
||||
function categories($account_id = "",$app_name = "")
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
@ -44,35 +73,25 @@
|
||||
$this->account_id = $account_id;
|
||||
$this->app_name = $app_name;
|
||||
$this->db = $phpgw->db;
|
||||
|
||||
$this->db->query("select * from phpgw_categories where cat_owner='$account_id' and cat_appname='"
|
||||
. "$app_name'",__LINE__,__FILE__);
|
||||
while ($this->db->next_record()) {
|
||||
$this->cats[]["id"] = $this->db->f("cat_id");
|
||||
$this->cats[]["parent"] = $this->db->f("cat_parent");
|
||||
$this->cats[]["name"] = $this->db->f("cat_name");
|
||||
$this->cats[]["description"] = $this->db->f("cat_description");
|
||||
$this->cats[]["data"] = $this->db->f("cat_data");
|
||||
}
|
||||
$this->cats = $this->return_array();
|
||||
}
|
||||
|
||||
// Return into a select box, list or other formats
|
||||
function formated_list($format,$type)
|
||||
function formated_list($format,$type,$selected = "")
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case "onlymains": $method = "and cat_parent='0'"; break;
|
||||
case "onlysubs": $method = "and cat_parent !='0'"; break;
|
||||
}
|
||||
$filter = $this->filter($type);
|
||||
|
||||
if ($format == "select") {
|
||||
$this->db->query("select * from phpgw_categories where cat_owner='" . $this->account_id
|
||||
. "' $method",__LINE__,__FILE__);
|
||||
. "' $filter",__LINE__,__FILE__);
|
||||
while ($this->db->next_record()) {
|
||||
$s .= '<option value="' . $this->db->f("cat_id") . '">'
|
||||
. $phpgw->strip_html($this->db->f("cat_name")) . '</option>';
|
||||
$s .= '<option value="' . $this->db->f("cat_id") . '"';
|
||||
if ($this->db->f("cat_id") == $selected) {
|
||||
$s .= " selected";
|
||||
}
|
||||
$s .= '>' . $phpgw->strip_html($this->db->f("cat_name"))
|
||||
. '</option>';
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
@ -101,5 +120,28 @@
|
||||
. $this->account_id . "' and cat_id='$cat_id'",__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
function return_name($cat_id)
|
||||
{
|
||||
$this->db->query("select cat_name from phpgw_categories where cat_id='"
|
||||
. "$cat_id'",__LINE__,__FILE__);
|
||||
$this->db->next_record();
|
||||
return $this->db->f("cat_name");
|
||||
}
|
||||
|
||||
function exists($type,$cat_name)
|
||||
{
|
||||
$filter = $this->filter($type);
|
||||
|
||||
$this->db->query("select count(*) from phpgw_categories where cat_name='"
|
||||
. addslashes($cat_name) . "' and cat_owner='"
|
||||
. $this->account_id . "' and cat_appname='"
|
||||
. $this->appname . "' $filter",__LINE__,__FILE__);
|
||||
$this->db->next_record();
|
||||
if ($this->db->f(0)) {
|
||||
return True;
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
@ -25,6 +25,14 @@
|
||||
/*********************************************/
|
||||
|
||||
class menutree {
|
||||
var $read_from_file; // You can send the tree info from a string or file
|
||||
var $root_level_value; // This is what the top level name or image will be
|
||||
|
||||
function menutree()
|
||||
{
|
||||
$this->read_from_file = True;
|
||||
}
|
||||
|
||||
function showtree($treefile, $expandlevels="", $num_menus = 50, $invisible_menus = Null){
|
||||
global $phpgw_info, $phpgw;
|
||||
|
||||
@ -53,22 +61,36 @@ class menutree {
|
||||
|
||||
$maxlevel=0;
|
||||
$cnt=0;
|
||||
|
||||
$fd = fopen($treefile, "r");
|
||||
if ($fd==0) die("menutree.inc : Unable to open file ".$treefile);
|
||||
while ($buffer = fgets($fd, 4096)) {
|
||||
$tree[$cnt][0]=strspn($buffer,".");
|
||||
$tmp=rtrim(substr($buffer,$tree[$cnt][0]));
|
||||
$node=explode("|",$tmp);
|
||||
$tree[$cnt][1]=$node[0];
|
||||
$tree[$cnt][2]=$node[1];
|
||||
$tree[$cnt][3]=$node[2];
|
||||
$tree[$cnt][4]=0;
|
||||
if ($tree[$cnt][0] > $maxlevel) $maxlevel=$tree[$cnt][0];
|
||||
$cnt++;
|
||||
|
||||
if ($this->read_from_file) {
|
||||
$fd = fopen($treefile, "r");
|
||||
if ($fd==0) die("menutree.inc : Unable to open file ".$treefile);
|
||||
while ($buffer = fgets($fd, 4096)) {
|
||||
$tree[$cnt][0]=strspn($buffer,".");
|
||||
$tmp=rtrim(substr($buffer,$tree[$cnt][0]));
|
||||
$node=explode("|",$tmp);
|
||||
$tree[$cnt][1]=$node[0];
|
||||
$tree[$cnt][2]=$node[1];
|
||||
$tree[$cnt][3]=$node[2];
|
||||
$tree[$cnt][4]=0;
|
||||
if ($tree[$cnt][0] > $maxlevel) $maxlevel=$tree[$cnt][0];
|
||||
$cnt++;
|
||||
}
|
||||
fclose($fd);
|
||||
} else {
|
||||
$ta = explode("\n",$treefile);
|
||||
while (list($null,$buffer) = each($ta)) {
|
||||
$tree[$cnt][0]=strspn($buffer,".");
|
||||
$tmp=rtrim(substr($buffer,$tree[$cnt][0]));
|
||||
$node=explode("|",$tmp);
|
||||
$tree[$cnt][1]=$node[0];
|
||||
$tree[$cnt][2]=$node[1];
|
||||
$tree[$cnt][3]=$node[2];
|
||||
$tree[$cnt][4]=0;
|
||||
if ($tree[$cnt][0] > $maxlevel) $maxlevel=$tree[$cnt][0];
|
||||
$cnt++;
|
||||
}
|
||||
}
|
||||
fclose($fd);
|
||||
|
||||
for ($i=0; $i<count($tree); $i++) {
|
||||
$expand[$i]=0;
|
||||
$visible[$i]=0;
|
||||
@ -196,8 +218,8 @@ class menutree {
|
||||
/****************************************/
|
||||
if($cnt==0) {
|
||||
$str = "<table cellspacing=0 cellpadding=0 border=0 cols=".($maxlevel+3)." width=".($maxlevel*16+100).">\n";
|
||||
$str .= "<a href=\"".$phpgw->link("index.php",$params)."\" target=_parent><img src=\"templates/default/images/docs.gif\" border=\"0\"></a>\n";
|
||||
$str .= "<tr>";
|
||||
$str .= '<a href="' . $phpgw->link("index.php",$params) . '" target="_parent">' . $this->root_level_value . '</a>';
|
||||
$str .= "\n<tr>";
|
||||
for ($i=0; $i<$maxlevel; $i++) $str .= "<td width=16></td>";
|
||||
$str .= "<td width=100></td></tr>\n";
|
||||
}
|
||||
@ -213,9 +235,9 @@ class menutree {
|
||||
$i=0;
|
||||
while ($i<$tree[$cnt][0]-1) {
|
||||
if ($levels[$i]==1)
|
||||
$str .= "<td><img src=\"".$img_line."\"></td>";
|
||||
$str .= '<td><img src="' . $img_line . '" alt="|"></td>';
|
||||
else
|
||||
$str .= "<td><img src=\"".$img_spc."\"></td>";
|
||||
$str .= '<td><img src="' . $img_spc . '" alt=" "></td>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -223,10 +245,10 @@ class menutree {
|
||||
/* corner at end of subtree or t-split */
|
||||
/****************************************/
|
||||
if ($tree[$cnt][4]==1) {
|
||||
$str .= "<td><img src=\"".$img_end."\"></td>";
|
||||
$str .= '<td><img src="' . $img_end . '" alt="\"></td>';
|
||||
$levels[$tree[$cnt][0]-1]=0;
|
||||
} else {
|
||||
$str .= "<td><img src=\"".$img_split."\"></td>";
|
||||
$str .= '<td><img src="' . $img_split . '" alt="|-"></td>';
|
||||
$levels[$tree[$cnt][0]-1]=1;
|
||||
}
|
||||
|
||||
@ -236,15 +258,15 @@ class menutree {
|
||||
if ($tree[$cnt+1][0]>$tree[$cnt][0]) {
|
||||
|
||||
if ($expand[$cnt]==0)
|
||||
$str .= "<td><a href=\"".$phpgw->link($script,$params)."\"><img src=\"".$img_expand."\" border=no></a></td>";
|
||||
$str .= "<td><a href=\"".$phpgw->link($script,$params)."\"><img src=\"".$img_expand."\" border=no alt=\"+\"></a></td>";
|
||||
else
|
||||
$str .= "<td><a href=\"".$phpgw->link($script,$params)."\"><img src=\"".$img_collapse."\" border=no></a></td>";
|
||||
$str .= "<td><a href=\"".$phpgw->link($script,$params)."\"><img src=\"".$img_collapse."\" border=no alt=\"-\"></a></td>";
|
||||
} else {
|
||||
/*************************/
|
||||
/* Tree Leaf */
|
||||
/*************************/
|
||||
|
||||
$str .= "<td><img src=\"".$img_leaf."\"></td>";
|
||||
$str .= '<td><img src="' . $img_leaf . '" alt="o"></td>';
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
|
@ -300,6 +300,13 @@ class nextmatchs
|
||||
return $tr_color;
|
||||
}
|
||||
|
||||
// If you are using the common bgcolor="{tr_color}"
|
||||
// This function is a little cleanier approch
|
||||
function template_alternate_row_color(&$tpl)
|
||||
{
|
||||
$tpl->set_var("tr_color",$this->alternate_row_color());
|
||||
}
|
||||
|
||||
function show_sort_order($sort,$var,$order,$program,$text,$extra="")
|
||||
{
|
||||
global $phpgw, $filter, $qfield, $start, $query;
|
||||
|
@ -30,6 +30,8 @@
|
||||
} unset($d1);
|
||||
|
||||
// Note: We should add a way to force the developer to say which ones to use. (jengo)
|
||||
include("/home/httpd/html/phpgroupware/phpgwapi/inc/class.sbox.inc.php");
|
||||
|
||||
class utilities
|
||||
{
|
||||
var $rssparser;
|
||||
@ -41,13 +43,13 @@
|
||||
|
||||
function utilities_()
|
||||
{
|
||||
$phpgw->rssparser = CreateObject("phpgwapi.rssparser");
|
||||
$phpgw->clientsniffer = CreateObject("phpgwapi.clientsniffer");
|
||||
$phpgw->http = CreateObject("phpgwapi.http");
|
||||
$phpgw->matrixview = CreateObject("phpgwapi.matrixview");
|
||||
$phpgw->menutree = CreateObject("phpgwapi.menutree");
|
||||
$phpgw->sbox = CreateObject("phpgwapi.sbox");
|
||||
$phpgw->sbox = CreateObject("phpgwapi.portalbox");
|
||||
// $phpgw->rssparser = CreateObject("phpgwapi.rssparser");
|
||||
// $phpgw->clientsniffer = CreateObject("phpgwapi.clientsniffer");
|
||||
// $phpgw->http = CreateObject("phpgwapi.http");
|
||||
// $phpgw->matrixview = CreateObject("phpgwapi.matrixview");
|
||||
// $phpgw->menutree = CreateObject("phpgwapi.menutree");
|
||||
$this->sbox = new sbox;
|
||||
// $phpgw->sbox = CreateObject("phpgwapi.portalbox");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user