function success_page() { global $script_url, $login_uid; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>PeopleAggregator SXIP Profile Import</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Language" content="en-us" /> <link rel="shortcut icon" href="<? echo PA::$theme_url ?>/favicon.ico" type="image/x-icon" /> <link rel="icon" href="<? echo PA::$theme_url ?>/favicon.ico" type="image/x-icon" /> <script src="<? echo PA::$theme_url ?>/javascript/prototype.js" type="text/javascript"></script> <link rel="stylesheet" href="<? echo PA::$theme_url ?>/style.css" type="text/css" /> <style> .profilediff { background-color: black; } .profilediff td { background-color: white; margin:1px; } .profilediff .action { background-color: black; color: white; font-weight: bold; font-size: 1.1em; } .profilediff .section { background-color: lightgrey; font-weight: bold; } </style> </head> <body style="background-color: white;"> <image name="dix:/membersite-logo-url" src="<?php echo PA::$theme_url; ?> /images/sxipms-logo.jpg" /> <h1>PeopleAggregator SXIP Profile Import</h1> <h2>The following data was imported into your User Profile</h2> <?php // load empty sxip properties XML $sxip = DOMDocument::load("api/ProfileIO/xml/sxipProperties.xml"); // stick the POSTed data into our DOM foreach ($sxip->getElementsByTagName('property') as $prop) { $label = urlencode($prop->getAttribute('label')); if ($_POST[$label] && $_POST[$label] != '') { $prop->setAttribute('value', $_POST[$label]); } } $homesite = $_REQUEST['dix:/homesite']; // echo "<hr><b>Input DOM:</b> // <br><pre>".htmlspecialchars($sxip->saveXML())."</pre>"; require_once "api/ProfileIO/ProfileIO.php"; $normalizer = new Normalizer("sxip"); $normalizer->setParameter('', 'nameSection', $homesite); $paDOM = $normalizer->transformToDoc($sxip); // echo "<hr><b>PA DOM:</b> <br><pre>".htmlspecialchars($paDOM->saveXML())."</pre>"; require_once "api/User/User.php"; $user = new User(); try { $user->load((int) $login_uid); } catch (PAException $e) { throw new PAException(USER_INVALID, $e->message); } $merger = new ProfileMerger($user, $paDOM); $merger->diff(); // here we might include another step with user interction!! // actualy SAVE the new profile print "<hr>saving to " . print_r($homesite, true) . "<hr>"; $merger->saveProfile($homesite); $diff = $merger->diffProfileSXML; // echo "<hr><b>PA DOM:</b> <br><pre>".htmlspecialchars($diff->asXML())."</pre>"; function tr($f) { ?> <tr> <td><b><? echo $f['name']; ?></b> </td> <td> <? echo $f['value']; ?> <? if($f['oldvalue']) echo "<br>was: ".$f['oldvalue']; ?> </td> </tr> <?php } ?> <table class=profilediff> <?php foreach (array('update', 'create') as $action) { ?> <tr><td colspan=2 class=action> <? echo $action ?>-ing these fields:</td> </tr> <?php $sections = array('core') + array_keys($merger->userSections); foreach ($sections as $section) { if ($diff->xpath("//field[@action='{$action}'][@section='{$section}']")) { ?> <tr> <td colspan=2 class=section>profile section: <? echo $section ?>:</td> </tr> <?php foreach ($diff->xpath("//field[@action='{$action}'][@section='{$section}']") as $f) { tr($f); } } } } ?> </table> <p> <a href="<?php echo $script_path; ?> ">Start over</a> </p> <!-- <pre> raw POST data <? print_r($_POST); ?> </pre> --> </body> </html> <?php }
} else { unset($_POST['exposePersonal']); // we don't need the Personal interests in Professional profile $companyType = isset($_POST['exposeCompany']) ? $_POST['exposeCompany'] : '0'; /* '0'=Current; '1'=Prior; '-1'=No company info */ } } else { $profileType = '0'; // default: 0-Personal! } //-------------------------------------------------------------------------------------------- $merger = new ProfileMerger(PA::$login_user, NULL); $sections = array_merge(array('core'), array_keys($merger->userSections)); $normalizer = new Normalizer('pa2hcard'); // setting parameters for the XSLT to include/exclude sections etc $normalizer->setParameter('', 'paUid', PA::$login_user->user_id); $normalizer->setParameter('', 'paUrl', PA::$url); //---- profile and compyny types: added by Zoran Hron ----- $normalizer->setParameter('', 'paType', $profileType); $normalizer->setParameter('', 'paCompanyType', $companyType); //--------------------------------------------------------- /* ------------------------ old code ------------------------ $allExposes = array( 'exposeCore', 'exposeAddress', 'exposeSummary', 'exposePersonal', 'exposeEducation', 'exposeCompany', 'exposePriorCompany', 'exposeEducation', 'exposeFlickrFriends', 'exposeFacebookFriends' ); ------------------------------------------------------------ */