function UserAnswers($answers, $userId = -1, $position = -1)
 {
     CommonTools::initializeCommonObjects($this);
     $this->userId = $userId;
     $this->setAnswers($answers);
     $this->setPosition($position);
 }
 function formatConfirmedAnswerRow($answersByUser, $questions, $position, $adminMode)
 {
     $configurations = CommonTools::getConfigurations();
     $webRoot = $configurations->webRoot;
     $rowClass = SignupGadgetAnswerFormater::getRowClass();
     $return = "<tr class=\"{$rowClass}\">";
     $debugger = CommonTools::getDebugger();
     $debugger->debugVar($answersByUser, "answerByUser", "formatConfirmedAnswerRow");
     $return .= "<td class=\"answer-position\">" . $answersByUser->getPosition() . "</td>";
     $lastAnswer = null;
     // Could be any answer, not only last answer
     foreach ($questions as $question) {
         // Gets answer to questin
         $answerObject = $answersByUser->getAnswerToQuestion($question->getId());
         if (is_a($answerObject, "Answer")) {
             $return .= "<td class=\"answer\">" . $answerObject->getReadableAnswer() . "</td>";
             $lastAnswer = $answerObject;
         } else {
             // Joku virheilmotus tähänkö?
         }
     }
     if ($adminMode && $lastAnswer != null) {
         $return .= "<td class=\"edit-answer\"><a href=\"" . $webRoot . "admin/editanswer/" . $lastAnswer->getSignupId() . "/?userid=" . $lastAnswer->getUserId() . "\">[muokkaa]</a></td>";
         $return .= "<td class=\"delete-answer\"><a href=\"" . $webRoot . "admin/deleteanswer/" . $lastAnswer->getSignupId() . "/?userid=" . $lastAnswer->getUserId() . "\">[poista]</a></td>";
     }
     $return .= "</tr>\n";
     return $return;
 }
 function selectSearchSignupGadget($keyword)
 {
     // Split search line into keywords
     $keywords = split(" ", $keyword);
     // clear previous entry forms
     $this->removeAll();
     $whereclause = "WHERE";
     $isFirst = true;
     foreach ($keywords as $word) {
         if ($isFirst) {
             $whereclause = $whereclause . " title LIKE '%{$word}%'";
             $isFirst = false;
         } else {
             // I'm not sure if AND is better than OR...
             $whereclause = $whereclause . " AND title LIKE '%{$word}%'";
         }
     }
     $sql = "SELECT id, opens, closes, title, description, eventdate, send_confirmation, confirmation_message " . "FROM ilmo_masiinat {$whereclause} ORDER BY id DESC";
     /* print_r(get_class_methods($whereclause));
     		print($whereclause->getDebugInfo());
     		die(); */
     $result = $this->database->doSelectQuery($sql, array(), array());
     // Adds gadgets to signupGadgets variable
     while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC)) {
         $singleGadget = new SignupGadget($row['id'], $row['title'], $row['description'], strtotime($row['eventdate']), strtotime($row['opens']), strtotime($row['closes']), CommonTools::sqlToBoolean($row['send_confirmation']), $row['confirmation_message']);
         array_push($this->signupGadgets, $singleGadget);
     }
 }
Exemple #4
0
 /**
  * display the current logo into simple image format.
  * @return simple img
  */
 public function toSimpleImage()
 {
     $splitStringArray = split(".", $this->filename);
     $extension = end($splitStringArray);
     $result = CommonTools::data_uri($this->getBytes(), "image/" . $extension);
     return $result;
 }
 function formatConfirmedAnswerRow($answersByUser, $questions, $position, $adminMode)
 {
     $configurations = CommonTools::getConfigurations();
     $webRoot = $configurations->webRoot;
     $rowClass = SignupGadgetAnswerFormater::getRowClass();
     $return = "<tr class=\"{$rowClass}\">";
     $debugger = CommonTools::getDebugger();
     $debugger->debugVar($answersByUser, "answerByUser", "formatConfirmedAnswerRow");
     $return .= "<td class=\"answer-position\">" . $answersByUser->getPosition() . "</td>";
     $lastAnswer = null;
     // Could be any answer, not only last answer
     foreach ($questions as $question) {
         // Gets answer to questin
         $answerObject = $answersByUser->getAnswerToQuestion($question->getId());
         if ($answerObject == null) {
             // We get null-values when the signup machine gets more options added after users
             // have already submitted their answers. So in order not to truly mess up the
             // nice table we are creating, add an empty table cell.
             $return .= '<td class="answer"></td>';
         } else {
             if (is_a($answerObject, "Answer")) {
                 $return .= "<td class=\"answer\">" . $answerObject->getReadableAnswer() . "</td>";
                 $lastAnswer = $answerObject;
             } else {
                 // Joku virheilmotus tähänkö?
             }
         }
     }
     if ($adminMode && $lastAnswer != null) {
         $return .= "<td class=\"edit-answer\"><a href=\"" . $webRoot . "admin/editanswer/" . $lastAnswer->getSignupId() . "/?userid=" . $lastAnswer->getUserId() . "\">[muokkaa]</a></td>";
         $return .= "<td class=\"delete-answer\"><a href=\"" . $webRoot . "admin/deleteanswer/" . $lastAnswer->getSignupId() . "/?userid=" . $lastAnswer->getUserId() . "\">[poista]</a></td>";
     }
     $return .= "</tr>\n";
     return $return;
 }
