コード例 #1
0
void user::sAdd()
{
  q.prepare("SELECT grantPriv(:username, :priv_id) AS result;");
  q.bindValue(":username", _cUsername);
  q.bindValue(":priv_id", _available->id());
  q.exec();
  // no storedProcErrorLookup because the function returns bool, not int
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  sModuleSelected(_module->currentText());
}
コード例 #2
0
void commentType::sRevoke()
{
  q.prepare("SELECT revokeCmnttypeSource(:cmnttype_id, :source_id) AS result;");
  q.bindValue(":cmnttype_id", _cmnttypeid);
  q.bindValue(":source_id", _granted->id());
  q.exec();
  // no storedProcErrorLookup because the function returns bool, not int
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  sModuleSelected(_module->currentText());
}
コード例 #3
0
enum SetResponse user::set(const ParameterList &pParams)
{
  QVariant param;
  bool     valid;

  param = pParams.value("username", &valid);
  if (valid)
  {
    _cUsername = param.toString();
    populate();
  }

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;
      _module->setCurrentItem(0);
      sModuleSelected(_module->text(0));

      _username->setFocus();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;

      _username->setEnabled(FALSE);

      _save->setFocus();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _close->setText(tr("&Close"));
      _save->hide();

      _close->setFocus();
    }
  }

  return NoError;
}
コード例 #4
0
ファイル: user.cpp プロジェクト: chengzhou/qt-client
void user::sAdd()
{
    if (_available->id() == -1)
    {
        QMessageBox::critical(this, tr("Error"), tr("Please select an Available Privilege."));
        return;
    }

    XSqlQuery privq;
    privq.prepare("SELECT grantPriv(:username, :priv_id) AS result;");
    privq.bindValue(":username", _cUsername);
    privq.bindValue(":priv_id", _available->id());
    privq.exec();
    if (ErrorReporter::error(QtCriticalMsg, this, tr("Granting Privilege"),
                             privq, __FILE__, __LINE__))
        return;

    sModuleSelected(_module->currentText());
}
コード例 #5
0
ファイル: user.cpp プロジェクト: chengzhou/qt-client
void user::sRevokeGroup()
{
    if (_grantedGroup->id() == -1)
    {
        QMessageBox::critical(this, tr("Error"), tr("Please select a Granted Role."));
        return;
    }

    XSqlQuery grpq;
    grpq.prepare("SELECT revokeGroup(:username, :grp_id) AS result;");
    grpq.bindValue(":username", _cUsername);
    grpq.bindValue(":grp_id", _grantedGroup->id());
    grpq.exec();
    // no storedProcErrorLookup because the function returns bool, not int
    if (ErrorReporter::error(QtCriticalMsg, this, tr("Revoking Group Privileges"),
                             grpq, __FILE__, __LINE__))
        return;

    sModuleSelected(_module->currentText());
}
コード例 #6
0
ファイル: user.cpp プロジェクト: chengzhou/qt-client
void user::sRevokeAll()
{
    XSqlQuery privq;
    privq.prepare("SELECT revokeAllModulePriv(:username, :module) AS result;");
    privq.bindValue(":username", _cUsername);
    privq.bindValue(":module", _module->currentText());
    privq.exec();
    if (privq.first())
    {
        int result = privq.value("result").toInt();
        if (result < 0)
        {
            ErrorReporter::error(QtCriticalMsg, this, tr("Revoking Privileges"),
                                 storedProcErrorLookup("revokeAllModulePriv", result),
                                 __FILE__, __LINE__);
            return;
        }
    }
    else if (ErrorReporter::error(QtCriticalMsg, this, tr("Revoking Privileges"),
                                  privq, __FILE__, __LINE__))
        return;

    sModuleSelected(_module->currentText());
}
コード例 #7
0
void commentType::sRevokeAll()
{
  q.prepare("SELECT revokeAllModuleCmnttypeSource(:cmnttype_id, :module) AS result;");
  q.bindValue(":cmnttype_id", _cmnttypeid);
  q.bindValue(":module", _module->currentText());
  q.exec();
  if (q.first())
  {
    int result = q.value("result").toInt();
    if (result < 0)
    {
      systemError(this, storedProcErrorLookup("revokeAllModuleCmnttypeSource", result),
                  __FILE__, __LINE__);
      return;
    }
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  sModuleSelected(_module->currentText());
}
コード例 #8
0
void user::sRevokeAll()
{
  q.prepare("SELECT revokeAllModulePriv(:username, :module) AS result;");
  q.bindValue(":username", _cUsername);
  q.bindValue(":module", _module->currentText());
  q.exec();
  if (q.first())
  {
    int result = q.value("result").toInt();
    if (result < 0)
    {
      systemError(this, storedProcErrorLookup("revokeAllModulePriv", result),
                  __FILE__, __LINE__);
      return;
    }
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  sModuleSelected(_module->currentText());
}
コード例 #9
0
ファイル: user.cpp プロジェクト: chengzhou/qt-client
enum SetResponse user::set(const ParameterList &pParams)
{
    XDialog::set(pParams);
    QVariant param;
    bool     valid;

    param = pParams.value("crmacct_id", &valid);
    if (valid)
        _crmacctid = param.toInt();

    param = pParams.value("username", &valid);
    if (valid)
        _cUsername = param.toString();

    if (! _cUsername.isEmpty() || _crmacctid > 0)
        if (! sPopulate())
            return UndefinedError;

    param = pParams.value("mode", &valid);
    if (valid)
    {
        if (param.toString() == "new")
        {
            _mode = cNew;
            _module->setCurrentIndex(0);
            sModuleSelected(_module->itemText(0));

            if (! _cUsername.isEmpty())
            {
                _username->setEnabled(false);
                _username->setText(_cUsername);
                sCheck();
            }
            if (_metrics->boolean("MultiWhs"))
                populateSite();
        }
        else if (param.toString() == "edit")
        {
            _mode = cEdit;

            _username->setEnabled(false);
        }
        else if (param.toString() == "view")
        {
            _mode = cView;

            _close->setText(tr("&Close"));
            _save->hide();
        }
    }

    bool canEdit = (cNew == _mode || cEdit == _mode);

    _active->setEnabled(canEdit);
    _add->setEnabled(canEdit);
    _addAll->setEnabled(canEdit);
    _addGroup->setEnabled(canEdit);
//  _addSite->setEnabled(canEdit);
    _agent->setEnabled(canEdit);
    _allSites->setEnabled(canEdit);
    _email->setEnabled(canEdit);
    _employee->setReadOnly(! canEdit);
    _enhancedAuth->setEnabled(canEdit);
    _exportContents->setEnabled(canEdit);
    _initials->setEnabled(canEdit);
    _locale->setEnabled(canEdit);
    _passwd->setEnabled(canEdit);
    _properName->setEnabled(canEdit);
    _revoke->setEnabled(canEdit);
    _revokeAll->setEnabled(canEdit);
    _revokeGroup->setEnabled(canEdit);
//  _revokeSite->setEnabled(canEdit);
    _save->setEnabled(canEdit);
    _selectedSites->setEnabled(canEdit);
    _verify->setEnabled(canEdit);
    if (! canEdit)
    {
        _available->setSelectionMode(QAbstractItemView::NoSelection);
        _availableGroup->setSelectionMode(QAbstractItemView::NoSelection);
        _availableSite->setSelectionMode(QAbstractItemView::NoSelection);
        _granted->setSelectionMode(QAbstractItemView::NoSelection);
        _grantedGroup->setSelectionMode(QAbstractItemView::NoSelection);
        _grantedSite->setSelectionMode(QAbstractItemView::NoSelection);
    }

    if(canEdit)
    {
        XSqlQuery begin;
        _inTransaction = begin.exec("BEGIN;");
    }

    return NoError;
}
コード例 #10
0
ファイル: user.cpp プロジェクト: chengzhou/qt-client
bool user::sPopulate()
{
    XSqlQuery usrq;
    if (! _cUsername.isEmpty())
    {
        usrq.prepare("SELECT usr_username, usr_active, usr_propername, usr_initials,"
                     "       usr_email, usr_locale_id, usr_agent,"
                     "       userCanCreateUsers(usr_username) AS createusers,"
                     "       userCanCreateUsers(getEffectiveXtUser()) AS enablecreateusers,"
                     "       crmacct_id, crmacct_emp_id, crmacct_owner_username"
                     "  FROM usr"
                     "  LEFT OUTER JOIN crmacct ON (usr_username=crmacct_usr_username) "
                     "WHERE (usr_username=:usr_username);" );
        usrq.bindValue(":usr_username", _cUsername);
    }
    else if (_crmacctid > 0)
    {
        usrq.prepare("SELECT LOWER(crmacct_number) AS usr_username,"
                     "       crmacct_name          AS usr_propername,"
                     "       (SELECT locale_id"
                     "          FROM locale"
                     "         WHERE locale_code='Default') AS usr_locale_id,"
                     "       NULL  AS usr_passwd,  cntct_initials AS usr_initials,"
                     "       false AS usr_agent,   crmacct_active AS usr_active,"
                     "       NULL  AS usr_window,  cntct_email AS usr_email,"
                     "       false AS createusers,"
                     "       userCanCreateUsers(getEffectiveXtUser()) AS enablecreateusers,"
                     "       crmacct_id, crmacct_emp_id, crmacct_owner_username"
                     "  FROM crmacct"
                     "  LEFT OUTER JOIN cntct ON (crmacct_cntct_id_1=cntct_id)"
                     " WHERE (crmacct_id=:id);");
        usrq.bindValue(":id", _crmacctid);
    }

    usrq.exec();
    if (usrq.first())
    {
        _username->setText(usrq.value("usr_username"));

        if (_crmacctid > 0)
        {
            if (_username->text().contains(QRegExp("\\s")))
            {
                QMessageBox::warning(this, tr("No Spaces Allowed"),
                                     tr("<p>Usernames cannot include space characters "
                                        "but must also match the associated Account "
                                        "numbers. Please Cancel the User Account window and "
                                        "remove the spaces from the Account number "
                                        "before trying to create this User Account."));
                return false;
            }
            _username->setEnabled(false);
        }
        _active->setChecked(usrq.value("usr_active").toBool());
        _properName->setText(usrq.value("usr_propername"));
        _initials->setText(usrq.value("usr_initials"));
        _email->setText(usrq.value("usr_email"));
        _locale->setId(usrq.value("usr_locale_id").toInt());
        _agent->setChecked(usrq.value("usr_agent").toBool());
        _createUsers->setChecked(usrq.value("createusers").toBool());
        _createUsers->setEnabled(usrq.value("enablecreateusers").toBool());
        _employee->setId(usrq.value("crmacct_emp_id").toInt());
        _crmacctid = usrq.value("crmacct_id").toInt();
        _crmowner = usrq.value("crmacct_owner_username").toString();
        _cUsername = _username->text().trimmed().toLower();

        _passwd->setText("        ");
        _verify->setText("        ");

        usrq.prepare( "SELECT usrpref_value "
                      "  FROM usrpref "
                      " WHERE ( (usrpref_name = 'DisableExportContents') "
                      "   AND (usrpref_username=:username) ); ");
        usrq.bindValue(":username", _cUsername);
        usrq.exec();
        if(usrq.first())
            _exportContents->setChecked(usrq.value("usrpref_value").toString()=="t");
        else
            _exportContents->setChecked(false);

        usrq.prepare( "SELECT usrpref_value "
                      "  FROM usrpref "
                      " WHERE ( (usrpref_name = 'UseEnhancedAuthentication') "
                      "   AND (usrpref_username=:username) ); ");
        usrq.bindValue(":username", _cUsername);
        usrq.exec();
        _authCache = false;
        if(usrq.first())
            _authCache = (usrq.value("usrpref_value").toString()=="t");
        _enhancedAuth->setChecked(_authCache);

        usrq.prepare( "SELECT priv_module "
                      "FROM usrpriv, priv "
                      "WHERE ( (usrpriv_priv_id=priv_id)"
                      " AND (usrpriv_username=:username) ) "
                      "ORDER BY priv_module "
                      "LIMIT 1;" );
        usrq.bindValue(":username", _cUsername);
        usrq.exec();
        if (usrq.first())
        {
            _module->setCode(usrq.value("priv_module").toString());
            sModuleSelected(_module->currentText());
        }
        else
        {
            _module->setCurrentIndex(0);
            sModuleSelected(_module->itemText(0));
        }
    }
    else if (ErrorReporter::error(QtCriticalMsg, this, tr("Getting User Account"),
                                  usrq, __FILE__, __LINE__))
        return false;

    usrq.prepare( "SELECT usrpref_value "
                  "  FROM usrpref "
                  " WHERE ( (usrpref_name = 'selectedSites') "
                  "   AND (usrpref_username=:username) "
                  "   AND (usrpref_value='t') ); ");
    usrq.bindValue(":username", _cUsername);
    usrq.exec();
    if(usrq.first())
        _selectedSites->setChecked(true);
    else if (ErrorReporter::error(QtCriticalMsg, this, tr("Getting User Sites"),
                                  usrq, __FILE__, __LINE__))
        return false;

    if (_metrics->boolean("MultiWhs"))
        populateSite();

    _crmacct->setEnabled(_crmacctid > 0 &&
                         (_privileges->check("MaintainAllCRMAccounts") ||
                          _privileges->check("ViewAllCRMAccounts") ||
                          (omfgThis->username() == _crmowner && _privileges->check("MaintainPersonalCRMAccounts")) ||
                          (omfgThis->username() == _crmowner && _privileges->check("ViewPersonalCRMAccounts"))));


    return true;
}
コード例 #11
0
enum SetResponse group::set(const ParameterList &pParams)
{
  QVariant param;
  bool     valid;

  param = pParams.value("grp_id", &valid);
  if (valid)
  {
    _grpid = param.toInt();
    populate();
  }

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      q.exec("SELECT NEXTVAL('grp_grp_id_seq') AS grp_id;");
      if (q.first())
        _grpid = q.value("grp_id").toInt();
      else if (q.lastError().type() != QSqlError::None)
      {
        systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        return UndefinedError;
      }

      _mode = cNew;
      q.exec("BEGIN;");
      q.prepare( "INSERT INTO grp "
                 "( grp_id, grp_name, grp_descrip)"
                 "VALUES( :grp_id, :grp_id, '' );" );
      q.bindValue(":grp_id", _grpid);
      q.exec();
      if (q.lastError().type() != QSqlError::None)
      {
        systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        q.exec("ROLLBACK;");
        return UndefinedError;
      }
      
      _module->setCurrentItem(0);
      sModuleSelected(_module->text(0));
      _name->setFocus();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;
      _name->setFocus();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;
      _name->setEnabled(FALSE);
      _description->setEnabled(FALSE);
      _save->hide();
      _close->setText(tr("&Close"));
      _close->setFocus();
    }
  }

  return NoError;
}
コード例 #12
0
void user::populate()
{
  q.prepare( "SELECT *, userCanCreateUsers(usr_username) AS createusers,"
             "       userCanCreateUsers(CURRENT_USER) AS enablecreateusers "
             "FROM usr "
             "WHERE (usr_username=:usr_username);" );
  q.bindValue(":usr_username", _cUsername);
  q.exec();
  if (q.first())
  {
    _username->setText(q.value("usr_username"));
    _active->setChecked(q.value("usr_active").toBool());
    _properName->setText(q.value("usr_propername"));
    _initials->setText(q.value("usr_initials"));
    _email->setText(q.value("usr_email"));
    //_passwd->setText(q.value("usr_passwd"));
    //_verify->setText(q.value("usr_passwd"));
    _locale->setId(q.value("usr_locale_id").toInt());
    _agent->setChecked(q.value("usr_agent").toBool());
    _createUsers->setChecked(q.value("createusers").toBool());
    _createUsers->setEnabled(q.value("enablecreateusers").toBool());
    // keep synchronized with the insert/update above, GUIClient, and main
    _woTimeClockOnly->setChecked(q.value("usr_window").toString()==("woTimeClock"));

    _passwd->setText("        ");
    _verify->setText("        ");

    q.prepare( "SELECT usrpref_value "
               "  FROM usrpref "
               " WHERE ( (usrpref_name = 'DisableExportContents') "
               "   AND (usrpref_username=:username) ); ");
    q.bindValue(":username", _cUsername);
    q.exec();
    if(q.first())
      _exportContents->setChecked(q.value("usrpref_value").toString()=="t");
    else
      _exportContents->setChecked(FALSE);

    q.prepare( "SELECT usrpref_value "
               "  FROM usrpref "
               " WHERE ( (usrpref_name = 'UseEnhancedAuthentication') "
               "   AND (usrpref_username=:username) ); ");
    q.bindValue(":username", _cUsername);
    q.exec();
    _authCache = false;
    if(q.first())
      _authCache = (q.value("usrpref_value").toString()=="t");
    _enhancedAuth->setChecked(_authCache);

    q.prepare( "SELECT priv_module "
               "FROM usrpriv, priv "
               "WHERE ( (usrpriv_priv_id=priv_id)"
               " AND (usrpriv_username=:username) ) "
               "ORDER BY priv_module "
               "LIMIT 1;" );
    q.bindValue(":username", _cUsername);
    q.exec();
    if (q.first())
    {
      for (int counter = 0; counter < _module->count(); counter++)
      {
        if (_module->text(counter) == q.value("priv_module").toString())
        {
          _module->setCurrentItem(counter);
          sModuleSelected(_module->text(counter));
        }
      }
    }
    else
    {
      _module->setCurrentItem(0);
      sModuleSelected(_module->text(0));
    }
  }
}
コード例 #13
0
enum SetResponse group::set(const ParameterList &pParams)
{
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("grp_id", &valid);
  if (valid)
  {
    _grpid = param.toInt();
    populate();
  }

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      q.exec("SELECT NEXTVAL('grp_grp_id_seq') AS grp_id;");
      if (q.first())
        _grpid = q.value("grp_id").toInt();
      else if (q.lastError().type() != QSqlError::NoError)
      {
        systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        return UndefinedError;
      }

