/**
  * Create a hierarchical ordered dropdown of all the content objects in the system for use
  * in the admin and various modules.  If $current or $parent variables are passed, care is taken
  * to make sure that children which could cause a loop are hidden, in cases of when you're creating
  * a dropdown for changing a content object's parent.
  *
  * @param string $current The currently selected content object.  If none is given, we show all items.
  * @param string $parent The parent of the currently selected content object. If none is given, we show all items.
  * @param string $name The html name of the dropdown
  * @param boolean $allowcurrent Overrides the logic if $current and/or $parent are passed. Defaults to false.
  * @param boolean $use_perms If true, checks authorship permissions on pages and only shows those the current
  *                user has access to.
  * @param boolean $ignore_current Ignores the value of $current totally by not marking any items as invalid.
  * @param boolean $allow_all If true, show all items, even if the content object 
  *                           doesn't have a valid link. Defaults to false.
  * @param boolean $use_name if true use Name() else use MenuText() Defaults to using the system preference.
  * @return string The html dropdown of the hierarchy
  */
 function CreateHierarchyDropdown($current = '', $parent = '', $name = 'parent_id', $allowcurrent = 0, $use_perms = 0, $ignore_current = 0, $allow_all = false, $use_name = null)
 {
     $result = '';
     $userid = -1;
     if (is_null($use_name)) {
         $use_name = get_site_preference('listcontent_showtitle', true);
     }
     $allcontent = $this->GetAllContent(false);
     if ($allcontent !== FALSE && count($allcontent) > 0) {
         if ($use_perms) {
             $userid = get_userid();
         }
         if ($userid > 0 && check_permission($userid, 'Manage All Content') || $userid == -1 || $parent == -1) {
             $result .= '<option value="-1">' . lang('none') . '</option>';
         }
         $curhierarchy = '';
         foreach ($allcontent as $one) {
             if (!is_object($one)) {
                 continue;
             }
             $value = $one->Id();
             if ($value == $current) {
                 // Grab hierarchy just in case we need to check children
                 // (which will always be after)
                 $curhierarchy = $one->Hierarchy();
                 if (!$allowcurrent) {
                     // Then jump out.  We don't want ourselves in the list.
                     continue;
                 }
                 $value = -1;
             }
             // If it doesn't have a valid link...
             // don't include it.
             if (!$allow_all && !$one->HasUsableLink()) {
                 continue;
             }
             // If it's a child of the current, we don't want to show it as it
             // could cause a deadlock.
             if (!$allowcurrent && $curhierarchy != '' && strstr($one->Hierarchy() . '.', $curhierarchy . '.') == $one->Hierarchy() . '.') {
                 continue;
             }
             // If we have a valid userid... only include pages where this user
             // has write access... or is an admin user... or has appropriate permission.
             if ($userid > 0 && $one->Id() != $parent) {
                 if (!check_permission($userid, 'Manage All Content') && !check_authorship($userid, $one->Id())) {
                     continue;
                 }
             }
             // Don't include content types that do not want children either...
             if (!$one->WantsChildren()) {
                 continue;
             }
             $result .= '<option value="' . $value . '"';
             // Select current parent if it exists
             if ($one->Id() == $parent) {
                 $result .= ' selected="selected"';
             }
             $txt = $use_name ? $one->Name() : $one->MenuText();
             if ($value == -1 && $ignore_current == 0) {
                 $result .= '>' . $one->Hierarchy() . '. - ' . $txt . ' (' . lang('invalid') . ')</option>';
             } else {
                 $result .= '>' . $one->Hierarchy() . '. - ' . $txt . '</option>';
             }
         }
     }
     if (!empty($result)) {
         $result = '<select name="' . $name . '" id="' . $name . '">' . $result . '</select>';
     }
     return $result;
 }
Exemple #2
0
function setactive($contentid, $active = true)
{
    $userid = get_userid();
    $hierManager = cmsms()->GetHierarchyManager();
    // to activate a page, you must be admin, owner, or additional author
    $permission = check_ownership($userid, $contentid) || check_authorship($userid, $contentid) || check_permission($userid, 'Manage All Content');
    if ($permission) {
        $node = $hierManager->getNodeById($contentid);
        $value = $node->getContent(false, false);
        $value->SetActive($active);
        $value->Save();
        $contentops = cmsms()->GetContentOperations();
        $contentops->ClearCache();
    }
}
Exemple #3
0
if (isset($_POST["cancel"])) {
    redirect("listcontent.php" . $urlext);
}
if ($apply) {
    $CMS_EXCLUDE_FROM_RECENT = 1;
}
#Get a list of content types and pick a default if necessary
$gCms = cmsms();
$contentops = $gCms->GetContentOperations();
$existingtypes = $contentops->ListContentTypes(false, true);
#Get current userid and make sure they have permission to add something
$userid = get_userid();
$access = check_ownership($userid, $content_id) || check_permission($userid, 'Modify Any Page') || check_permission($userid, 'Manage All Content');
$adminaccess = $access;
if (!$access) {
    $access = check_authorship($userid, $content_id);
}
if ($access) {
    // get the content object.
    $contentobj = "";
    $content_type = 'content';
    // default content type.
    if (!is_object($contentobj) && $content_id != -1) {
        // load the content object from the database.
        $contentobj = $contentops->LoadContentFromId($content_id);
        $content_type = $contentobj->Type();
    }
    if (isset($_POST['content_type'])) {
        $content_type = $_POST['content_type'];
    }
    $xajax->processRequest();
Exemple #4
0
     $modifyall = check_permission($userid, 'Modify Any Page');
     foreach ($nodelist as $node) {
         $permission = $modifyall || check_ownership($userid, $node->Id()) || check_authorship($userid, $node->Id()) || check_persmission($userid, 'Manage All Content');
         if ($permission) {
             $node->SetSecure($flag);
             $node->Save();
         }
     }
     redirect("listcontent.php" . $urlext . '&message=bulk_success');
 } else {
     if ($action == 'showinmenu' || $action == 'hidefrommenu') {
         $flag = $action == 'showinmenu' ? true : false;
         $userid = get_userid();
         $modifyall = check_permission($userid, 'Modify Any Page');
         foreach ($nodelist as $node) {
             $permission = $modifyall || check_ownership($userid, $node->Id()) || check_authorship($userid, $node->Id()) || check_persmission($userid, 'Manage All Content');
             if ($permission) {
                 $node->SetShowInMenu($flag);
                 $node->Save();
             }
         }
         redirect("listcontent.php" . $urlext . '&message=bulk_success');
     } else {
         if ($action == 'reorder') {
             if (FALSE == $reorder_error) {
                 redirect('listcontent.php' . $urlext . '&amp;message=pages_reordered');
             } else {
                 redirect('listcontent.php' . $urlext . '&amp;error=' . $reorder_error);
             }
         } else {
             redirect('listcontent.php' . $urlext . '&message=no_bulk_performed');