Exemple #6
0
 function Email($address)
 {
     // Initializes the debugger
     CommonTools::initializeCommonObjects($this);
     if (!Email::isValidEmail($address)) {
         $this->debugger->error("The email address is invalid");
     } else {
         $this->address = $address;
     }
 }
 function getAnswersInCsvFormat($signupGadget)
 {
     $answersByUsersArray = $signupGadget->getAllAnswersByUsers();
     $questions = $signupGadget->getAllQuestions();
     // Print questions
     print "Sija;";
     foreach ($questions as $question) {
         print $question->getQuestion() . ";";
     }
     print "\n";
     foreach ($answersByUsersArray as $userId => $answersByUser) {
         // Unconfirmed?
         if ($answersByUser == null) {
             print "-\r\n";
             // Adds windows style line delimeter
             continue;
         }
         $answerRow = "";
         $answerRow .= $answersByUser->getPosition() . ";";
         // Print answers
         foreach ($questions as $questionId => $question) {
             $answerObject = $answersByUser->getAnswerToQuestion($questionId);
             $answerString = "";
             if ($answerObject != null) {
                 if ($question->getType() == "checkbox") {
                     $answerString = CommonTools::arrayToReadableFormat($answerObject->getAnswer());
                 } else {
                     $answerString = $answerObject->getAnswer();
                 }
             }
             $answerString = html_entity_decode($answerString, ENT_QUOTES);
             // Remove new line characters
             $answerString = stripslashes(str_replace("\r\n", "", $answerString));
             // Windows
             $answerString = stripslashes(str_replace("\n", "", $answerString));
             // Unix
             // Because semicolon is the line delimeter, rudely replace all the semicolons to commas
             $answerString = stripslashes(str_replace(";", ",", $answerString));
             $answerRow .= $answerString . ";";
         }
         // Remove the last semicolon
         $answerRow = substr($answerRow, 0, -1);
         print "{$answerRow}\r\n";
         // Adds windows style line delimeter
     }
 }
 /**
  * Luo uuden käyttäjälle lähetettävän vahvistusviestin
  * @param string message Viesti käyttäjälle
  * @param string email Käyttäjän email
  * @param SignupGadget signupgadget Tiedot ilmosta
  * @param array answers vastaukset masiinaan
  */
 public function ConfirmationMail($message, Email $email, $signupGadget, $answers = null)
 {
     CommonTools::initializeCommonObjects($this);
     $this->message = $message;
     $this->email = $email;
     $this->signupGadget = $signupGadget;
     $this->answers = $answers;
     if (!is_a($email, 'Email')) {
         $this->debugger->error("email parameter must be an instance of Email class");
     }
     // Tulostetaan ilmoittautumisen vahvistus vain jos käyttäjän id on annettu
     if ($answers != null) {
         $questions = $this->signupGadget->getAllQuestions();
         $this->message .= "\n\n*** Ilmoittautumisesi tiedot ***\n\n";
         foreach ($answers as $answer) {
             // Gets answer to question
             if (is_a($answer, "Answer")) {
                 $this->message .= $answer->getQuestion()->getQuestion() . ": " . $answer->getReadableAnswer() . "\n";
             } else {
                 // Tähän joku virhe?
             }
         }
     }
 }
 /**
  * Displays the contact page
  */
 public function actionContactus()
 {
     CommonTools::getBiobankInfo();
     $model = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $model->attributes = $_POST['ContactForm'];
         if ($model->validate()) {
             $name = '=?UTF-8?B?' . base64_encode($model->name) . '?=';
             $subject = '=?UTF-8?B?' . base64_encode($model->subject) . '?=';
             $headers = "From: {$name} <{$model->email}>\r\n" . "Reply-To: {$model->email}\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=UTF-8";
             mail(Yii::app()->params['adminEmail'], $subject, $model->body, $headers);
             Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
             $this->refresh();
         }
     }
     $this->render('../site/contact', array('model' => $model));
 }
Exemple #10
0
        <link rel="stylesheet" type="text/css" href="<?php 
echo Yii::app()->request->baseUrl;
?>
/css/form.css" />

        <script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/dojo.js"></script>
    </head>
    <?php 
CommonTools::getBiobankInfo();
$splitStringArray = split(".", $_SESSION['vitrine']['biobankLogo']->filename);
$extention = end($splitStringArray);
?>
    <body class="container" id="page" >
        <div style="float:left;">
            <a href="http://www.biobanques.eu" target="_blank"><img src="<?php 
echo CommonTools::data_uri($_SESSION['vitrine']['biobankLogo']->getBytes(), "image/{$extention}");
?>
" alt="1 photo" style="height:120px;"/></a>
        </div>
        <div style="float:left;">
            
            <h1><?php 
echo $_SESSION['vitrine']['biobank']->identifier;
?>
</h1>
        </div>
        <div style="float:right;padding-right:20px;padding-top:20px;">
            <div >


                <?php 
Exemple #11
0
?>

<?php 
/**
 * Création des listes d'attributs à affciher dans les différentes parties
 * La liste $attributes_oblig représente la liste des attributs obligatoire, et doit être présente.
 * Elle ne doit pas être ajoutée à la liste d'onglets
 *
 * La liste $attributes_other regroupe tous les attributs non présents dans les autres listes. Elle doit être ajoutée en dernière à la liste d'onglets
 */
