Move contacts class calls into functions.inc.php to prepare for acl implementation

This commit is contained in:
Miles Lott 2001-02-14 00:56:07 +00:00
parent 21670c3780
commit a3e18e5064
5 changed files with 153 additions and 143 deletions

View File

@ -32,9 +32,9 @@
} else if ($add_email) { } else if ($add_email) {
list($fields["firstname"],$fields["lastname"]) = explode(" ", $name); list($fields["firstname"],$fields["lastname"]) = explode(" ", $name);
$fields["email"] = $add_email; $fields["email"] = $add_email;
form("","add.php","Add",$fields); addressbook_form("","add.php","Add",$fields);
} else if (! $submit && ! $add_email) { } else if (! $submit && ! $add_email) {
form("","add.php","Add","","",""); addressbook_form("","add.php","Add","");
} else { } else {
if (! $bday_month && ! $bday_day && ! $bday_year) { if (! $bday_month && ! $bday_day && ! $bday_year) {
$bday = ""; $bday = "";
@ -77,7 +77,7 @@
$fields["url"] = $url; $fields["url"] = $url;
$fields["notes"] = $notes; $fields["notes"] = $notes;
$this->add($phpgw_info["user"]["account_id"],$fields); addressbook_add_entry($phpgw_info["user"]["account_id"],$fields);
Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"]."/addressbook/","cd=14")); Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"]."/addressbook/","cd=14"));
} }

View File

@ -43,12 +43,9 @@
"notes" => "notes" "notes" => "notes"
); );
$qfields = $this->stock_contact_fields + $extrafields; $qfields = $this->stock_contact_fields + $extrafields;
$fields = $this->read_single_entry($ab_id,$qfields); $fields = addressbook_read_entry($ab_id,$qfields);
form("","edit.php","Edit",$fields[0]); addressbook_form("","edit.php","Edit",$fields[0]);
} else { } else {
//verify edit capabilities
$rights = $phpgw->acl->get_rights($owner,$phpgw_info["flags"]["currentapp"]);
if ( ($rights & PHPGW_ACL_EDIT) || ($owner == $phpgw_info["user"]["account_id"]) ) {
if ($url == "http://") { if ($url == "http://") {
$url = ""; $url = "";
} }
@ -89,14 +86,14 @@
$fields["url"] = $url; $fields["url"] = $url;
$fields["notes"] = $notes; $fields["notes"] = $notes;
$this->update($ab_id,$phpgw_info["user"]["account_id"],$fields); // this is now in functions.inc.php and will handle acl soon
//if (!$userid) {
$userid = $phpgw_info["user"]["account_id"];
//}
addressbook_update_entry($ab_id,$userid,$fields);
Header("Location: " . $phpgw->link("view.php","&ab_id=$ab_id&order=$order&sort=$sort&filter=$filter&start=$start")); Header("Location: " . $phpgw->link("view.php","&ab_id=$ab_id&order=$order&sort=$sort&filter=$filter&start=$start"));
$phpgw->common->phpgw_exit(); $phpgw->common->phpgw_exit();
} else {
$phpgw->redirect($phpgw->session->link($phpgw_info["server"]["webserver_url"]. "/addressbook/","cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query"));
$phpgw->common->phpgw_exit();
}
} }
$t->set_var("ab_id",$ab_id); $t->set_var("ab_id",$ab_id);

View File

