Beispiel #1
0
 /**
  * Setup additional keys/values when searching all created
  *
  * @param $searchTerms
  * @param $roles
  * @param $adminId
  * @return array|mixed
  */
 public function prepareSearchAllCreated($searchTerms, $roles, $adminId)
 {
     // If user has root privileges, get all the plans that were created.
     // Otherwise just get the plans created with administrator privilege.
     $adminList = [];
     $roleName = '';
     if (in_array('root', $roles)) {
         $userId = 0;
         $roleName = 'root';
     }
     // Display selected creator of the plan
     if (isset($adminId)) {
         $userId = $adminId;
     }
     // Administrators who created plans
     $admins = $this->userApi->getAllUsersByRole(['root', 'administrator']);
     // Set up dropdown list of all admins
     $adminsList = Tools::getUsersDropdrownOptions($admins, 'admin');
     $columns = ['description', 'first_name', 'last_name', 'status', 'created_at', 'updated_at', 'edit'];
     $results = $this->tablesApi->searchPlans($searchTerms, $columns);
     $results += ['userId' => $userId, 'role' => $roleName, 'adminsList' => $adminsList];
     return $results;
 }