$attributes_oblig = array('identifier', 'name', 'collection_name', 'collection_id', 'biobank_class', 'diagnosis_available', array('attributeName' => 'contact_id', 'value' => Contact::model()->getArrayContacts()), 'address');
$attributes_facult = array('website', 'folder_reception', 'folder_done', 'date_entry', 'passphrase', 'longitude', 'latitude');
$listOnglets['facultatif'] = $attributes_facult;
$attributes_qualite = array('cert_ISO9001', 'cert_NFS96900', 'cert_autres', 'observations');
$listOnglets['qualite'] = $attributes_qualite;
$attributes_info = array(array('attributeName' => 'gest_software', 'value' => CommonTools::getSoftwareList()), 'other_software', array('attributeName' => 'connector_installed', 'value' => array('Oui' => 'Oui', 'Non' => 'Non')), 'connector_version');
$listOnglets['info'] = $attributes_info;
$attributes_sampling = array(array('attributeName' => 'sampling_practice', 'value' => Biobank::model()->getArraySamplingPractice()), 'sampling_disease_group', 'sampling_disease_group_code', 'nbs_dna_samples_affected', 'nbs_dna_samples_relatives', 'nbs_cdna_samples_affected', 'nbs_cdna_samples_relatives', 'nbs_wholeblood_samples_affected', 'nbs_wholeblood_samples_relatives', 'nbs_bloodcellisolates_samples_affected', 'nbs_bloodcellisolates_samples_relatives', 'nbs_serum_samples_affected', 'nbs_serum_samples_relatives', 'nbs_plasma_samples_affected', 'nbs_plasma_samples_relatives', 'nbs_fluids_samples_affected', 'nbs_fluids_samples_relatives', 'nbs_tissuescryopreserved_samples_affected', 'nbs_tissuescryopreserved_samples_relatives', 'nbs_tissuesparaffinembedded_samples_affected', 'nbs_tissuesparaffinembedded_samples_relatives', 'nbs_celllines_samples_affected', 'nbs_celllines_samples_relatives', 'nbs_other_samples_affected', 'nbs_other_samples_relatives', 'nbs_other_specification');
$listOnglets['sampling'] = $attributes_sampling;
//make array of attributes stored but not defined in the common model
$attributes_other = array();
$definedAttributes = array_merge($attributes_oblig, $attributes_facult, $attributes_qualite, $attributes_info, $attributes_sampling, array('_id', 'contact_id', 'gest_software', 'connector_installed', 'vitrine', 'sampling_practice'));
$att = $model->getAttributes();
foreach ($att as $attributeName => $attributeValue) {
    if (!in_array($attributeName, $definedAttributes)) {
        $attributes_other[] = $attributeName;
    }
}
$listOnglets['other'] = $attributes_other;
?>
 public function indexForBiobank($id)
 {
     $lastImportDate = FileImported::model()->getDateLastImportByBiobank($id);
     $today = date('Y-m-d H:i:s');
     $diffSec = strtotime($today) - strtotime($lastImportDate);
     $diffJours = round($diffSec / 60 / 60 / 24, 0);
     $args = array();
     $args['diffJours'] = $diffJours;
     if (Yii::app()->getLocale()->id == "fr") {
         $args['lastImportDate'] = CommonTools::toShortDateFR($lastImportDate);
     } else {
         if (Yii::app()->getLocale()->id == "en") {
             $args['lastImportDate'] = CommonTools::toShortDateEN($lastImportDate);
         }
     }
     $args['status'] = 'success';
     if ($diffJours < 10) {
         $args['status'] = 'success';
     } elseif ($diffJours < 30) {
         $args['status'] = 'notice';
     } else {
         $args['status'] = 'error';
     }
     Yii::app()->user->setFlash($args['status'], Yii::t('myBiobank', 'lastImportMessage' . '_' . $args['status'], $args));
     $model = $this->loadModel($id);
     Yii::app()->params['biobank'] = $model;
     $this->render('index', array('model' => $model));
 }
 public function getShortValue($attribute)
 {
     return CommonTools::getShortValue($this->{$attribute});
 }
Exemple #14
0
 function updateToDatabase()
 {
     $answer = null;
     if ($this->question->getType() == "checkbox") {
         $answer = CommonTools::arrayToSql($this->answer);
     } else {
         $answer = htmlentities($this->answer, ENT_QUOTES);
     }
     $question_id = $this->question->getId();
     $user_id = $this->getUserId();
     $sql = "UPDATE ilmo_answers SET answer='{$answer}' WHERE " . "question_id='{$question_id}' AND user_id='{$user_id}'";
     $this->database->doQuery($sql);
 }
Exemple #15
0
<?php

//recuperation des preferences d dattributs affiches du user
$prefs = CommonTools::getPreferences();
//recuperation des noms des attributs affichables des colonnes du grid
$scriptCB = '';
foreach ($prefs as $property => $propertyValue) {
    if ($property != 'id_user') {
        $scriptCB = $scriptCB . '$(\'#Preferences_' . $property . '\').change(function(){
$(\'.col_' . $property . '\').toggle();
$(\'.prefs-form form\').submit();
return false;
});
';
    }
}
// recharge le tableau d'affichage des échantillons après envoi du formulaire de recherche avancée
Yii::app()->clientScript->registerScript('search', "\n \$('.search-button').click(function(){\n \t\$('.search-form').toggle();\n \treturn false;\n });\n\n\$('.prefs-button').click(function(){\n\t\$('.prefs-form').toggle();\n\treturn false;\n});\n\n\$('.search-form form').submit(function(){\n\t\$('#sample-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n\$('.prefs-form form').submit(function(){\n\t\$('#sample-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\n\treturn false;\n});\n{$scriptCB};\n");
//
?>
<h1><?php 
echo Yii::t('common', 'searchsamples');
?>
</h1>
<div style="margin: 5px;"><?php 
echo Yii::t('common', 'totalnumbersamples');
?>
 : <b><?php 
echo $model->count();
?>
</b>.<br>
 function arrayToReadableFormat($array)
 {
     $arrayString = "";
     $atLeastOneValueSet = false;
     foreach ($array as $id) {
         if ($id >= 0) {
             $arrayString .= "{$id}, ";
             $atLeastOneValueSet = true;
         } else {
             $debugger = CommonTools::getDebugger();
             $debugger->error("The array must include only positive integer values", "idArrayToSql");
         }
     }
     if ($atLeastOneValueSet) {
         // Remove last comma
         $arrayString = substr($arrayString, 0, -2);
     }
     return $arrayString;
 }
