Welcome to the PufferPanel community forums! If you need help please register an account and post in the Support category.

Server rules



  • Hi guys,

    Is there a way to add another group to the panel for staff with custom permissions?

    Thanks in advance.

    @puffrfish said:

    I'm just going to put a disclaimer on this thread. While I am grateful that @Incrementing has provided a very detailed response to this, much like anything in the modifications section the PufferPanel developers do not endorse or provide support for the modifications being discussed here, and they should not be attempted by users who are not comfortable working with PHP. Thanks.



  • it could be done but with allot of work.

    well it would take allot of editing but ill do you the favor of telling you where some of the important files for that are. this is very technical and is best if you have an idea of what your doing. I also want to point out that im only showing you where you want to look if you want to setup groups.

    Before we get started I wanted to point out a few things. Pufferpanel groups are confirmed by the "root_admin" number (1 = admin, 0 = default). So I suggest representing the new groups with numbers (eg. mod = 2).

    1 pufferpanel gets the user's group at /srv/pufferpanel/src/core/authentication.php.
    here is the section where that is determined.

    	/**
    	 * Returns the admin status of a user.
    	 *
    	 * @return bool
    	 */
    	public final function isAdmin() {
    
    		if(!$this->select) {
    			return false;
    		} else {
    			return ($this->select->root_admin == 1) ? true : false;
    		}
    
    	}
    
    

    2 next the users rank is stored in mysql > pufferpanel > users > root_admin (table)

    3 the dropdown menu in account viewing to set a user's access is located at /srv/pufferpanel/app/views/admin/account/view.html
    in this section.

    					<div class="form-group">
    						<label for="email" class="control-label">Root Administrator</label>
    						<div>
    							<select name="root_admin" class="form-control">
    								<option value="0">No</option>
    								<option value="1" {% if user.root_admin == 1 %}selected="selected"{% endif %}>Yes</option>
    							</select>
    							<p><small class="text-muted"><em><strong><i class="fa fa-warning"></i></strong> Setting this to "Yes" gives a user full administrative access to PufferPanel.</em></small></p>
    						</div>
    					</div>
    

    4 and you may want to add a the user tag is located at /srv/pufferpanel/app/views/admin/account/find.html
    in this section

    			{% for user in users %}
    				<tr>
    					<td><a href="/admin/account/view/{{ user.id }}">{% if user.username != null %}{{ user.username }}{% else %}[ unregistered subuser ]{% endif %}</a> {% if user.root_admin == 1 %}<span class="badge">Administrator</span>{% endif %}</td>
    					<td>{{ user.email }}</td>
    				</tr>
    			{% endfor %}
    

    Now that i covered the main files for groups now we have to do permissions. Im only going to give a few examples because explaining on how to do them all would be way to long.

    when adding and permissions you want to look for statements like this

    {% if user.root_admin == 1 %}
    

    and make sure you dont break the original access.

    some of the most common places to find that admin access rule is
    /srv/pufferpanel/app/views
    /srv/pufferpanel/src/core

    If you want the new group to be able to see all the servers.
    go to /srv/pufferpanel/app/views/panel/index.html
    and edit this section

    	{% if user.root_admin == 1 %}
    		<div class="alert alert-info">
    			You are viewing this server listing as an admin. As such, all servers installed on the system are displayed. Any servers that you are set as the owner of are marked with a blue dot to the left of their name.
    		</div>
    

    and this section

    		<table class="table table-striped table-bordered table-hover">
    			<thead>
    				<tr>
    					{% if user.root_admin == 1 %}<th></th>{% endif %}
    					<th>{{ l.render('string.name') }}</th>
    					<th>{{ l.render('string.location') }}</th>
    					<th>{{ l.render('string.node') }}</th>
    					<th>{{ l.render('string.connect') }}</th>
    					<th></th>
    				</tr>
    			</thead>
    			<tbody>
    				{% for server in servers %}
    					<tr class="dynUpdate" id="{{ server.hash }}">
    						{% if user.root_admin == 1 %}<td style="width:26px;">{% if server.owner_id == user.id %}<i class="fa fa-circle" style="color:#008cba;"></i>{% else %}<i class="fa fa-circle" style="color:#ddd;"></i>{% endif %}</td>{% endif %}
    						<td><a href="/index/{{ server.hash }}">{{ server.name }}</a></td>
    						<td>{{ server.location }}</td>
    						<td>{{ server.node_name }}</td>
    						<td><code>{{ server.server_ip }}:{{ server.server_port }}</code></td>
    						<td style="width:26px;"><i class="fa fa-circle-o-notch fa-spinner fa-spin applyUpdate"></i></td>
    					</tr>
    				{% endfor %}
    			</tbody>
    		</table>
    

    well anyhow i hope you have a better understanding on how to setup more groups.



  • @SirCoolness I'll give it a shot when I made a backup.

    Thank you for responing.



  • no problem tell me if it works out :)



  • @SirCoolness I managed to add the group and the permissions to the files and to the MySQL server.

    The other problem is when I click on an user this text will appear. Error message

    Can you help me with this?



  • Did you add the group by adding and elseif statement.

    The error seems to be caused by improper implementation.

    This also could be caused because I might have missed a file. I'll try this too and report my results.



  • @SirCoolness This is how I added the group: http://paste.ee/p/ObABA

    I was using numbers 2 and 3 from root_admin for the rank, this was not very effective. Now I'm using an extra row with root_mod and the numbers 0 and 1.



  • I was going to suggest something more like
    (This is an example and actually won't work)

    If(isAdmin(1)){
    Echo "this is admin";
    }elseif(isAdmin(2)){
    Echo "this is mod";
    }else{
    Echo "this is default";
    }
    


  • I'm just going to put a disclaimer on this thread. While I am grateful that @Incrementing has provided a very detailed response to this, much like anything in the modifications section the PufferPanel developers do not endorse or provide support for the modifications being discussed here, and they should not be attempted by users who are not comfortable working with PHP. Thanks.


Log in to reply
 

1
Online

666
Users

708
Topics

3.2k
Posts

Looks like your connection to PufferPanel Community was lost, please wait while we try to reconnect.