Esempio n. 1
0
function getProjects($pdo)
{
    // returns in order of position
    $sectionsInUse = getSectionsInUse($pdo);
    $projects = [];
    foreach ($sectionsInUse as $section) {
        $query = $pdo->prepare('SELECT * FROM sc_projects WHERE section_id = :section_id ORDER BY pos ASC');
        $query->bindParam(':section_id', $section['id']);
        $query->execute();
        $pros = $query->fetchAll();
        foreach ($pros as $project) {
            array_push($projects, $project);
        }
    }
    $query = $pdo->prepare('SELECT * FROM sc_projects WHERE section_id = 0 ORDER BY pos ASC');
    $query->execute();
    $pros = $query->fetchAll();
    foreach ($pros as $project) {
        array_push($projects, $project);
    }
    return $projects;
}
Esempio n. 2
0
<?php

error_reporting(0);
session_start();
if (isset($_SESSION['username']) && !empty($_SESSION['username'])) {
    $session = $_SESSION['username'];
} else {
    header('Location: index.php?error=login');
}
require_once 'inc/functions.php';
require_once 'inc/config.php';
if (!file_exists('sc_projects') || empty($dbName) || !tablesExist($pdo)) {
    header('Location: install.php');
    exit;
}
$sectionsInUse = getSectionsInUse($pdo);
$allSections = getAllSections($pdo);
$sectionsNotInUse = [];
foreach ($allSections as $section) {
    $inUse = false;
    foreach ($sectionsInUse as $sec) {
        if ($sec['section_name'] === $section['section_name']) {
            $inUse = true;
        }
    }
    if (!$inUse) {
        array_push($sectionsNotInUse, $section);
    }
}
$projectsWithoutSections = getProjectsWithoutSections($pdo);
?>