Example #1
0
function selectAllPosts()
{
    require_once inc_manage_post;
    $where = "1=1";
    $whereParam = array();
    //-----------------------
    if (!empty($_POST["post_no"])) {
        $where .= " AND p.post_no=:pno";
        $whereParam[":pno"] = $_POST["post_no"];
    }
    if (!empty($_POST["post_type"]) && $_POST["post_type"] != -1) {
        $where .= " AND p.post_type=:ptype";
        $whereParam[":ptype"] = $_POST["post_type"];
    }
    if (!empty($_POST["title"])) {
        $where .= " AND p.title like :title";
        $whereParam[":title"] = "%" . $_POST["title"] . "%";
    }
    if (!empty($_POST["ouid"]) && $_POST["ouid"] != -1) {
        $result = QueryHelper::MK_org_units($_POST["ouid"], isset($_POST["sub_units"]) ? true : false);
        $where .= " AND " . $result["where"];
        $whereParam = array_merge($whereParam, $result["param"]);
    }
    $where .= dataReader::makeOrder();
    $temp = manage_posts::GetAllPosts($where, $whereParam);
    $no = count($temp);
    $temp = array_slice($temp, $_GET["start"], $_GET["limit"]);
    for ($i = 0; $i < count($temp); $i++) {
        if ($temp[$i]["ouid"] != "") {
            $temp[$i]["full_unit_title"] = manage_units::get_full_title($temp[$i]["ouid"]);
        } else {
            $temp[$i]["full_unit_title"] = "";
        }
    }
    echo dataReader::getJsonData($temp, $no, $_GET["callback"]);
    die;
}