Exemple #17
0
require_once "classes/Configurations.php";
require_once "classes/Page.php";
require_once "classes/SignupGadgets.php";
require_once "classes/Debugger.php";
require_once "classes/SignupGadget.php";
require_once "classes/CommonTools.php";
/* Implementations of the most critical classes */
$configurations = new Configurations();
$page = new Page(1);
$debugger = new Debugger();
$database = new Database();
/* The code */
$signupGadgets = new SignupGadgets();
// Check if the search was performed
$searchString = CommonTools::GET('search');
$year = CommonTools::GET('year');
// Is the search performed?
if ($searchString != null && $searchString != "") {
    $debugger->debug("Searching signup gadgets using search string {$searchString}", "index.php");
    $signupGadgets->selectSearchSignupGadget($searchString);
} else {
    if ($year != null && $year != "") {
        $signupGadgets->selectSignupGadgetsByYear($year);
    } else {
        $signupGadgets->selectOpenGadgetsOrClosedDuringLastDays(7);
    }
}
// Get all selected gadgets to array
$signupGadgets_array = $signupGadgets->getSignupGadgets();
// Print table headers
$page->addContent("<table id=\"signup-gadgets\">");
 function formatQuestionCheckbox($question, $value)
 {
     $return = "";
     $return .= "<div class=\"question-container\">";
     $return .= "<p class=\"question-label\"><span>" . $question->getQuestion() . "</span>";
     if ($question->getRequired()) {
         $return .= " <span class=\"required\">*</span>";
     }
     $return .= "</p>";
     $i = 0;
     foreach ($question->getOptions() as $option) {
         $selected = "";
         $debugger = CommonTools::getDebugger();
         // $debugger->debug("Option: $option, inArray: " . in_array($option, $value), "questionCheckbox");
         $debugger->debugVar($value, "value", "checkBox");
         if (is_array($value) && in_array($option, $value)) {
             $selected = "checked=\"checked\"";
         }
         $option = htmlentities($option);
         $return .= "<p class=\"question-checkbox-label\"><input class=\"question-checkbox\" type=\"checkbox\" name=\"" . $question->getId() . "-{$i}\" size=\"30\" value=\"{$option}\" {$selected} />{$option}</p>";
         $i++;
     }
     $return .= "</div>";
     return $return;
 }
Exemple #19
0
 /**
  * get biobank infos and convert into an LDIF format
  * @return string
  */
 private function getBiobanksLDIF()
 {
     $result = "\ndn: c=fr,ou=biobanks,dc=directory,dc=bbmri-eric,dc=eu\nobjectClass: country\nobjectClass: top\nc: fr\n\n";
     //FIXME Mandatory empty line here ( TODO use ldif exporter to check syntax)
     $biobanks = Biobank::model()->findAll();
     foreach ($biobanks as $biobank) {
         $attributes = array();
         $attributes['biobankCountry'] = "FR";
         $attributes['biobankID'] = "bbmri-eric:ID:FR_" . $biobank->identifier;
         $attributes['biobankName'] = $biobank->name;
         $attributes['biobankJuridicalPerson'] = $biobank->name;
         //TODO flase in cappital
         $attributes['biobankMaterialStoredDNA'] = "FALSE";
         $attributes['biobankMaterialStoredRNA'] = "FALSE";
         // $attributes['biobankMaterialStoredcDNAmRNA'] = "FALSE";
         // $attributes['biobankMaterialStoredmicroRNA'] = "FALSE";
         //   $attributes['biobankMaterialStoredWholeBlood'] = "FALSE";
         //  $attributes['biobankMaterialStoredPBC'] = "FALSE";
         $attributes['biobankMaterialStoredBlood'] = "FALSE";
         $attributes['biobankMaterialStoredPlasma'] = "FALSE";
         $attributes['biobankMaterialStoredSerum'] = "FALSE";
         //            $attributes['biobankMaterialStoredTissueCryo'] = "FALSE";
         $attributes['biobankMaterialStoredTissueFrozen'] = "FALSE";
         //            $attributes['biobankMaterialStoredTissueParaffin'] = "FALSE";
         $attributes['biobankMaterialStoredTissueFFPE'] = "FALSE";
         //            $attributes['biobankMaterialStoredCellLines'] = "FALSE";
         $attributes['biobankMaterialStoredImmortalizedCellLines'] = "FALSE";
         $attributes['biobankMaterialStoredUrine'] = "FALSE";
         $attributes['biobankMaterialStoredSaliva'] = "FALSE";
         $attributes['biobankMaterialStoredFaeces'] = "FALSE";
         //            $attributes['biobankMaterialStoredPathogen'] = "FALSE";
         $attributes['biobankMaterialStoredIsolatedPathogen'] = "FALSE";
         $attributes['biobankMaterialStoredOther'] = "FALSE";
         //TODO each biobank need to sign a chart between bbmri and the biobank (TODO to discuss)
         $attributes['biobankPartnerCharterSigned'] = "FALSE";
         //nmber of samples 10^n n=number
         $attributes['biobankSize'] = "1";
         $attributes['objectClass'] = "biobankClinical";
         //TODO implementer la valeur de ce champ Si biobankClinical Diagnosis obligatoire
         $attributes['diagnosisAvailable'] = "urn:miriam:icd:D*";
         $contact = $biobank->getContact();
         $attributes['biobankContactCountry'] = "FR";
         //TODO get pays avec FR pas integer $contact->pays;
         //TODO info de contact obligatoire lever un warning si pas affectée pour l export
         if ($contact != null) {
             $attributes['biobankContactFirstName'] = $contact->first_name;
             $attributes['biobankContactLastName'] = $contact->last_name;
             $attributes['biobankContactPhone'] = CommonTools::getIntPhone($contact->phone);
             $attributes['biobankContactAddress'] = $contact->adresse;
             $attributes['biobankContactZIP'] = $contact->code_postal;
             $attributes['biobankContactCity'] = $contact->ville;
             //TODO contact email need to be filled
             if (isset($contact->email)) {
                 $attributes['biobankContactEmail'] = $contact->email;
             } else {
                 $attributes['biobankContactEmail'] = $contact->email;
             }
         } else {
             $attributes['biobankContactEmail'] = "N/A";
             Yii::log("contact must be filled for export LDIF. Biobank without contact:" . $biobank->name, CLogger::LEVEL_WARNING, "application");
         }
         $this->checkAttributesComplianceWithBBMRI($attributes);
         $result .= "dn: biobankID=" . trim($attributes['biobankID']) . ",c=fr,ou=biobanks,dc=directory,dc=bbmri-eric,dc=eu\n";
         //TODO recuperer le diagnistique agréger
         foreach ($attributes as $key => $value) {
             if (isset($value)) {
                 //$result.=$key . ":: " . base64_encode(trim($value)) . "\n";
                 $result .= $key . ":: " . trim($value) . "\n";
             }
         }
         //FIXME mandatory empty line
         $result .= "objectClass: biobank\n\n";
     }
     return $result;
 }
