~ubuntu-branches/ubuntu/natty/mahara/natty

« back to all changes in this revision

Viewing changes to htdocs/artefact/internal/import/leap/lib.php

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2011-03-25 16:08:31 UTC
  • mfrom: (6.3.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110325160831-mogklck7j71quyf9
Tags: 1.2.7-1
* New upstream security release:
  - CVE-2011-0439 (XSS in select boxes)
  - CVE-2011-0440 (CSRF when deleting blogs)

* Add Italian debconf translation (closes: #606378)
* Add Danish debconf translation (closes: #597766)
* Bump debhelper compatibility to 8

Show diffs side-by-side

added added

removed removed

Lines of Context:
227
227
     *                                   to the author, if there is one
228
228
     */
229
229
    public static function import_author_data(PluginImportLeap $importer, $persondataid) {
 
230
        $namespaces = $importer->get_namespaces();
 
231
        $ns = $namespaces[$importer->get_leap2a_namespace()];
230
232
        if ($persondataid) {
231
233
            // Grab all the leap:persondata elements and import them
232
234
            $person = $importer->get_entry_by_id($persondataid);
239
241
            }
240
242
 
241
243
            // Most of the rest of the profile data comes from leap:persondata elements
242
 
            $persondata = $person->xpath('leap:persondata');
 
244
            $persondata = $person->xpath($ns.':persondata');
243
245
            foreach ($persondata as $item) {
244
 
                $leapattributes = PluginImportLeap::get_attributes($item, PluginImportLeap::NS_LEAP);
 
246
                $leapattributes = PluginImportLeap::get_attributes($item, $importer->get_leap2a_namespace());
245
247
 
246
248
                if (isset($leapattributes['field'])) {
247
249
                    self::import_persondata($importer, $item, $leapattributes);
259
261
            self::import_namedata($importer, $persondata);
260
262
 
261
263
            // People can have address info associated with them
262
 
            $addressdata = $person->xpath('leap:spatial');
263
 
            if (count($addressdata) == 1) {
 
264
            $addressdata = $person->xpath($ns.':spatial');
 
265
            if (is_array($addressdata) && count($addressdata) == 1) {
264
266
                self::import_addressdata($importer, $addressdata[0]);
265
267
            }
266
268
 
456
458
    private static function import_addressdata(PluginImportLeap $importer, SimpleXMLElement $addressdata) {
457
459
        // TODO: this xpath doesn't respect the namespace prefix - we should 
458
460
        // look it up from $importer->namespaces[NS_LEAP]
459
 
        $addresslines = $addressdata->xpath('leap:addressline');
 
461
        $namespaces = $importer->get_namespaces();
 
462
        $ns = $namespaces[$importer->get_leap2a_namespace()];
 
463
        $addresslines = $addressdata->xpath($ns.':addressline');
460
464
 
461
465
        // We look for 'town' and 'city' deliberately, Mahara has 
462
466
        // separate fields for those. The rest get thrown in the 
483
487
        }
484
488
 
485
489
        // Now deal with country
486
 
        $country = $addressdata->xpath('leap:country');
 
490
        $country = $addressdata->xpath($ns.':country');
487
491
 
488
492
        if (count($country) == 1) {
489
493
            $country = $country[0];
490
 
            $leapattributes = PluginImportLeap::get_attributes($country, PluginImportLeap::NS_LEAP);
 
494
            $leapattributes = PluginImportLeap::get_attributes($country, $importer->get_leap2a_namespace());
491
495
 
492
496
            // Try using countrycode attribute first, but fall back to name if it's not present or 
493
497
            // doesn't represent a country
520
524
        );
521
525
 
522
526
        foreach ($persondata as $item) {
523
 
            $leapattributes = PluginImportLeap::get_attributes($item, PluginImportLeap::NS_LEAP);
 
527
            $leapattributes = PluginImportLeap::get_attributes($item, $importer->get_leap2a_namespace());
524
528
            if (isset($leapattributes['field'])) {
525
529
                if (in_array($leapattributes['field'], array_keys($namefields))) {
526
530
                    // legal_given_name is allowed to occur any number of times