コード例 #1
0
ファイル: FLVar.cpp プロジェクト: Miguel-J/eneboo-core
bool FLVar::set(const QString &n, const QVariant &v)
{
  QString idSesion(aqApp->timeUser().toString(Qt::ISODate));
  QString where(QString::fromLatin1("idvar='") + n +
                QString::fromLatin1("' AND idsesion='") + idSesion +
                QString::fromLatin1("'"));

  FLSqlQuery q;
  q.setTablesList("flvar");
  q.setSelect("id");
  q.setFrom("flvar");
  q.setWhere(where);
  q.setForwardOnly(true);

  if (!q.exec())
    return false;
  if (q.next())
    return FLUtil::sqlUpdate("flvar", "valor", v.toString(),
                             QString::fromLatin1("id='") + q.value(0).toString() +
                             QString::fromLatin1("'"));

  QString values(n + QString::fromLatin1(",") + idSesion +
                 QString::fromLatin1(",") + v.toString());
  return FLUtil::sqlInsert("flvar", "idvar,idsesion,valor", values);
}
コード例 #2
0
void FLAccessControlLists::makeRuleGroup(FLSqlQuery *q, QDomDocument *d, const QString &idgroup)
{
  if (idgroup.isEmpty() || !q || !d)
    return;

  FLSqlQuery qU;

  qU.setTablesList("flusers");
  qU.setSelect("iduser");
  qU.setFrom("flusers");
  qU.setWhere(QString::fromLatin1("idgroup='") + idgroup + QString::fromLatin1("'"));
  qU.setForwardOnly(true);

  if (qU.exec())
    while (qU.next())
      makeRuleUser(q, d, qU.value(0).toString());
}
コード例 #3
0
void FLAccessControlLists::makeRuleUser(FLSqlQuery *q, QDomDocument *d, const QString &iduser)
{
  if (iduser.isEmpty() || !q || !d)
    return;

  FLAccessControl *ac = FLAccessControlFactory::create(q->value(1).toString());

  if (ac) {
    ac->setName(q->value(2).toString());
    ac->setUser(iduser);
    ac->setPerm(q->value(6).toString());

    FLSqlQuery qAcos;

    qAcos.setTablesList("flacos");
    qAcos.setSelect("nombre,permiso");
    qAcos.setFrom("flacos");
    qAcos.setWhere(QString::fromLatin1("idac='") + q->value(0).toString() +
                   QString::fromLatin1("'"));
    qAcos.setForwardOnly(true);

    QStringList acos;

    if (qAcos.exec()) {
      while (qAcos.next()) {
        acos << qAcos.value(0).toString();
        acos << qAcos.value(1).toString();
      }
    }

    ac->setAcos(acos);
    ac->get(d);

    delete ac;
  }
}