Exemple #20
0
 function insertToDatabase()
 {
     // Change options array to sql format
     $id = $this->getSignupId();
     $questionString = $this->getQuestion();
     $type = $this->getType();
     $options = CommonTools::arrayToSql($this->getOptions());
     $public = CommonTools::booleanToSql($this->getPublic());
     $required = CommonTools::booleanToSql($this->getRequired());
     $sql = "INSERT INTO ilmo_questions " . "(ilmo_id, question, type, options, public, required) " . "VALUES " . "({$id}, '{$questionString}', '{$type}', '{$options}', " . "{$public}, {$required})";
     // do query
     $this->database->doQuery($sql);
 }
Exemple #21
0
<footer>
    <div style="text-align:center;background-color: white;">
        Copyright Inserm - Version 1.6 alpha rev. <?php 
include 'revision_number.php';
?>
- Project Biobanques <a href="http://www.biobanques.eu">www.biobanques.eu</a>
    </div>
</footer>

<?php 
if (!CommonTools::isInDevMode()) {
    ?>
    <!-- code google analytics pour tracking du suivi -->
    <script type="text/javascript">

        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-44379278-1']);
        _gaq.push(['_trackPageview']);

        (function () {
            var ga = document.createElement('script');
            ga.type = 'text/javascript';
            ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(ga, s);
        })();

    </script>
    <?php 
}
 public function createFicheNeuropath()
 {
     $index = 0;
     $criteria = new EMongoCriteria();
     $criteria->login = "******";
     $user = User::model()->find($criteria);
     $neuropath = Neuropath::model()->findAll();
     if ($neuropath != null) {
         foreach ($neuropath as $neuro) {
             $answer = new Answer();
             $answer->creator = "Bernard TE";
             $answer->id = "neuropath_filemaker_form";
             $answer->type = "neuropathologique";
             $answer->login = new MongoId($user->_id);
             $answer->questionnaireMongoId = new MongoId();
             $answer->name = "Import Neuropath";
             $answer->last_modified = DateTime::createFromFormat('d/m/Y', date('d/m/Y'));
             $answer->description = "Données neuropathologiques de la base FileMaker";
             $answer->last_updated = DateTime::createFromFormat('d/m/Y', date('d/m/Y'));
             $answerGroup = new AnswerGroup();
             $answerGroup->id = "onglet";
             $answerGroup->title = "Données neuropathologiques FileMaker";
             $answerGroup->title_fr = $answerGroup->title;
             foreach ($neuro as $k => $v) {
                 if ($k != "_id") {
                     if ($k == "id_cbsd") {
                         $answer->id_patient = (string) $v;
                     } else {
                         $answerQuestion = new AnswerQuestion();
                         $answerQuestion->id = $k;
                         $answerQuestion->label = $k;
                         $answerQuestion->label_fr = $k;
                         if (is_numeric($v)) {
                             $answerQuestion->type = "number";
                         } elseif (CommonTools::isDate($v)) {
                             $answerQuestion->type = "date";
                         } else {
                             $answerQuestion->type = "input";
                         }
                         $answerQuestion->style = "";
                         if ($answerQuestion->type == "date") {
                             $answerQuestion->answer = DateTime::createFromFormat('d/m/Y', date('d/m/Y', strtotime($v)));
                         } else {
                             $answerQuestion->answer = $v;
                         }
                         $answerGroup->answers[] = $answerQuestion;
                     }
                 }
             }
             $answer->answers_group[] = $answerGroup;
             $answer->save();
         }
     }
 }
 /**
  * testing method to check if function return an object
  */
 public function testWsAddPatient()
 {
     $patient = $this->patient();
     $this->assertInternalType('string', CommonTools::wsAddPatient($patient));
     // TODO : test exception
 }
