PHP Classes

File: update.php

Recommend this page to a friend!
  Packages of Michael J. Fuhrman   People   update.php   Download  
File: update.php
Role: Example script
Content type: text/plain
Description: Updates the Person data captured by the Person Panel
Class: People
Manage user contacts
Author: By
Last change:
Date: 16 years ago
Size: 4,036 bytes
 

 

Contents

Class file image Download
<?
/*    =======================================
    Copyright 1998 - 2010 - E Net Arch
    This program is distributed under the terms of the GNU
    General Public License (or the Lesser GPL).
    ======================================= */

function dirPath() { return ("../../"); }

Include_Once (dirPath() . "Shared/Classes/Ladder/Ladder_Ladder.cls");
Include_Once ("Panel_Panel.cls");
Include_Once ("Common_People.cls");
Include_Once ("Common_Person.cls");
Include_Once ("Common_Name.cls");
Include_Once ("Common_Address.cls");
Include_Once ("Common_Contacts.cls");
Include_Once ("Common_Contact.cls");
Include_Once ("Common_ContactType.cls");
Include_Once ("Common_ContactMethod.cls");
Include_Once ("Common_ContactTypes.cls");
Include_Once ("Common_ContactTypes_Ref.cls");
Include_Once ("Panel_Person.cls");
Include_Once ("Panel_Name.cls");
Include_Once ("Panel_Address.cls");
Include_Once ("Panel_Contacts.cls");
Include_Once ("Panel_Contact.cls");
Include_Once ("Panel_ContactTypes.cls");
Include_Once ("Panel_ContactMethod.cls");
Include_Once (dirPath() . "Shared/_app.inc");

Function php_Main ()
{
    $nFolderID = 0;
    if (isset ($_REQUEST ['nFolderID']))
        $nFolderID = $_REQUEST ['nFolderID'];

    $nPos = 0;
    if (isset ($_REQUEST ['nPos']))
        $nPos = $_REQUEST ['nPos'];

    // ==========================================
    // Validations

    if ($nFolderID == 0) return;
    if ($nPos == 0) return;

    // =======================================
    // Classes

    $clsCommon_Person = gblLadder()->getClass ("Common_ContactType")->ID();
    $clsCommon_People = gblLadder()->getClass ("Common_People")->ID();

    // ==========================================
    // Get Person Folder

    $fldrTarget = gblLadder()->getItem ($nFolderID);

    // =======================================
    // Set Person Folder

    $fldrPeople = New ENetArch_Common_People();
    $fldrPeople->setState ($fldrTarget);
    $fdlrContactTypes = $fldrPeople->get_ContactTypes();

    // ==========================================
    // Panels

    $pnlPerson = new ENetArch_Panels_Common_Person();
    $pnlName = new ENetArch_Panels_Common_Name();
    $pnlAddress = new ENetArch_Panels_Common_Address();
    $pnlContacts = new ENetArch_Panels_Common_Contacts();
    $pnlContact = new ENetArch_Panels_Common_Contact();
    $pnlContactTypes = new ENetArch_Panels_Common_ContactTypes();
    $pnlContactMethod = new ENetArch_Panels_Common_ContactMethod();

    $pnlContactTypes->setFolder ($fdlrContactTypes);

    // ==========================================
    // View

    $pnlPerson->setPanelName ("ENetArch.Person");
    $pnlPerson->setPanel_Name ($pnlName);
    $pnlPerson->setPanel_Address ($pnlAddress );
    $pnlPerson->setPanel_Contacts ($pnlContacts);
    $pnlContacts->setPanel_Contact ($pnlContact );
    $pnlContact->setPanel_Type ($pnlContactTypes);
    $pnlContact->setPanel_Method ($pnlContactMethod);

    // ==========================================
    // Store View

    $pnlPerson->getPOST();

    $fldrPerson = $fldrPeople->get_Person ($nPos);
        $pnlPerson->updateObject ($fldrPerson);
        $fldrPerson->Store();

    $itmName = $fldrPerson->get_Name();
        $pnlName->updateObject ($itmName);
        $itmName->Store();

    $itmAddress = $fldrPerson->get_Address();
        $pnlAddress->updateObject ($itmAddress);
        $itmAddress->Store();

    $fldrContacts = $fldrPerson->get_Contacts();
    $fldrContacts->Store();

    $nCount = $pnlContacts->Count();
    $nFldrCount = $fldrContacts->Count();

    for ($t=0; $t<$nCount; $t++)
    {
        if ($t+1 > $fldrContacts->Count())
        {
            $fldrContact = $fldrContacts->Create_Contact();
            $fldrContact->Store();

            $fldrContact->Init_Folder();
        }
        else
        { $fldrContact = $fldrContacts->get_Contact($t+1); }

        $pnlContacts->updateContact ($t, $fldrContact);
    }

    header ("Location:list.php?nFolderID=" . $nFolderID . "&");

    return;

    // ==========================================
    // for testing

    print ("<HR>");
    foreach ($_REQUEST as $key => $value)
        print ($key . " = " . $value . "<BR>\n");


}
?>