The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
Permissions for pages - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26)
+--- Thread: Permissions for pages (/showthread.php?tid=278)



Permissions for pages - kampfaffe - 09-22-2016

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


Permissions for pages - brian - 09-22-2016

Hi, I'm not sure I understand what the issue is. What is not working as expected?


Permissions for pages - mudmin - 09-22-2016

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...

Code:
<?php if (checkMenu(2,$user->data()->id)){
//Your php/html code here
Code:
}  ?>





Permissions for pages - kampfaffe - 09-23-2016

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>
Code:
<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>
Code:
<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>
Code:
<?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!


Permissions for pages - mudmin - 09-23-2016

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.



Permissions for pages - kampfaffe - 09-23-2016

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


Permissions for pages - mudmin - 09-24-2016

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 ...

Code:
<?php if (checkMenu(2,$user->data()->id)){
Code:
<li class="purple"><a href="/sani/admin/erstellen.php">Erstellen</a>
Code:
</li>
Code:
} ?>

It should be

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

I hope that helps.