/**
  * Returns whether or not the specified page is visible to the user
  * 
  * @param  array $page  Page data
  * @return boolean      Access
  */
 public static function is_page_visible($page)
 {
     $show_page = true;
     // Get visibility scheme and bail if there isn't one.
     if (!($scheme = array_get($page, '_admin'))) {
         return true;
     }
     // Clean up the scheme
     foreach ($scheme as $key => $val) {
         if (!in_array($key, array('hide', 'show'))) {
             unset($scheme[$key]);
         }
     }
     // Get/set member's roles
     if (!self::$member_roles) {
         self::$member_roles = Auth::getCurrentMember()->get('roles');
     }
     $roles = self::$member_roles;
     // Hiding is checked first because we'd rather show a page than hide it if there's crossover.
     if (array_get($scheme, 'hide')) {
         if (!is_array($scheme['hide'])) {
             // Flag as hidden if `hide: true|yes|1` is specified
             $show_page = false;
         } else {
             // Flat as hidden if the member's role is in scheme's "hide" list
             $show_page = array_intersect($scheme['hide'], $roles) ? false : true;
         }
     }
     if (array_get($scheme, 'show')) {
         // Flat as showable if the member's role is in scheme's "show" list
         $show_page = (bool) array_intersect(array_get($scheme, 'show', array()), $roles);
     }
     return $show_page;
 }
Example #2
0
    echo $app->config['_site_root'];
    ?>
">
              <span class="ss-icon">link</span>
              <span class="title"><?php 
    echo Localization::fetch('view_site');
    ?>
</span>
            </a>
          </li>
          <?php 
}
?>

          <?php 
if (CP_Helper::show_page('logout', true)) {
    ?>
          <li>
            <a href="<?php 
    echo $app->urlFor("logout");
    ?>
">
              <span class="ss-icon">logout</span>
              <span class="title"><?php 
    echo Localization::fetch('logout');
    ?>
</span>
            </a>
          </li>
          <?php 
}
Example #3
0
function display_folder($app, $folder, $base = "")
{
    ?>
  <ul class="subpages">
  <?php 
    foreach ($folder as $page) {
        ?>
  <?php 
        if (CP_Helper::is_page_visible($page)) {
            ?>
  <li class="page">
    <div class="page-wrapper">
      <div class="page-primary">

      <!-- PAGE TITLE -->
        <?php 
            if ($page['type'] == 'file') {
                ?>
          <a href="<?php 
                print $app->urlFor('publish') . "?path={$base}/{$page['slug']}";
                ?>
"><span class="page-title"><?php 
                print isset($page['title']) ? $page['title'] : Slug::prettify($page['slug']);
                ?>
</span></a>
        <?php 
            } else {
                ?>
          <a href="<?php 
                print $app->urlFor('publish') . "?path={$page['file_path']}";
                ?>
"><span class="page-title"><?php 
                print isset($page['title']) ? $page['title'] : Slug::prettify($page['slug']);
                ?>
</span></a>

        <?php 
            }
            ?>

      <!-- ENTRIES -->
      <?php 
            if (isset($page['has_entries']) && $page['has_entries']) {
                ?>
        <div class="control-entries">
          <span class="ss-icon">textfile</span>
          <span class="muted"><?php 
                echo $page['entries_label'];
                ?>
:</span>
          <a href="<?php 
                print $app->urlFor('entries') . "?path={$base}/{$page['slug']}";
                ?>
">
            <?php 
                echo Localization::fetch('list');
                ?>
          </a>
          <span class="muted"><?php 
                echo Localization::fetch('or');
                ?>
</span>
          <a href="<?php 
                print $app->urlFor('publish') . "?path={$base}/{$page['slug']}&new=true";
                ?>
">
            <?php 
                echo Localization::fetch('create');
                ?>
          </a>
        </div>
      <?php 
            }
            ?>
      </div>

      <!-- SLUG & VIEW PAGE LINK -->
      <div class="page-extras">

        <div class="page-view">
          <a href="<?php 
            print Path::tidy(Config::getSiteRoot() . '/' . $page['url']);
            ?>
" class="tip" title="View Page">
            <span class="ss-icon">link</span>
          </a>
        </div>

        <?php 
            if ($page['type'] != 'file' && Config::get('_enable_add_child_page', true)) {
                ?>
          <div class="page-add"><a href="#" data-path="<?php 
                print $page['raw_url'];
                ?>
" data-title="<?php 
                print $page['title'];
                ?>
" class="tip add-page-btn add-page-modal-trigger" title="<?php 
                echo Localization::fetch('new_child_page');
                ?>
"><span class="ss-icon">addfile</span></a></div>
        <?php 
            }
            ?>

        <?php 
            if (Config::get('_enable_delete_page', true)) {
                ?>
          <div class="page-delete">
            <?php 
                if (array_get($page, '_admin:protected', false)) {
                    ?>
              <a alt="This page is protected" class="tip"><span class="ss-icon protected">lock</span></a>
            <?php 
                } else {
                    ?>
              <a class="confirm tip" href="<?php 
                    print $app->urlFor('delete_page') . '?path=' . $page['raw_url'] . '&type=' . $page['type'];
                    ?>
" title="<?php 
                    echo Localization::fetch('delete_page');
                    ?>
" data-confirm-message="<?php 
                    echo Localization::fetch('pagedelete_confirm');
                    ?>
">
                <span class="ss-icon">delete</span>
              </a>
            <?php 
                }
                ?>
          </div>
        <?php 
            }
            ?>

        <div class="slug-preview">
          <?php 
            print isset($page['url']) ? $page['url'] : $base . ' /' . $page['slug'];
            ?>
        </div>

      </div>

    </div>
    <?php 
            if (isset($page['children']) && sizeof($page['children']) > 0) {
                display_folder($app, $page['children'], $base . "/" . $page['slug']);
            }
            ?>

  </li>
  <?php 
        }
        ?>
  <?php 
    }
    ?>
  </ul>
  <?php 
}
Example #4
0
<div id="subnav">
  <ul>
    <li><a href="<?php 
