Modules.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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\Uni;
  7. class Modules extends \We7Table {
  8. protected $tableName = 'uni_modules';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'uniacid',
  12. 'module_name',
  13. );
  14. protected $default = array(
  15. 'uniacid' => '',
  16. 'module_name' => '',
  17. );
  18. public function getallByUniacid($uniacid) {
  19. return $this->query->where('uniacid', $uniacid)->getall();
  20. }
  21. public function searchLikeModuleTitle($module_title) {
  22. return $this->query->where('m.title LIKE', "%{$module_title}%");
  23. }
  24. public function searchWithModuleLetter($module_letter) {
  25. return $this->query->where('m.title_initial', $module_letter);
  26. }
  27. public function searchWithModuleName($module_name) {
  28. $this->query->where('u.module_name', $module_name);
  29. }
  30. public function searchGroupbyModuleName() {
  31. return $this->query->groupby('u.module_name');
  32. }
  33. public function getModulesByUid($uid, $uniacid = 0) {
  34. global $_W;
  35. if (empty($uid)) {
  36. $uid = $_W['uid'];
  37. }
  38. if (!empty($uniacid)) {
  39. $this->where('u.uniacid', $uniacid);
  40. } else {
  41. $this->where('u.uniacid <>', 0);
  42. }
  43. $select_fields = "
  44. u.uniacid,
  45. u.module_name
  46. ";
  47. if (!user_is_founder($uid) && $_W['highest_role'] != ACCOUNT_MANAGE_NAME_CLERK || user_is_vice_founder($uid)) {
  48. $select_fields .= ", uau.role";
  49. $this->where('uau.uid', $uid);
  50. $this->query->from('uni_account_users', 'uau')
  51. ->leftjoin('uni_modules', 'u')
  52. ->on(array('uau.uniacid' => 'u.uniacid'));
  53. } elseif (!user_is_founder($uid) && $_W['highest_role'] == ACCOUNT_MANAGE_NAME_CLERK) {
  54. $select_fields .= ", up.uniacid as permission_uniacid";
  55. $this->where('up.uid', $uid);
  56. $this->query->from('users_permission', 'up')
  57. ->leftjoin('uni_modules', 'u')
  58. ->on(array('up.type' => 'u.module_name'));
  59. } else {
  60. $this->query->from('uni_modules', 'u');
  61. }
  62. $modules = $this->query
  63. ->select($select_fields)
  64. ->getall();
  65. $total = $this->getLastQueryTotal();
  66. return array('modules' => $modules, 'total' => $total);
  67. }
  68. public function deleteUniModules($module_name, $uniacid) {
  69. $this->query->where('module_name', $module_name)->where('uniacid', $uniacid)->delete();
  70. }
  71. }