PluginProbe
ShiftController Employee Shift Scheduling / 4.9.66
ShiftController Employee Shift Scheduling v4.9.66
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
← All changes | sh4/app/query.php +20 -12 4.9.964.9.66 View file →
@@ -76,15 +76,11 @@
76 76 global $wpdb;
77 77 $sql = 'SELECT post_id AS employee_id, meta_value AS user_id FROM ' . $wpdb->postmeta . ' wpostmeta' . ' JOIN ' . $wpdb->posts . ' wposts ON wposts.ID = wpostmeta.post_id WHERE wpostmeta.meta_key="user_id" AND wposts.post_type="sh4_employee"';
78 78 $res = $wpdb->get_results( $sql, ARRAY_A );
79 79 foreach( $res as $e ){
80 - if (!isset($e['user_id'])) {
81 - continue;
82 - }
83 80 if( ! $e['employee_id'] ) continue;
84 - if( ! $e['user_id'] ) continue;
85 81 $this->repoEmployeeUser[ $e['employee_id'] ] = $e['user_id'];
86 - $this->repoUserEmployee[ $e['user_id'] ?? '' ] = $e['employee_id'];
82 + $this->repoUserEmployee[ $e['user_id'] ] = $e['employee_id'];
87 83 }
88 84
89 85 if( $this->repoUserEmployee ){
90 86 $this->repoUser = $this->usersQuery->findManyById( array_keys($this->repoUserEmployee) );
@@ -515,29 +511,41 @@
515 511
516 512 return $ret;
517 513 }
518 514
519 - public function findEmployeeByUserId( $userId )
515 + public function findEmployeeByUser( HC3_Users_Model $user )
520 516 {
521 517 $ret = null;
518 +
519 + $userId = $user->getId();
522 520 if( ! $userId ){
523 521 return $ret;
524 522 }
525 523
526 524 $employeeId = isset( $this->repoUserEmployee[$userId] ) ? $this->repoUserEmployee[$userId] : null;
525 +
526 + // $crud = $this->crudFactory->make('employee');
527 + // $args = array();
528 + // $args[] = array('user_id', '=', $userId );
529 + // $results = $crud->read( $args );
530 +
531 + // if( ! $results ){
532 + // return $ret;
533 + // }
534 +
535 + // $results = array_shift( $results );
536 + // $employeeId = array_key_exists('id', $results) ? $results['id'] : null;
537 +
527 538 if( ! $employeeId ){
528 539 return $ret;
529 540 }
530 541
542 + // $ret = $this->employeesQuery->findById( $employeeId );
543 +
531 544 if( ! isset($this->repoEmployee[$employeeId]) ){
532 545 $this->repoEmployee[$employeeId] = $this->employeesQuery->findById( $employeeId );
533 546 }
534 - $ret = $this->repoEmployee[$employeeId];
547 + $ret = $this->repoEmployee[$employeeId];
535 548
536 549 return $ret;
537 - }
538 -
539 - public function findEmployeeByUser( HC3_Users_Model $user )
540 - {
541 - return $this->self->findEmployeeByUserId( $user->getId() );
542 550 }
543 551 }