diff --git a/locallib.php b/locallib.php index 593faa0e7beace7f6afd8b61d1f1087457337789..d0f3bbea942aa25497084057f6efd404f908eec6 100644 --- a/locallib.php +++ b/locallib.php @@ -435,6 +435,23 @@ function aconnect_get_content_folder($aconnect) { $folderscoid = aconnect_get_user_folder($aconnect, $folderscoid, $username); return $folderscoid; } +// +// DFNVC +// +function aconnect_urlpath_exists($aconnect, $urlpath) { + $folderscoid = false; + $params = array('action' => 'sco-by-url', + 'url-path' => $urlpath, + ); + $aconnect->create_request($params); + + if ($aconnect->call_success()) { + return true; + } + else { + return false; + } +} /** * Log in as the admin user. This should only be used to conduct API calls. diff --git a/mod_form.php b/mod_form.php index e6395171b6b15ad8e22fe3b9b66af35847d58cf7..66de3e92987caafafcc40bba6e6d87039a48a1fd 100644 --- a/mod_form.php +++ b/mod_form.php @@ -20,12 +20,11 @@ class mod_adobeconnect_mod_form extends moodleform_mod { global $COURSE, $CFG; $mform =& $this->_form; -//------------------------------------------------------------------------------- - /// Adding the "general" fieldset, where all the common settings are showed + /// Adding the "general" fieldset, where all the common settings are showed $mform->addElement('header', 'general', get_string('general', 'form')); - /// Adding the standard "name" field + /// Adding the standard "name" field $mform->addElement('text', 'name', get_string('adobeconnectname', 'adobeconnect'), array('size'=>'64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); @@ -35,7 +34,7 @@ class mod_adobeconnect_mod_form extends moodleform_mod { $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); - /// Adding the required "intro" field to hold the description of the instance + /// Adding the required "intro" field to hold the description of the instance $this->add_intro_editor(false, get_string('adobeconnectintro', 'adobeconnect')); // $mform->addElement('htmleditor', 'intro', get_string('adobeconnectintro', 'adobeconnect')); @@ -43,12 +42,11 @@ class mod_adobeconnect_mod_form extends moodleform_mod { // $mform->addRule('intro', get_string('required'), 'required', null, 'client'); // $mform->setHelpButton('intro', array('writing', 'richtext'), false, 'editorhelpbutton'); - /// Adding "introformat" field +/// Adding "introformat" field // $mform->addElement('format', 'introformat', get_string('format')); - //------------------------------------------------------------------------------- - /// Adding the rest of adobeconnect settings, spreeading all them into this fieldset - /// or adding more fieldsets ('header' elements) if needed for better logic +/// Adding the rest of adobeconnect settings, spreeading all them into this fieldset +/// or adding more fieldsets ('header' elements) if needed for better logic $mform->addElement('header', 'adobeconnectfieldset', get_string('adobeconnectfieldset', 'adobeconnect')); @@ -124,9 +122,9 @@ class mod_adobeconnect_mod_form extends moodleform_mod { // Search for a Meeting with the same starting name. It will cause a duplicate // meeting name (and error) when the user begins to add participants to the meeting + // // DFNVC // - // $meetfldscoid = aconnect_get_folder($aconnect, 'meetings'); $meetfldscoid = aconnect_get_meeting_folder($aconnect); // // @@ -136,8 +134,6 @@ class mod_adobeconnect_mod_form extends moodleform_mod { if (empty($namematches)) { $namematches = array(); } - - // Now search for existing meeting room URLs $url = $data['meeturl']; @@ -149,23 +145,14 @@ class mod_adobeconnect_mod_form extends moodleform_mod { $errors['meeturl'] = get_string('invalidadobemeeturl', 'adobeconnect'); } -# $filter = array('filter-like-url-path' => $url); -# DFNVC ERROR !! -# - $filter = array('filter-url-path' => "/$url/"); - $urlmatches = aconnect_meeting_exists($aconnect, $meetfldscoid, $filter); - #$errors['meeturl'] = 'urlmatches:'; - - if (empty($urlmatches)) { $urlmatches = array(); - } else { - + } + else { // format url for comparison if ((false === strpos($url, '/')) or (0 != strpos($url, '/'))) { $url = '/' . $url; } - } // Check URL for correct length and format @@ -177,9 +164,11 @@ class mod_adobeconnect_mod_form extends moodleform_mod { $errors['meeturl'] = get_string('invalidurl', 'adobeconnect'); } - // Adding activity - if (empty($data['update'])) { + if (empty($data['update'])) { + // + // Adding activity + // if ($data['starttime'] == $data['endtime']) { $errors['starttime'] = get_string('samemeettime', 'adobeconnect'); $errors['endtime'] = get_string('samemeettime', 'adobeconnect'); @@ -201,13 +190,10 @@ class mod_adobeconnect_mod_form extends moodleform_mod { } } - foreach($urlmatches as $matchkey => $match) { - $matchurl = rtrim($match->url, '/'); - if ($matchurl == $url) { - $errors['meeturl'] = get_string('duplicateurl', 'adobeconnect'); - } + if (aconnect_urlpath_exists($aconnect, $url)) { + $errors['meeturl'] = get_string('duplicateurl', 'adobeconnect'); } - + } else { // Updating activity // Look for existing meeting names, excluding this activity's group meeting(s) @@ -229,14 +215,10 @@ class mod_adobeconnect_mod_form extends moodleform_mod { } } - foreach($urlmatches as $matchkey => $match) { - if (!array_key_exists($match->scoid, $grpmeetings)) { - if (0 == substr_compare($match->url, $url . '_', 0, strlen($url . '_'), false)) { - $errors['meeturl'] = get_string('duplicateurl', 'adobeconnect'); - } - } + if (aconnect_urlpath_exists($aconnect, $url)) { + $errors['meeturl'] = get_string('duplicateurl', 'adobeconnect'); } - + // Validate start and end times if ($data['starttime'] == $data['endtime']) { $errors['starttime'] = get_string('samemeettime', 'adobeconnect');