Exemple #1
0
 /**
  * Взять категории документов
  *
  * @return array Данные выборки
  */
 public static function getSections()
 {
     global $DB;
     $sql = 'SELECT DISTINCT A.id, A."name", A.date_create, A.date_update, A.sort, COUNT(B.id) 
             FROM docs_sections A 
             LEFT JOIN docs B ON (A.id = B.docs_sections_id) 
             GROUP BY A.id, A."name", A.date_create, A.date_update, A.sort 
             ORDER BY A.sort';
     $data = $DB->rows($sql);
     if ($data) {
         docs_files::SelectMinMax($data);
     }
     return $data;
 }
Exemple #2
0
 /**
  * Удалить Doc.
  *
  * @param mixed $docs_id Ид вопроса или строка в виде id|id2|id3...
  *
  * @return string Сообщение об ошибке
  */
 public static function Delete($id)
 {
     if (is_numeric($id)) {
         $files = docs_files::getDocsFiles($id);
         $file = new CFile();
         foreach ($files as $key => $value) {
             $file->Delete($value['file_id']);
         }
         global $DB;
         $DB->query('DELETE FROM docs WHERE id = ?i', $id);
         return $DB->error;
     } else {
         foreach (explode('|', $id) as $idx) {
             if (!(int) $idx) {
                 continue;
             }
             self::Delete((int) $idx);
         }
         return false;
     }
 }
Exemple #3
0
function RefreshUploadedFiles($doc_id)
{
    $objResponse = new xajaxResponse();
    if (hasPermissions('docs')) {
        $error = false;
        if ($files = docs_files::getDocsFiles($doc_id)) {
            $page = $_SERVER['DOCUMENT_ROOT'] . '/service/docs/admin_docs_uploaded_files.php';
            ob_start();
            include $page;
            $html = ob_get_contents();
            ob_end_clean();
            $objResponse->assign('form_files_added', 'innerHTML', $html);
        } else {
            $objResponse->assign('form_files_added', 'innerHTML', 'Не возожно получить список файлов');
        }
    }
    return $objResponse;
}
Exemple #4
0
             $files = docs_files::getDocsFiles(intval($_POST['dosc_id_f']));
             if (count($files) == 0 && count($files_attache) == 0) {
                 $error_add_file = 'Необходимо загрузить хотя бы один файл';
                 $error = true;
             }
             if (intval($_POST['dosc_id_f']) == 0) {
                 $error_add_file = 'Ошибка';
                 $error = true;
             }
             if ($error !== false) {
                 $docs = docs::getDocs();
                 $sections = docs_sections::getSections();
             } else {
                 docs::Update(intval($_POST['dosc_id_f']), $_POST['name'], $_POST['desc'], intval($_POST['section']));
                 foreach ($files_attache as $file) {
                     docs_files::Add(intval($_POST['dosc_id_f']), $file->id, $file->original_name);
                 }
                 header('Location: ' . $_SERVER['REQUEST_URI']);
             }
             break;
     }
 } else {
     $docs = docs::getDocs();
     $sections = docs_sections::getSections();
 }
 if (!$docs) {
     $docs = array();
 }
 if (!$sections) {
     $section = array();
 }