PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / libraries / mvc / admin / models / acl.php
vikappointments / libraries / mvc / admin / models Last commit date
acl.php 2 days ago license.php 2 days ago override.php 2 days ago overrides.php 2 days ago shortcode.php 2 days ago shortcodes.php 2 days ago
acl.php
62 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 JLoader::import('adapter.mvc.models.form');
15
16 /**
17 * VikAppointments plugin ACL model.
18 *
19 * @since 1.0
20 * @see JModelForm
21 */
22 class VikAppointmentsModelAcl extends JModelForm
23 {
24 /**
25 * A list containing the roles to ignore.
26 *
27 * @var array
28 */
29 private $ignores = array('administrator');
30
31 /**
32 * @override
33 * Updates the ACL for the existing Wordpress user roles.
34 *
35 * @param array &$data The array data containing the ACL rules.
36 *
37 * @return boolean True on success, otherwise false.
38 */
39 public function save(&$data)
40 {
41 foreach ($data as $slug => $actions)
42 {
43 $role = get_role($slug);
44
45 if ($role && !in_array($slug, $this->ignores))
46 {
47 foreach ($actions as $cap => $has)
48 {
49 $has = (int) $has;
50
51 if ($has != -1)
52 {
53 $b = $role->add_cap($cap, (bool) $has);
54 }
55 }
56 }
57 }
58
59 return true;
60 }
61 }
62