mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 23:29:20 +01:00
Move contacts class calls into functions.inc.php to prepare for acl implementation
This commit is contained in:
parent
21670c3780
commit
a3e18e5064
@ -32,9 +32,9 @@
|
||||
} else if ($add_email) {
|
||||
list($fields["firstname"],$fields["lastname"]) = explode(" ", $name);
|
||||
$fields["email"] = $add_email;
|
||||
form("","add.php","Add",$fields);
|
||||
addressbook_form("","add.php","Add",$fields);
|
||||
} else if (! $submit && ! $add_email) {
|
||||
form("","add.php","Add","","","");
|
||||
addressbook_form("","add.php","Add","");
|
||||
} else {
|
||||
if (! $bday_month && ! $bday_day && ! $bday_year) {
|
||||
$bday = "";
|
||||
@ -77,7 +77,7 @@
|
||||
$fields["url"] = $url;
|
||||
$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"));
|
||||
}
|
||||
|
@ -43,60 +43,57 @@
|
||||
"notes" => "notes"
|
||||
);
|
||||
$qfields = $this->stock_contact_fields + $extrafields;
|
||||
$fields = $this->read_single_entry($ab_id,$qfields);
|
||||
form("","edit.php","Edit",$fields[0]);
|
||||
$fields = addressbook_read_entry($ab_id,$qfields);
|
||||
addressbook_form("","edit.php","Edit",$fields[0]);
|
||||
} 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://") {
|
||||
$url = "";
|
||||
}
|
||||
if (! $bday_month && ! $bday_day && ! $bday_year) {
|
||||
$bday = "";
|
||||
} else {
|
||||
$bday = "$bday_month/$bday_day/$bday_year";
|
||||
}
|
||||
|
||||
$fields["org_name"] = $company;
|
||||
$fields["org_unit"] = $department;
|
||||
$fields["n_given"] = $firstname;
|
||||
$fields["n_family"] = $lastname;
|
||||
$fields["n_middle"] = $middle;
|
||||
$fields["n_prefix"] = $prefix;
|
||||
$fields["n_suffix"] = $suffix;
|
||||
if ($prefix) { $pspc = " "; }
|
||||
if ($middle) { $mspc = " "; }
|
||||
if ($suffix) { $sspc = " "; }
|
||||
$fields["fn"] = $prefix.$pspc.$firstname.$mspc.$middle.$mspc.$lastname.$sspc.$suffix;
|
||||
$fields["d_email"] = $email;
|
||||
$fields["d_emailtype"] = $email_type;
|
||||
$fields["title"] = $title;
|
||||
$fields["a_tel"] = $wphone;
|
||||
$fields["b_tel"] = $hphone;
|
||||
$fields["c_tel"] = $fax;
|
||||
$fields["pager"] = $pager;
|
||||
$fields["mphone"] = $mphone;
|
||||
$fields["ophone"] = $ophone;
|
||||
$fields["adr_street"] = $street;
|
||||
$fields["address2"] = $address2;
|
||||
$fields["adr_locality"] = $city;
|
||||
$fields["adr_region"] = $state;
|
||||
$fields["adr_postalcode"] = $zip;
|
||||
$fields["adr_countryname"] = $country;
|
||||
$fields["tz"] = $timezone;
|
||||
$fields["bday"] = $bday;
|
||||
$fields["url"] = $url;
|
||||
$fields["notes"] = $notes;
|
||||
|
||||
$this->update($ab_id,$phpgw_info["user"]["account_id"],$fields);
|
||||
|
||||
Header("Location: " . $phpgw->link("view.php","&ab_id=$ab_id&order=$order&sort=$sort&filter=$filter&start=$start"));
|
||||
$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();
|
||||
if ($url == "http://") {
|
||||
$url = "";
|
||||
}
|
||||
if (! $bday_month && ! $bday_day && ! $bday_year) {
|
||||
$bday = "";
|
||||
} else {
|
||||
$bday = "$bday_month/$bday_day/$bday_year";
|
||||
}
|
||||
|
||||
$fields["org_name"] = $company;
|
||||
$fields["org_unit"] = $department;
|
||||
$fields["n_given"] = $firstname;
|
||||
$fields["n_family"] = $lastname;
|
||||
$fields["n_middle"] = $middle;
|
||||
$fields["n_prefix"] = $prefix;
|
||||
$fields["n_suffix"] = $suffix;
|
||||
if ($prefix) { $pspc = " "; }
|
||||
if ($middle) { $mspc = " "; }
|
||||
if ($suffix) { $sspc = " "; }
|
||||
$fields["fn"] = $prefix.$pspc.$firstname.$mspc.$middle.$mspc.$lastname.$sspc.$suffix;
|
||||
$fields["d_email"] = $email;
|
||||
$fields["d_emailtype"] = $email_type;
|
||||
$fields["title"] = $title;
|
||||
$fields["a_tel"] = $wphone;
|
||||
$fields["b_tel"] = $hphone;
|
||||
$fields["c_tel"] = $fax;
|
||||
$fields["pager"] = $pager;
|
||||
$fields["mphone"] = $mphone;
|
||||
$fields["ophone"] = $ophone;
|
||||
$fields["adr_street"] = $street;
|
||||
$fields["address2"] = $address2;
|
||||
$fields["adr_locality"] = $city;
|
||||
$fields["adr_region"] = $state;
|
||||
$fields["adr_postalcode"] = $zip;
|
||||
$fields["adr_countryname"] = $country;
|
||||
$fields["tz"] = $timezone;
|
||||
$fields["bday"] = $bday;
|
||||
$fields["url"] = $url;
|
||||
$fields["notes"] = $notes;
|
||||
|
||||
// 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"));
|
||||
$phpgw->common->phpgw_exit();
|
||||
}
|
||||
|
||||
$t->set_var("ab_id",$ab_id);
|
||||
|
@ -71,8 +71,35 @@
|
||||
if ($column == $name[0]) { return $name[1]; }
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
#$t = new Template($phpgw_info["server"]["app_tpl"]);
|
||||
|
@ -67,7 +67,8 @@
|
||||
$qcols = $columns_to_display + array("access");
|
||||
|
||||
// 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"]);
|
||||
|
||||
@ -109,39 +110,32 @@
|
||||
|
||||
// Show the entries
|
||||
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,"");
|
||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||
$t->set_var(row_tr_color,$tr_color);
|
||||
$myid = $entries[$i]["id"];
|
||||
$myowner = $entries[$i]["owner"];
|
||||
$t->set_var(columns,"");
|
||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||
$t->set_var(row_tr_color,$tr_color);
|
||||
$myid = $entries[$i]["id"];
|
||||
$myowner = $entries[$i]["owner"];
|
||||
|
||||
while ($column = each($columns_to_display)) { // each entry column
|
||||
$ref=$data="";
|
||||
$coldata = $entries[$i][$column[0]];
|
||||
// Some fields require special formatting.
|
||||
if ($column[0] == "url") {
|
||||
$ref='<a href="'.$coldata.'" target="_new">';
|
||||
$data=$coldata.'</a>';
|
||||
} elseif ($column[0] == "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">';
|
||||
} 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.'">';
|
||||
}
|
||||
$data=$coldata."</a>";
|
||||
} else { // But these do not
|
||||
$ref=""; $data=$coldata;
|
||||
while ($column = each($columns_to_display)) { // each entry column
|
||||
$ref=$data="";
|
||||
$coldata = $entries[$i][$column[0]];
|
||||
// Some fields require special formatting.
|
||||
if ($column[0] == "url") {
|
||||
$ref='<a href="'.$coldata.'" target="_new">';
|
||||
$data=$coldata.'</a>';
|
||||
} elseif ($column[0] == "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">';
|
||||
} else {
|
||||
$ref='<a href="mailto:'.$coldata.'">';
|
||||
}
|
||||
$t->set_var(col_data,$ref.$data);
|
||||
$t->parse("columns","column",True);
|
||||
$data=$coldata."</a>";
|
||||
} else { // But these do not
|
||||
$ref=""; $data=$coldata;
|
||||
}
|
||||
$t->set_var(col_data,$ref.$data);
|
||||
$t->parse("columns","column",True);
|
||||
}
|
||||
|
||||
$t->set_var(row_view_link,$phpgw->link("view.php","ab_id=$myid&start=$start&order=$order&filter="
|
||||
. "$filter&query=$query&sort=$sort"));
|
||||
@ -153,7 +147,6 @@
|
||||
$t->parse("rows","row",True);
|
||||
$t->pparse("out","row");
|
||||
reset($columns_to_display); // If we don't reset it, our inside while won't loop
|
||||
}
|
||||
}
|
||||
|
||||
$t->pparse("out","addressbook_footer");
|
||||
|
@ -50,37 +50,34 @@
|
||||
"notes" => "notes",
|
||||
);
|
||||
$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"];
|
||||
|
||||
$rights = $phpgw->acl->get_rights($owner,$phpgw_info["flags"]["currentapp"]);
|
||||
if ( ($rights & PHPGW_ACL_READ) || ($owner == $phpgw_info["user"]["account_id"]) ) {
|
||||
|
||||
$view_header = "<p> <b>" . lang("Address book - view") . "</b><hr><p>";
|
||||
$view_header .= '<table border="0" cellspacing="2" cellpadding="2" width="80%" align="center">';
|
||||
$view_header = "<p> <b>" . lang("Address book - view") . "</b><hr><p>";
|
||||
$view_header .= '<table border="0" cellspacing="2" cellpadding="2" width="80%" align="center">';
|
||||
|
||||
while ($column = each($columns_to_display)) { // each entry column
|
||||
$columns_html .= "<tr><td><b>" . lang(display_name($colname[$column[0]])) . "</b>:</td>";
|
||||
$ref=$data="";
|
||||
$coldata = $fields[0][$column[0]];
|
||||
// Some fields require special formatting.
|
||||
if ($column[0] == "url") {
|
||||
$ref='<a href="'.$coldata.'" target="_new">';
|
||||
$data=$coldata.'</a>';
|
||||
} elseif ($column[0] == "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">';
|
||||
} else {
|
||||
$ref='<a href="mailto:'.$coldata.'">';
|
||||
}
|
||||
$data=$coldata."</a>";
|
||||
} else { // But these do not
|
||||
$ref=""; $data=$coldata;
|
||||
while ($column = each($columns_to_display)) { // each entry column
|
||||
$columns_html .= "<tr><td><b>" . lang(display_name($colname[$column[0]])) . "</b>:</td>";
|
||||
$ref=$data="";
|
||||
$coldata = $fields[0][$column[0]];
|
||||
// Some fields require special formatting.
|
||||
if ($column[0] == "url") {
|
||||
$ref='<a href="'.$coldata.'" target="_new">';
|
||||
$data=$coldata.'</a>';
|
||||
} elseif ($column[0] == "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">';
|
||||
} else {
|
||||
$ref='<a href="mailto:'.$coldata.'">';
|
||||
}
|
||||
$columns_html .= "<td>" . $ref . $data . "</td>";
|
||||
$data=$coldata."</a>";
|
||||
} else { // But these do not
|
||||
$ref=""; $data=$coldata;
|
||||
}
|
||||
$columns_html .= "<td>" . $ref . $data . "</td>";
|
||||
}
|
||||
|
||||
/*
|
||||
if ($access == "private") {
|
||||
@ -91,38 +88,34 @@
|
||||
$access_link ="";
|
||||
}
|
||||
*/
|
||||
$columns_html .= '<tr><td colspan="4"> </td></tr>'
|
||||
$columns_html .= '<tr><td colspan="4"> </td></tr>'
|
||||
. '<tr><td><b>' . lang("Record owner") . '</b></td><td>'
|
||||
. $phpgw->common->grab_owner_name($owner) . '</td><td><b>'
|
||||
. $access_link . '</b></td><td></table>';
|
||||
|
||||
$editlink = $phpgw->common->check_owner($owner,"edit.php",lang("edit"),"ab_id=" . $ab_id . "&start=".$start."&sort=".$sort."&order=".$order);
|
||||
$vcardlink = '<form action="'.$phpgw->link("vcardout.php","ab_id=$ab_id&order=$order&start=$start&filter=$filter&query=$query&sort=$sort").'">';
|
||||
$donelink = '<form action="'.$phpgw->link("index.php","order=$order&start=$start&filter=$filter&query=$query&sort=$sort").'">';
|
||||
|
||||
$t->set_var("access_link",$access_link);
|
||||
$t->set_var("ab_id",$ab_id);
|
||||
$t->set_var("sort",$sort);
|
||||
$t->set_var("order",$order);
|
||||
$t->set_var("filter",$filter);
|
||||
$t->set_var("start",$start);
|
||||
$t->set_var("view_header",$view_header);
|
||||
$t->set_var("cols",$columns_html);
|
||||
$t->set_var("lang_ok",lang("ok"));
|
||||
$t->set_var("lang_done",lang("done"));
|
||||
$t->set_var("lang_edit",lang("edit"));
|
||||
$t->set_var("lang_submit",lang("submit"));
|
||||
$t->set_var("lang_vcard",lang("vcard"));
|
||||
$t->set_var("done_link",$donelink);
|
||||
$t->set_var("edit_link",$editlink);
|
||||
$t->set_var("vcard_link",$vcardlink);
|
||||
|
||||
$t->parse("out","view");
|
||||
$t->pparse("out","view");
|
||||
$editlink = $phpgw->common->check_owner($owner,"edit.php",lang("edit"),"ab_id=" . $ab_id . "&start=".$start."&sort=".$sort."&order=".$order);
|
||||
$vcardlink = '<form action="'.$phpgw->link("vcardout.php","ab_id=$ab_id&order=$order&start=$start&filter=$filter&query=$query&sort=$sort").'">';
|
||||
$donelink = '<form action="'.$phpgw->link("index.php","order=$order&start=$start&filter=$filter&query=$query&sort=$sort").'">';
|
||||
|
||||
$t->set_var("access_link",$access_link);
|
||||
$t->set_var("ab_id",$ab_id);
|
||||
$t->set_var("sort",$sort);
|
||||
$t->set_var("order",$order);
|
||||
$t->set_var("filter",$filter);
|
||||
$t->set_var("start",$start);
|
||||
$t->set_var("view_header",$view_header);
|
||||
$t->set_var("cols",$columns_html);
|
||||
$t->set_var("lang_ok",lang("ok"));
|
||||
$t->set_var("lang_done",lang("done"));
|
||||
$t->set_var("lang_edit",lang("edit"));
|
||||
$t->set_var("lang_submit",lang("submit"));
|
||||
$t->set_var("lang_vcard",lang("vcard"));
|
||||
$t->set_var("done_link",$donelink);
|
||||
$t->set_var("edit_link",$editlink);
|
||||
$t->set_var("vcard_link",$vcardlink);
|
||||
|
||||
$t->parse("out","view");
|
||||
$t->pparse("out","view");
|
||||
|
||||
$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();
|
||||
}
|
||||
$phpgw->common->phpgw_footer();
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user