CValue::setSession("text", $text);
CValue::setSession("server_ip", $server_ip);
CValue::setSession("_datetime_min", $datetime_min);
CValue::setSession("_datetime_max", $datetime_max);
CValue::setSession("order_by", $order_by);
CValue::setSession("group_similar", $group_similar);
CValue::setSession("user_id", $user_id);
CValue::setSession("human", $human);
CValue::setSession("robot", $robot);
CView::enforceSlave();
$where = array();
$error_log = new CErrorLog();
$spec = $error_log->_spec;
$ds = $spec->ds;
if (($human || $robot) && !($human && $robot)) {
    $tag = CMediusers::getTagSoftware();
    $robots = array();
    if ($tag) {
        $query = "SELECT users.user_id\r\n            FROM users\r\n            LEFT JOIN id_sante400 ON users.user_id = id_sante400.object_id\r\n            WHERE (id_sante400.object_class = 'CMediusers'\r\n              AND id_sante400.tag = ?)\r\n              OR users.dont_log_connection = '1'\r\n            GROUP BY users.user_id";
        $query = $ds->prepare($query, $tag);
    } else {
        $query = "SELECT users.user_id\r\n            FROM users\r\n            WHERE users.dont_log_connection = '1'";
    }
    $robots = $ds->loadColumn($query);
}
if ($human && !$robot) {
    if (count($robots)) {
        $where["user_id"] = $ds->prepareNotIn($robots);
    }
}
if ($robot && !$human) {
// Récupération des spécialités CPAM
$spec_cpam = new CSpecCPAM();
$spec_cpam = $spec_cpam->loadList(null, 'spec_cpam_id ASC');
// Récupération des profils
$profile = new CUser();
$profile->template = 1;
/** @var CUser[] $profiles */
$profiles = $profile->loadMatchingList();
// Creation du tableau de profil en fonction du type
$tabProfil = array();
foreach ($profiles as $profil) {
    $tabProfil[$profil->user_type][] = $profil->_id;
}
$tag = false;
if ($object->_id) {
    $tag = CIdSante400::getMatch($object->_class, CMediusers::getTagSoftware(), null, $object->_id)->id400;
}
$password_info = CAppUI::$user->_specs['_user_password']->minLength > 4 ? "Le mot de passe doit être composé d'au moins 6 caractères, comprenant des lettres et au moins un chiffre." : "Le mot de passe doit être composé d'au moins 4 caractères.";
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("tabProfil", $tabProfil);
$smarty->assign("utypes", CUser::$types);
$smarty->assign("ps_types", CUser::$ps_types);
$smarty->assign("banques", $banques);
$smarty->assign("object", $object);
$smarty->assign("profiles", $profiles);
$smarty->assign("functions", $functions);
$smarty->assign("disciplines", $disciplines);
$smarty->assign("spec_cpam", $spec_cpam);
$smarty->assign("tag_mediuser", CMediusers::getTagMediusers($group->_id));
$smarty->assign("is_admin", CAppUI::$user->isAdmin());
 /**
  * Is the user a robot?
  *
  * @return bool
  */
 function isRobot()
 {
     if (!$this->_id) {
         return false;
     }
     $tag_software = CMediusers::getTagSoftware();
     if (CModule::getActive("dPsante400") && $tag_software) {
         if (CIdSante400::getMatch($this->_class, $tag_software, null, $this->_id)->_id != null) {
             return true;
         }
     }
     if (!$this->_ref_user || !$this->_ref_user->_id) {
         $this->loadRefUser();
     }
     return $this->_ref_user->dont_log_connection;
 }