summaryrefslogtreecommitdiff
path: root/forum/utils/addressbook.php
diff options
context:
space:
mode:
Diffstat (limited to 'forum/utils/addressbook.php')
-rw-r--r--forum/utils/addressbook.php279
1 files changed, 147 insertions, 132 deletions
diff --git a/forum/utils/addressbook.php b/forum/utils/addressbook.php
index 20548ce..240831f 100644
--- a/forum/utils/addressbook.php
+++ b/forum/utils/addressbook.php
@@ -1,5 +1,4 @@
<?php
-include_once($UTIL_DIR . "/contacts.php");
function form($cid,
$posturl,
@@ -18,138 +17,154 @@ function form($cid,
$essential = "on",
$notes = "")
{
-?>
-<form method="post" action="<?php echo $posturl; ?>">
- <input type="hidden" name="cid" value="<?php echo $cid;?>">
- Name: <input name="name" value="<?php echo $name;?>"><br/>
- c/o: <input name="co" value="<?php echo $co;?>"><br/>
- Address: <input name="address" value="<?php echo $address;?>"><br/>
- City: <input name="city" value="<?php echo $city;?>"><br/>
- Country: <input name="country" value="<?php echo $country;?>"><br/>
- Phone: <input name="phone" value="<?php echo $phone;?>"><br/>
- Phone2: <input name="phone2" value="<?php echo $phone2;?>"><br/>
- Email: <input name="email" value="<?php echo $email;?>"><br/>
- Email2: <input name="email2" value="<?php echo $email2;?>"><br/>
- URL: <input name="url" value="<?php echo $url;?>"><br/>
- URL2: <input name="url2" value="<?php echo $url2;?>"><br/>
- Essential: <input type="checkbox" name="essential"<?php if($essential == "on") echo " checked";?>> (show on frontpage)<br/>
- Notes:<br/>
- <textarea name="notes" cols="60" rows="10"><?php echo $notes;?></textarea><br/>
- <button type="submit"><?php echo $buttontext; ?></button>
-</form>
-<?php
-}
-
-
-$name = stripslashes($name);
-$co = stripslashes($co);
-$address = stripslashes($address);
-$city = stripslashes($city);
-$country = stripslashes($country);
-$phone = stripslashes($phone);
-$phone2 = stripslashes($phone2);
-$email = stripslashes($email);
-$email2 = stripslashes($email2);
-$url = stripslashes($url);
-$url2 = stripslashes($url2);
-$notes = stripslashes($notes);
-
-$contacts = new Contacts($DATA_DIR . "/contacts.xml");
-
-if($action == "addgroup" && $gid) {
- $contactgroup = new ContactGroup($gid, $name);
- $contacts->add($contactgroup);
- $contacts->write();
- $gid = 0;
-}
-
-elseif($action == "addcontact" && $gid && $cid) {
- $contact = new Contact($cid,
- $name,
- $co,
- $address,
- $city,
- $country,
- $phone,
- $phone2,
- $email,
- $email2,
- $url,
- $url2,
- $essential,
- $notes);
- $contactgroup = $contacts->getContactGroup($gid);
- $contactgroup->add($contact);
- $contacts->write();
- $cid = 0;
-}
-
-elseif($action =="editcontact" && $cid) {
- $contact = $contacts->getContact($cid);
- form($contact->cid,
- "?mode=addressbook&amp;action=updatecontact".$gid,
- "Update contact",
- $contact->name,
- $contact->co,
- $contact->address,
- $contact->city,
- $contact->country,
- $contact->phone,
- $contact->phone2,
- $contact->email,
- $contact->email2,
- $contact->url,
- $contact->url2,
- $contact->essential,
- $contact->notes);
+ $str = "";
+
+ $str .= "<form method=\"post\" action=\"" . $posturl . "\">\n";
+ $str .= " <input type=\"hidden\" name=\"cid\" value=\"". $cid . "\">\n";
+ $str .= " Name: <input name=\"name\" value=\"" . $name . "\"><br/>\n";
+ $str .= " c/o: <input name=\"co\" value=\"" . $co . "\"><br/>\n";
+ $str .= " Address: <input name=\"address\" value=\"" . $address . "\"><br/>\n";
+ $str .= " City: <input name=\"city\" value=\"" . $city . "\"><br/>\n";
+ $str .= " Country: <input name=\"country\" value=\"" . $country . "\"><br/>\n";
+ $str .= " Phone: <input name=\"phone\" value=\"" . $phone . "\"><br/>\n";
+ $str .= " Phone2: <input name=\"phone2\" value=\"" . $phone2 . "\"><br/>\n";
+ $str .= " Email: <input name=\"email\" value=\"" . $email . "\"><br/>\n";
+ $str .= " Email2: <input name=\"email2\" value=\"" . $email2 . "\"><br/>\n";
+ $str .= " URL: <input name=\"url\" value=\"" . $url . "\"><br/>\n";
+ $str .= " URL2: <input name=\"url2\" value=\"" . $url2 . "\"><br/>\n";
+ $ess = "";
+ if($essential == "on") $ess = " checked";
+ $str .= " Essential: <input type=\"checkbox\" name=\"essential\"" .
+ $ess . "> (show on frontpage)<br/>\n";
+ $str .= " Notes:<br/>\n";
+ $str .= " <textarea name=\"notes\" cols=\"60\" rows=\"10\">" .
+ $notes . "</textarea><br/>\n";
+ $str .= " <button type=\"submit\">" . $buttontext . "</button>\n";
+ $str .= "</form>\n";
+
+ return $str;
}
-elseif($action == "updatecontact" && $cid) {
- $contact = $contacts->getContact($cid);
-
- $contact->name = $name;
- $contact->co = $co;
- $contact->address = $address;
- $contact->city = $city;
- $contact->country = $country;
- $contact->phone = $phone;
- $contact->phone2 = $phone2;
- $contact->email = $email;
- $contact->email2 = $email2;
- $contact->url = $url;
- $contact->url2 = $url2;
- $contact->essential = $essential;
- $contact->notes = $notes;
-
- $contacts->write();
-
- $contact->show();
-}
-
-elseif($cid) {
- $contact = $contacts->getContact($cid);
- $contact->show();
-}
-
-elseif($gid) {
- $contactgroup = $contacts->getContactGroup($gid);
- $contactgroup->show();
-
- form($contacts->getNextCID(),
- "?mode=addressbook&amp;action=addcontact&amp;gid=".$gid,
- "Add contact");
-
-} else {
- $contacts->show();
- if($current_user->uid == 0) {
-?>
-<form method="post" action="?mode=addressbook&amp;action=addgroup">
- <input type="hidden" name="gid" value="<?php echo $contacts->getNextGID();?>">
- Name: <input name="name" value="">
- <button type="submit">Add group</button>
-</form>
-<?php
- }
+function addressbook()
+{
+ global $UTIL_DIR, $DATA_DIR, $GLOBALS, $gid, $cid, $smileys;
+
+ include_once($UTIL_DIR . "/contacts.php");
+
+ $str = "";
+
+ $name = stripslashes($GLOBALS['name']);
+ $co = stripslashes($GLOBALS['co']);
+ $address = stripslashes($GLOBALS['address']);
+ $city = stripslashes($GLOBALS['city']);
+ $country = stripslashes($GLOBALS['country']);
+ $phone = stripslashes($GLOBALS['phone']);
+ $phone2 = stripslashes($GLOBALS['phone2']);
+ $email = stripslashes($GLOBALS['email']);
+ $email2 = stripslashes($GLOBALS['email2']);
+ $url = stripslashes($GLOBALS['url']);
+ $url2 = stripslashes($GLOBALS['url2']);
+ $notes = stripslashes($GLOBALS['notes']);
+
+ $contacts = new Contacts($DATA_DIR . "/contacts.xml");
+
+ if($GLOBALS['action'] == "addgroup" && $gid) {
+ $contactgroup = new ContactGroup($gid, $name);
+ $contacts->add($contactgroup);
+ $contacts->write();
+ $gid = 0;
+ }
+
+ elseif($GLOBALS['action'] == "addcontact" && $gid && $cid) {
+ $contact = new Contact($cid,
+ $name,
+ $co,
+ $address,
+ $city,
+ $country,
+ $phone,
+ $phone2,
+ $email,
+ $email2,
+ $url,
+ $url2,
+ $essential,
+ $notes);
+ $contactgroup = $contacts->getContactGroup($gid);
+ $contactgroup->add($contact);
+ $contacts->write();
+ $cid = 0;
+ }
+
+ elseif($GLOBALS['action'] =="editcontact" && $cid) {
+ $contact = $contacts->getContact($cid);
+ $str .= form($contact->cid,
+ "?mode=addressbook&amp;action=updatecontact".$gid,
+ "Update contact",
+ $contact->name,
+ $contact->co,
+ $contact->address,
+ $contact->city,
+ $contact->country,
+ $contact->phone,
+ $contact->phone2,
+ $contact->email,
+ $contact->email2,
+ $contact->url,
+ $contact->url2,
+ $contact->essential,
+ $contact->notes);
+ }
+
+ elseif($GLOBALS['action'] == "updatecontact" && $cid) {
+ $contact = $contacts->getContact($cid);
+
+ $contact->name = $name;
+ $contact->co = $co;
+ $contact->address = $address;
+ $contact->city = $city;
+ $contact->country = $country;
+ $contact->phone = $phone;
+ $contact->phone2 = $phone2;
+ $contact->email = $email;
+ $contact->email2 = $email2;
+ $contact->url = $url;
+ $contact->url2 = $url2;
+ $contact->essential = $essential;
+ $contact->notes = $notes;
+
+ $contacts->write();
+
+ $str .= $contact->show();
+ }
+
+ elseif($cid) {
+ $contact = $contacts->getContact($cid);
+ $str .= $contact->show();
+ }
+
+ elseif($gid) {
+ $contactgroup = $contacts->getContactGroup($gid);
+ $str .= $contactgroup->show();
+
+ $str .= form($contacts->getNextCID(),
+ "?mode=addressbook&amp;action=addcontact&amp;gid=".$gid,
+ "Add contact");
+
+ } else {
+ $str .= $contacts->show();
+ if($current_user->uid == 0) {
+
+ $str .= "<form method=\"post\" action=\"?mode=addressbook&amp;action=addgroup\">\n";
+ $str .= " <input type=\"hidden\" name=\"gid\" value=\"" .
+ sprintf("%d", $contacts->getNextGID()) . "\">\n";
+ $str .= " Name: <input name=\"name\" value=\"\">\n";
+ $str .= " <button type=\"submit\">Add group</button>\n";
+ $str .= "</form>\n";
+
+ }
+ }
+
+ return $str;
}
-
?> \ No newline at end of file