Fixed a few problems with the result objects

This commit is contained in:
jengo 2001-01-19 23:45:37 +00:00
parent 1272648985
commit 31f38a5d8e
5 changed files with 144 additions and 61 deletions

View File

@ -25,6 +25,14 @@
class acl class acl
{ {
var $db;
function acl()
{
global $phpgw;
$this->db = $phpgw->db;
}
/* This is a new class. These are sample table entries /* 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) insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)
values('filemanager', 'create', 1, 'u', 4); values('filemanager', 'create', 1, 'u', 4);
@ -38,6 +46,8 @@
function check($location, $required, $appname = False){ function check($location, $required, $appname = False){
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
// $this->db = $phpgw->db;
if ($appname == False){ if ($appname == False){
$appname = $phpgw_info["flags"]["currentapp"]; $appname = $phpgw_info["flags"]["currentapp"];
} }
@ -56,11 +66,11 @@
} }
$sql .= ")))"; $sql .= ")))";
$rights = 0; $rights = 0;
$phpgw->db->query($sql ,__LINE__,__FILE__); $this->db->query($sql ,__LINE__,__FILE__);
if ($phpgw->db->num_rows() == 0 && $phpgw_info["server"]["acl_default"] != "deny"){ return True; } if ($this->db->num_rows() == 0 && $phpgw_info["server"]["acl_default"] != "deny"){ return True; }
while ($phpgw->db->next_record()) { while ($this->db->next_record()) {
if ($phpgw->db->f("acl_rights") == 0){ return False; } if ($this->db->f("acl_rights") == 0){ return False; }
$rights |= $phpgw->db->f("acl_rights"); $rights |= $this->db->f("acl_rights");
} }
return !!($rights & $required); return !!($rights & $required);
} }
@ -68,7 +78,7 @@
function add($app, $location, $id, $id_type, $rights){ 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 = "insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)";
$sql .= " values('".$app."', '".$location."', ".$id.", '".$id_type."', ".$rights.")"; $sql .= " values('".$app."', '".$location."', ".$id.", '".$id_type."', ".$rights.")";
$phpgw->db->query($sql ,__LINE__,__FILE__); $this->db->query($sql ,__LINE__,__FILE__);
return True; return True;
} }
@ -76,7 +86,7 @@
$sql = "delete from phpgw_acl where acl_appname='".$app."'"; $sql = "delete from phpgw_acl where acl_appname='".$app."'";
$sql .= " and acl_location ='".$location."' and "; $sql .= " and acl_location ='".$location."' and ";
$sql .= " acl_account_type = '".$id_type."' and acl_account = ".$id.")"; $sql .= " acl_account_type = '".$id_type."' and acl_account = ".$id.")";
$phpgw->db->query($sql ,__LINE__,__FILE__); $this->db->query($sql ,__LINE__,__FILE__);
return True; return True;
} }

View File

@ -30,6 +30,35 @@
var $cats; var $cats;
var $db; 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 = "") function categories($account_id = "",$app_name = "")
{ {
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
@ -44,35 +73,25 @@
$this->account_id = $account_id; $this->account_id = $account_id;
$this->app_name = $app_name; $this->app_name = $app_name;
$this->db = $phpgw->db; $this->db = $phpgw->db;
$this->cats = $this->return_array();
$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");
}
} }
// Return into a select box, list or other formats // Return into a select box, list or other formats
function formated_list($format,$type) function formated_list($format,$type,$selected = "")
{ {
global $phpgw; global $phpgw;
$filter = $this->filter($type);
switch ($type)
{
case "onlymains": $method = "and cat_parent='0'"; break;
case "onlysubs": $method = "and cat_parent !='0'"; break;
}
if ($format == "select") { if ($format == "select") {
$this->db->query("select * from phpgw_categories where cat_owner='" . $this->account_id $this->db->query("select * from phpgw_categories where cat_owner='" . $this->account_id
. "' $method",__LINE__,__FILE__); . "' $filter",__LINE__,__FILE__);
while ($this->db->next_record()) { while ($this->db->next_record()) {
$s .= '<option value="' . $this->db->f("cat_id") . '">' $s .= '<option value="' . $this->db->f("cat_id") . '"';
. $phpgw->strip_html($this->db->f("cat_name")) . '</option>'; if ($this->db->f("cat_id") == $selected) {
$s .= " selected";
}
$s .= '>' . $phpgw->strip_html($this->db->f("cat_name"))
. '</option>';
} }
return $s; return $s;
} }
@ -101,5 +120,28 @@
. $this->account_id . "' and cat_id='$cat_id'",__LINE__,__FILE__); . $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;
}
}
} }
?> ?>

View File

@ -25,6 +25,14 @@
/*********************************************/ /*********************************************/
class menutree { 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){ function showtree($treefile, $expandlevels="", $num_menus = 50, $invisible_menus = Null){
global $phpgw_info, $phpgw; global $phpgw_info, $phpgw;
@ -54,6 +62,7 @@ class menutree {
$maxlevel=0; $maxlevel=0;
$cnt=0; $cnt=0;
if ($this->read_from_file) {
$fd = fopen($treefile, "r"); $fd = fopen($treefile, "r");
if ($fd==0) die("menutree.inc : Unable to open file ".$treefile); if ($fd==0) die("menutree.inc : Unable to open file ".$treefile);
while ($buffer = fgets($fd, 4096)) { while ($buffer = fgets($fd, 4096)) {
@ -68,7 +77,20 @@ class menutree {
$cnt++; $cnt++;
} }
fclose($fd); 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++;
}
}
for ($i=0; $i<count($tree); $i++) { for ($i=0; $i<count($tree); $i++) {
$expand[$i]=0; $expand[$i]=0;
$visible[$i]=0; $visible[$i]=0;
@ -196,8 +218,8 @@ class menutree {
/****************************************/ /****************************************/
if($cnt==0) { if($cnt==0) {
$str = "<table cellspacing=0 cellpadding=0 border=0 cols=".($maxlevel+3)." width=".($maxlevel*16+100).">\n"; $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 .= '<a href="' . $phpgw->link("index.php",$params) . '" target="_parent">' . $this->root_level_value . '</a>';
$str .= "<tr>"; $str .= "\n<tr>";
for ($i=0; $i<$maxlevel; $i++) $str .= "<td width=16></td>"; for ($i=0; $i<$maxlevel; $i++) $str .= "<td width=16></td>";
$str .= "<td width=100></td></tr>\n"; $str .= "<td width=100></td></tr>\n";
} }
@ -213,9 +235,9 @@ class menutree {
$i=0; $i=0;
while ($i<$tree[$cnt][0]-1) { while ($i<$tree[$cnt][0]-1) {
if ($levels[$i]==1) if ($levels[$i]==1)
$str .= "<td><img src=\"".$img_line."\"></td>"; $str .= '<td><img src="' . $img_line . '" alt="|"></td>';
else else
$str .= "<td><img src=\"".$img_spc."\"></td>"; $str .= '<td><img src="' . $img_spc . '" alt=" "></td>';
$i++; $i++;
} }
@ -223,10 +245,10 @@ class menutree {
/* corner at end of subtree or t-split */ /* corner at end of subtree or t-split */
/****************************************/ /****************************************/
if ($tree[$cnt][4]==1) { 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; $levels[$tree[$cnt][0]-1]=0;
} else { } else {
$str .= "<td><img src=\"".$img_split."\"></td>"; $str .= '<td><img src="' . $img_split . '" alt="|-"></td>';
$levels[$tree[$cnt][0]-1]=1; $levels[$tree[$cnt][0]-1]=1;
} }
@ -236,15 +258,15 @@ class menutree {
if ($tree[$cnt+1][0]>$tree[$cnt][0]) { if ($tree[$cnt+1][0]>$tree[$cnt][0]) {
if ($expand[$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 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 { } else {
/*************************/ /*************************/
/* Tree Leaf */ /* Tree Leaf */
/*************************/ /*************************/
$str .= "<td><img src=\"".$img_leaf."\"></td>"; $str .= '<td><img src="' . $img_leaf . '" alt="o"></td>';
} }
/****************************************/ /****************************************/

View File

@ -300,6 +300,13 @@ class nextmatchs
return $tr_color; 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="") function show_sort_order($sort,$var,$order,$program,$text,$extra="")
{ {
global $phpgw, $filter, $qfield, $start, $query; global $phpgw, $filter, $qfield, $start, $query;

View File

@ -30,6 +30,8 @@
} unset($d1); } unset($d1);
// Note: We should add a way to force the developer to say which ones to use. (jengo) // 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 class utilities
{ {
var $rssparser; var $rssparser;
@ -41,13 +43,13 @@
function utilities_() function utilities_()
{ {
$phpgw->rssparser = CreateObject("phpgwapi.rssparser"); // $phpgw->rssparser = CreateObject("phpgwapi.rssparser");
$phpgw->clientsniffer = CreateObject("phpgwapi.clientsniffer"); // $phpgw->clientsniffer = CreateObject("phpgwapi.clientsniffer");
$phpgw->http = CreateObject("phpgwapi.http"); // $phpgw->http = CreateObject("phpgwapi.http");
$phpgw->matrixview = CreateObject("phpgwapi.matrixview"); // $phpgw->matrixview = CreateObject("phpgwapi.matrixview");
$phpgw->menutree = CreateObject("phpgwapi.menutree"); // $phpgw->menutree = CreateObject("phpgwapi.menutree");
$phpgw->sbox = CreateObject("phpgwapi.sbox"); $this->sbox = new sbox;
$phpgw->sbox = CreateObject("phpgwapi.portalbox"); // $phpgw->sbox = CreateObject("phpgwapi.portalbox");
} }
} }
?> ?>