Exemple #1
0
 /**
  * Change prat usernames to prat ids
  *
  * @return bool
  */
 protected function swapPratIds()
 {
     $ds = CSQLDataSource::get("std");
     CApp::setTimeLimit(1800);
     $user = new CUser();
     // Changement des chirurgiens
     $query = "SELECT id_chir\r\n        FROM plagesop\r\n        GROUP BY id_chir";
     $listPlages = $ds->loadList($query);
     foreach ($listPlages as $plage) {
         $where["user_username"] = "******" . $plage["id_chir"] . "'";
         $user->loadObject($where);
         if ($user->user_id) {
             $query = "UPDATE plagesop\r\n            SET chir_id = '{$user->user_id}'\r\n            WHERE id_chir = '{$user->user_username}'";
             $ds->exec($query);
             $ds->error();
         }
     }
     //Changement des anesthésistes
     $query = "SELECT id_anesth\r\n         FROM plagesop\r\n         GROUP BY id_anesth";
     $listPlages = $ds->loadList($query);
     foreach ($listPlages as $plage) {
         $where["user_username"] = "******" . $plage["id_anesth"] . "'";
         $user->loadObject($where);
         if ($user->user_id) {
             $query = "UPDATE plagesop\r\n            SET anesth_id = '{$user->user_id}'\r\n            WHERE id_anesth = '{$user->user_username}'";
             $ds->exec($query);
             $ds->error();
         }
     }
     return true;
 }
<?php

