modformcustomizationprofile.class.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. require_once (dirname(__DIR__) . '/modformcustomizationprofile.class.php');
  11. /**
  12. * @package modx
  13. * @subpackage mysql
  14. */
  15. class modFormCustomizationProfile_mysql extends modFormCustomizationProfile {
  16. public static function listProfiles(xPDO &$xpdo, array $criteria = array(), array $sort = array('id' => 'ASC'), $limit = 0, $offset = 0) {
  17. /* query for profiles */
  18. $c = $xpdo->newQuery('modFormCustomizationProfile');
  19. $c->select(array(
  20. 'modFormCustomizationProfile.*',
  21. ));
  22. $c->select('
  23. (SELECT GROUP_CONCAT(UserGroup.name) FROM '.$xpdo->getTableName('modUserGroup').' AS UserGroup
  24. INNER JOIN '.$xpdo->getTableName('modFormCustomizationProfileUserGroup').' AS fcpug
  25. ON fcpug.usergroup = UserGroup.id
  26. WHERE fcpug.profile = modFormCustomizationProfile.id
  27. ) AS usergroups
  28. ');
  29. $c->where($criteria,null,2);// also log issue in remine to look at this usage of where()
  30. $count = $xpdo->getCount('modFormCustomizationProfile',$c);
  31. foreach($sort as $field=> $dir) {
  32. $c->sortby($xpdo->getSelectColumns('modFormCustomizationProfile','modFormCustomizationProfile','',array($field)),$dir);
  33. }
  34. if ((int) $limit > 0) {
  35. $c->limit((int) $limit, (int) $offset);
  36. }
  37. return array(
  38. 'count'=> $count,
  39. 'collection'=> $xpdo->getCollection('modFormCustomizationProfile',$c)
  40. );
  41. }
  42. }