Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mahara
mahara
Commits
f064d60e
Commit
f064d60e
authored
Dec 10, 2014
by
Aaron Wells
Committed by
Gerrit Code Review
Dec 10, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge "Tidying up the webservices menu structure (Bug #1396435)"
parents
f9e7fe6c
46f75143
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
80 additions
and
111 deletions
+80
-111
htdocs/auth/lib.php
htdocs/auth/lib.php
+13
-0
htdocs/auth/webservice/lang/en.utf8/auth.webservice.php
htdocs/auth/webservice/lang/en.utf8/auth.webservice.php
+2
-1
htdocs/auth/webservice/lib.php
htdocs/auth/webservice/lib.php
+37
-87
htdocs/lib/web.php
htdocs/lib/web.php
+7
-1
htdocs/theme/raw/auth/webservice/templates/configform.tpl
htdocs/theme/raw/auth/webservice/templates/configform.tpl
+5
-0
htdocs/webservice/admin/index.php
htdocs/webservice/admin/index.php
+8
-12
htdocs/webservice/admin/oauthv1sregister.php
htdocs/webservice/admin/oauthv1sregister.php
+1
-1
htdocs/webservice/admin/webservicelogs.php
htdocs/webservice/admin/webservicelogs.php
+2
-2
htdocs/webservice/apptokens.php
htdocs/webservice/apptokens.php
+3
-2
htdocs/webservice/testclient.php
htdocs/webservice/testclient.php
+2
-5
No files found.
htdocs/auth/lib.php
View file @
f064d60e
...
...
@@ -2485,6 +2485,19 @@ class PluginAuth extends Plugin {
return
true
;
}
/**
* This function returns an array of menu items
* to be displayed
*
* See the function find_menu_children() in lib/web.php
* for a description of the expected array structure.
*
* @return array
*/
public
static
function
menu_items
()
{
return
array
();
}
public
static
function
update_active_flag
(
$event
,
$user
)
{
if
(
!
isset
(
$user
[
'id'
]))
{
log_warn
(
"update_active_flag called without a user id"
);
...
...
htdocs/auth/webservice/lang/en.utf8/auth.webservice.php
View file @
f064d60e
...
...
@@ -14,7 +14,8 @@ defined('INTERNAL') || die();
$string
[
'webservice'
]
=
'Webservice'
;
$string
[
'title'
]
=
'Webservice'
;
$string
[
'description'
]
=
'Webservice only users Authenticated against Mahara\'s database'
;
$string
[
'webservicesconfig'
]
=
'Configuration'
;
$string
[
'webservicesconfigdesc'
]
=
'Here you can set up the varying webservice rules and enable/disable the services.'
;
$string
[
'completeregistration'
]
=
'Complete Registration'
;
$string
[
'emailalreadytaken'
]
=
'This e-mail address has already registered here'
;
$string
[
'iagreetothetermsandconditions'
]
=
'I agree to the Terms and Conditions'
;
...
...
htdocs/auth/webservice/lib.php
View file @
f064d60e
...
...
@@ -18,30 +18,6 @@ set_include_path($path . PATH_SEPARATOR . get_include_path());
require_once
(
get_config
(
'docroot'
)
.
'/webservice/lib.php'
);
require_once
(
get_config
(
'docroot'
)
.
'api/xmlrpc/lib.php'
);
/**
* if the local_right_nav_update doesn't exist, then when can
* inject the app token itme in the menu
*/
if
(
!
function_exists
(
'local_right_nav_update'
))
{
function
local_right_nav_update
(
&
$menu
)
{
$menu
=
(
$menu
?
$menu
:
array
());
foreach
(
$menu
as
$item
)
{
if
(
$item
[
'path'
]
==
'settings/apps'
)
{
return
;
}
}
$menu
[]
=
array
(
'path'
=>
'settings/apps'
,
'url'
=>
'webservice/apptokens.php'
,
'title'
=>
get_string
(
'apptokens'
,
'auth.webservice'
),
'weight'
=>
40
,
'selected'
=>
false
,
'submenu'
=>
array
(),
);
}
}
/**
* The webservice authentication method, which authenticates users against the
* Mahara database, but ensures that these users can only be used for webservices
...
...
@@ -111,70 +87,44 @@ class PluginAuthWebservice extends PluginAuth {
return
array
();
}
public
static
function
menu_items
(
$smarty
=
null
,
$selected
=
null
)
{
global
$SELECTEDSUBNAV
,
$USER
;
$items
=
array
(
'webservice'
=>
array
(
'path'
=>
'webservice'
,
'url'
=>
'webservice/admin/index.php'
,
'title'
=>
get_string
(
'webservices'
,
'auth.webservice'
),
'weight'
=>
10
,
'selected'
=>
false
,
'submenu'
=>
array
(),
),
'webservice/oauthconfig'
=>
array
(
'path'
=>
'webservice/oauthconfig'
,
'url'
=>
'webservice/admin/oauthv1sregister.php'
,
'title'
=>
get_string
(
'oauth'
,
'auth.webservice'
),
'weight'
=>
10
,
'selected'
=>
false
,
'submenu'
=>
array
(),
),
'webservice/logs'
=>
array
(
'path'
=>
'webservice/logs'
,
'url'
=>
'webservice/admin/webservicelogs.php'
,
'title'
=>
get_string
(
'webservicelogs'
,
'auth.webservice'
),
'weight'
=>
20
,
'selected'
=>
false
,
'submenu'
=>
array
(),
),
'webservice/testclient'
=>
array
(
'path'
=>
'webservice/testclient'
,
'url'
=>
'webservice/testclient.php'
,
'title'
=>
get_string
(
'testclient'
,
'auth.webservice'
),
'weight'
=>
30
,
'selected'
=>
false
,
'submenu'
=>
array
(),
),
);
if
(
$USER
->
is_logged_in
()
&&
$smarty
)
{
$SELECTEDSUBNAV
=
(
$SELECTEDSUBNAV
?
$SELECTEDSUBNAV
:
array
());
$items
=
array_merge
(
$SELECTEDSUBNAV
,
$items
);
$apps
=
false
;
$SELECTEDSUBNAV
=
array
();
foreach
(
$items
as
$sub
)
{
$sub
[
'selected'
]
=
(
$selected
==
$sub
[
'path'
]
?
true
:
false
);
$SELECTEDSUBNAV
[]
=
$sub
;
if
(
$sub
[
'path'
]
==
'settings/apps'
)
{
$apps
=
true
;
}
}
if
(
!
$apps
)
{
$SELECTEDSUBNAV
[]
=
array
(
'path'
=>
'settings/apps'
,
'url'
=>
'webservice/apptokens.php'
,
'title'
=>
get_string
(
'apptokens'
,
'auth.webservice'
),
'weight'
=>
40
,
'selected'
=>
(
$selected
==
'settings/apps'
?
true
:
false
),
'submenu'
=>
array
(),
);
}
$smarty
->
assign
(
'SELECTEDSUBNAV'
,
$SELECTEDSUBNAV
);
public
static
function
menu_items
()
{
global
$USER
;
if
(
$USER
->
is_logged_in
())
{
return
array
(
'configextensions/webservices/webservice'
=>
array
(
'path'
=>
'configextensions/webservices/webservice'
,
'parent'
=>
'configextensions/webservices'
,
'url'
=>
'webservice/admin/index.php'
,
'title'
=>
get_string
(
'webservicesconfig'
,
'auth.webservice'
),
'weight'
=>
5
,
),
'configextensions/webservices/oauthconfig'
=>
array
(
'path'
=>
'configextensions/webservices/oauthconfig'
,
'url'
=>
'webservice/admin/oauthv1sregister.php'
,
'title'
=>
get_string
(
'oauth'
,
'auth.webservice'
),
'weight'
=>
10
,
),
'configextensions/webservices/logs'
=>
array
(
'path'
=>
'configextensions/webservices/logs'
,
'url'
=>
'webservice/admin/webservicelogs.php'
,
'title'
=>
get_string
(
'webservicelogs'
,
'auth.webservice'
),
'weight'
=>
20
,
),
'configextensions/webservices/testclient'
=>
array
(
'path'
=>
'configextensions/webservices/testclient'
,
'url'
=>
'webservice/testclient.php'
,
'title'
=>
get_string
(
'testclient'
,
'auth.webservice'
),
'weight'
=>
30
,
),
'configextensions/webservices/apps'
=>
array
(
'path'
=>
'configextensions/webservices/apps'
,
'url'
=>
'webservice/apptokens.php'
,
'title'
=>
get_string
(
'apptokens'
,
'auth.webservice'
),
'weight'
=>
40
,
),
);
}
return
$items
;
}
/*
...
...
htdocs/lib/web.php
View file @
f064d60e
...
...
@@ -2262,6 +2262,12 @@ function admin_nav() {
'title'
=>
get_string
(
'cleanurls'
,
'admin'
),
'weight'
=>
40
,
),
'configextensions/webservices'
=>
array
(
'path'
=>
'configextensions/webservices'
,
'url'
=>
'webservice/admin/index.php'
,
'title'
=>
get_string
(
'webservices'
,
'auth.webservice'
),
'weight'
=>
50
,
),
);
// Add the menu items for skins, if that feature is enabled
...
...
@@ -2669,7 +2675,7 @@ function main_nav() {
$menu
=
array_filter
(
$menu
,
create_function
(
'$a'
,
'return empty($a["ignore"]);'
));
// enable plugins to augment the menu structure
foreach
(
array
(
'artefact'
,
'interaction'
,
'module'
)
as
$plugintype
)
{
foreach
(
array
(
'artefact'
,
'interaction'
,
'module'
,
'auth'
)
as
$plugintype
)
{
if
(
$plugins
=
plugins_installed
(
$plugintype
))
{
foreach
(
$plugins
as
&
$plugin
)
{
if
(
safe_require_plugin
(
$plugintype
,
$plugin
->
name
))
{
...
...
htdocs/theme/raw/auth/webservice/templates/configform.tpl
View file @
f064d60e
{
include
file
=
"header.tpl"
}
<p
class=
"intro"
>
{
$pagedescription
}
</p>
{
foreach
from
=
$form.elements
item
=
element
}
<div
class=
"pseudofieldset collapsible collapsed"
>
<span
class=
"pseudolegend"
><h4
id=
"
{
$element.name
}
_pseudofieldset"
><a
href=
""
>
{
$element.legend
}
</a></h4></span>
...
...
@@ -31,3 +34,5 @@ jQuery(function() {
});
</script>
{
include
file
=
"footer.tpl"
}
htdocs/webservice/admin/index.php
View file @
f064d60e
...
...
@@ -12,7 +12,7 @@
define
(
'INTERNAL'
,
1
);
define
(
'ADMIN'
,
1
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
define
(
'MENUITEM'
,
'configextensions/
pluginadmin
webservices'
);
define
(
'MENUITEM'
,
'configextensions/webservices'
);
$path
=
get_config
(
'docroot'
)
.
'lib/zend'
;
set_include_path
(
$path
.
PATH_SEPARATOR
.
get_include_path
());
...
...
@@ -21,22 +21,18 @@ require_once(get_config('docroot') . 'api/xmlrpc/lib.php');
define
(
'TITLE'
,
get_string
(
'webservices_title'
,
'auth.webservice'
));
require_once
(
'pieforms/pieform.php'
);
safe_require
(
'auth'
,
'webservice'
);
$heading
=
get_string
(
'webservices_title'
,
'auth.webservice'
);
$webservice_menu
=
PluginAuthWebservice
::
menu_items
(
MENUITEM
);
$form
=
get_config_options_extended
();
$smarty
=
smarty
_core
(
);
$smarty
=
smarty
(
array
(),
array
(
'<link rel="stylesheet" type="text/css" href="'
.
$THEME
->
get_url
(
'style/webservice.css'
,
false
,
'auth/webservice'
)
.
'">'
)
);
$smarty
->
assign
(
'form'
,
$form
);
$smarty
->
assign
(
'opened'
,
param_alphanumext
(
'open'
,
''
));
$mainform
=
$smarty
->
fetch
(
'auth:webservice:configform.tpl'
);
unset
(
$smarty
);
$smarty
=
smarty
(
array
(),
array
(
'<link rel="stylesheet" type="text/css" href="'
.
$THEME
->
get_url
(
'style/webservice.css'
,
false
,
'auth/webservice'
)
.
'">'
,));
safe_require
(
'auth'
,
'webservice'
);
PluginAuthWebservice
::
menu_items
(
$smarty
,
'webservice'
);
$smarty
->
assign
(
'form'
,
$mainform
);
$heading
=
get_string
(
'webservices_title'
,
'auth.webservice'
);
$smarty
->
assign
(
'TERTIARYMENU'
,
$webservice_menu
);
$smarty
->
assign
(
'PAGEHEADING'
,
$heading
);
$smarty
->
display
(
'form.tpl'
);
$smarty
->
assign
(
'pagedescription'
,
get_string
(
'webservicesconfigdesc'
,
'auth.webservice'
));
$smarty
->
display
(
'auth:webservice:configform.tpl'
);
/* pieforms callback for activate_webservices for
*/
...
...
htdocs/webservice/admin/oauthv1sregister.php
View file @
f064d60e
...
...
@@ -11,7 +11,7 @@
define
(
'INTERNAL'
,
1
);
define
(
'ADMIN'
,
1
);
define
(
'MENUITEM'
,
'
adminhome/pluginadminwebservices
'
);
define
(
'MENUITEM'
,
'
configextensions/webservices/oauthconfig
'
);
define
(
'SECTION_PAGE'
,
'oauth'
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
define
(
'TITLE'
,
get_string
(
'oauthv1sregister'
,
'auth.webservice'
));
...
...
htdocs/webservice/admin/webservicelogs.php
View file @
f064d60e
...
...
@@ -11,7 +11,7 @@
define
(
'INTERNAL'
,
1
);
define
(
'ADMIN'
,
1
);
define
(
'MENUITEM'
,
'
adminhome/pluginadmin
webservices'
);
define
(
'MENUITEM'
,
'
configextensions/
webservices
/logs
'
);
define
(
'SECTION_PAGE'
,
'webservicelogs'
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
require_once
(
'webservicessearchlib.php'
);
...
...
@@ -47,7 +47,7 @@ else {
$smarty
=
smarty
(
array
(
get_config
(
'wwwroot'
)
.
'webservice/admin/js/usersearch.js'
),
array
(
'<link rel="stylesheet" type="text/css" href="'
.
$THEME
->
get_url
(
'style/webservice.css'
,
false
,
'auth/webservice'
)
.
'">'
,));
safe_require
(
'auth'
,
'webservice'
);
PluginAuthWebservice
::
menu_items
(
$smarty
,
'webservice/logs'
);
$smarty
->
assign
(
'search'
,
$search
);
$smarty
->
assign
(
'alphabet'
,
explode
(
','
,
get_string
(
'alphabet'
)));
$smarty
->
assign
(
'cancel'
,
get_string
(
'cancel'
));
...
...
htdocs/webservice/apptokens.php
View file @
f064d60e
...
...
@@ -21,7 +21,8 @@
*/
define
(
'INTERNAL'
,
1
);
define
(
'MENUITEM'
,
'settings/applications'
);
define
(
'MENUITEM'
,
'configextensions/webservices/apps'
);
define
(
'INADMINMENU'
,
1
);
require
(
dirname
(
dirname
(
__FILE__
))
.
'/init.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/lib.php'
);
...
...
@@ -422,7 +423,7 @@ $form = pieform($form);
$smarty
=
smarty
(
array
(),
array
(
'<link rel="stylesheet" type="text/css" href="'
.
$THEME
->
get_url
(
'style/webservice.css'
,
false
,
'auth/webservice'
)
.
'">'
,));
safe_require
(
'auth'
,
'webservice'
);
PluginAuthWebservice
::
menu_items
(
$smarty
,
'settings/apps'
);
$smarty
->
assign
(
'form'
,
$form
);
$smarty
->
assign
(
'PAGEHEADING'
,
TITLE
);
$smarty
->
display
(
'form.tpl'
);
htdocs/webservice/testclient.php
View file @
f064d60e
...
...
@@ -11,10 +11,7 @@
define
(
'INTERNAL'
,
1
);
define
(
'ADMIN'
,
1
);
// define('MENUITEM', 'webservice/testclient');
define
(
'MENUITEM'
,
'adminhome/pluginadminwebservices'
);
// define('SECTION_PLUGINTYPE', 'core');
// define('SECTION_PLUGINNAME', 'admin');
define
(
'MENUITEM'
,
'configextensions/webservices/testclient'
);
define
(
'SECTION_PAGE'
,
'wstestclient'
);
require
(
dirname
(
dirname
(
__FILE__
))
.
'/init.php'
);
...
...
@@ -173,7 +170,7 @@ $form = pieform(array(
$smarty
=
smarty
(
array
(),
array
(
'<link rel="stylesheet" type="text/css" href="'
.
$THEME
->
get_url
(
'style/webservice.css'
,
false
,
'auth/webservice'
)
.
'">'
,));
safe_require
(
'auth'
,
'webservice'
);
PluginAuthWebservice
::
menu_items
(
$smarty
,
'webservice/testclient'
);
$smarty
->
assign
(
'form'
,
$form
);
$heading
=
get_string
(
'testclient'
,
'auth.webservice'
);
$smarty
->
assign
(
'PAGEHEADING'
,
$heading
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment