Results 1 to 5 of 5

Thread: Create new users dynamically

  1. #1
    Tom79 is offline Member
    Join Date
    Jun 2006
    Posts
    5

    Default Create new users dynamically

    Hi,

    I try to create new users dynamically. But, I don't find the funtction of this (in user.php or logger...)

    Can you help me please ?

    Thank you,

    Thomas

  2. #2
    Tom79 is offline Member
    Join Date
    Jun 2006
    Posts
    5

    Default Re: Create new users dynamically

    Hi,

    I try this but i have an error because the save funtion doesn't record anything in the database ? Why ?

    require_once('log4php/LoggerManager.php');
    require_once('include/formbase.php');
    require_once('modules/Candidats/Candidat.php');
    require_once('include/database/PearDatabase.php');
    require_once('modules/Users/User.php');
    require_once('include/database/DBManager.php');

    global $mod_strings;
    global $db;
    $user = new User();
    $candidat = new Candidat();

    echo "\n<p>\n";
    echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'].": ", true);
    echo "\n</p>\n";

    $user = populateFromPost('', $user);

    global $theme;
    $theme_path="themes/".$theme."/";
    $image_path=$theme_path."images/";
    require_once($theme_path.'layout_utils.php');


    //Message d'erreur si id est null...
    if(!isset($_REQUEST['record'])) //record == id
    sugar_die($mod_strings['ERR_DELETE_RECORD']);


    // Traitement du candidat à partir de son id...
    // Création d'un user au nom du candidat...

    $user->first_name = $_REQUEST['candidat_first_name'];
    $user->last_name = $_REQUEST['candidat_last_name'];
    $user->id = $_REQUEST['candidat_id'];
    $candidat_first_name = $user->first_name;

    [....]

    $user->user_name = $candidat_login;
    $date_entered_modified = date("Y-m-d H:i:s");

    $user->date_entered = $date_entered_modified;
    $user->date_modified = $date_entered_modified;


    $user->save($GLOBALS['check_notify']); <= ???????????????????????????????

    [.....]

  3. #3
    Tom79 is offline Member
    Join Date
    Jun 2006
    Posts
    5

    Default Re: Create new users dynamically

    Hi,

    Nobody have an idea
    I try another method but it is not really interesting... So if you have an idea.... Help me please !

    Thomas

  4. #4
    sacramentojoe is offline Sugar Community Member
    Join Date
    Nov 2005
    Posts
    447

    Default Re: Create new users dynamically

    Quote Originally Posted by Tom79
    Hi,

    Nobody have an idea
    I try another method but it is not really interesting... So if you have an idea.... Help me please !

    Thomas
    Hi There, when you create a new user from the Admin it calls the EditView action of the User Module. The save feature part of the main app so you can't just call 'save' . Your best bet is to create your own function that you can call.

    I know for Opportunities. we tried to do the same thing you want. We noticed that for the Opportunity it loads OpportunityFormBase and then calls the method handleSave();
    This appears to be standard for most of the modules.

    I would do something like this
    //Maybe pass it a user object
    include_once('include/utils.php');
    function save($User){
    $User->id = create_guid(); //this comes from the include file
    Create a sql statement to insert into the table
    since your class extends Sugar bean
    you can call
    $this->db->query($sql);


    Good Luck

    }

  5. #5
    Tom79 is offline Member
    Join Date
    Jun 2006
    Posts
    5

    Default Re: Create new users dynamically

    Thank you, it's perfect !

    Thomas

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •