*
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
// Perform acl check, set $rights
if(!isset($owner)) { $owner = 0; }
$grants = $phpgw->acl->get_grants('addressbook');
if(!isset($owner) || !$owner) {
$owner = $phpgw_info['user']['account_id'];
$rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
} else {
if($grants[$owner]) {
$rights = $grants[$owner];
if (!($rights & PHPGW_ACL_READ)) {
$owner = $phpgw_info['user']['account_id'];
$rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
}
}
}
// this cleans up the fieldnames for display
function display_name($column) {
$abc = array(
"fn" => "full name", //'firstname lastname'
"sound" => "",
"org_name" => "company name", //company
"org_unit" => "department", //division
"title" => "title",
"n_prefix" => "prefix",
"n_given" => "first name", //firstname
"n_middle" => "middle name",
"n_family" => "last name", //lastname
"n_suffix" => "suffix",
"label" => "label",
"adr_street" => "street",
"adr_locality" => "city", //city
"adr_region" => "state", //state
"adr_postalcode" => "zip code", //zip
"adr_countryname" => "country",
"adr_work" => "", //yn
"adr_home" => "", //yn
"adr_parcel" => "", //yn
"adr_postal" => "", //yn
"tz" => "time zone",
"geo" => "geo",
"a_tel" => "home phone",
"a_tel_work" => "", //yn
"a_tel_home" => "", //yn
"a_tel_voice" => "", //yn
"a_tel_msg" => "", //yn
"a_tel_fax" => "", //yn
"a_tel_prefer" => "", //yn
"b_tel" => "work phone",
"b_tel_work" => "", //yn
"b_tel_home" => "", //yn
"b_tel_voice" => "", //yn
"b_tel_msg" => "", //yn
"b_tel_fax" => "", //yn
"b_tel_prefer" => "", //yn
"c_tel" => "fax",
"c_tel_work" => "", //yn
"c_tel_home" => "", //yn
"c_tel_voice" => "", //yn
"c_tel_msg" => "", //yn
"c_tel_fax" => "", //yn
"c_tel_prefer" => "", //yn
"d_email" => "email",
"d_emailtype" => "email type", //'INTERNET','CompuServe',etc...
"d_email_work" => "", //yn
"d_email_home" => "", //yn
//"access" => "access"
"pager" => "Pager",
"mphone" => "mobile phone",
"ophone" => "other phone",
"address2" => "address2",
"bday" => "birthday",
"url" => "url",
"notes" => "notes"
);
while($name = each($abc) ) {
if ($column == $name[0]) { return lang($name[1]); }
}
}
function addressbook_read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order,$userid="") {
global $this,$rights;
$readrights = $rights & PHPGW_ACL_READ;
$entries = $this->read($start,$offset,$qcols,$query,$qfilter,$sort,$order,$readrights);
return $entries;
}
function addressbook_read_entry($id,$fields,$userid="") {
global $this,$rights;
if ($rights & PHPGW_ACL_READ) {
$entry = $this->read_single_entry($id,$fields);
return $entry;
} else {
$rtrn = array("No access" => "No access");
return $rtrn;
}
}
function addressbook_add_entry($userid,$fields) {
global $this,$rights;
if ($rights & PHPGW_ACL_ADD) {
$this->add($userid,$fields);
}
return;
}
function addressbook_get_lastid() {
global $this;
$entry = $this->read_last_entry();
$ab_id = $entry[0]["id"];
return $ab_id;
}
function addressbook_update_entry($id,$userid,$fields) {
global $this,$rights;
if ($rights & PHPGW_ACL_EDIT) {
$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"]);
$t = new Template($phpgw->common->get_tpl_dir("addressbook"));
$t->set_file(array( "form" => "form.tpl"));
$email = $fields["d_email"];
$emailtype = $fields["d_emailtype"];
$firstname = $fields["n_given"];
$middle = $fields["n_middle"];
$prefix = $fields["n_prefix"];
$suffix = $fields["n_suffix"];
$lastname = $fields["n_family"];
$title = $fields["title"];
$hphone = $fields["a_tel"];
$wphone = $fields["b_tel"];
$fax = $fields["c_tel"];
$pager = $fields["pager"];
$mphone = $fields["mphone"];
$ophone = $fields["ophone"];
$street = $fields["adr_street"];
$address2 = $fields["address2"];
$city = $fields["adr_locality"];
$state = $fields["adr_region"];
$zip = $fields["adr_postalcode"];
$country = $fields["adr_countryname"];
$timezone = $fields["tz"];
$bday = $fields["bday"];
$notes = stripslashes($fields["notes"]);
$company = $fields["org_name"];
$department = $fields["org_unit"];
$url = $fields["url"];
//$access = $fields["access"];
if ($format != "view") {
$email = "";
$firstname = "";
$lastname = "";
$middle = "";
$prefix = "";
$suffix = "";
$title = "";
$hphone = "";
$wphone = "";
$fax = "";
$pager = "";
$mphone = "";
$ophone = "";
$street = "";
$address2 = "";
$city = "";
$state = "";
$zip = "";
$country = "";
/*
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company = '";
} else { */
$company = "";
$department = "";
/* } */
if (strlen($bday) > 2) {
list( $month, $day, $year ) = split( '/', $bday );
$temp_month[$month] = "SELECTED";
$bday_month = "";
$bday_day = '';
$bday_year = '';
} else {
$bday_month = "";
$bday_day = '';
$bday_year = '';
}
$time_zone = "";
$notes = '';
} else {
$notes = "
";
if ($bday == "//")
$bday = "";
/*
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company = $company_name;
} else { */
$company = $company;
/* } */
}
if ($action) {
echo "