public function CheckPermission()
 {
     $Content = $this->_Sender->Data('Content');
     if (CheckPermission('Candy.Page.Edit') || IsContentOwner($Content) && CheckPermission('Candy.Page.Add')) {
         return True;
     }
 }
 public function Edit($Reference = 0, $ParentID = '')
 {
     $Session = Gdn::Session();
     $Model = new SectionModel();
     $this->Form->SetModel($Model);
     if ($ParentID) {
         $this->Form->AddHidden('ParentID', $ParentID);
     }
     $Section = False;
     if ($Reference) {
         $Section = $Model->GetID($Reference);
         if (!IsContentOwner($Section, 'Candy.Sections.Edit')) {
             $Section = False;
         }
         if ($Section) {
             $this->Form->AddHidden('SectionID', $Section->SectionID);
             $this->Form->SetData($Section);
         }
     }
     if (!$Section) {
         $this->Permission('Candy.Sections.Add');
     }
     if ($this->Form->AuthenticatedPostBack()) {
         $this->Form->Save($Section);
         if ($this->Form->ErrorCount() == 0) {
             $this->InformMessage(T('Saved'), array('Sprite' => 'Check', 'CssClass' => 'Dismissable AutoDismiss'));
         }
     }
     $this->Title(ConcatSep(' - ', T('Section'), GetValue('Name', $Section)));
     $this->Render();
 }
 public function Edit($Reference = '')
 {
     //$this->AddJsFile('jquery.autocomplete.pack.js');
     $this->AddJsFile('jquery.textpandable.js');
     $this->AddJsFile('editform.js');
     $this->Form->SetModel($this->PageModel);
     $Session = Gdn::Session();
     $SectionModel = new SectionModel();
     $this->Tree = $SectionModel->DropDownArray('Name', $SectionModel->GetNodes(array('Depth >' => 0)));
     $this->FormatOptions = LocalizedOptions(array('Text', 'xHtml', 'Html', 'Markdown', 'Raw'));
     if (!$Session->CheckPermission('Candy.Pages.Raw')) {
         unset($this->FormatOptions['Raw']);
     }
     $this->EventArguments['FormatOptions'] =& $this->FormatOptions;
     $this->FireEvent('FormatOptions');
     $Content = False;
     if ($Reference != '') {
         $Content = $this->PageModel->GetID($Reference);
         if (!IsContentOwner($Content, 'Candy.Pages.Edit')) {
             $Content = False;
         }
         if ($Content) {
             $this->Form->AddHidden('PageID', $Content->PageID);
             $this->Form->SetData($Content);
             $this->Editing = True;
         }
     }
     if (!$Content) {
         $this->Permission('Candy.Pages.Add');
     }
     if ($this->Form->AuthenticatedPostBack()) {
         if ($this->Form->ButtonExists('Delete')) {
             $this->PageModel->Delete($Content->PageID);
             $this->InformMessage(T('Page deleted'), array('Sprite' => 'SkullBones', 'CssClass' => 'Dismissable AutoDismiss'));
         } else {
             $SavedID = $this->Form->Save($Content);
             if ($SavedID) {
                 $Message = LocalizedMessage('Saved. You can check it here: %s', Anchor($this->Form->GetFormValue('Title'), 'content/page/' . $SavedID));
                 $this->InformMessage($Message, array('Sprite' => 'Check', 'CssClass' => 'Dismissable'));
             }
         }
     } else {
         $URI = trim(GetIncomingValue('URI'), '/');
         if ($URI) {
             $this->Form->SetValue('URI', $URI);
         }
     }
     $this->SetData('Content', $Content, True);
     $this->Title(ConcatSep(' - ', T('Page'), GetValue('Title', $Content)));
     $this->Render();
 }
Exemple #4
0
 } else {
     if ($Counter > 0) {
         echo "</li>";
     }
 }
 $CurrentDepth = $Node->Depth;
 ++$Counter;
 $ItemAttribute = array('id' => 'Tree_' . $Node->SectionID);
 if ($Node->Depth < 2) {
     $ItemAttribute['class'] = 'Open';
 }
 $Options = array();
 if ($PermissionAdd) {
     $Options[] = Anchor(T('Add'), 'candy/section/add/' . $Node->SectionID, '');
 }
 if (IsContentOwner($Node, 'Candy.Sections.Edit')) {
     $Options[] = Anchor(T('Edit'), 'candy/section/edit/' . $Node->SectionID, '');
 }
 if ($Node->Depth == 0) {
     // This is root
     //$Options[] = Anchor('Properties', 'candy/content/properties/'.$Node->ContentID, '');
 } else {
     if ($PermissionSwap) {
         $Options[] = Anchor(T('Swap'), 'candy/section/swap/' . $Node->SectionID, '');
     }
     if ($PermissionMove) {
         $Options[] = Anchor(T('Move'), 'candy/section/move/' . $Node->SectionID, '');
     }
     if ($PermissionDelete) {
         $Options[] = Anchor(T('Delete'), 'candy/section/delete/' . $Node->SectionID, 'PopConfirm');
     }
Exemple #5
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
$Page = (object) GetValue('Content', $Data);
$Title = GetValue('Title', $Data, $Page->Title);
$TargetUrl = $this->_Sender->SelfUrl;
// Wrapper box <div class="Box"> in Module::String()
$PermissionEdit = IsContentOwner($Page, 'Candy.Pages.Edit');
?>

<h4><?php 
echo Anchor($Title, 'content/page/' . $Page->PageID . '/' . CleanupString($Page->Title));
?>
</h4>

<ul class="PanelInfo">
	<?php 
if ($PermissionEdit) {
    ?>
	<li><?php 
    echo Anchor(T('Published'), 'candy/page/visible/' . $Page->PageID . '?Target=' . $TargetUrl, 'BoolButton');
    ?>
		<span class="Aside"><?php 
    echo T($Page->Visible == 1 ? 'Yes' : 'No');
    ?>
</span>
	</li>
	<li><?php 
    echo Anchor(T('Edit'), 'candy/page/edit/' . $Page->PageID, '');
Exemple #6
0
</h1>

<?php 
include $this->FetchViewLocation('menu', 'candy');
?>

<?php 
echo $this->Pager->ToString('less');
?>
<table class="AltRows" style="width:100%">

<tbody>
<?php 
foreach ($this->Pages as $Page) {
    $Options = array();
    if (IsContentOwner($Page, 'Candy.Pages.Edit')) {
        $Options[] = Anchor(T('Edit'), 'candy/page/edit/' . $Page->PageID, '');
    }
    if ($PermissionDelete) {
        $Options[] = Anchor(T('Delete'), 'candy/page/delete/' . $Page->PageID, '');
    }
    ?>
	<tr>
	<td><?php 
    echo $Page->URI ? $Page->URI : 'None';
    ?>
</td>
	<td><?php 
    echo Anchor($Page->Title, 'content/page/' . $Page->PageID);
    ?>
</td>