@@ -22,14 +22,17 @@ class IndexController extends ActionController
2222{
2323 /**
2424 * Default action
25+ *
2526 * @return array|void
2627 */
2728 public function indexAction ()
2829 {
2930 $ this ->view ()->setTemplate ('user ' );
30- $ this ->view ()->assign ([
31- 'roles ' => $ this ->getRoles (),
32- ]);
31+ $ this ->view ()->assign (
32+ [
33+ 'roles ' => $ this ->getRoles (),
34+ ]
35+ );
3336 }
3437
3538 /**
@@ -43,6 +46,7 @@ public function allAction()
4346 $ limit = Pi::config ('list_limit ' , 'user ' );
4447 $ offset = (int )($ page - 1 ) * $ limit ;
4548
49+ $ condition = [];
4650 $ condition ['activated ' ] = _get ('activated ' ) ?: '' ;
4751 $ condition ['active ' ] = _get ('active ' ) ?: '' ;
4852 $ condition ['enable ' ] = _get ('enable ' ) ?: '' ;
@@ -51,8 +55,9 @@ public function allAction()
5155 $ condition ['register_date ' ] = _get ('register_date ' ) ?: '' ;
5256 $ condition ['name ' ] = _get ('name ' ) ?: '' ;
5357 $ condition ['email ' ] = _get ('email ' ) ?: '' ;
58+ $ condition ['identity ' ] = _get ('identity ' ) ?: '' ;
5459
55- list ( $ users , $ count) = $ this ->getUsers ($ condition , $ limit , $ offset );
60+ [ $ users , $ count] = $ this ->getUsers ($ condition , $ limit , $ offset );
5661
5762 // Set paginator
5863 $ paginator = [
@@ -79,6 +84,7 @@ public function activatedAction()
7984 $ limit = Pi::config ('list_limit ' , 'user ' );
8085 $ offset = (int )($ page - 1 ) * $ limit ;
8186
87+ $ condition = [];
8288 $ condition ['activated ' ] = 'activated ' ;
8389 $ condition ['active ' ] = _get ('active ' ) ?: '' ;
8490 $ condition ['enable ' ] = _get ('enable ' ) ?: '' ;
@@ -88,8 +94,9 @@ public function activatedAction()
8894 $ condition ['search ' ] = _get ('search ' ) ?: '' ;
8995 $ condition ['name ' ] = _get ('name ' ) ?: '' ;
9096 $ condition ['email ' ] = _get ('email ' ) ?: '' ;
97+ $ condition ['identity ' ] = _get ('identity ' ) ?: '' ;
9198
92- list ( $ users , $ count) = $ this ->getUsers ($ condition , $ limit , $ offset );
99+ [ $ users , $ count] = $ this ->getUsers ($ condition , $ limit , $ offset );
93100
94101 // Set paginator
95102 $ paginator = [
@@ -116,6 +123,7 @@ public function pendingAction()
116123 $ limit = Pi::config ('list_limit ' , 'user ' );
117124 $ offset = (int )($ page - 1 ) * $ limit ;
118125
126+ $ condition = [];
119127 $ condition ['activated ' ] = 'pending ' ;
120128 $ condition ['enable ' ] = _get ('enable ' ) ?: '' ;
121129 $ condition ['front_role ' ] = _get ('front_role ' ) ?: '' ;
@@ -124,8 +132,9 @@ public function pendingAction()
124132 $ condition ['search ' ] = _get ('search ' ) ?: '' ;
125133 $ condition ['name ' ] = _get ('name ' ) ?: '' ;
126134 $ condition ['email ' ] = _get ('email ' ) ?: '' ;
135+ $ condition ['identity ' ] = _get ('identity ' ) ?: '' ;
127136
128- list ( $ users , $ count) = $ this ->getUsers ($ condition , $ limit , $ offset );
137+ [ $ users , $ count] = $ this ->getUsers ($ condition , $ limit , $ offset );
129138
130139 // Set paginator
131140 $ paginator = [
@@ -287,7 +296,7 @@ public function searchAction()
287296 $ limit = Pi::config ('list_limit ' , 'user ' );
288297 $ offset = (int )($ page - 1 ) * $ limit ;
289298
290- list ( $ users , $ count) = $ this ->getUsers ($ condition , $ limit , $ offset );
299+ [ $ users , $ count] = $ this ->getUsers ($ condition , $ limit , $ offset );
291300
292301 // Set paginator
293302 $ paginator = [
@@ -408,7 +417,7 @@ public function deleteUserAction()
408417 foreach ($ uids as $ uid ) {
409418 $ status = Pi::api ('user ' , 'user ' )->deleteUser ($ uid );
410419 if (Pi::service ('module ' )->isActive ('subscription ' )) {
411- Pi::api ('people ' , 'subscription ' )->update (array ( 'status ' => 0 ) , $ uid );
420+ Pi::api ('people ' , 'subscription ' )->update ([ 'status ' => 0 ] , $ uid );
412421 }
413422 if (!is_array ($ status ) && $ status !== false ) {
414423 $ count ++;
@@ -547,9 +556,11 @@ public function assignRoleAction()
547556 }
548557
549558 $ users = [];
550- array_walk ($ uids , function ($ uid ) use (&$ users ) {
559+ array_walk (
560+ $ uids , function ($ uid ) use (&$ users ) {
551561 $ users [$ uid ] = ['id ' => $ uid ];
552- });
562+ }
563+ );
553564 $ data = $ this ->renderRole ($ users );
554565 $ result ['data ' ] = $ data ;
555566 $ result ['status ' ] = 1 ;
@@ -561,7 +572,7 @@ public function assignRoleAction()
561572 /**
562573 * Get users and count according to conditions
563574 *
564- * @param $condition
575+ * @param $condition
565576 * @param int $limit
566577 * @param int $offset
567578 *
@@ -630,10 +641,12 @@ protected function getUsers($condition, $limit = 0, $offset = 0)
630641 $ i = 1 ;
631642 foreach ($ condition ['front_role ' ] as $ role ) {
632643 $ prefix = $ i ;
633- $ whereRoleFront = Pi::db ()->where ()->create ([
634- 'front ' . $ prefix . '.role ' => $ role ,
635- 'front ' . $ prefix . '.section ' => 'front ' ,
636- ]);
644+ $ whereRoleFront = Pi::db ()->where ()->create (
645+ [
646+ 'front ' . $ prefix . '.role ' => $ role ,
647+ 'front ' . $ prefix . '.section ' => 'front ' ,
648+ ]
649+ );
637650 $ where ->add ($ whereRoleFront );
638651 $ select ->join (
639652 ['front ' . $ prefix => $ modelRole ->getTable ()],
@@ -643,10 +656,12 @@ protected function getUsers($condition, $limit = 0, $offset = 0)
643656 $ i ++;
644657 }
645658 } else {
646- $ whereRoleFront = Pi::db ()->where ()->create ([
647- 'front.role ' => $ condition ['front_role ' ],
648- 'front.section ' => 'front ' ,
649- ]);
659+ $ whereRoleFront = Pi::db ()->where ()->create (
660+ [
661+ 'front.role ' => $ condition ['front_role ' ],
662+ 'front.section ' => 'front ' ,
663+ ]
664+ );
650665 $ where ->add ($ whereRoleFront );
651666 $ select ->join (
652667 ['front ' => $ modelRole ->getTable ()],
@@ -661,10 +676,12 @@ protected function getUsers($condition, $limit = 0, $offset = 0)
661676 $ i = 1 ;
662677 foreach ($ condition ['admin_role ' ] as $ role ) {
663678 $ prefix = $ i ;
664- $ whereRoleFront = Pi::db ()->where ()->create ([
665- 'admin ' . $ prefix . '.role ' => $ role ,
666- 'admin ' . $ prefix . '.section ' => 'admin ' ,
667- ]);
679+ $ whereRoleFront = Pi::db ()->where ()->create (
680+ [
681+ 'admin ' . $ prefix . '.role ' => $ role ,
682+ 'admin ' . $ prefix . '.section ' => 'admin ' ,
683+ ]
684+ );
668685 $ where ->add ($ whereRoleFront );
669686 $ select ->join (
670687 ['admin ' . $ prefix => $ modelRole ->getTable ()],
@@ -674,10 +691,12 @@ protected function getUsers($condition, $limit = 0, $offset = 0)
674691 $ i ++;
675692 }
676693 } else {
677- $ whereRoleFront = Pi::db ()->where ()->create ([
678- 'admin.role ' => $ condition ['admin_role ' ],
679- 'admin.section ' => 'admin ' ,
680- ]);
694+ $ whereRoleFront = Pi::db ()->where ()->create (
695+ [
696+ 'admin.role ' => $ condition ['admin_role ' ],
697+ 'admin.section ' => 'admin ' ,
698+ ]
699+ );
681700 $ where ->add ($ whereRoleFront );
682701 $ select ->join (
683702 ['admin ' => $ modelRole ->getTable ()],
@@ -689,9 +708,11 @@ protected function getUsers($condition, $limit = 0, $offset = 0)
689708
690709 if (!empty ($ condition ['ip_register ' ])) {
691710 $ profileModel = $ this ->getModel ('profile ' );
692- $ whereProfile = Pi::db ()->where ()->create ([
693- 'profile.ip_register like ? ' => '% ' . $ condition ['ip_register ' ] . '% ' ,
694- ]);
711+ $ whereProfile = Pi::db ()->where ()->create (
712+ [
713+ 'profile.ip_register like ? ' => '% ' . $ condition ['ip_register ' ] . '% ' ,
714+ ]
715+ );
695716 $ where ->add ($ whereProfile );
696717 $ select ->join (
697718 ['profile ' => $ profileModel ->getTable ()],
@@ -746,18 +767,22 @@ protected function getUsers($condition, $limit = 0, $offset = 0)
746767 'register_source ' ,
747768 ];
748769 $ users = Pi::api ('user ' , 'user ' )->get ($ uids , $ columns );
749- array_walk ($ users , function (&$ user , $ uid ) {
750- $ user ['link ' ] = Pi::service ('user ' )->getUrl ('profile ' , [
770+ array_walk (
771+ $ users , function (&$ user , $ uid ) {
772+ $ user ['link ' ] = Pi::service ('user ' )->getUrl (
773+ 'profile ' , [
751774 'id ' => $ uid ,
752- ]);
775+ ]
776+ );
753777 $ user ['active ' ] = (bool )$ user ['active ' ];
754778 $ user ['time_disabled ' ] = $ user ['time_disabled ' ]
755779 ? _date ($ user ['time_disabled ' ]) : 0 ;
756780 $ user ['time_activated ' ] = $ user ['time_activated ' ]
757781 ? _date ($ user ['time_activated ' ]) : 0 ;
758782 $ user ['time_created ' ] = $ user ['time_created ' ]
759783 ? _date ($ user ['time_created ' ]) : 0 ;
760- });
784+ }
785+ );
761786 $ users = $ this ->renderRole ($ users );
762787 }
763788 }
@@ -876,14 +901,16 @@ protected function renderRole(array $users)
876901 $ roleKey = $ section . '_roles ' ;
877902 $ roleList [$ uid ][$ roleKey ][] = $ roles [$ row ['role ' ]]['title ' ];
878903 }
879- array_walk ($ users , function (&$ user , $ uid ) use ($ roleList ) {
904+ array_walk (
905+ $ users , function (&$ user , $ uid ) use ($ roleList ) {
880906 if (isset ($ roleList [$ uid ]['front_roles ' ])) {
881907 $ user ['front_roles ' ] = $ roleList [$ uid ]['front_roles ' ];
882908 }
883909 if (isset ($ roleList [$ uid ]['admin_roles ' ])) {
884910 $ user ['admin_roles ' ] = $ roleList [$ uid ]['admin_roles ' ];
885911 }
886- });
912+ }
913+ );
887914
888915 return $ users ;
889916 }
@@ -892,6 +919,7 @@ protected function renderRole(array $users)
892919 * Get users status: active, activated, disable
893920 *
894921 * @param int[] $uids
922+ *
895923 * @return array
896924 */
897925 protected function getUserStatus ($ uids )
@@ -919,9 +947,10 @@ protected function getUserStatus($uids)
919947 /**
920948 * Delete user field
921949 *
922- * @param $uid
923- * @param $field
950+ * @param $uid
951+ * @param $field
924952 * @param string $type core or user
953+ *
925954 * @return int
926955 */
927956 protected function deleteUser ($ uid , $ field , $ type = '' )
@@ -963,10 +992,12 @@ protected function sendNotification($uid)
963992 $ failedUsers = [];
964993 foreach ($ users as $ id => $ data ) {
965994 $ redirect = Pi::user ()->data ()->get ($ id , 'register_redirect ' ) ?: '' ;
966- $ url = Pi::api ('user ' , 'user ' )->getUrl ('login ' , [
995+ $ url = Pi::api ('user ' , 'user ' )->getUrl (
996+ 'login ' , [
967997 'redirect ' => $ redirect ,
968998 'section ' => 'front ' ,
969- ]);
999+ ]
1000+ );
9701001 $ url = Pi::url ($ url , true );
9711002 $ params = [
9721003 'username ' => $ data ['identity ' ],
0 commit comments