PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/core/model/modx/mysql/modusersetting.class.php

http://github.com/modxcms/revolution
PHP | 40 lines | 31 code | 1 blank | 8 comment | 0 complexity | 702992756c3acfc8206bcf0ed6b4497f MD5 | raw file
Possible License(s): GPL-2.0, Apache-2.0, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /*
  3. * This file is part of MODX Revolution.
  4. *
  5. * Copyright (c) MODX, LLC. All Rights Reserved.
  6. *
  7. * For complete copyright and license information, see the COPYRIGHT and LICENSE
  8. * files found in the top-level directory of this distribution.
  9. */
  10. include_once (strtr(realpath(dirname(__FILE__)), '\\', '/') . '/../modusersetting.class.php');
  11. /**
  12. * @package modx
  13. * @subpackage mysql
  14. */
  15. class modUserSetting_mysql extends modUserSetting {
  16. public static function listSettings(xPDO &$xpdo, array $criteria = array(), array $sort = array('id' => 'ASC'), $limit = 0, $offset = 0) {
  17. $c = $xpdo->newQuery('modUserSetting');
  18. $c->select(array(
  19. $xpdo->getSelectColumns('modUserSetting','modUserSetting'),
  20. 'Entry.value AS name_trans',
  21. 'Description.value AS description_trans',
  22. ));
  23. $c->leftJoin('modLexiconEntry','Entry',"CONCAT('setting_',modUserSetting.`key`) = Entry.name");
  24. $c->leftJoin('modLexiconEntry','Description',"CONCAT('setting_',modUserSetting.`key`,'_desc') = Description.name");
  25. $c->where($criteria);
  26. $count = $xpdo->getCount('modUserSetting',$c);
  27. $c->sortby($xpdo->getSelectColumns('modUserSetting','modUserSetting','',array('area')),'ASC');
  28. foreach($sort as $field=> $dir) {
  29. $c->sortby($xpdo->getSelectColumns('modUserSetting','modUserSetting','',array($field)),$dir);
  30. }
  31. if ((int) $limit > 0) {
  32. $c->limit((int) $limit, (int) $offset);
  33. }
  34. return array(
  35. 'count'=> $count,
  36. 'collection'=> $xpdo->getCollection('modUserSetting',$c)
  37. );
  38. }
  39. }