コード例 #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;
  }
}
コード例 #4
0
void FLAccessControlLists::installACL(const QString &idacl)
{
  QDomDocument doc("ACL");

  QDomElement root = doc.createElement("ACL");
  doc.appendChild(root);

  QDomElement name = doc.createElement("name");
  root.appendChild(name);
  QDomText n = doc.createTextNode(idacl);
  name.appendChild(n);

  FLSqlQuery q;

  q.setTablesList("flacs");
  q.setSelect("idac,tipo,nombre,iduser,idgroup,degrupo,permiso");
  q.setFrom("flacs");
  q.setWhere(QString::fromLatin1("idacl='") + idacl + QString::fromLatin1("'"));
  q.setOrderBy("prioridad DESC,tipo");
  q.setForwardOnly(true);

  if (q.exec()) {
    uint step = 0;
    QProgressDialog progress(QApplication::tr("Instalando control de acceso..."), 0,
                             q.size(), 0, 0, true);
    progress.setCaption(QApplication::tr("Instalando ACL"));
    progress.setMinimumDuration(0);
    progress.setProgress(++step);
    while (q.next()) {
      makeRule(&q, &doc);
      progress.setProgress(++step);
    }
    FLSqlConnections::database()->managerModules()->setContent("acl.xml", "sys",
                                                               doc.toString());
  }
}
コード例 #5
0
FLSqlQuery *FLManager::query(const QString &n, QObject *parent)
{
  FLSqlQuery *q;
  QDomDocument doc(n);

  if (!FLUtil::domDocumentSetContent(
        doc, db_->managerModules()->contentCached(n + QString::fromLatin1(".qry"))
      )) {
#ifdef FL_DEBUG
    qWarning("FLManager : " + QApplication::tr("Error al cargar la consulta %1").arg(n));
#endif

    return 0;
  }

  q = new FLSqlQuery(parent, db_->connectionName());

  QDomElement docElem = doc.documentElement();
  QDomNode no = docElem.firstChild();

  while (!no.isNull()) {
    QDomElement e = no.toElement();

    if (!e.isNull()) {
      if (e.tagName() == "name") {
        q->setName(e.text());
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "tables") {
        q->setTablesList(e.text());
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "select") {
        q->setSelect(e.text());
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "from") {
        q->setFrom(e.text());
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "where") {
        q->setWhere(e.text());
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "param") {
        q->addParameter(queryParameter(&e));
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "group") {
        q->addGroup(queryGroup(&e));
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "order") {
        q->setOrderBy(e.text());
        no = no.nextSibling();
        continue;
      }
    }
    no = no.nextSibling();
  }

  return q;
}