public function getRecipients()
 {
     $recipients_list = array();
     if (isset($this->notification['send_conditions'])) {
         //echo $this -> notification['send_conditions'];
         if ($this->notification['send_conditions'] == "N;") {
             $recipients = eF_getTableData("users", "*", "active=1 and archive=0");
             //sending_queue_msgs[$key]['recipients'] = _ALLUSERS;
             foreach ($recipients as $recipient) {
                 $recipients_list[$recipient['login']] = $recipient;
             }
         } else {
             // the send_conditions field contains the information which identify the recipients
             // it is defined in ....
             //digests.php during the definition of the event notification
             $this->notification['send_conditions'] = unserialize($this->notification['send_conditions']);
             if ($this->notification['send_conditions'] == "supervisors") {
                 if (G_VERSIONTYPE == 'enterprise') {
                     #cpp#ifdef ENTERPRISE
                     $recipients = eF_getTableData("module_hcd_employee_works_at_branch as meb, users as u", "u.*", "meb.users_login=u.login and u.active=1 and u.archive=0 and meb.supervisor=1");
                     foreach ($recipients as $recipient) {
                         $recipients_list[$recipient['login']] = $recipient;
                     }
                 }
                 #cpp#endif
             } elseif (is_array($this->notification['send_conditions'])) {
                 $this->recipients = $this->notification['send_conditions'];
                 // The recipients array definitely exists, due to constructor checks
                 if (isset($this->recipients["lessons_ID"]) && $this->recipients["lessons_ID"]) {
                     $lesson = new EfrontLesson($this->recipients["lessons_ID"]);
                     if (isset($this->recipients["user_type"])) {
                         // return lesson users of specific type
                         $recipients = array();
                         foreach ($lesson->getUsers($this->recipients["user_type"]) as $value) {
                             if ($value['active']) {
                                 $recipients[] = $value;
                             }
                         }
                     } else {
                         if (isset($this->recipients["completed"])) {
                             // return lesson students according to whether they have completed the lesson or not
                             $recipients = array();
                             foreach ($lesson->getUsersCompleted($this->recipients["completed"]) as $value) {
                                 if ($value['active']) {
                                     $recipients[] = $value;
                                 }
                             }
                         } else {
                             // return all users
                             $recipients = array();
                             foreach ($lesson->getUsers() as $value) {
                                 if ($value['active']) {
                                     $recipients[] = $value;
                                 }
                             }
                         }
                     }
                 } else {
                     if (isset($this->recipients["courses_ID"])) {
                         $entity_parts = explode("_", $this->notification['id_type_entity']);
                         $notification_type = $entity_parts[1];
                         if ($this->recipients['user_type'] == "professor") {
                             $completed_condition = " AND uc.user_type = 'professor'";
                         } else {
                             if ($this->recipients['completed'] == "1") {
                                 $completed_condition = " AND completed = '1'";
                             } else {
                                 if ($this->recipients['completed'] == "2" || $notification_type == EfrontEvent::COURSE_PROGRAMMED_EXPIRY) {
                                     $completed_condition = " AND completed = '0' and uc.user_type in ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "')";
                                 } else {
                                     $completed_condition = "";
                                 }
                             }
                         }
                         if ($this->recipients['supervisor']) {
                             if ($this->recipients['users_login']) {
                                 $editedUser = EfrontUserFactory::factory($this->recipients['users_login']);
                                 //new EfrontUser();
                                 $editedEmployee = $editedUser->aspects['hcd'];
                                 $supervisors = $editedEmployee->getSupervisors();
                                 $recipients = array();
                                 foreach ($supervisors as $supervisor) {
                                     $recipients[$supervisor] = array("login" => $supervisor);
                                 }
                             } else {
                                 $query = "select distinct u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID from module_hcd_employee_works_at_branch ewb join users u on u.login=ewb.users_login where supervisor=1 and u.active=1 and u.archive=0 and branch_ID in (select branch_ID from module_hcd_employee_works_at_branch ewb, users_to_courses uc where uc.users_LOGIN=ewb.users_login and uc.courses_ID=" . $this->recipients["courses_ID"] . " and uc.archive=0)";
                                 //get course users' supervisors
                                 $result = eF_executeNew($query);
                                 $recipients = $result->getAll();
                             }
                         } elseif ($this->recipients['immediate_supervisor']) {
                             if ($this->recipients['users_login']) {
                                 $result = eF_getTableDataFlat("module_hcd_employee_works_at_branch", "users_LOGIN", "supervisor=1 and assigned=1 and branch_ID IN (select branch_ID from module_hcd_employee_works_at_branch where assigned=1 and supervisor=0 and users_login='******'users_login'] . "')");
                                 $recipients = array();
                                 foreach ($result['users_LOGIN'] as $supervisor) {
                                     $recipients[$supervisor] = array("login" => $supervisor);
                                 }
                                 $filtered_recipients = array();
                                 if (!empty($recipients)) {
                                     $active_recipients = eF_getTableDataFlat("users", "login", "active=1 and archive=0 and login IN ('" . implode("','", array_keys($recipients)) . "')");
                                     foreach ($active_recipients["login"] as $login) {
                                         $filtered_recipients[$login] = array("login" => $login);
                                     }
                                     $recipients = $filtered_recipients;
                                 }
                             } else {
                                 $query = "select distinct u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID from module_hcd_employee_works_at_branch ewb join users u on u.login=ewb.users_login where ewb.assigned=1 and supervisor=1 and u.active=1 and u.archive=0 and branch_ID in (select branch_ID from module_hcd_employee_works_at_branch ewb, users_to_courses uc where uc.users_LOGIN=ewb.users_login and ewb.assigned=1 and uc.courses_ID=" . $this->recipients["courses_ID"] . " and uc.archive=0)";
                                 //get course users' supervisors
                                 $result = eF_executeNew($query);
                                 $recipients = $result->getAll();
                             }
                         } else {
                             $recipients = eF_getTableData("users_to_courses uc, users u", "u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID, uc.user_type as role", "u.active=1 and u.archive=0 and uc.archive=0 and uc.users_LOGIN = u.login and uc.courses_ID=" . $this->recipients["courses_ID"] . $completed_condition);
                         }
                     } else {
                         if (isset($this->recipients['user_type'])) {
                             $recipients = eF_getTableData("users", "*", "active=1 and archive=0 and user_type = '" . $this->recipients['user_type'] . "'");
                         } else {
                             if (isset($this->recipients['entity_ID']) && isset($this->recipients['entity_category'])) {
                                 if ($this->recipients['entity_category'] == "survey") {
                                     $recipients = eF_getTableData("users_to_surveys JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and surveys_ID = '" . $this->recipients["entity_ID"] . "'");
                                     $notified = eF_getTableDataFlat("users_to_surveys JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and users_to_surveys.last_post > 1 and surveys_ID = '" . $this->recipients["entity_ID"] . "'");
                                     //$resDone		= eF_getTableDataFlat("users_to_done_surveys", "users_LOGIN", "surveys_ID=".$this -> recipients["entity_ID"]);
                                     $usersToSent = array();
                                     if (!empty($notified['login'])) {
                                         foreach ($recipients as $key => $value) {
                                             if (!in_array($value['login'], $notified['login'])) {
                                                 $usersToSent[] = $value;
                                                 //eF_updateTableData("users_to_surveys", array("last_post" => time()), "users_LOGIN='******'login']."' and surveys_ID='".$this -> recipients["entity_ID"]."'");
                                             }
                                         }
                                         $recipients = $usersToSent;
                                     }
                                     foreach ($recipients as $key => $value) {
                                         // in order to include case empty($notified['login']
                                         eF_updateTableData("users_to_surveys", array("last_post" => time()), "users_LOGIN='******'login'] . "' and surveys_ID='" . $this->recipients["entity_ID"] . "'");
                                     }
                                 } else {
                                     if ($this->recipients['entity_category'] == "projects") {
                                         $recipients = eF_getTableData("users_to_projects JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and projects_ID = '" . $this->recipients["entity_ID"] . "'");
                                     }
                                 }
                             } else {
                                 if (isset($this->recipients["groups_ID"])) {
                                     $recipients = eF_getTableData("users_to_groups JOIN users ON users_login = users.login", "users.*", "users.active=1 and users.archive=0 and groups_ID = '" . $this->recipients["groups_ID"] . "'");
                                 } else {
                                     if (isset($this->recipients['users_login'])) {
                                         if (G_VERSIONTYPE == 'enterprise') {
                                             #cpp#ifdef ENTERPRISE
                                             if (isset($this->recipients['supervisor'])) {
                                                 $editedUser = EfrontUserFactory::factory($this->recipients['users_login']);
                                                 //new EfrontUser();
                                                 $editedEmployee = $editedUser->aspects['hcd'];
                                                 $supervisors = $editedEmployee->getSupervisors();
                                                 $recipients = array();
                                                 foreach ($supervisors as $supervisor) {
                                                     $recipients[$supervisor] = array("login" => $supervisor);
                                                 }
                                             } elseif (isset($this->recipients['immediate_supervisor'])) {
                                                 $result = eF_getTableDataFlat("module_hcd_employee_works_at_branch", "users_LOGIN", "supervisor=1 and branch_ID IN (select branch_ID from module_hcd_employee_works_at_branch where assigned=1 and supervisor=0 and users_login='******'users_login'] . "')");
                                                 $recipients = array();
                                                 foreach ($result['users_LOGIN'] as $supervisor) {
                                                     $recipients[$supervisor] = array("login" => $supervisor);
                                                 }
                                             } else {
                                                 $recipients = $this->recipients['users_login'];
                                             }
                                         } else {
                                             #cpp#else
                                             $recipients = $this->recipients['users_login'];
                                         }
                                         #cpp#endif
                                     }
                                 }
                             }
                         }
                     }
                 }
                 foreach ($recipients as $recipient) {
                     $recipients_list[$recipient['login']] = $recipient;
                 }
             } else {
                 if ($this->notification['recipient'] != "") {
                     preg_match("/\\d+_(\\d+)/", $this->notification['id_type_entity'], $matches);
                     if ($matches[1] == EfrontEvent::SYSTEM_ON_EMAIL_ACTIVATION) {
                         //In this case, we want an inactive user to receive the email
                         $user = eF_getTableData("users", "*", "archive=0 and login = '******'recipient'] . "'");
                     } else {
                         $user = eF_getTableData("users", "*", "active=1 and archive=0 and login = '******'recipient'] . "'");
                     }
                     if (!empty($user)) {
                         $recipients_list[$this->notification['recipient']] = $user[0];
                     }
                 }
             }
         }
     } else {
         if ($this->notification['recipient'] != "") {
             $user = eF_getTableData("users", "*", "active=1 and archive=0 and login = '******'recipient'] . "'");
             if (!empty($user)) {
                 $recipients_list[$this->notification['recipient']] = $user[0];
             }
         }
     }
     return $recipients_list;
 }