Exemple #24
0
function parseNormalAnswer($question)
{
    global $userId;
    $answerFromPost = CommonTools::POST($question->getId());
    return new Answer($answerFromPost, $userId, $question);
}
Exemple #25
0
 /**
  * affichage de la page de recherche des echantillons
  */
 public function actionSearch()
 {
     $model = new Sample('search');
     $model->unsetAttributes();
     $biobankId = null;
     if (isset($_GET['id']) && isset($_GET['layout']) && $_GET['layout'] == 'vitrine_layout') {
         $biobankId = $_GET['id'];
     }
     $model->biobank_id = $biobankId;
     $user = CommonTools::getConnectedUser();
     if (isset($_GET['Preferences'])) {
         $user->preferences->attributes = $_GET['Preferences'];
         $user->disableBehavior('LoggableBehavior');
         if ($user->validate(array('preferences'))) {
             $user->save(false);
         } else {
             var_dump($user->preferences->errors);
         }
     }
     if (isset($_GET['Sample'])) {
         $model->attributes = $_GET['Sample'];
         //Used to search terms in model->biobank->collection_id and model->biobank->collection_name
         $arrayOfBiobanks = array();
         if (!empty($_GET['collection_id'])) {
             $criteria = new EMongoCriteria();
             $listWords = explode(",", $_GET['collection_id']);
             $regexId = "";
             foreach ($listWords as $word) {
                 $regexId .= "{$word}|";
             }
             $regexId = substr($regexId, 0, -1);
             $criteria->addCond('collection_id', '==', new MongoRegex("/({$regexId})/i"));
             $criteria->select(array('_id'));
             $biobanks = Biobank::model()->findAll($criteria);
             foreach ($biobanks as $biobank) {
                 $arrayOfBiobanks[(string) $biobank->_id] = (string) $biobank->_id;
             }
         }
         if (!empty($_GET['collection_name'])) {
             $criteria = new EMongoCriteria();
             $listWords = explode(",", $_GET['collection_name']);
             $regexId = "";
             foreach ($listWords as $word) {
                 $regexId .= "{$word}|";
             }
             $regexId = substr($regexId, 0, -1);
             $criteria->addCond('collection_name', '==', new MongoRegex("/({$regexId})/i"));
             $criteria->select(array('_id'));
             $biobanks = Biobank::model()->findAll($criteria);
             foreach ($biobanks as $biobank) {
                 $arrayOfBiobanks[$biobank->_id] = (string) $biobank->_id;
             }
         }
         if (!empty($arrayOfBiobanks)) {
             //     $model->arrayOfBiobanks;
             $model->setArrayOfBiobanks(array_values($arrayOfBiobanks));
         }
         $content = '';
         foreach ($_GET['Sample'] as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $vkey => $vval) {
                     $content = $content . (string) $vkey . '=' . str_replace(';', ',', (string) $vval) . ';';
                 }
             } else {
                 if ($value != null && !empty($value) && (string) $value != '0') {
                     $content = $content . (string) $key . '=' . str_replace(';', ',', (string) $value) . ';';
                 }
             }
         }
         if (Yii::app()->session['SampleForm'] != $_GET['Sample']) {
             $_GET['Echantillon_page'] = null;
             $this->logAdvancedSearch($content);
         }
         Yii::app()->session['SampleForm'] = $_GET['Sample'];
     }
     //form de la recherche intelligente
     $smartForm = new SampleSmartForm();
     if (isset($_POST['SampleSmartForm'])) {
         $model->unsetAttributes();
         $smartForm->attributes = $_POST['SampleSmartForm'];
         if (Yii::app()->session['keywords'] != $smartForm->keywords) {
             $_GET['Echantillon_page'] = null;
             $this->logSmartSearch($smartForm->keywords);
         }
         Yii::app()->session['keywords'] = $smartForm->keywords;
         $model = SmartResearcherTool::search($smartForm->keywords, $biobankId);
     }
     $this->render('search_samples', array('model' => $model, 'smartForm' => $smartForm));
 }
Exemple #26
0
 /**
  * send an email to indicate to the admin that there is a new user to confirm
  * @param type $user
  * @return type
  */
 public static function sendSubscribeAdminMail($user)
 {
     $base = CommonTools::isInDevMode() ? CommonMailer::DEV_URL : CommonMailer::PROD_URL;
     $to = Yii::app()->params['adminEmail'];
     $subject = "Inscription d'un nouvel utilisateur sur ebiobanques.fr";
     $userDetails = '';
     foreach ($user->getAttributes() as $label => $value) {
         $userDetails .= "<li>{$label} : {$value}</li>";
     }
     $body = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd\">\n\t\t\t\t<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\t\t\t\t<html><head>\n\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\t<title>Inscription d'un nouvel utilisateur sur ebiobanques.fr</title>\n\t\t\t\t</head><body>\n\t\t\t\t{$user->prenom} {$user->nom} s'est inscrit sur le site ebiobanques.fr.<br>\n\t\t\t\t\t\tDétails :<br>\n\t<ul>{$userDetails}</ul><br>\n\tVous pouvez valider cet utilisateur en cliquant sur ce lien : <a href={$base}/index.php/user/validate/id/{$user->_id}\">Valider l'utilisateur</a>, le <a href={$base}/index.php/user/refuseRegistration/id/{$user->_id}\">désactiver</a>\n\t ou le retrouver dans <a href={$base}/index.php/user/admin\">la liste des utilisateurs</a>.\n\t</body>\n\t\t";
     return CommonMailer::sendMail($to, $subject, $body);
 }
