/**
 * Function will return all pages below the specified parent_id, the current user has access to.
 *
 * @param int $identifier
 * @param int $indent
 * @return string
 */
function community_type_pages_inlists($community_type_id, $identifier = 0, $indent = 0, $options = array(), $checked_ids = array())
{
    global $db;
    if ($indent > 99) {
        die("Preventing infinite loop");
    }
    $selected = 0;
    $selectable_children = true;
    if (is_array($options)) {
        if (isset($options["selected"]) && ($tmp_input = clean_input($options["selected"], array("nows", "int")))) {
            $selected = $tmp_input;
        }
        if (isset($options["selectable_children"])) {
            $selectable_children = (bool) $options["selectable_children"];
        }
        if (isset($options["id"])) {
            $ul_id = $options["id"];
            $options["id"] = null;
        }
    }
    $locked_ids = array();
    $query = "SELECT `ctpage_id` FROM `community_type_pages`\n\t\t\t\tWHERE `type_id` = " . $db->qstr($community_type_id) . "\n\t\t\t\tAND `type_scope` = 'organisation'\n\t\t\t\tAND `lock_page` = 1";
    $locked_pages = $db->CacheGetAll(CACHE_TIMEOUT, $query);
    if ($locked_pages) {
        foreach ($locked_pages as $locked_page) {
            $locked_ids[] = $locked_page["ctpage_id"];
        }
    }
    $identifier = (int) $identifier;
    $output = "";
    if ($identifier && $indent === 0) {
        $query = "SELECT `ctpage_id`, `page_url`, `menu_title`, `parent_id`, `page_visible`, `page_type` FROM `community_type_pages` WHERE `type_id` = " . $community_type_id . " AND `type_scope` = 'organisation' AND `ctpage_id` = " . $db->qstr((int) $identifier) . " AND `page_url` != '0' AND `page_active` = '1' ORDER BY `page_order` ASC";
    } else {
        $query = "SELECT `ctpage_id`, `page_url`, `menu_title`, `parent_id`, `page_visible`, `page_type` FROM `community_type_pages` WHERE `type_id` = " . $community_type_id . " AND `type_scope` = 'organisation' AND `parent_id` = " . $db->qstr((int) $identifier) . " AND `page_active` = '1' ORDER BY `page_order` ASC";
    }
    $results = $db->GetAll($query);
    if ($results) {
        $output .= "<ul class=\"community-page-list\" " . (isset($ul_id) ? "id = \"" . $ul_id . "\"" : "") . ">";
        foreach ($results as $result) {
            $output .= "<li id=\"content_" . $result["ctpage_id"] . "\">\n";
            $output .= "<div class=\"community-page-container\">";
            if ($indent > 0 && !$selectable_children) {
                $output .= "\t<span class=\"include\">&nbsp;</span>\n";
                $output .= "\t<span class=\"" . ((int) $result["page_visible"] == 0 ? "hidden-page " : "") . "next off\">" . html_encode($result["menu_title"]) . "</span>\n";
            } else {
                $output .= "\t<span class=\"include\"><input type=\"checkbox\" id=\"page_" . $result["ctpage_id"] . "\" name=\"page_ids[]\" value=\"" . $result["ctpage_id"] . "\"" . (array_search($result["ctpage_id"], $locked_ids) !== false || array_search($result["ctpage_id"], $checked_ids) !== false ? " checked=\"checked\"" : "") . (array_search($result["ctpage_id"], $locked_ids) !== false ? " disabled=\"disabled\"" : "") . " /></span>\n";
                $output .= "\t<span class=\"" . ((int) $result["page_visible"] == 0 ? "hidden-page " : "") . "next\">" . html_encode($result["menu_title"]) . "</span>\n";
                if (array_search($result["ctpage_id"], $locked_ids) !== false) {
                    $output .= "\t<input type=\"hidden\" name=\"page_ids[]\" value=\"" . $result["ctpage_id"] . "\" />";
                }
            }
            $output .= "</div>";
            $output .= community_type_pages_inlists($community_type_id, $result["ctpage_id"], $indent + 1, $options);
            $output .= "</li>\n";
        }
        $output .= "</ul>";
    } else {
        $output .= "<ul class=\"community-page-list empty\"></ul>";
    }
    return $output;
}
        }
        ?>
                </ul>
                <?php 
        echo isset($large_template_images) && $large_template_images ? $large_template_images : "";
    }
    ?>
        </div>
    </div>
    <div class="clearfix"></div>
    <h3>Community Pages</h3>
    <div class="control-group">
        <label class="control-label form-required">Default Pages</label>
        <div class="controls">
			<?php 
    $pages_output = community_type_pages_inlists($community_type_id, 0, 0, array(), $page_ids);
    if ($pages_output != "<ul class=\"community-page-list empty\"></ul>") {
        echo $pages_output;
    } else {
        add_notice("No default pages found for this community type.");
        echo display_notice();
    }
    ?>
		</div>
	</div>
	<?php 
    $query = "SELECT `community_type_options` FROM `org_community_types`\n                WHERE `octype_id` = " . $db->qstr($community_type_id);
    $type_options_serialized = $db->GetOne($query);
    if ($type_options_serialized && ($type_options = json_decode($type_options_serialized)) && @count($type_options)) {
        foreach ($type_options as $type_option => $active) {
            if ($type_option == "course_website" && $active && $ENTRADA_ACL->amIAllowed("course", "create", false)) {
Example #3
0
         ?>
                         </ul>
                         <?php 
         echo isset($large_template_images) && $large_template_images ? $large_template_images : "";
     }
 }
 ?>
             </div>
         </div>
         <div class="clearfix"></div>
         <h3>Community Pages</h3>
         <div class="control-group">
             <label class="control-label form-required">Default Pages</label>
             <div class="controls">
                 <?php 
 $pages_output = community_type_pages_inlists($PROCESSED["octype_id"], 0, 0, array(), $PROCESSED["page_ids"]);
 if ($pages_output != "<ul class=\"community-page-list empty\"></ul>") {
     echo $pages_output;
 } else {
     add_notice("No default pages found for this community type.");
     echo display_notice();
 }
 ?>
             </div>
         </div>
         <?php 
 $query = "SELECT `community_type_options` FROM `org_community_types`\n                                WHERE `octype_id` = " . $db->qstr($PROCESSED["octype_id"]);
 $type_options_serialized = $db->GetOne($query);
 if ($type_options_serialized && ($type_options = json_decode($type_options_serialized)) && @count($type_options)) {
     foreach ($type_options as $type_option => $active) {
         if ($type_option == "course_website" && $active && $ENTRADA_ACL->amIAllowed("course", "create", false)) {