private function importDoc()
 {
     $html = "";
     $html .= "<div class='ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix'>\n                <span class='ui-dialog-title'>Importing document</span>\n              </div>\n              <br/>";
     $uploaddir = $this->m_tblConfig['CDISCOO_PATH'] . "/import/";
     $uploadfile = $uploaddir . basename($_FILES['uploadedDoc']['name']);
     if (move_uploaded_file($_FILES['uploadedDoc']['tmp_name'], $uploadfile)) {
         //Detection of the target container
         $containerName = $this->m_ctrl->boimport()->getContainer($uploadfile);
         $html .= "<div style='text-align: left'><ul>";
         try {
             $html .= "<li>adding {$_FILES['uploadedDoc']['name']}...</li>";
             $fileOID = $this->m_ctrl->socdiscoo()->addDocument($uploadfile, false, $containerName);
         } catch (Exception $e) {
             if (sedna_ercls() == "SE2004") {
                 //SE2004 = Document with the same name already exists in the collection.
                 try {
                     $html .= "<li>document already imported, replacing...</li>";
                     $fileOID = $this->m_ctrl->socdiscoo()->replaceDocument($uploadfile, false, $containerName);
                 } catch (Exception $e) {
                     $this->addLog(__METHOD__ . " " . $e->getMessage(), FATAL);
                 }
             } else {
                 if (sedna_ercls() == "SE2003") {
                     //SE2003 = No collection with this name.
                     try {
                         //Database initialization
                         $html .= "<li>oups, it appears that the database wasn't initialized. Initializing database...</li>";
                         $this->initDB();
                         //Try again to add the document
                         $html .= "<li>adding {$_FILES['uploadedDoc']['name']}...</li>";
                         $fileOID = $this->m_ctrl->socdiscoo()->addDocument($uploadfile, false, $containerName);
                     } catch (Exception $e) {
                         $this->addLog(__METHOD__ . " " . $e->getMessage(), FATAL);
                     }
                 } else {
                     $this->addLog(__METHOD__ . " " . $e->getMessage(), FATAL);
                 }
             }
         }
         $html .= "<li>import successfull !</li>";
         $html .= "</ul>";
         $html .= "<a href='" . $GLOBALS['egw']->link('/index.php', array('menuaction' => $this->getCurrentApp(false) . '.uietude.dbadminInterface', 'container' => $containerName, 'action' => 'viewDocs')) . "'>See {$containerName}</a><br/>";
         $html .= "</div><br />";
         //Update the subject in the SubjectsList
         if (is_numeric($fileOID)) {
             $this->m_ctrl->bosubjects()->updateSubjectInList($fileOID);
         }
         return $html;
     }
 }
 private function setXQLib($reload = false)
 {
     $results = array();
     $strLib = implode("','", $this->m_tblConfig['XQUERY_LIB']);
     //unloading module
     if ($reload) {
         $query = "DROP MODULE 'http://www.alix-edc.com/alix'";
         if (sedna_execute($query)) {
             //dropping existing module definition
             $results[] = "xquery module {$strLib} dropped";
         }
     }
     //loading module
     $query = "LOAD MODULE '{$strLib}'";
     if (!sedna_execute($query)) {
         if (sedna_ercls() != "SE1073") {
             //Module with the same name already exists.
             $str = "Could create module '{$query}': " . sedna_error() . " (" . __METHOD__ . ")";
             $this->addLog($str, FATAL);
         } else {
             $results[] = "xquery module {$strLib} already loaded";
         }
     } else {
         $results[] = "xquery module {$strLib} loaded";
     }
     return $results;
 }