Exemple #27
0
 /**
  * Gets user's position from database
  */
 function selectPositionFromDatabase()
 {
     $sql = "SELECT ilmo_id, id_string, confirmed FROM ilmo_users WHERE " . "ilmo_id = {$this->newSignupid} ORDER BY time";
     $result = $this->database->doQuery($sql);
     $position = 1;
     $unconfirmedSignups = 0;
     $foundIdFromQueue = false;
     // Tries to find current users
     while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC)) {
         $this->debugger->debug("id_string: " . $row['id_string'] . ", sessionId: " . $this->sessionId, "selectPositionFromDatabase");
         if ($row['id_string'] == $this->sessionId) {
             // User's id found!
             $foundIdFromQueue = true;
             break;
         } else {
             $position++;
             if (CommonTools::sqlToBoolean($row['confirmed']) == false) {
                 $unconfirmedSignups++;
             }
         }
     }
     // Sets position
     if ($foundIdFromQueue) {
         $this->position = $position;
         $this->unconfirmedSignups = $unconfirmedSignups;
     } else {
         $this->position = -1;
         $this->unconfirmedSignups = -1;
     }
 }
 public function actionAdmin()
 {
     $model = new UploadedFile();
     if (isset($_FILES['uploadFileField']) && $_FILES['uploadFileField']['error'] == 0) {
         $add = false;
         if (isset($_POST['UploadedFile']['addOrReplace']) && $_POST['UploadedFile']['addOrReplace'] == 'add') {
             $add = true;
         }
         $fileId = $this->uploadEchFile($_FILES['uploadFileField']);
         if ($fileId != null) {
             $file = CommonTools::importFile($this->loadModel($fileId), $add);
         } else {
         }
     }
     $datas[] = new SampleProperty("id_sample", "Identification number of the biological material", "Text");
     $datas[] = new SampleProperty("id_depositor", "Identification of depositor", "Text");
     $datas[] = new SampleProperty("id_familiy", "Identification number of the family", "Text");
     $datas[] = new SampleProperty("id_donor", "Identification number of the donor", "Text");
     $datas[] = new SampleProperty("consent_ethical", "Consent/Approval by ethical commitee", "Fixed values(Yes, No, Unknown) : Y,N,U");
     $datas[] = new SampleProperty("gender", "Gender of donor", "Fixed values(Male, Female, Hermaphrodite, Unknown) : M, F, H, U ");
     $datas[] = new SampleProperty("age", "Age of donor", "Integer");
     $datas[] = new SampleProperty("pathology", "Pathology of family with OMIM number", "Integer (unique six-digit number)");
     $datas[] = new SampleProperty("status_sample", "Status of the biological materiel", "Fixed Values( A=Affected, NA= Non-affected, IS=indication of suspected diagnosis, IT=indication of grade of tumor+value) : ");
     $datas[] = new SampleProperty("collect_date", "date of collect of the material", "ISO-standard (8601) time format : 2014-04-18");
     $datas[] = new SampleProperty("nature_sample_dna", "nature of the human biological material where dna was extracted from", "fixed values ( affected, non affected)");
     $datas[] = new SampleProperty("storage_conditions", "preservation or storage conditions", "fixed values (LN=liquid nitrogen, 80=-80C, RT=room temperature, 4=4°C, 20=-20°C)");
     $datas[] = new SampleProperty("quantity", "quantity of biological material", "for dna concentration µg/µl and number of µl");
     $datas[] = new SampleProperty("disease_diagnosis", "Disease diagnosis", "Text");
     $datas[] = new SampleProperty("origin", "Origin of the biological material", "Organ and tissue");
     $datas[] = new SampleProperty("hazard_status", "hazard status", "Text");
     $datas[] = new SampleProperty("nature_sample_tissue", "nature of the human biological material", "fixed values ( T=tissue, S=slide,C=cells, P=pellet)");
     $datas[] = new SampleProperty("processing_method", "documentation on processing method", "Text");
     $datas[] = new SampleProperty("nature_sample_cells", "nature of the cells", "fixed values(epithelia, fibroblast,myphocyt)");
     $datas[] = new SampleProperty("culture_condition", "culture condition", "medium and subculture routine");
     $datas[] = new SampleProperty("consent", "consent", "Fixed values(Yes, No, Unknown) : Y,N,U");
     $datas[] = new SampleProperty("family_tree", "family tree", "Fixed values(Yes, No, Unknown) : Y,N,U");
     $datas[] = new SampleProperty("available_relatives_samples", "samples from relatives available", "Fixed values(Yes, No, Unknown) : Y,N,U");
     $datas[] = new SampleProperty("supply", "form of supply", "Text");
     $datas[] = new SampleProperty("max_delay_delivery", "maximum delay for delivery", "Integer ( hours)");
     $datas[] = new SampleProperty("karyotype", "karyotype", "Text");
     $datas[] = new SampleProperty("quantity_families", "quantity of families and subjects available for the specific disease", "Integer");
     $datas[] = new SampleProperty("detail_treatment", "detail information of treatment/medications", "Text");
     $datas[] = new SampleProperty("disease_outcome", "information on disease outcome", "Text");
     $datas[] = new SampleProperty("associated_clinical_data", "associated clinical data", "Fixed values(Yes, No, Unknown) : Y,N,U");
     $datas[] = new SampleProperty("associated_molecular_data", "associated molecular data ( ref associated clinical data OCDE)", "Fixed values(Yes, No, Unknown) : Y,N,U");
     $datas[] = new SampleProperty("associated_imagin_data", "associated imagin data ( ref associated clinical data OCDE)", "Fixed values(Yes, No, Unknown) : Y,N,U");
     $datas[] = new SampleProperty("life_style", "information on life style", "Text");
     $datas[] = new SampleProperty("family_history", "information on family history", "Text");
     $datas[] = new SampleProperty("authentication_method", "dna fingerprinting or another method of authentication", "Text");
     $datas[] = new SampleProperty("hazard_status", "hazard status", "Text");
     $datas[] = new SampleProperty("details_diagnosis", "details of diagnosis", "Text");
     $datas[] = new SampleProperty("related_biological_material", "related biological material", "Fixed Values : DNA Biopsy, tissue,serum, dna");
     $datas[] = new SampleProperty("quantity_available", "Quantiy available", "Text");
     $datas[] = new SampleProperty("concentration_available", "Concentration available", "Text");
     $datas[] = new SampleProperty("samples_characteristics", "characteristics of the sample", "Text (sample composition, content tumour cells)");
     $datas[] = new SampleProperty("delay_freezing", "delay of freezing", "Integer(minutes)");
     $datas[] = new SampleProperty("cells_characterization", "characterization of cells", "Text (doubling time, tumorigenicity, karyotype etc)");
     $datas[] = new SampleProperty("number_of_passage", "number of passage", "Text");
     $datas[] = new SampleProperty("morphology_and_growth_characteristics", "morphology and growth characteristics", "Text");
     $datas[] = new SampleProperty("reference_paper", "reference paper", "Text");
     $datas[] = new SampleProperty("biobank_id", "biobank id", "Text : Use BRIF Code to store this variable");
     $datas[] = new SampleProperty("biobank_name", "biobank name", "Text");
     $datas[] = new SampleProperty("biobank_date_entry", "Date of Entry", " ISO-standard (8601) time format when data about the biobank was reported into a database. : 2014-04-18T06:28:42Z");
     $datas[] = new SampleProperty("biobank_collection_id", "Sample Collection/Study ID*", "Text :   Textual string depicting the unique ID or acronym for the sample collection or study");
     $datas[] = new SampleProperty("biobank_collection_name", "Collection/Study name*", "Text : Textual string of letters denoting the name of the study in English");
     $datas[] = new SampleProperty("patient_birth_date", "birth date patient", "Date format ISO 8601 : YYYY-MM-DD exemple 2014-04-18");
     $datas[] = new SampleProperty("tumor_diagnosis", "tumor_diagnosis", "Text : CIM 10 format");
     $dataProviderProperties = new CArrayDataProvider($datas, array('keyField' => false, 'pagination' => false));
     $model->addOrReplace = 'add';
     $this->render('admin', array('model' => $model, 'dataProviderProperties' => $dataProviderProperties));
 }
