Esempio n. 1
0
 function copySearchSourcesFromLibrary()
 {
     $libraryId = $_REQUEST['id'];
     if (isset($_REQUEST['submit'])) {
         $library = new Library();
         $library->libraryId = $libraryId;
         $library->find(true);
         $library->clearSearchSources();
         $libraryToCopyFromId = $_REQUEST['libraryToCopyFrom'];
         $libraryToCopyFrom = new Library();
         $libraryToCopyFrom->libraryId = $libraryToCopyFromId;
         $library->find(true);
         $searchSourcesToCopy = $libraryToCopyFrom->searchSources;
         foreach ($searchSourcesToCopy as $searchKey => $searchSources) {
             $searchSources->libraryId = $libraryId;
             $searchSources->id = null;
             $searchSourcesToCopy[$searchKey] = $searchSources;
         }
         $library->searchSources = $searchSourcesToCopy;
         $library->update();
         header("Location: /Admin/Libraries?objectAction=edit&id=" . $libraryId);
     } else {
         //Prompt user for the library to copy from
         $allLibraries = $this->getAllObjects();
         unset($allLibraries[$libraryId]);
         foreach ($allLibraries as $key => $library) {
             if (count($library->searchSources) == 0) {
                 unset($allLibraries[$key]);
             }
         }
         global $interface;
         $interface->assign('allLibraries', $allLibraries);
         $interface->assign('id', $libraryId);
         $interface->setTemplate('../Admin/copyLibrarySearchSources.tpl');
     }
 }
        $iCompanyId = $_SESSION['sess_iCompanyId'];
        $iSGroupId = $_SESSION['sess_iSGroupId'];
        $qs = '';
    } else {
        $qs = '&iCompanyId=' . $iCompanyId . '&iSGroupId=' . $iSGroupId;
    }
}
if ($mode == "Add") {
    # echo "<pre>";  print_r($_FILES) ; exit;
    $redirect_file = "index.php?file=m-libraryadd&mode=" . $mode . "&iLibCategoryId=" . $iLibCategoryId . $qs;
    $GeneralObj->checkDuplicate('iLibCategoryId', 'LibraryCategory', array('vCategoryName', 'iSGroupId'), $redirect_file, "Category Already Exists ", $vCategoryName, ' and ');
    // $libraryObj->setdCreated($dCreated);
    $libraryObj->setiSGroupId($iSGroupId);
    $iLibCategoryId = $libraryObj->insert();
    $msg = MSG_ADD;
    $url = 'index.php?file=Library&AX=Yes' . $qs . '&var_msg=' . $msg;
    header("Location:" . $url);
    exit;
} else {
    if ($mode == "Update") {
        $update_sql = "UPDATE Document SET eStatus = '" . $eStatus . "'\n\t\t\tWHERE iLibCategoryId IN(" . $iLibCategoryId . ")";
        #echo $update_sql;exit;
        $obj->sql_query($update_sql);
        $libraryObj->setiSGroupId($iSGroupId);
        $libraryObj->update($iLibCategoryId);
        $msg = MSG_UPDATE;
        $url = 'index.php?file=Library&AX=Yes' . $qs . '&var_msg=' . $msg;
        header("Location:" . $url);
        exit;
    }
}