コード例 #1
0
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 
}
コード例 #2
0
/*
values currently used in PA
Nobody="0"
Everybody="1"
Immediate Relations="2"
so to show all info a friend would see
we need to allow perms 1 AND 2
while friends only would be 2
*/
$perms = isset($_POST['perms']) ? $_POST['perms'] : "1,2";
$filter = new Normalizer('filterPerms');
foreach (preg_split('/,\\s*/', $perms) as $p) {
    $parr[] = "perm" . $p;
}
$filter->setParams($parr, TRUE);
$filteredDOM = $filter->transformToDoc($merger->currentProfileDOM);
$exps = array();
foreach ($_POST as $k => $v) {
    if (preg_match('/^expose/', $k)) {
        $exps[] = $k;
    }
}
if (!count($exps)) {
    $exps = $allExposes;
    foreach ($exps as $e) {
        $_POST[$e] = 1;
    }
}
// generate the hCard
displayNone($normalizer, $allExposes);
$normalizer->setParams($exps, TRUE);