Exemple #29
0
 protected static function analyzeCsv($bytes, $biobank_id, $fileImportedId, $add)
 {
     $import = fopen(CommonTools::data_uri($bytes, 'text/csv'), 'r');
     $row = 1;
     $keysArray = array();
     $listBadSamples = array();
     $newSamples = array();
     //        $tempSaveList = new MongoInsertBatch(Sample::model()->getCollection());
     $tempSaveList = array();
     /**
      * Version 1 : Les champs non repertorés sont ajoutés en notes
      */
     while (($data = fgetcsv($import, 1000, ",")) !== FALSE) {
         /*
          * Traitement de la ligne d'entete
          */
         if ($row == 1) {
             foreach ($data as $key => $value) {
                 if ($value != null && $value != "") {
                     $keysArray[$key] = $value;
                 }
             }
         } else {
             $model = new Sample();
             $model->disableBehavior('LoggableBehavior');
             $model->_id = new MongoId();
             while (!$model->validate(array('_id'))) {
                 $model->_id = new MongoId();
             }
             $model->biobank_id = $biobank_id;
             $model->file_imported_id = $fileImportedId;
             foreach ($keysArray as $key2 => $value2) {
                 if ($value2 != "biobank_id" && $value2 != "file_imported_id") {
                     if (in_array($value2, Sample::model()->attributeNames())) {
                         $model->{$value2} = $data[$key2];
                         if (!$model->validate(array($value2))) {
                             //   Yii::log("Problem with item" . $model->getAttributeLabel($value2) . ",set to null.\n " . implode(", ", $model->errors[$value2]), CLogger::LEVEL_ERROR);
                             $model->{$value2} = null;
                         }
                     } else {
                         $note = new Note();
                         $note->key = $value2;
                         $note->value = $data[$key2];
                         $model->notes[] = $note->attributes;
                     }
                 }
             }
             if (!$model->validate()) {
                 Yii::log("Problem with sample validation " . print_R($model->errors, true), CLogger::LEVEL_ERROR);
                 $listBadSamples[] = $row;
             } else {
                 $tempSaveList[] = $model->attributes;
                 //                        $tempSaveList->add($model->attributes);
                 $newSamples[] = $model->_id;
             }
         }
         $row++;
         if ($row != 2 && $row % 400 == 2) {
             Yii::log("Nb treated : " . $row, 'error');
             Sample::model()->getCollection()->batchInsert($tempSaveList, array());
             $tempSaveList = array();
             //$tempSaveList->execute(array());
             //$tempSaveList = new MongoInsertBatch(Sample::model()->getCollection());
         }
     }
     Sample::model()->getCollection()->batchInsert($tempSaveList, array("w" => 1));
     /*
      * Version 2 : seuls nes champs dont la colonne est annotée avec le préfixe 'notes' sont pris en note
      */
     //        while (($data = fgetcsv($import, 1000, ",")) !== FALSE) {
     //
     //            /*
     //             * Traitement de la ligne d'entete
     //             */
     //
     //
     //
     //            if ($row == 1) {
     //                foreach ($data as $key => $value) {
     //                    if (in_array($value, Sample::model()->attributeNames())) {
     //                        $keysArray[$key] = $value;
     //                    } elseif (substr($value, 0, 5) == 'notes') {
     //                        $keysArray[$key] = $value;
     //                    }
     //                }
     //                /*
     //                 * Traitement des lignes de données
     //                 */
     //            } else {
     //                $model = new Sample();
     //                $model->disableBehavior('LoggableBehavior');
     //                $model->biobank_id = $biobank_id;
     //                $model->file_imported_id = $fileImportedId;
     //                foreach ($keysArray as $key2 => $value2) {
     //                    if (substr($value2, 0, 5) != 'notes') {
     //
     //                        $model->$value2 = $data[$key2];
     //                        if (!$model->validate($value2)) {
     //
     //                            Yii::log("Problem with item" . $model->getAttributeLabel($value2) . ",set to null.", CLogger::LEVEL_ERROR);
     //                            $model->$value2 = null;
     //                        }
     //                    } else {
     //
     //                        $noteKey = end(explode(':', $value2));
     //                        $note = new Note();
     //                        $note->key = $noteKey;
     //                        $note->value = $data[$key2];
     //                        $model->notes[] = $note;
     //                    }
     //                }
     //
     //                if (!$model->save()) {
     //                    $listBadSamples[] = $row;
     //                } else {
     //                    $newSamples[] = $model->_id;
     //                }
     //            }
     //            $row++;
     //        }
     fclose($import);
     if (!$add && count($newSamples) > 0) {
         $deleteCriteria = new EMongoCriteria();
         $deleteCriteria->biobank_id('==', $biobank_id);
         $deleteCriteria->_id('notIn', $newSamples);
         Sample::model()->deleteAll($deleteCriteria);
     }
     if (count($listBadSamples) != 0) {
         $log = '';
         foreach ($listBadSamples as $badSample) {
             $log = 'Error with manual import. File id : ' . $fileImportedId . ' - line : ' . $badSample;
             Yii::log($log, CLogger::LEVEL_ERROR);
         }
     }
     return count($listBadSamples);
 }
Exemple #30
0
 /**
  * test the method to translate a mysql date to another date format
  */
 public function testToDate()
 {
     $madate = "2000-12-27 23:45:00";
     $this->assertEquals("27/12/2000", CommonTools::toDate("d/m/Y", $madate));
 }