echo $app->urlFor("pages");
?>
"><?php 
echo Localization::fetch('pages');
?>
</a></li>
    <li class="separator">&nbsp;</li>
    <?php 
foreach ($listings as $listing) {
    ?>
      <?php 
    if (CP_Helper::is_page_visible($listing)) {
        ?>
        <li><a href="entries?path=<?php 
        echo $listing['slug'];
        ?>
" <?php 
        if ($listing['slug'] === $path) {
            ?>
 class="active" <?php 
        }
        ?>
><?php 
        echo $listing['title'];
        ?>
</a></li>
      <?php 
    }
Example #5
0
        if ($key == 'password' && $value == '') {
            continue;
        }
        $field_config = array_get($config, $key, array());
        // only save values if save_value isn't false
        if (array_get($field_config, 'save_value', true)) {
            $member->set($key, $value);
        } else {
            $member->remove($key);
        }
    }
    // save member
    $member->save();
    // REDIRECT
    $admin_app->flash('success', Localization::fetch('member_saved'));
    $url = CP_Helper::show_page('members') ? $admin_app->urlFor('members') : $admin_app->urlFor('pages');
    $admin_app->redirect($url);
});
// GET: MEMBER
// --------------------------------------------------------
$admin_app->get('/member', function () use($admin_app) {
    authenticateForRole('admin');
    doStatamicVersionCheck($admin_app);
    $data = array();
    if (!Statamic::are_users_writable()) {
        $url = $admin_app->urlFor('error') . "?code=users_not_writable";
        $admin_app->redirect($url);
    }
    $name = Session::getFlash('member_is_new', filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING));
    $new = Session::getFlash('member_is_new', filter_input(INPUT_GET, 'new', FILTER_SANITIZE_NUMBER_INT));
    $original_name = $name;
"<?php 
    if ($route === "logs") {
        ?>
 class="active"<?php 
    }
    ?>
><?php 
    echo Localization::fetch('logs');
    ?>
</a></li>
    <?php 
}
?>

    <?php 
if (CP_Helper::show_page('export', true)) {
    ?>
    <li><a href="<?php 
    echo $app->urlFor("export");
    ?>
"<?php 
    if ($route === "export") {
        ?>
 class="active"<?php 
    }
    ?>
><?php 
    echo Localization::fetch('export_to_html');
    ?>
</a></li>
    <?php