Exemple #1
0
        set_update_state();
        $display['msg'] .= display_ok_msg("$l_user : $l_insert_ok");
        $display['msg'] .= display_ok_msg("<input type='button' onclick=\"window.location='$path/user/user_index.php?action=pdf&user_id=$params[user_id]'\" value=\"$l_download_user_card\" />", false);
        $display['detail'] = dis_user_consult($params);
      } else {
        $display['msg'] .= display_err_msg("$l_user : $l_insert_error");
        $display['detail'] = dis_user_form($action, $params);
      }

    // If it is the first try, we warn the user if some user seem similar
    } else {
      $obm_q = check_user_context('', $params);
      if ($obm_q->num_rows() > 0) {
        $display['detail'] = dis_user_warn_insert('', $obm_q, $params);
      } else {
        $cid = run_query_user_insert($params);
        if ($cid > 0) {
          set_update_state();
          $params['user_id'] = $cid;
          $display['msg'] .= display_ok_msg("$l_user : $l_insert_ok");
          $display['msg'] .= display_ok_msg("<input type='button' onclick=\"window.location='$path/user/user_index.php?action=pdf&user_id=$params[user_id]'\" value=\"$l_download_user_card\" />", false);
          $display['detail'] = dis_user_consult($params);
        } else {
          $display['msg'] .= display_err_msg("$l_user : $l_insert_error");
          $display['detail'] = dis_user_form($action, $params);
        }
      }
    }

  // Form data are not valid
  } else {
Exemple #2
0
  /**
   * Add a new user with informations found into HTTP headers.
   * @param $login A username.
   * @param $domain_id A domain identifier.
   * @return int The user identifier, or false.
   */
  function addUser($login, $domain_id)
  {
    global $obm;
    $success = false;

    //
    // Some internal functions used
    // global variables. To prevent from unstable creation, we prefer
    // to set those internal variables.
    //

    $backup['domain_id'] = $obm['domain_id'];
    $backup['uid'] = $obm['uid'];
    $backup['globals_module'] = $GLOBALS['module'];

    $obm['uid'] = 1;    // Contains the parent user
    $obm['domain_id'] = $domain_id;
    $GLOBALS['module'] = "user";

    //
    // The above code is taken from php/user/user_index.php, when
    // $user['action'] equals to 'insert'. But, we have to insert
    // the file that contains all necessary user methods. It seems
    // that it is $path which contains may OBM directory.
    //

    $params = $this->_buildInternalUserData($login, $domain_id);
    $params = $this->_setDefaultUserData($params, $login, $domain_id);

    //
    // Original one use also check_user_defined_rules() function
    // in the following condition.
    //

    if (!check_user_data_form('', $params))
    {
      return false;
    }

    if (($user_id = run_query_user_insert($params)) > 0)
    {
      $params['user_id'] = $user_id;
      set_update_state();
      $succeed = $user_id;
      $this->_updated = true;
    }

    $obm['uid'] = $backup['uid'];
    $obm['domain_id'] = $backup['domain_id'];
    $GLOBALS['module'] = $backup['globals_module'];
    unset($backup);

    return $succeed;
  }