Import Code Development

  • katzlbt

    katzlbt - 2007-01-25

    I am very interested in the import code. Thank you very much in advance for the effort:

    If possible put the code into plugins/Import/import.php
    I can write the menu to access the import and upload files later if needed.

    Take a look at the previous import code:

    Lines 125-152 have the reading code for a CSV file. The code around is probably outdated.

    There is a sample xls file in the support directory that matches this scheme.

    $data must be loaded in the same way as $_POST the format is pretty complicated but you can discover it by making a var_dump($_POST) just before saving in contact.php

    After loading the $data array, just call these functions:

    $contact = new Contact();

    All error checking will be done for you.

    This refers to 3.0.4 code after revision 310

    • Magnus Westin

      Magnus Westin - 2007-01-25

      umm.. it just became a little more advanced. Ive never used svn here on sourceforge, and I'm really not a php programmer (c++ for my day job). I will probably do a direct to DB import as I said earlier and then take a look at your stuff.


      • katzlbt

        katzlbt - 2007-01-25

        You do not need to use SVN, just replace 3 files with revision 310 (from the most recent file release) with the SVN web access ... and then fill in this zulu code into import.php:

        Here are the files:\checkout*/tab-2/trunk/contact.php?revision=310\

        foreach row in the csv

        $data['contact']['lastname'] = $something_from_csv;
        $data['contact']['firstname'] = $something_from_csv;

        $data['address'][0]['line1'] = $something_from_csv;
        $data['address'][0]['phone1'] = $something_from_csv;

        // another address
        $data['address'][0]['line1'] = $something_from_csv;

        // other data
        $data['blank'][0]['type'] = email OR www OR other OR chat OR phone;
        $data['blank'][0]['label'] = STRING;
        $data['blank'][0]['value'] = STRING;
        $data['blank'][0]['visibility'] = visible OR hidden OR admin;

        $data['blank'][1]['type'] = 'email';
        $data['blank'][1]['label'] = 'private email';
        $data['blank'][1]['value'] = '';
        $data['blank'][1]['visibility'] = 'visible';

        $contact = new Contact();


        should be MUCH easier than SQL queries.

      • katzlbt

        katzlbt - 2007-01-25

        I can send you a tgz of the newest code if you want.

    • Magnus Westin

      Magnus Westin - 2007-01-31

      Ive succeeded in downloading the code with svn and will probably have a go at it this weekend. Its been crazy at work, so its been a little delayed.

      If you want I can try and upload the file also when I'm done, trying to learn a little svn :)

      Another question, what revision is 3.0.4?


      • katzlbt

        katzlbt - 2007-01-31

        The most advanced SVN release that is probably save to use - I hope :=D - can be found by looking at:

        It says:

        Please log in as
        Back to project page.
        This version is newer than the latest file release!
        SVN revision: 337 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        So curretly it is 337 (which happens to be the HEAD revision).

        Uploading per svn is only possible for registered developers/admins of the project.

        Just post a zip or tar.gz as attachment to the feature request: "Import" and I will (let SVN) do the rest.

        3.0.4 is the database version of TABR. It does not correspond to a SVN revision. Probably 3.0.4 will be the final '3.0' release.

    • katzlbt

      katzlbt - 2007-01-31

      I forgot to mention ...

      saveContactFromPost() was renamed to saveContactFromArray()

    • katzlbt

      katzlbt - 2007-02-18

      I have added import.php prototype/zulu code to plugins/Import.


Log in to post a comment.