This forum is archived. Posts are preserved for historical reference. For current help, join us on Discord.

Permissions for pages

In UserSpice 4.3 and Below · Started by kampfaffe on 2016-09-22 1:49 pm · 13929 views · 6 replies

Hello,
I have set the permissions for my own pages in the dashboard. The side only shall be shown if one has the right to it (Admin)
I hope somebody can say me what I have made wrong.
Best regards,
kampfaffe
Hi, I'm not sure I understand what the issue is. What is not working as expected?
Ahh. I see what you're saying. You only want a particular element of the page to be shown if you are an admin. That is very similar to the way we do the menus.

Whatever you want to "hide" for non admin users, wrap the entire thing in this statement...
<?php if (checkMenu(2,$user->data()->id)){
//Your php/html code here
}  ?>


Hello,
thank you for response. That sounds good, but it don`t work for me.

At the moment, this is my script for the menu of the homepage:
<pre>
<pre>
 <nav>
    <div class="wrapper">
      <ul id="menu" class="clearfix">
        <li><a href="/sani">Home</a></li>
         
<li><a href="#">Dienstpläne</a>
          <ul>
            <li class="purple"><a href="/sani/aktuell/kw38.php">Aktuell</a>
            </li>
            <li class="purple"><a href="#">Archiv</a>
              <ul>
                <li><a href="/sani/archiv/2016/september">September</a></li>
				
                <li><a href="/sani/archiv/2016/juli">Juli</a></li>
                <li><a href="#">Juni</a></li>
              </ul>
            </li>

            <li class="purple"><a href="#">Erstellen</a>
              <ul>
                <li><a href="/sani/admin/kw38_erstellen.php">KW38</a></li>
                <li><a href="#">KW39</a></li>
                <li><a href="#">KW40</a></li>
              </ul>
            </li>

          </ul>
        </li>
		        <li><a href="/sani/termine.php">Termine</a></li>
		        <li><a href="/sani/changelog.php">Changelog</a></li>

      </ul>
    </div>
  </nav>
</pre>

</pre>

Now, i wan't to hide the following:
<pre>
<pre>
            <li class="purple"><a href="#">Erstellen</a>
              <ul>
                <li><a href="/sani/admin/kw38_erstellen.php">KW38</a></li>
                <li><a href="#">KW39</a></li>
                <li><a href="#">KW40</a></li>
              </ul>
            </li>
</pre>



So I did this:

<pre>
<?php if (checkMenu(2,$user->data()->id)){
            <li class="purple"><a href="#">Erstellen</a>
              <ul>
                <li><a href="/sani/admin/kw38_erstellen.php">KW38</a></li>
                <li><a href="#">KW39</a></li>
                <li><a href="#">KW40</a></li>
              </ul>
            </li>
} ?>
</pre>

</pre>

But now, there is the following Error in the Apache log: PHP Parse error: syntax error, unexpected '<' in /var/www/html/secret/sani/termine.php on line 35.


Thank you for your help!
Can you paste these chunks of code over at pastebin.com or hastebin.com and share the links back here so I can read them a little bit better. We're working on a fix for the code in our forums, but right now, I can't read that very well.
Hello,
here with Hastebin:

At the moment, this is my script for the menu of the homepage:
http://hastebin.com/qikiwehoba.html

Now, I wan’t to hide the following:
http://hastebin.com/emenokuxog.html

So I did this:
http://hastebin.com/ufucoxojeb.html

But now, there is the following Error in the Apache log: PHP Parse error: syntax error, unexpected '<' in /var/www/html/secret/sani/menu/index.html on line 19
When you make that change, you are essentially going from html here:
</li>
to php and then back to html and then back to php and back to html. Each time you need to make sure you close php and reopen it. So, instead of ...
<?php if (checkMenu(2,$user->data()->id)){
<li class="purple"><a href="/sani/admin/erstellen.php">Erstellen</a>
</li>
} ?>

It should be
<?php if (checkMenu(2,$user->data()->id)){ ?>
See how I closed php?
<li class="purple"><a href="/sani/admin/erstellen.php">Erstellen</a>
I went back to standard html
</li>
<?php } ?>
Then I opened php put a } and closed it to complete the if statement
</ul>
Then went back to regular html.

I hope that helps.