人人商城

ProfileFields.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. namespace We7\Table\Core;
  7. class ProfileFields extends \We7Table {
  8. protected $tableName = 'profile_fields';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'field',
  12. 'available',
  13. 'title',
  14. 'description',
  15. 'displayorder',
  16. 'required',
  17. 'unchangeable',
  18. 'showinregister',
  19. 'field_length',
  20. );
  21. protected $default = array(
  22. 'field' => '',
  23. 'available' => 1,
  24. 'title' => '',
  25. 'description' => '',
  26. 'displayorder' => 0,
  27. 'required' => 0,
  28. 'unchangeable' => 0,
  29. 'showinregister' => 0,
  30. 'field_length' => 0,
  31. );
  32. public function getProfileFields() {
  33. return $this->query->from($this->tableName)->getall('field');
  34. }
  35. public function searchKeyword($keyword) {
  36. $this->query->where('title LIKE', "%{$keyword}%");
  37. return $this;
  38. }
  39. public function getFieldsList() {
  40. return $this->query->from($this->tableName)->orderby('displayorder', 'DESC')->getall();
  41. }
  42. public function getExtraFields() {
  43. $default_field = array('realname', 'births', 'qq', 'mobile', 'address', 'resides');
  44. $fields = $this->getFieldsList();
  45. $extra_fields = array();
  46. if (!empty($fields) && is_array($fields)) {
  47. foreach ($fields as $field_info) {
  48. if ($field_info['available'] == 1 && $field_info['showinregister'] == 1 && !in_array($field_info['field'], $default_field)) {
  49. $extra_fields[] = $field_info;
  50. }
  51. }
  52. }
  53. return $extra_fields;
  54. }
  55. }