Restrict the list actions

In this tutorial topic you will modify the list created in the previous topic so that the required conditions will be met:

Hide the add button from all but authors

To hide or display page elements you can use a MX Kollection server behavior - Show If Conditional Region. For the add new button to be displayed, the user that is currently logged in must have the access level set to 1 - author. Upon login, as set in the unified login settings, a session variable that stores the access level is created - kt_login_level - and that is what will be used as a condition.

  1. Open the admin/list page in Dreamweaver.

  2. From the last row of the list select the drop-down menu and the dynamic add new link:


                

  3. Go to the Server Behaviors tab > Plus (+) > MX Kollection > Conditional Regions and select the Show If Conditional Region server behavior.

  4. Configure the user interface fields:


                  

  5. Click OK to close the user interface and apply the server behavior.

To test the changes login with an editor's account. You can no longer add elements:

 

Allow delete for webmaster only

The approach to hide the delete button is similar to the method used to hide the add new elements. The only difference lies in the element to hide and the user level to match:

  1. First select the delete link in the list, next to the row elements:


              

  2. Go to the Server Behaviors tab > Plus (+) > MX Kollection > Conditional Regions and select the Show If Conditional Region server behavior.

  3. Configure the user interface fields:


                       

  4. Click OK to apply the server behavior

  5. Now select the Delete link on the bottom of the list:


                     

  6. Repeat steps 2 through 4 to hide this link as well.

  7. The checkbox displayed next to each record (on the left) allows selecting multiple records for editing or deleting. As each record is an article with potentially large content, multiple editing would not be used. As such, its only use is for deletion. Select the checkbox displayed next to each list item and repeat steps 2 through 4 to hide them as well. Apply the same steps for the checkbox displayed on the list header (before the Topic column).

To test the change, login with a regular account - author or editor. The delete buttons will not be displayed any more:

 

Display the edit link conditionally

The edit link next to each row can be displayed in two cases:

  1. The article is a draft and the logged in user is the author.

  2. The article is set to assigned for review and the logged in user is the editor that will review it.

In both cases above, the user that is currently logged in is also the user who has the article assigned to. Therefore, the two cases can be reduced to only one: if the currently logged in user is also the user who has an assigned article, show the edit link next to the article. No user will be able to use the multiple edit feature, so the link on the list's last row will be removed entirely.

 

First you need to edit the list recordset, to add the assigned_to_art column to be retrieved:

  1. Double-click the ListRecordset in the Bindings tab to edit it.

  2. After the SELECT keyword enter article_art.assigned_to_art, . Do not forget the trailing space.

  3. Click OK to save the changes to the recordset.

Next you will restrict the display of the edit link next to each list item:

  1. Select the edit dynamic link next to the list row:


                  

  2. Go to the Server Behaviors tab > Plus (+) > MX Kollection > Conditional Regions and select the Show If Conditional Region server behavior.

  3. Configure the user interface fields:


               

  4. Click OK to apply the server behavior.

  5. The multiple edit link will be entirely removed. Select it on the last line of the list and press Delete.

If you login with an author account (author1@interaktcms.org, author2@interaktcms.org) only the add new button is displayed. If you login with an editor account (editor1@interakcms.org, editor2@interaktcms.org) that has no articles set for review, the list will be displayed without buttons.

 

In the next topic you will create the pages that allow assigning and approving articles.