コード例 #1
0
function get_sections($con, $args)
{
    $sections = array();
    if (isset($args["section_id"])) {
        $section_id = $args["section_id"];
        $sql = $con->prepare("SELECT section_name,tid,`order` FROM section WHERE section_id=?");
        $sql->bind_param("i", $section_id);
        $sql->bind_result($section_name, $tid, $order);
        $sql->execute();
        $sql->fetch();
        $sql->close();
        if (isset($section_name) && isset($tid) && isset($order)) {
            $tmp = new Section();
            $tmp->populate($section_id, $tid, $section_name, [], $order);
            $sections[] = $tmp->expose();
        }
    } else {
        if (isset($args["section_name"])) {
            $section_name = $args["section_name"];
            $sql = $con->prepare("SELECT section_id,tid,`order` FROM section WHERE section_name=?");
            $sql->bind_param("s", $section_name);
            $sql->bind_result($section_id, $tid, $order);
            $sql->execute();
            while ($sql->fetch()) {
                if (isset($section_id) && isset($tid) && isset($order)) {
                    $tmp = new Section();
                    $tmp->populate($section_id, $tid, $section_name, [], $order);
                    $sections[] = $tmp->expose();
                }
            }
            $sql->close();
        } else {
            $sql = $con->prepare("SELECT section_id,tid,section_name,`order` FROM section");
            $sql->bind_result($section_id, $tid, $section_name, $order);
            $sql->execute();
            while ($sql->fetch()) {
                if (isset($section_id) && isset($tid) && isset($section_name) && isset($order)) {
                    $tmp = new Section();
                    $tmp->populate($section_id, $tid, $section_name, [], $order);
                    $section = $tmp->expose();
                    $sections[] = $section;
                }
            }
            $sql->close();
        }
    }
    return $sections;
}
コード例 #2
0
ファイル: setting.php プロジェクト: kofeve/yana-server
            } else {
                $description = "Ajout d'un rang";
                $button = "Ajouter";
            }
            $tpl->assign('description', $description);
            $tpl->assign('button', $button);
            $tpl->assign('ranks', $ranks);
            break;
        case 'right':
            $rightManager = new Right();
            $sectionManager = new Section();
            $rank = new Rank();
            $rank = $rank->getById($_['id']);
            $rights = $rightManager->loadAll(array('rank' => $_['id']));
            $rightsDictionnary = array();
            foreach ($rights as $value) {
                $rightsDictionnary[$value->getSection()]['c'] = $value->getCreate();
                $rightsDictionnary[$value->getSection()]['r'] = $value->getRead();
                $rightsDictionnary[$value->getSection()]['u'] = $value->getUpdate();
                $rightsDictionnary[$value->getSection()]['d'] = $value->getDelete();
            }
            $tpl->assign('rights', $rightsDictionnary);
            $tpl->assign('sections', $sectionManager->populate('label'));
            $tpl->assign('rank', $rank);
            break;
    }
    $view = 'setting';
} else {
    exit('Vous devez être connecté');
}
require_once dirname(__FILE__) . '/footer.php';