/**
 * $Id$
 *
 * @category Admin
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$ds = CSQLDataSource::get("std");
$do = new CDoObjectAddEdit("CUser", "user_id");
$do->doBind();
if (intval(CValue::post("del"))) {
    $do->doDelete();
} else {
    // Verification de la non existence d'un utilisateur avec le même login
    $otherUser = new CUser();
    $where = array();
    $where["user_username"] = $ds->prepare("= %", $do->_obj->user_username);
    $where["user_id"] = $ds->prepare("!= %", $do->_obj->user_id);
    $otherUser->loadObject($where);
    if ($otherUser->user_id) {
        CAppUI::setMsg("Login déjà existant dans la base", UI_MSG_ERROR);
    } else {
        $do->doStore();
    }
}
$do->doRedirect();
 /**
  * Return the Object with the information of the medecin in the message
  *
  * @param DOMNode   $node   Node
  * @param CMbObject $object object
  *
  * @return int|null|string
  */
 function getDoctor(DOMNode $node, CMbObject $object)
 {
     $type_id = $this->queryTextNode("XCN.13", $node);
     $id = $this->queryTextNode("XCN.1", $node);
     $last_name = $this->queryTextNode("XCN.2/FN.1", $node);
     $first_name = $this->queryTextNode("XCN.3", $node);
     switch ($type_id) {
         case "RPPS":
             $object->rpps = $id;
             break;
         case "ADELI":
             $object->adeli = $id;
             break;
         case "RI":
             // Notre propre RI
             if ($this->queryTextNode("XCN.9/HD.2", $node) == CAppUI::conf("hl7 assigning_authority_universal_id")) {
                 return $id;
             }
         default:
             // Recherche du praticien par son idex
             $idex = CIdSante400::getMatch($object->_class, $this->_ref_sender->_tag_mediuser, $id);
             if ($idex->_id) {
                 return $idex->object_id;
             }
             if ($object instanceof CMediusers) {
                 $object->_user_first_name = $first_name;
                 $object->_user_last_name = $last_name;
             }
             if ($object instanceof CMedecin) {
                 $object->prenom = $first_name;
                 $object->nom = $last_name;
             }
             break;
     }
     // Cas où l'on a aucune information sur le médecin
     if (!$object->rpps && !$object->adeli && !$object->_id && ($object instanceof CMediusers && !$object->_user_last_name || $object instanceof CMedecin && !$object->nom)) {
         return null;
     }
     if ($object instanceof CMedecin && $object->loadMatchingObjectEsc()) {
         return $object->_id;
     }
     $sender = $this->_ref_sender;
     $ds = $object->getDS();
     if ($object instanceof CMediusers) {
         $ljoin = array();
         $ljoin["functions_mediboard"] = "functions_mediboard.function_id = users_mediboard.function_id";
         $where = array();
         $where["functions_mediboard.group_id"] = " = '{$sender->group_id}'";
         if ($object->rpps || $object->adeli) {
             if ($object->rpps) {
                 $where[] = $ds->prepare("rpps = %", $object->rpps);
             }
             if ($object->adeli) {
                 $where[] = $ds->prepare("adeli = %", $object->adeli);
             }
             // Dans le cas où le praticien recherché par son ADELI ou RPPS est multiple
             if ($object->countList($where, null, $ljoin) > 1) {
                 $ljoin["users"] = "users_mediboard.user_id = users.user_id";
                 $where[] = $ds->prepare("users.user_last_name = %", $last_name);
             }
             $object->loadObject($where, null, null, $ljoin);
             if ($object->_id) {
                 return $object->_id;
             }
         }
         $user = new CUser();
         $ljoin = array();
         $ljoin["users_mediboard"] = "users.user_id = users_mediboard.user_id";
         $ljoin["functions_mediboard"] = "functions_mediboard.function_id = users_mediboard.function_id";
         $where = array();
         $where["functions_mediboard.group_id"] = " = '{$sender->group_id}'";
         $where[] = $ds->prepare("users.user_first_name = %", $first_name);
         $where[] = $ds->prepare("users.user_last_name = %", $last_name);
         $order = "users.user_id ASC";
         if ($user->loadObject($where, $order, null, $ljoin)) {
             return $user->_id;
         }
         $object->_user_first_name = $first_name;
         $object->_user_last_name = $last_name;
         return $this->createDoctor($object);
     }
 }
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkEdit();
$user = CUser::get(CValue::getOrSession("user_id"));
$user_id = CValue::getOrSession("user_id", $user->_id);
if (!$user_id) {
    CAppUI::setMsg("Vous devez sélectionner un utilisateur");
    CAppUI::redirect("m=admin&tab=vw_edit_users");
}
$modulesInstalled = CModule::getInstalled();
$isAdminPermSet = false;
$profile = new CUser();
if ($user->profile_id) {
    $where["user_id"] = "= '{$user->profile_id}'";
    $profile->loadObject($where);
}
$order = "mod_id";
//Droit de l'utilisateur sur les modules
$whereUser = array();
$whereUser["user_id"] = "= '{$user->user_id}'";
$whereProfil = array();
$whereProfil["user_id"] = "= '{$user->profile_id}'";
// DROITS SUR LES MODULES
$permModule = new CPermModule();
$permsModule = array();
$permsModuleCount = 0;
// Droit du profil sur les modules
foreach ($permModule->loadList($whereProfil, $order) as $_perm) {
    $permsModuleCount++;
    $_perm->_owner = "template";
Exemple #5
0
 /**
  * @see parent::updatePlainFields()
  */
 function updatePlainFields()
 {
     parent::updatePlainFields();
     // To prevent from recalculate new salt and re-hash password
     if ($this->_merging) {
         return;
     }
     $this->user_password = null;
     // If no raw password or already hashed, nothing to do
     if (!$this->_user_password || preg_match('/^[0-9a-f]{32}$/i', $this->_user_password)) {
         return;
     }
     // If the new password hashing system is not ready yet
     if (!$this->loginSaltReady()) {
         CValue::setSessionAbs("_pass_deferred", $this->_user_password);
         $this->user_password = md5($this->_user_password);
         return;
     }
     // If user is logging, get the salt value in table
     if (!$this->_is_logging || $this->_is_changing) {
         $this->generateUserSalt();
         return;
     }
     // If user is trying to log in, we have to compare hashes with corresponding user in table
     $where = array("user_username" => " = '{$this->user_username}'");
     $_user = new CUser();
     $_user->loadObject($where);
     // If user exists, we compare hashes
     if ($_user->_id) {
         // Password is a SHA256 hash, we get user's salt
         if ($this->_user_password && strlen($_user->user_password) == 64) {
             $this->user_password = hash("SHA256", $_user->user_salt . $this->_user_password);
             return;
         }
         // Password is an old MD5 hash, we have to update
         if ($_user->user_password == md5($this->_user_password)) {
             $this->generateUserSalt();
             $_user->_user_password = $this->_user_password;
             $_user->_user_salt = $this->user_salt;
             $_user->store();
         } else {
             // Won't load anything
             $this->user_password = "******";
         }
     }
 }
Exemple #6
0
 $user = new CUser();
 $ljoin["users_mediboard"] = "users_mediboard.user_id = users.user_id";
 $ljoin["functions_mediboard"] = "functions_mediboard.function_id = users_mediboard.function_id";
 $where = array("users_mediboard.adeli" => " = '" . $results[$i]["adeli"] . "'", "functions_mediboard.group_id" => " = '{$group_id}'");
 $user = new CUser();
 $count = $user->countList($where, null, $ljoin);
 if ($count == 0) {
     $results[$i]["error"] = "L'utilisateur n'a pas été retrouvé dans Mediboard";
     $i++;
     continue;
 } elseif ($count > 1) {
     $results[$i]["error"] = "Plusieurs utilisateurs correspondent à cette recherche";
     $i++;
     continue;
 }
 $user->loadObject($where, null, null, $ljoin);
 $mediuser = $user->loadRefMediuser();
 // Recherche pas nom/prenom si pas de code ADELI
 if (!$mediuser->_id) {
     $user = new CUser();
     $user->user_last_name = $results[$i]["lastname"];
     $user->user_first_name = $results[$i]["firstname"];
     $count = $user->countMatchingList();
     if ($count == "0") {
         $results[$i]["error"] = "L'utilisateur n'a pas été retrouvé dans Mediboard";
         $i++;
         continue;
     } elseif ($count > 1) {
         $results[$i]["error"] = "Plusieurs utilisateurs correspondent à cette recherche";
         $i++;
         continue;
Exemple #7
0
<?php

/**
 * $Id: do_perms_cp.php 18997 2013-05-02 09:24:16Z rhum1 $
 *
 * @category Admin
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision: 18997 $
 * @link     http://www.mediboard.org
 */
$tempUserName = CValue::post("temp_user_name", "");
$permission_user = CValue::post("permission_user", "");
$delPermissions = CValue::post("delPerms", false);
// pull user_id for unique user_username (templateUser)
$tempUser = new CUser();
$where = array();
$where["user_username"] = "******";
$tempUser->loadObject($where);
$user = new CUser();
$user->user_id = $permission_user;
$msg = $user->copyPermissionsFrom($tempUser->user_id, $delPermissions);
CAppUI::setMsg("Permissions");
CAppUI::setMsg($msg ? $msg : "copied from template", $msg ? UI_MSG_ERROR : UI_MSG_OK, true);
CAppUI::redirect();
 /**
  * Return or create the doctor of the message
  *
  * @param DOMNode $node Node
  *
  * @return CMediusers|int|null
  */
 function getDoctor($node)
 {
     $xpath = new CHPrimSanteMessageXPath($node ? $node->ownerDocument : $this);
     $nodeDoctor = $xpath->query("P.13", $node);
     $code = null;
     $nom = null;
     $prenom = null;
     $type_code = null;
     foreach ($nodeDoctor as $_node_doctor) {
         $code = $xpath->queryTextNode("CNA.1", $_node_doctor);
         $nom = $xpath->queryTextNode("CNA.2/PN.1", $_node_doctor);
         $prenom = $xpath->queryTextNode("CNA.2/PN.2", $_node_doctor);
         $type_code = $xpath->queryTextNode("CNA.3", $_node_doctor);
         if ($code && $nom) {
             break;
         }
     }
     $mediuser = new CMediusers();
     $mediuser->_user_last_name = $nom;
     switch ($type_code) {
         case "R":
             $mediuser->rpps = $code;
             break;
         case "A":
             $mediuser->adeli = $code;
             break;
         default:
             if (strlen($code) == 9 && luhn($code)) {
                 $mediuser->adeli = $code;
             }
             if (strlen($code) == 11 && luhn($code)) {
                 $mediuser->rpps = $code;
             }
     }
     // Cas où l'on a aucune information sur le médecin
     if (!$mediuser->rpps && !$mediuser->adeli && !$mediuser->_id && !$mediuser->_user_last_name) {
         return null;
     }
     $sender = $this->_ref_sender;
     $ds = $mediuser->getDS();
     $ljoin = array();
     $ljoin["functions_mediboard"] = "functions_mediboard.function_id = users_mediboard.function_id";
     $where = array();
     $where["functions_mediboard.group_id"] = " = '{$sender->group_id}'";
     if ($mediuser->rpps || $mediuser->adeli) {
         if ($mediuser->rpps) {
             $where[] = $ds->prepare("rpps = %", $mediuser->rpps);
         }
         if ($mediuser->adeli) {
             $where[] = $ds->prepare("adeli = %", $mediuser->adeli);
         }
         // Dans le cas où le praticien recherché par son ADELI ou RPPS est multiple
         if ($mediuser->countList($where, null, $ljoin) > 1) {
             $ljoin["users"] = "users_mediboard.user_id = users.user_id";
             $where[] = $ds->prepare("users.user_last_name = %", $nom);
         }
         $mediuser->loadObject($where, null, null, $ljoin);
         if ($mediuser->_id) {
             return $mediuser;
         }
     }
     $user = new CUser();
     $ljoin = array();
     $ljoin["users_mediboard"] = "users.user_id = users_mediboard.user_id";
     $ljoin["functions_mediboard"] = "functions_mediboard.function_id = users_mediboard.function_id";
     $where = array();
     $where["functions_mediboard.group_id"] = " = '{$sender->group_id}'";
     $where[] = $ds->prepare("users.user_first_name = %", $prenom);
     $where[] = $ds->prepare("users.user_last_name = %", $nom);
     $order = "users.user_id ASC";
     if ($user->loadObject($where, $order, null, $ljoin)) {
         return $user->loadRefMediuser();
     }
     $mediuser->_user_first_name = $prenom;
     $mediuser->_user_last_name = $nom;
     return $this->createDoctor($mediuser);
 }