      _mode = cNew;
      _trapClose = true;
      q.exec("BEGIN;");
      q.prepare( "INSERT INTO grp "
                 "( grp_id, grp_name, grp_descrip)"
                 "VALUES( :grp_id, :grp_id, '' );" );
      q.bindValue(":grp_id", _grpid);
      q.exec();
      if (q.lastError().type() != QSqlError::NoError)
      {
        systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        q.exec("ROLLBACK;");
        _trapClose = false;
        return UndefinedError;
      }

      _module->setCurrentIndex(0);
      sModuleSelected(_module->itemText(0));
      _name->setFocus();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;
      _name->setFocus();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;
      _name->setEnabled(FALSE);
      _description->setEnabled(FALSE);
      _addAll->setEnabled(FALSE);
      _revokeAll->setEnabled(FALSE);
      disconnect(_available, SIGNAL(itemSelected(int)), this, SLOT(sAdd()));
      disconnect(_available, SIGNAL(valid(bool)), _add, SLOT(setEnabled(bool)));
      disconnect(_granted, SIGNAL(itemSelected(int)), this, SLOT(sRevoke()));
      disconnect(_granted, SIGNAL(valid(bool)), _revoke, SLOT(setEnabled(bool)));
      _save->hide();
      _close->setText(tr("&Close"));
      _close->setFocus();
    }
  }
