Commit 2b635df3538cff1dac3ed5c1f60b88c07f039a1d

Authored by DFNVC
1 parent 8df6df7272
Exists in master

Existierende URL-Pfade müssen systemweit erkannt werden,

damit in Moodle keine leeren Adobe-Connect-Aktivitäten
erstellt werden können.

Showing 2 changed files with 36 additions and 37 deletions Side-by-side Diff

... ... @@ -435,6 +435,23 @@ function aconnect_get_content_folder($aconnect) {
435 435 $folderscoid = aconnect_get_user_folder($aconnect, $folderscoid, $username);
436 436 return $folderscoid;
437 437 }
  438 +//
  439 +// DFNVC
  440 +//
  441 +function aconnect_urlpath_exists($aconnect, $urlpath) {
  442 + $folderscoid = false;
  443 + $params = array('action' => 'sco-by-url',
  444 + 'url-path' => $urlpath,
  445 + );
  446 + $aconnect->create_request($params);
  447 +
  448 + if ($aconnect->call_success()) {
  449 + return true;
  450 + }
  451 + else {
  452 + return false;
  453 + }
  454 +}
438 455  
439 456 /**
440 457 * Log in as the admin user. This should only be used to conduct API calls.
... ... @@ -20,12 +20,11 @@ class mod_adobeconnect_mod_form extends moodleform_mod {
20 20 global $COURSE, $CFG;
21 21 $mform =& $this->_form;
22 22  
23   -//-------------------------------------------------------------------------------
24   - /// Adding the "general" fieldset, where all the common settings are showed
  23 + /// Adding the "general" fieldset, where all the common settings are showed
25 24 $mform->addElement('header', 'general', get_string('general', 'form'));
26 25  
27 26  
28   - /// Adding the standard "name" field
  27 + /// Adding the standard "name" field
29 28 $mform->addElement('text', 'name', get_string('adobeconnectname', 'adobeconnect'), array('size'=>'64'));
30 29 if (!empty($CFG->formatstringstriptags)) {
31 30 $mform->setType('name', PARAM_TEXT);
... ... @@ -35,7 +34,7 @@ class mod_adobeconnect_mod_form extends moodleform_mod {
35 34 $mform->addRule('name', null, 'required', null, 'client');
36 35 $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
37 36  
38   - /// Adding the required "intro" field to hold the description of the instance
  37 + /// Adding the required "intro" field to hold the description of the instance
39 38 $this->add_intro_editor(false, get_string('adobeconnectintro', 'adobeconnect'));
40 39  
41 40 // $mform->addElement('htmleditor', 'intro', get_string('adobeconnectintro', 'adobeconnect'));
... ... @@ -43,12 +42,11 @@ class mod_adobeconnect_mod_form extends moodleform_mod {
43 42 // $mform->addRule('intro', get_string('required'), 'required', null, 'client');
44 43 // $mform->setHelpButton('intro', array('writing', 'richtext'), false, 'editorhelpbutton');
45 44  
46   - /// Adding "introformat" field
  45 +/// Adding "introformat" field
47 46 // $mform->addElement('format', 'introformat', get_string('format'));
48   -
49 47 //-------------------------------------------------------------------------------
50   - /// Adding the rest of adobeconnect settings, spreeading all them into this fieldset
51   - /// or adding more fieldsets ('header' elements) if needed for better logic
  48 +/// Adding the rest of adobeconnect settings, spreeading all them into this fieldset
  49 +/// or adding more fieldsets ('header' elements) if needed for better logic
52 50  
53 51 $mform->addElement('header', 'adobeconnectfieldset', get_string('adobeconnectfieldset', 'adobeconnect'));
54 52  
... ... @@ -124,9 +122,9 @@ class mod_adobeconnect_mod_form extends moodleform_mod {
124 122  
125 123 // Search for a Meeting with the same starting name. It will cause a duplicate
126 124 // meeting name (and error) when the user begins to add participants to the meeting
  125 + //
127 126 // DFNVC
128 127 //
129   - // $meetfldscoid = aconnect_get_folder($aconnect, 'meetings');
130 128 $meetfldscoid = aconnect_get_meeting_folder($aconnect);
131 129 //
132 130 //
... ... @@ -136,8 +134,6 @@ class mod_adobeconnect_mod_form extends moodleform_mod {
136 134 if (empty($namematches)) {
137 135 $namematches = array();
138 136 }
139   -
140   -
141 137  
142 138 // Now search for existing meeting room URLs
143 139 $url = $data['meeturl'];
... ... @@ -149,23 +145,14 @@ class mod_adobeconnect_mod_form extends moodleform_mod {
149 145 $errors['meeturl'] = get_string('invalidadobemeeturl', 'adobeconnect');
150 146 }
151 147  
152   -# $filter = array('filter-like-url-path' => $url);
153   -# DFNVC ERROR !!
154   -#
155   - $filter = array('filter-url-path' => "/$url/");
156   - $urlmatches = aconnect_meeting_exists($aconnect, $meetfldscoid, $filter);
157   - #$errors['meeturl'] = 'urlmatches:';
158   -
159   -
160 148 if (empty($urlmatches)) {
161 149 $urlmatches = array();
162   - } else {
163   -
  150 + }
  151 + else {
164 152 // format url for comparison
165 153 if ((false === strpos($url, '/')) or (0 != strpos($url, '/'))) {
166 154 $url = '/' . $url;
167 155 }
168   -
169 156 }
170 157  
171 158 // Check URL for correct length and format
... ... @@ -177,9 +164,11 @@ class mod_adobeconnect_mod_form extends moodleform_mod {
177 164 $errors['meeturl'] = get_string('invalidurl', 'adobeconnect');
178 165 }
179 166  
180   - // Adding activity
181   - if (empty($data['update'])) {
182 167  
  168 + if (empty($data['update'])) {
  169 + //
  170 + // Adding activity
  171 + //
183 172 if ($data['starttime'] == $data['endtime']) {
184 173 $errors['starttime'] = get_string('samemeettime', 'adobeconnect');
185 174 $errors['endtime'] = get_string('samemeettime', 'adobeconnect');
... ... @@ -201,13 +190,10 @@ class mod_adobeconnect_mod_form extends moodleform_mod {
201 190 }
202 191 }
203 192  
204   - foreach($urlmatches as $matchkey => $match) {
205   - $matchurl = rtrim($match->url, '/');
206   - if ($matchurl == $url) {
207   - $errors['meeturl'] = get_string('duplicateurl', 'adobeconnect');
208   - }
  193 + if (aconnect_urlpath_exists($aconnect, $url)) {
  194 + $errors['meeturl'] = get_string('duplicateurl', 'adobeconnect');
209 195 }
210   -
  196 +
211 197 } else {
212 198 // Updating activity
213 199 // Look for existing meeting names, excluding this activity's group meeting(s)
... ... @@ -229,14 +215,10 @@ class mod_adobeconnect_mod_form extends moodleform_mod {
229 215 }
230 216 }
231 217  
232   - foreach($urlmatches as $matchkey => $match) {
233   - if (!array_key_exists($match->scoid, $grpmeetings)) {
234   - if (0 == substr_compare($match->url, $url . '_', 0, strlen($url . '_'), false)) {
235   - $errors['meeturl'] = get_string('duplicateurl', 'adobeconnect');
236   - }
237   - }
  218 + if (aconnect_urlpath_exists($aconnect, $url)) {
  219 + $errors['meeturl'] = get_string('duplicateurl', 'adobeconnect');
238 220 }
239   -
  221 +
240 222 // Validate start and end times
241 223 if ($data['starttime'] == $data['endtime']) {
242 224 $errors['starttime'] = get_string('samemeettime', 'adobeconnect');