# shiftcontroller/4.9.66/sh4/employees/html/admin/controller/user.php

ShiftController Employee Shift Scheduling, version 4.9.66. 34 lines.

- Page: https://pluginprobe.com/plugins/shiftcontroller/4.9.66/code/sh4/employees/html/admin/controller/user.php
- Raw: https://pluginprobe.com/plugins/shiftcontroller/4.9.66/raw/sh4/employees/html/admin/controller/user.php
- Modified: 2023-05-29T12:46:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/shiftcontroller/4.9.66/code/sh4/employees/html/admin/controller/user.php#L10-L20`.

```php
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
#[AllowDynamicProperties]
class SH4_Employees_Html_Admin_Controller_User
{
	public function __construct(
		HC3_Hooks $hooks,

		SH4_App_Command $appCommand,
		SH4_Employees_Query $query,
		HC3_Users_Query $usersQuery
		)
	{
		$this->appCommand = $hooks->wrap($appCommand);
		$this->usersQuery = $hooks->wrap($usersQuery);
		$this->query = $hooks->wrap($query);
	}

	public function execute( $id, $userId )
	{
		$employee = $this->query->findById( $id );
		$user = $this->usersQuery->findById( $userId );

		if( $user && $userId ){
			$this->appCommand->linkEmployeeToUser( $employee, $user );
			$return = array( 'admin/employees', '__Employee Linked To User Account__' );
		}
		else {
			$this->appCommand->unlinkEmployeeFromUser( $employee );
			$return = array( 'admin/employees', '__Employee Unlinked From User Account__' );
		}

		return $return;
	}
}
```
