From: <dts...@us...> - 2003-05-29 16:56:27
|
Update of /cvsroot/phpwebsite-comm/modules/contacts/class In directory sc8-pr-cvs1:/tmp/cvs-serv17690/class Modified Files: Contact.php Manager.php Log Message: Some cosmetic changes and starting to flesh out the contact Index: Contact.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/contacts/class/Contact.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Contact.php 28 May 2003 18:01:11 -0000 1.1 --- Contact.php 29 May 2003 16:56:23 -0000 1.2 *************** *** 7,10 **** --- 7,270 ---- class CONTACTS_Contact extends PHPWS_Item { + /** + * The given (first) name of the contact + * + * @var string + * @access private + */ + var $_givenname = NULL; + + + /** + * The middle name of the contact + * + * @var string + * @access private + */ + var $_middlename = NULL; + + + /** + * The family (last) name of the contact + * + * @var string + * @access private + */ + var $_familyname = NULL; + + + /** + * The prefix (Dr. , Mr. , Fr. , etc) of the contact + * + * @var string + * @access private + */ + var $_prefix = NULL; + + + /** + * The suffix (Jr. , Sr. , III, M.D., PhD) of the contact + * + * @var string + * @access private + */ + var $_suffix = NULL; + + + /** + * The email address of the contact + * + * @var string + * @access private + */ + var $_email = NULL; + + + /** + * The website URL of the contact + * + * @var string + * @access private + */ + var $_website = NULL; + + + /** + * The birthday of the contact + * + * @var string + * @access private + */ + var $_birthday = NULL; + + + /** + * The organization (workplace) of the contact + * + * @var string + * @access private + */ + var $_organization = NULL; + + + /** + * The unit (division/department) within the + * organization (workplace) of the contact + * + * @var string + * @access private + */ + var $_orgunit = NULL; + + + /** + * The title/role of the contact + * + * @var string + * @access private + */ + var $_title = NULL; + + + + function CONTACTS_Contact($CONTACT_ID = NULL) { + /* These vars are excluded on commit() */ + // $exclude = array(); + // $this->addExclude($exclude); + + $this->setTable("mod_contacts_contacts"); + + if(isset($CONTACT_ID)) { + $this->setId($CONTACT_ID); + $this->init(); + } + }// END FUNC CONTACTS_Contact + + + function _edit() { + // Need to see if the userid matches the object owner + if(($_SESSION["OBJ_user"]->username != $this->getOwner()) || !$_SESSION["OBJ_user"]->allow_access("contacts","edit_contacts")) { + $message = $_SESSION["translate"]->it("Access to edit contact was denied due to lack of proper permissions."); + $error = new PHWPS_Error("contacts", "CONTACTS_Contact::_edit()", $message, "exit", 1); + $error->message(); + return FALSE; + } + + + /* Create form */ + $form = new EZform("CONTACTS_Contact_edit"); + + /* Contact Name */ + $form->add("Contact_contact", "text", $this->_contact); + $form->setSize("Contact_contact", 33); + $form->setTab("Contact_contact", 1); + + /* Contact Abbreviation */ + $form->add("Contact_code", "text", $this->_code); + $form->setSize("Contact_code", 5); + $form->setTab("Contact_code", 2); + + /* Save Button */ + $form->add("Contact_save", "submit", $_SESSION["translate"]->it("Save")); + $form->setTab("Contact_save", 3); + + /* Module Information */ + $form->add("module", "hidden", "contacts"); + $form->add("CONTACTS_Contact_OP", "hidden", "save"); + + $tags = array(); + $tags = $form->getTemplate(); + + $tags["CONTACT_TEXT"] = $_SESSION["translate"]->it("Contact"); + $tags["CODE_TEXT"] = $_SESSION["translate"]->it("Abbreviation"); + + return $GLOBALS["core"]->processTemplate($tags, "contacts", "edit_contacts.tpl"); + + }// END FUNC _edit + + + function _save() { + if(!$_SESSION["OBJ_user"]->allow_access("contacts", "edit_contacts")) { + $message = $_SESSION["translate"]->it("Access to save contact was denied due to lack of proper permissions."); + $error = new PHWPS_Error("contacts", "CONTACTS_Contact::_save()", $message, "exit", 1); + $error->message(); + return FALSE; + } + + if(isset($_REQUEST["Contact_contact"])) + $this->_contact = $_REQUEST["Contact_contact"]; + + $this->setLabel($this->_contact); + + if(isset($_REQUEST["Contact_code"])) + $this->_code = $_REQUEST["Contact_code"]; + + $error = $this->commit(); + + if(PHPWS_Error::isError($error)) { + $message = $_SESSION["translate"]->it("The contact could not be saved to the database."); + $error = new PHPWS_Error("contacts", $message, "continue", 0); + $error->message("CNT_contacts"); + + $_REQUEST["CONTACTS_Contact_OP"] = "edit"; + $this->action(); + return; + } else { + $GLOBALS["CNT_contacts"]["content"] .= $_SESSION["translate"]->it("The contact was successfully saved.") . "<br />\n"; + $_REQUEST["CONTACTS_MAN_OP"] = "listcontacts"; + $_SESSION["CONTACTS_Manager"]->action(); + } + }// END FUNC _save + + + function _delete() { + if(!$_SESSION["OBJ_user"]->allow_access("contacts", "delete_contacts")) { + $message = $_SESSION["translate"]->it("Access to delete contact was denied due to lack of proper permissions."); + $error = new PHWPS_Error("contacts", "CONTACTS_Contact::_delete()", $message, "exit", 1); + $error->message(); + return FALSE; + } + + if(isset($_REQUEST["Contact_yes"])) { + $this->kill(); + $message = $_SESSION["translate"]->it("The contact [var1] was successfully deleted from the database.", "<b><i>" . $this->getLabel() . "</i></b>"); + $_SESSION["CONTACTS_Manager"]->message = new PHPWS_Message($message, "CNT_contacts"); + $_REQUEST["CONTACTS_MAN_OP"] = "listcontacts"; + $_SESSION["CONTACTS_Manager"]->action(); + + } elseif(isset($_REQUEST["Contact_no"])) { + $message = $_SESSION["translate"]->it("No contact was deleted from the database."); + $_SESSION["CONTACTS_Manager"]->message = new PHPWS_Message($message, "CNT_contacts"); + $_REQUEST["CONTACTS_MAN_OP"] = "listcontacts"; + $_REQUEST["CONTACTS_Manager"]->action(); + + } else { + $title = $_SESSION["translate"]->it("Delete Contact Confirmation"); + + $form = new EZform("CONTACTS_Contact_delete"); + $form->add("module", "hidden", "contacts"); + $form->add("CONTACTS_Contact_OP", "hidden", "delete"); + + $form->add("Contact_yes", "submit", $_SESSION["translate"]->it("Yes")); + $form->add("Contact_no", "submit", $_SESSION["translate"]->it("No")); + + $tags = array(); + $tags = $form->getTemplate(); + $tags["MESSAGE"] = $_SESSION["translate"]->it("Are you sure you want to delete this contact?"); + + $content = $GLOBALS["core"]->processTemplate($tags, "contacts", "delete_contact.tpl"); + $_SESSION["OBJ_layout"]->popbox($title, $content, NULL, "CNT_contacts"); + } + + }// END FUNC _delete + + + function action() { + switch($_REQUEST["CONTACTS_Contact_OP"]) { + case "edit": + $title = $_SESSION["translate"]->it("Edit Contact Information"); + $content = $this->_edit(); + break; + + case "save": + $this->_save(); + break; + + case "delete": + $this->_delete(); + break; + + default: + $title = "NO OP"; + $content = "This function is not yet implemented."; + } + + if(isset($content)) { + $GLOBALS["CNT_contacts"]["title"] = $title; + $GLOBALS["CNT_contacts"]["content"] = $content; + } + }// END FUNC action + + }// END CLASS CONTACTS_Contact Index: Manager.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/contacts/class/Manager.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Manager.php 28 May 2003 21:31:11 -0000 1.4 --- Manager.php 29 May 2003 16:56:23 -0000 1.5 *************** *** 43,46 **** --- 43,47 ---- $GLOBALS["CNT_contacts"]["title"] = $_SESSION["translate"]->it("Contacts"); $GLOBALS["CNT_contacts"]["content"] .= $this->_menu(); + $GLOBALS["CNT_contacts"]["content"] .= "<a href=\"index.php?module=contacts&CONTACTS_MAN_OP=edit\">" . $_SESSION["translate"]->it("Add / Edit My Contact Information") . "</a>"; $GLOBALS["CNT_contacts"]["content"] .= $this->getList("contacts"); }// END FUNC _list *************** *** 80,85 **** --- 81,94 ---- + /* function _new() { $this->contact = new CONTACTS_Contact; + $_REQUEST["CONTACTS_Contact_OP"] = "edit"; + }// END FUNC _new + */ + + + function _edit() { + $this->contact = new CONTACTS_Contact($_REQUEST["PHPWS_MAN_ITEMS"][0]); $_REQUEST["CONTACTS_Contact_OP"] = "edit"; }// END FUNC _new |