コード例 #14
0
ファイル: user.cpp プロジェクト: Wushaowei001/xtuple-1
bool user::sPopulate()
{
  XSqlQuery usrq;
  if (! _cUsername.isEmpty())
  {
    usrq.prepare("SELECT *, userCanCreateUsers(usr_username) AS createusers,"
                 "       userCanCreateUsers(getEffectiveXtUser()) AS enablecreateusers,"
                 "       crmacct_id, crmacct_emp_id, crmacct_owner_username"
                 "  FROM usr"
                 "  LEFT OUTER JOIN crmacct ON (usr_username=crmacct_usr_username) "
                 "WHERE (usr_username=:usr_username);" );
    usrq.bindValue(":usr_username", _cUsername);
  }
  else if (_crmacctid > 0)
  {
    usrq.prepare("SELECT LOWER(crmacct_number) AS usr_username,"
                 "       crmacct_name          AS usr_propername,"
                 "       (SELECT locale_id"
                 "          FROM locale"
                 "         WHERE locale_code='Default') AS usr_locale_id,"
                 "       NULL  AS usr_passwd,  cntct_initials AS usr_initials,"
                 "       FALSE AS usr_agent,   crmacct_active AS usr_active,"
                 "       NULL  AS usr_window,  cntct_email AS usr_email,"
                 "       FALSE AS createusers,"
                 "       userCanCreateUsers(getEffectiveXtUser()) AS enablecreateusers,"
                 "       crmacct_id, crmacct_emp_id, crmacct_owner_username"
                 "  FROM crmacct"
                 "  LEFT OUTER JOIN cntct ON (crmacct_cntct_id_1=cntct_id)"
                 " WHERE (crmacct_id=:id);");
    usrq.bindValue(":id", _crmacctid);
  }

  usrq.exec();
  if (usrq.first())
  {
    if(omfgThis->useCloud() && usrq.value("usr_username").toString().endsWith("_"+omfgThis->company()))
      _username->setText(usrq.value("usr_username").toString().left(usrq.value("usr_username").toString().length() - (omfgThis->company().length()+1)));
    else
      _username->setText(usrq.value("usr_username"));
    _active->setChecked(usrq.value("usr_active").toBool());
    _properName->setText(usrq.value("usr_propername"));
    _initials->setText(usrq.value("usr_initials"));
    _email->setText(usrq.value("usr_email"));
    _locale->setId(usrq.value("usr_locale_id").toInt());
    _agent->setChecked(usrq.value("usr_agent").toBool());
    _createUsers->setChecked(usrq.value("createusers").toBool());
    _createUsers->setEnabled(usrq.value("enablecreateusers").toBool());
    _employee->setId(usrq.value("crmacct_emp_id").toInt());
    _crmacctid = usrq.value("crmacct_id").toInt();
    _crmowner = usrq.value("crmacct_owner_username").toString();

    _passwd->setText("        ");
    _verify->setText("        ");

    usrq.prepare( "SELECT usrpref_value "
               "  FROM usrpref "
               " WHERE ( (usrpref_name = 'DisableExportContents') "
               "   AND (usrpref_username=:username) ); ");
    usrq.bindValue(":username", _cUsername);
    usrq.exec();
    if(usrq.first())
      _exportContents->setChecked(usrq.value("usrpref_value").toString()=="t");
    else
      _exportContents->setChecked(FALSE);

    usrq.prepare( "SELECT usrpref_value "
               "  FROM usrpref "
               " WHERE ( (usrpref_name = 'UseEnhancedAuthentication') "
               "   AND (usrpref_username=:username) ); ");
    usrq.bindValue(":username", _cUsername);
    usrq.exec();
    _authCache = false;
    if(usrq.first())
      _authCache = (usrq.value("usrpref_value").toString()=="t");
    _enhancedAuth->setChecked(_authCache);

    usrq.prepare( "SELECT priv_module "
               "FROM usrpriv, priv "
               "WHERE ( (usrpriv_priv_id=priv_id)"
               " AND (usrpriv_username=:username) ) "
               "ORDER BY priv_module "
               "LIMIT 1;" );
    usrq.bindValue(":username", _cUsername);
    usrq.exec();
    if (usrq.first())
    {
      _module->setCode(usrq.value("priv_module").toString());
      sModuleSelected(_module->currentText());
    }
    else
    {
      _module->setCurrentIndex(0);
      sModuleSelected(_module->itemText(0));
    }
  }
  else if (ErrorReporter::error(QtCriticalMsg, this, tr("Getting User"),
                                usrq, __FILE__, __LINE__))
    return false;

  usrq.prepare( "SELECT usrpref_value "
             "  FROM usrpref "
             " WHERE ( (usrpref_name = 'selectedSites') "
             "   AND (usrpref_username=:username) "
             "   AND (usrpref_value='t') ); ");
  usrq.bindValue(":username", _cUsername);
  usrq.exec();
  if(usrq.first())
    _selectedSites->setChecked(TRUE);
  else if (ErrorReporter::error(QtCriticalMsg, this, tr("Getting User Sites"),
                                usrq, __FILE__, __LINE__))
    return false;

  if (_metrics->boolean("MultiWhs"))
    populateSite();

  _crmacct->setEnabled(_crmacctid > 0 &&
                       (_privileges->check("MaintainAllCRMAccounts") ||
                        _privileges->check("ViewAllCRMAccounts") ||
                        (omfgThis->username() == _crmowner && _privileges->check("MaintainPersonalCRMAccounts")) ||
                        (omfgThis->username() == _crmowner && _privileges->check("ViewPersonalCRMAccounts"))));


  return true;
}
コード例 #15
0
void user::populate()
{
  q.prepare( "SELECT *, userCanCreateUsers(usr_username) AS createusers,"
             "       userCanCreateUsers(CURRENT_USER) AS enablecreateusers,"
             "       emp_id "
             "FROM usr LEFT OUTER JOIN emp ON (usr_username=emp_username) "
             "WHERE (usr_username=:usr_username);" );
  q.bindValue(":usr_username", _cUsername);
  q.exec();
  if (q.first())
  {
    _username->setText(q.value("usr_username"));
    _active->setChecked(q.value("usr_active").toBool());
    _properName->setText(q.value("usr_propername"));
    _initials->setText(q.value("usr_initials"));
    _email->setText(q.value("usr_email"));
    _locale->setId(q.value("usr_locale_id").toInt());
    _agent->setChecked(q.value("usr_agent").toBool());
    _createUsers->setChecked(q.value("createusers").toBool());
    _createUsers->setEnabled(q.value("enablecreateusers").toBool());
    _employee->setId(q.value("emp_id").toInt());

    _passwd->setText("        ");
    _verify->setText("        ");

    q.prepare( "SELECT usrpref_value "
               "  FROM usrpref "
               " WHERE ( (usrpref_name = 'DisableExportContents') "
               "   AND (usrpref_username=:username) ); ");
    q.bindValue(":username", _cUsername);
    q.exec();
    if(q.first())
      _exportContents->setChecked(q.value("usrpref_value").toString()=="t");
    else
      _exportContents->setChecked(FALSE);

    q.prepare( "SELECT usrpref_value "
               "  FROM usrpref "
               " WHERE ( (usrpref_name = 'UseEnhancedAuthentication') "
               "   AND (usrpref_username=:username) ); ");
    q.bindValue(":username", _cUsername);
    q.exec();
    _authCache = false;
    if(q.first())
      _authCache = (q.value("usrpref_value").toString()=="t");
    _enhancedAuth->setChecked(_authCache);

    q.prepare( "SELECT priv_module "
               "FROM usrpriv, priv "
               "WHERE ( (usrpriv_priv_id=priv_id)"
               " AND (usrpriv_username=:username) ) "
               "ORDER BY priv_module "
               "LIMIT 1;" );
    q.bindValue(":username", _cUsername);
    q.exec();
    if (q.first())
    {
      for (int counter = 0; counter < _module->count(); counter++)
      {
        if (_module->text(counter) == q.value("priv_module").toString())
        {
          _module->setCurrentIndex(counter);
          sModuleSelected(_module->text(counter));
        }
      }
    }
    else
    {
      _module->setCurrentIndex(0);
      sModuleSelected(_module->text(0));
    }
  }
  
  q.prepare( "SELECT usrpref_value "
             "  FROM usrpref "
             " WHERE ( (usrpref_name = 'selectedSites') "
             "   AND (usrpref_username=:username) "
             "   AND (usrpref_value='t') ); ");
  q.bindValue(":username", _cUsername);
  q.exec();
  if(q.first())
    _selectedSites->setChecked(TRUE);
  
  if (_metrics->boolean("MultiWhs"))
    populateSite();
}