Commit db3af394 by Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1520028: Add portfolio links in TinyMCE link plugin"

parents 258afd85 13fc2089
...@@ -8,21 +8,7 @@ ...@@ -8,21 +8,7 @@
* @copyright For copyright information on Mahara, please see the README file distributed with this software. * @copyright For copyright information on Mahara, please see the README file distributed with this software.
*/ */
/**
* Return the specified request variable from the URL.
* This should be moved to mahara.js to everyone can use it.
*/
function getURLParameter(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return false;
}
function isTinyMceUsed(elementname) { function isTinyMceUsed(elementname) {
return (tinyMCE !== undefined && tinyMCE.get(elementname) !== undefined); return (tinyMCE !== undefined && tinyMCE.get(elementname) !== undefined);
...@@ -38,8 +24,8 @@ function initTinyMCE(formname){ ...@@ -38,8 +24,8 @@ function initTinyMCE(formname){
function modifyAnnotationFeedbackSuccess(form, data) { function modifyAnnotationFeedbackSuccess(form, data) {
var formname = form.name; var formname = form.name;
var limit = getURLParameter('limit'); var limit = getUrlParameter('limit');
var offset = getURLParameter('offset'); var offset = getUrlParameter('offset');
if (limit === false && offset === false) { if (limit === false && offset === false) {
// Pagination is not used. // Pagination is not used.
...@@ -81,8 +67,8 @@ function modifyAnnotationFeedbackSuccess(form, data) { ...@@ -81,8 +67,8 @@ function modifyAnnotationFeedbackSuccess(form, data) {
function addAnnotationFeedbackSuccess(form, data) { function addAnnotationFeedbackSuccess(form, data) {
var formname = form.name; var formname = form.name;
var blockid = jQuery('#' + formname + '_blockid').val(); var blockid = jQuery('#' + formname + '_blockid').val();
var limit = getURLParameter('limit'); var limit = getUrlParameter('limit');
var offset = getURLParameter('offset'); var offset = getUrlParameter('offset');
var tinymce = jQuery('#' + form.id + '_message'); var tinymce = jQuery('#' + form.id + '_message');
if (limit === false && offset === false) { if (limit === false && offset === false) {
......
...@@ -39,6 +39,7 @@ if ($id = param_integer('id', null)) { ...@@ -39,6 +39,7 @@ if ($id = param_integer('id', null)) {
} }
else { else {
define('TITLE', get_string('creategroup', 'group')); define('TITLE', get_string('creategroup', 'group'));
define('CREATEGROUP', true);
if (!group_can_create_groups()) { if (!group_can_create_groups()) {
throw new AccessDeniedException(get_string('accessdenied', 'error')); throw new AccessDeniedException(get_string('accessdenied', 'error'));
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* *
*/ */
// Expects strings array // Expects strings array
function get_string(name) { function get_string(name) {
// Flatten the arguments in case string parameters were passed as an array // Flatten the arguments in case string parameters were passed as an array
......
<?php
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
global $USER;
require_once(get_config('libroot') . 'view.php');
$viewid = param_integer('viewid', null);
$linklist= array();
list($collections, $views) = View::get_views_and_collections( $USER->get('id'));
if (!empty($views) || !empty($collections)) {
foreach ($views as $view) {
if ($viewid != $view['id']) { // dont list the current view
$linklist[] = array(
'title' => $view['name'],
'value' => $view['url'],
);
}
}
foreach ($collections as $collection) {
$collectionitem = array();
if (!isset($collection['views'][$viewid])) { // dont list the collection that contains the current view
$collectionitem['title'] = $collection['name'];
usort($collection['views'], function($a, $b) {return $a['displayorder'] > $b['displayorder'];});
foreach ($collection['views'] as $view) {
if ($viewid != $view['id']) {
$collectionitem['menu'][] = array(
'title' => $view['name'],
'value' => $view['url'],
);
}
}
$linklist[] = $collectionitem;
}
}
}
usort($linklist, function($a, $b) {
return strnatcasecmp($a['title'], $b['title']);
});
json_reply(false, array('data' => json_encode($linklist), 'count' => count($linklist)));
...@@ -6347,7 +6347,8 @@ class View { ...@@ -6347,7 +6347,8 @@ class View {
db_format_tsfield('v.submittedtime', 'submittedtime') . ", v.submittedstatus, db_format_tsfield('v.submittedtime', 'submittedtime') . ", v.submittedstatus,
c.id AS cid, c.name AS cname, c.framework, c.id AS cid, c.name AS cname, c.framework,
c.submittedgroup AS csubmitgroup, c.submittedhost AS csubmithost, " . c.submittedgroup AS csubmitgroup, c.submittedhost AS csubmithost, " .
db_format_tsfield('c.submittedtime', 'csubmittime') . ", c.submittedstatus AS csubmitstatus db_format_tsfield('c.submittedtime', 'csubmittime') . ", c.submittedstatus AS csubmitstatus,
cv.displayorder
FROM {view} v FROM {view} v
LEFT JOIN {collection_view} cv ON v.id = cv.view LEFT JOIN {collection_view} cv ON v.id = cv.view
LEFT JOIN {collection} c ON cv.collection = c.id LEFT JOIN {collection} c ON cv.collection = c.id
...@@ -6403,6 +6404,7 @@ class View { ...@@ -6403,6 +6404,7 @@ class View {
'submittedhost' => $r['submittedhost'], 'submittedhost' => $r['submittedhost'],
'submittedtime' => $r['submittedtime'], 'submittedtime' => $r['submittedtime'],
'submittedstatus' => $r['submittedstatus'], 'submittedstatus' => $r['submittedstatus'],
'displayorder' => $r['displayorder'],
); );
if (isset($r['user'])) { if (isset($r['user'])) {
$v['ownername'] = display_name($r['user']); $v['ownername'] = display_name($r['user']);
......
...@@ -112,6 +112,15 @@ function get_stylesheets_for_current_page($stylesheets, $extraconfig) { ...@@ -112,6 +112,15 @@ function get_stylesheets_for_current_page($stylesheets, $extraconfig) {
return $stylesheets; return $stylesheets;
} }
/**
* True if we are not in admin, institution or admin section
*/
function user_personal_section() {
$usersection = !defined('ADMIN') && !defined('STAFF') && !defined('INSTITUTIONALADMIN') &&
!defined('INSTITUTIONALSTAFF') && !defined('GROUP') && !defined('CREATEGROUP');
return $usersection ? 1 : 0;
}
/** /**
* This function creates a Smarty object and sets it up for use within our * This function creates a Smarty object and sets it up for use within our
...@@ -141,7 +150,7 @@ function get_stylesheets_for_current_page($stylesheets, $extraconfig) { ...@@ -141,7 +150,7 @@ function get_stylesheets_for_current_page($stylesheets, $extraconfig) {
function smarty($javascript = array(), $headers = array(), $pagestrings = array(), $extraconfig = array()) { function smarty($javascript = array(), $headers = array(), $pagestrings = array(), $extraconfig = array()) {
global $USER, $SESSION, $THEME, $HEADDATA, $langselectform, $CFG; global $USER, $SESSION, $THEME, $HEADDATA, $langselectform, $CFG, $viewid;
if (!is_array($headers)) { if (!is_array($headers)) {
$headers = array(); $headers = array();
...@@ -217,6 +226,15 @@ function smarty($javascript = array(), $headers = array(), $pagestrings = array( ...@@ -217,6 +226,15 @@ function smarty($javascript = array(), $headers = array(), $pagestrings = array(
if (is_html_editor_enabled()) { if (is_html_editor_enabled()) {
$checkarray = array(&$javascript, &$headers); $checkarray = array(&$javascript, &$headers);
$found_tinymce = false; $found_tinymce = false;
$tinymceviewid = 'null';
if ($inpersonalarea = user_personal_section()) {
if (defined('SECTION_PAGE') && (SECTION_PAGE == 'view' || SECTION_PAGE == 'blocks' || SECTION_PAGE == 'editlayout')) {
if (isset($viewid) && $viewid > 0) {
$tinymceviewid = $viewid;
}
}
}
foreach ($checkarray as &$check) { foreach ($checkarray as &$check) {
if (($key = array_search('tinymce', $check)) !== false || ($key = array_search('tinytinymce', $check)) !== false) { if (($key = array_search('tinymce', $check)) !== false || ($key = array_search('tinytinymce', $check)) !== false) {
if (!$found_tinymce) { if (!$found_tinymce) {
...@@ -327,6 +345,26 @@ tinyMCE.init({ ...@@ -327,6 +345,26 @@ tinyMCE.init({
remove_script_host: false, remove_script_host: false,
relative_urls: false, relative_urls: false,
target_list: false, target_list: false,
link_list: function(success) {
// Only show the list of links in the normal user section
if ({$inpersonalarea}) {
var params = {
'viewid': {$tinymceviewid}
}
sendjsonrequest(config['wwwroot'] + 'json/tinymceviewlist.json.php', params, 'POST', function(data) {
if (data.count > 0) {
success(JSON.parse(data.data));
}
else {
success(''); // stop showing list with only option being 'none'
}
});
}
else {
success(''); // stop showing list with only option being 'none'
}
},
cache_suffix: '?v={$CFG->cacheversion}', cache_suffix: '?v={$CFG->cacheversion}',
{$extramceconfig} {$extramceconfig}
setup: function(ed) { setup: function(ed) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment