modformcustomizationprofile.class.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 sqlsrv
  14. */
  15. class modFormCustomizationProfile_sqlsrv extends modFormCustomizationProfile {
  16. public static function listProfiles(xPDO &$xpdo, array $criteria = array(), array $sort = array('id' => 'ASC'), $limit = 0, $offset = 0) {
  17. $objCollection= array ();
  18. /* query for profiles */
  19. $c = $xpdo->newQuery('modFormCustomizationProfile');
  20. $c->select(array(
  21. $xpdo->getSelectColumns('modFormCustomizationProfile','modFormCustomizationProfile'),
  22. ));
  23. $c->where($criteria,null,2);// also log issue in remine to look at this usage of where()
  24. $count = $xpdo->getCount('modFormCustomizationProfile',$c);
  25. foreach($sort as $field=> $dir) {
  26. $c->sortby($xpdo->getSelectColumns('modFormCustomizationProfile','modFormCustomizationProfile','',array($field)),$dir);
  27. }
  28. if ((int) $limit > 0) {
  29. $c->limit((int) $limit, (int) $offset);
  30. }
  31. $rows= xPDOObject :: _loadRows($xpdo, 'modFormCustomizationProfile', $c);
  32. $rowsArray = $rows->fetchAll(PDO::FETCH_ASSOC);
  33. $rows->closeCursor();
  34. foreach($rowsArray as $row) {
  35. $objCollection[] = $xpdo->call('modFormCustomizationProfile', '_loadInstance', array(&$xpdo, 'modFormCustomizationProfile', $c, $row));
  36. }
  37. unset($row, $rowsArray);
  38. return array(
  39. 'count'=> $count,
  40. 'collection'=> $objCollection
  41. );
  42. }
  43. public static function _loadInstance(& $xpdo, $className, $criteria, $row) {
  44. $sql = "SELECT gr.[name]
  45. FROM {$xpdo->config['table_prefix']}membergroup_names AS gr,
  46. {$xpdo->config['table_prefix']}fc_profiles_usergroups AS pu,
  47. {$xpdo->config['table_prefix']}fc_profiles AS pr
  48. WHERE gr.id = pu.usergroup
  49. AND pu.profile = pr.id
  50. AND pr.id = {$row['id']}
  51. ORDER BY gr.name";
  52. $groupNamesStatement = $xpdo->query($sql);
  53. $groupNamesArray = $groupNamesStatement->fetchAll(PDO::FETCH_COLUMN, 0);
  54. $row['usergroups'] = implode(', ', $groupNamesArray);
  55. return parent :: _loadInstance($xpdo, $className, $criteria, $row);
  56. }
  57. }
  58. ?>