From 648878fb3a0430506c3b0f5a92bc7699b7ceb3ed Mon Sep 17 00:00:00 2001 From: deva Date: Sun, 26 Oct 2008 13:24:26 +0000 Subject: Hide unused fields when showing a contact. Add number of contacts in groups and number of hidden contacts. --- forum/utils/addressbook.php | 5 +++++ forum/utils/contacts.php | 40 +++++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 15 deletions(-) (limited to 'forum') diff --git a/forum/utils/addressbook.php b/forum/utils/addressbook.php index c3c5d65..fb34156 100644 --- a/forum/utils/addressbook.php +++ b/forum/utils/addressbook.php @@ -5,6 +5,7 @@ function form($cid, $posturl, $buttontext, $name = "", + $co = "", $address = "", $city = "", $country = "", @@ -21,6 +22,7 @@ function form($cid,
Name:
+ c/o:
Address:
City:
Country:
@@ -51,6 +53,7 @@ if($action == "addgroup" && $gid) { elseif($action == "addcontact" && $gid && $cid) { $contact = new Contact($cid, $name, + $co, $address, $city, $country, @@ -74,6 +77,7 @@ elseif($action =="editcontact" && $cid) { "?mode=addressbook&action=updatecontact".$gid, "Update contact", $contact->name, + $contact->co, $contact->address, $contact->city, $contact->country, @@ -91,6 +95,7 @@ elseif($action == "updatecontact" && $cid) { $contact = $contacts->getContact($cid); $contact->name = $name; + $contact->co = $co; $contact->address = $address; $contact->city = $city; $contact->country = $country; diff --git a/forum/utils/contacts.php b/forum/utils/contacts.php index bd59d16..a83e3f5 100644 --- a/forum/utils/contacts.php +++ b/forum/utils/contacts.php @@ -6,6 +6,7 @@ include_once($UTIL_DIR . "/parser.php"); class Contact { public $cid; public $name; + public $co; public $address; public $city; public $country; @@ -20,7 +21,8 @@ class Contact { public function write($fp) { fwrite($fp, " cid, ENT_QUOTES, "UTF-8") . "\"\n"); - fwrite($fp, " name=\"" . convert_xml($this->name, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " name=\"" . convert_xml($this->name, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " co=\"" . convert_xml($this->co, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " address=\"" . convert_xml($this->address, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " city=\"" . convert_xml($this->city, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " country=\"" . convert_xml($this->country, ENT_QUOTES, "UTF-8") . "\"\n"); @@ -38,18 +40,19 @@ class Contact { public function show() { echo "

\n"; - // echo "\tcid: " . $this->cid . "
"; - echo "\tname: " . $this->name . "
"; - echo "\taddress: " . $this->address . "
"; - echo "\tcity: " . $this->city . "
"; - echo "\tcountry: " . $this->country . "
"; - echo "\tphone: " . $this->phone . "
"; - echo "\tphone2: " . $this->phone2 . "
"; - echo "\temail: email . "\">" . $this->email . "
"; - echo "\temail2: email2 . "\">" . $this->email2 . "
"; - echo "\turl: url . "\">" . $this->url . "
"; - echo "\turl2: url2 . "\">" . $this->url2 . "
"; - echo "\tnotes: " . parse($this->notes) . "
"; + // echo "\tcid: " . $this->cid . "
\n"; + echo "\tName: " . $this->name . "
\n"; + if($this->co) echo "\tc/o: " . $this->co . "
\n"; + if($this->address) echo "\tAddress: " . $this->address . "
\n"; + if($this->city) echo "\tCity: " . $this->city . "
\n"; + if($this->country) echo "\tCountry: " . $this->country . "
\n"; + if($this->phone) echo "\tPhone: " . $this->phone . "
\n"; + if($this->phone2) echo "\tPhone2: " . $this->phone2 . "
\n"; + if($this->email) echo "\tEmail: email . "\">" . $this->email . "
\n"; + if($this->email2) echo "\tEmail2: email2 . "\">" . $this->email2 . "
\n"; + if($this->url) echo "\tURL: url . "\">" . $this->url . "
\n"; + if($this->url2) echo "\tURL2: url2 . "\">" . $this->url2 . "
\n"; + if($this->notes) echo "\tNotes:
\n" . parse($this->notes) . "
\n"; echo "\tcid . "\">Edit\n"; echo "

\n"; } @@ -59,10 +62,11 @@ class Contact { echo ""; } - function Contact($cid, $name, $address, $city, $country, $phone, $phone2, $email, $email2, $url, $url2, $essential, $notes) + function Contact($cid, $name, $co, $address, $city, $country, $phone, $phone2, $email, $email2, $url, $url2, $essential, $notes) { $this->cid = $cid; $this->name = $name; + $this->co = $co; $this->address = $address; $this->city = $city; $this->country = $country; @@ -126,8 +130,13 @@ class ContactGroup { public function showshort() { + $ness = 0; + foreach($this->contacts as $contact) { + if($contact->essential) $ness += 1; + } + echo "
\n"; - echo " \n"; + echo "
gid . "\">" . $this->name . " - ".sizeof($this->contacts)." contacts (". sprintf("%d", sizeof($this->contacts) - $ness)." hidden)
\n"; echo "
\n"; foreach($this->contacts as $contact) { if($contact->essential) $contact->showshort(); @@ -229,6 +238,7 @@ class Contacts { foreach ($contacts as $c) { $contact = new Contact($c->getAttribute('cid'), $c->getAttribute('name'), + $c->getAttribute('co'), $c->getAttribute('address'), $c->getAttribute('city'), $c->getAttribute('country'), -- cgit v1.2.3