@ -72,7 +72,34 @@
} }
} }
function form($format,$action,$title,$fields) { // used for add/edit function addressbook_read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order,$userid="") {
global $this;
$entries = $this->read($start,$offset,$qcols,$query,$qfilter,$sort,$order);
return $entries;
}
function addressbook_read_entry($id,$fields,$userid="") {
global $this;
$entry = $this->read_single_entry($id,$fields);
return $entry;
}
function addressbook_add_entry($userid,$fields) {
global $this;
$this->add($userid,$fields);
return;
}
function addressbook_update_entry($id,$userid,$fields) {
global $this;
//$rights = $phpgw->acl->get_rights($owner,$phpgw_info["flags"]["currentapp"]);
//if ( ($rights & PHPGW_ACL_EDIT) || ($owner == $phpgw_info["user"]["account_id"]) ) {
$this->update($id,$userid,$fields);
return;
}
function addressbook_form($format,$action,$title="",$fields="") { // used for add/edit
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
#$t = new Template($phpgw_info["server"]["app_tpl"]); #$t = new Template($phpgw_info["server"]["app_tpl"]);

View File

@ -67,7 +67,8 @@
$qcols = $columns_to_display + array("access"); $qcols = $columns_to_display + array("access");
// read the entry list // read the entry list
$entries = $this->read($start,$offset,$qcols,$query,$qfilter,$sort,$order); if (!$userid) { $userid = $phpgw_info["user"]["account_id"]; }
$entries = addressbook_read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order,$userid);
$search_filter = $phpgw->nextmatchs->show_tpl("index.php",$start, $this->total_records,"&order=$order&filter=$filter&sort=$sort&query=$query","75%", $phpgw_info["theme"]["th_bg"]); $search_filter = $phpgw->nextmatchs->show_tpl("index.php",$start, $this->total_records,"&order=$order&filter=$filter&sort=$sort&query=$query","75%", $phpgw_info["theme"]["th_bg"]);
@ -109,11 +110,6 @@
// Show the entries // Show the entries
for ($i=0;$i<count($entries);$i++) { // each entry for ($i=0;$i<count($entries);$i++) { // each entry
$rights = $phpgw->acl->get_rights($entries[$i]["owner"],$phpgw_info["flags"]["currentapp"]);
if ( ($rights & PHPGW_ACL_READ) || ($entries[$i]["owner"] == $phpgw_info["user"]["account_id"]) ) {
//if ( ($entries[$i]["access"] == $filter) ||
// ($entries[$i]["access"] == "," . $filter . ",") ||
// ($filter == "") || ($filter == "none")) {
$t->set_var(columns,""); $t->set_var(columns,"");
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$t->set_var(row_tr_color,$tr_color); $t->set_var(row_tr_color,$tr_color);
@ -131,8 +127,6 @@
if ($phpgw_info["user"]["apps"]["email"]) { if ($phpgw_info["user"]["apps"]["email"]) {
$ref='<a href="'.$phpgw->link($phpgw_info["server"]["webserver_url"] . "/email/compose.php","to=" . urlencode($coldata)).'" target="_new">'; $ref='<a href="'.$phpgw->link($phpgw_info["server"]["webserver_url"] . "/email/compose.php","to=" . urlencode($coldata)).'" target="_new">';
} else { } else {
//changed frmo a patch posted on sf, have not fully tested. Seek3r, Jan 30 2001
// $ref='<a href="mailto:"'.$coldata.'">'.$coldata.'</a>';
$ref='<a href="mailto:'.$coldata.'">'; $ref='<a href="mailto:'.$coldata.'">';
} }
$data=$coldata."</a>"; $data=$coldata."</a>";
@ -154,7 +148,6 @@
$t->pparse("out","row"); $t->pparse("out","row");
reset($columns_to_display); // If we don't reset it, our inside while won't loop reset($columns_to_display); // If we don't reset it, our inside while won't loop
} }
}
$t->pparse("out","addressbook_footer"); $t->pparse("out","addressbook_footer");
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();

View File

@ -50,13 +50,10 @@
"notes" => "notes", "notes" => "notes",
); );
$qfields = $this->stock_contact_fields + $extrafields; $qfields = $this->stock_contact_fields + $extrafields;
$fields = $this->read_single_entry($ab_id,$qfields); $fields = addressbook_read_entry($ab_id,$qfields);
$owner = $fields[0]["owner"]; $owner = $fields[0]["owner"];
$rights = $phpgw->acl->get_rights($owner,$phpgw_info["flags"]["currentapp"]);
if ( ($rights & PHPGW_ACL_READ) || ($owner == $phpgw_info["user"]["account_id"]) ) {
$view_header = "<p>&nbsp;<b>" . lang("Address book - view") . "</b><hr><p>"; $view_header = "<p>&nbsp;<b>" . lang("Address book - view") . "</b><hr><p>";
$view_header .= '<table border="0" cellspacing="2" cellpadding="2" width="80%" align="center">'; $view_header .= '<table border="0" cellspacing="2" cellpadding="2" width="80%" align="center">';
@ -121,8 +118,4 @@
$t->pparse("out","view"); $t->pparse("out","view");
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
} else {
$phpgw->redirect($phpgw->session->link($phpgw_info["server"]["webserver_url"]. "/addressbook/","cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query"));
$phpgw->common->phpgw_exit();
}
?> ?>