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 / controllers / rss.php
vikappointments / libraries / mvc / admin / controllers Last commit date
acl.php 2 days ago feedback.php 2 days ago license.php 2 days ago override.php 2 days ago rss.php 2 days ago shortcode.php 2 days ago shortcodes.php 2 days ago
rss.php
141 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 VAPLoader::import('libraries.mvc.controllers.admin');
15
16 /**
17 * VikAppointments plugin RSS controller.
18 *
19 * @since 1.1.9
20 */
21 class VikAppointmentsControllerRss extends VAPControllerAdmin
22 {
23 /**
24 * Sets the opt-in status for the RSS service of the user.
25 *
26 * @return void
27 */
28 public function optin()
29 {
30 if (!JFactory::getUser()->authorise('core.admin', 'com_vikappointments'))
31 {
32 // not authorised to view this resource
33 throw new Exception(JText::translate('RESOURCE_AUTH_ERROR'), 403);
34 }
35
36 $input = JFactory::getApplication()->input;
37
38 // get opt-in status
39 $status = $input->getBool('status', false);
40
41 // get RSS instance
42 $rss = VikAppointmentsBuilder::setupRssReader();
43
44 // update opt-in status
45 $rss->optIn($status);
46
47 if (wp_doing_ajax())
48 {
49 wp_die();
50 }
51
52 // back to the dashboard
53 $this->setRedirect('admin.php?page=vikappointments');
54 }
55
56 /**
57 * Dismesses the specified RSS feed.
58 *
59 * @return void
60 */
61 public function dismiss()
62 {
63 if (!JFactory::getUser()->authorise('core.admin', 'com_vikappointments'))
64 {
65 // not authorised to view this resource
66 throw new Exception(JText::translate('RESOURCE_AUTH_ERROR'), 403);
67 }
68
69 $input = JFactory::getApplication()->input;
70
71 // get ID of the feed to dismiss
72 $id = $input->getString('id', '');
73
74 if (!$id)
75 {
76 // make sure the feed ID is set
77 throw new Exception('Missing feed ID', 400);
78 }
79
80 JLoader::import('adapter.rss.feed');
81
82 // get RSS feed instance
83 $feed = new JRssFeed(array('id' => $id), 'vikappointments');
84
85 // dismiss the feed for this user
86 $feed->dismiss();
87
88 if (wp_doing_ajax())
89 {
90 wp_die();
91 }
92
93 // back to the dashboard
94 $this->setRedirect('admin.php?page=vikappointments');
95 }
96
97 /**
98 * Delays the specified RSS feed.
99 *
100 * @return void
101 */
102 public function remind()
103 {
104 if (!JFactory::getUser()->authorise('core.admin', 'com_vikappointments'))
105 {
106 // not authorised to view this resource
107 throw new Exception(JText::translate('RESOURCE_AUTH_ERROR'), 403);
108 }
109
110 $input = JFactory::getApplication()->input;
111
112 // get ID of the feed to dismiss
113 $id = $input->getString('id', '');
114
115 if (!$id)
116 {
117 // make sure the feed ID is set
118 throw new Exception('Missing feed ID', 400);
119 }
120
121 // get specified delay
122 $delay = $input->getUint('delay', 60);
123
124 JLoader::import('adapter.rss.feed');
125
126 // get RSS feed instance
127 $feed = new JRssFeed(array('id' => $id), 'vikappointments');
128
129 // delay the feed for this user
130 $feed->delay($delay);
131
132 if (wp_doing_ajax())
133 {
134 wp_die();
135 }
136
137 // back to the dashboard
138 $this->setRedirect('admin.php?page=vikappointments');
139 }
140 }
141