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
ada7221a
Commit
ada7221a
authored
Aug 25, 2008
by
Richard Mansfield
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark views as automatically created for new users/groups
parent
12d46d3e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
133 additions
and
42 deletions
+133
-42
htdocs/lang/en.utf8/view.php
htdocs/lang/en.utf8/view.php
+6
-0
htdocs/lib/db/install.xml
htdocs/lib/db/install.xml
+12
-0
htdocs/lib/db/upgrade.php
htdocs/lib/db/upgrade.php
+8
-0
htdocs/lib/version.php
htdocs/lib/version.php
+1
-1
htdocs/lib/view.php
htdocs/lib/view.php
+15
-0
htdocs/view/access.php
htdocs/view/access.php
+91
-41
No files found.
htdocs/lang/en.utf8/view.php
View file @
ada7221a
...
...
@@ -247,5 +247,11 @@ $string['copythisview'] = 'Copy this View';
$string
[
'createemptyview'
]
=
'Create Empty View'
;
$string
[
'copyaview'
]
=
'Copy a View'
;
$string
[
'Untitled'
]
=
'Untitled'
;
$string
[
'copyfornewusers'
]
=
'Copy for new users'
;
$string
[
'copyfornewusersdescription'
]
=
'Whenever a new user is created, automatically make a personal copy of this View in the user\'s portfolio.'
;
$string
[
'copyfornewmembers'
]
=
'Copy for new institution members'
;
$string
[
'copyfornewmembersdescription'
]
=
'Automatically make a personal copy of this View for all new members of %s.'
;
$string
[
'copyfornewgroups'
]
=
'Copy for new groups'
;
$string
[
'copyfornewgroupsdescription'
]
=
'Make a copy of this view in all new groups with these Group Types:'
;
?>
htdocs/lib/db/install.xml
View file @
ada7221a
...
...
@@ -510,6 +510,7 @@
<FIELD
NAME=
"numcolumns"
TYPE=
"int"
LENGTH=
"2"
NOTNULL=
"true"
/>
<FIELD
NAME=
"layout"
TYPE=
"int"
LENGTH=
"10"
/>
<FIELD
NAME=
"template"
TYPE=
"int"
LENGTH=
"1"
DEFAULT=
"0"
NOTNULL=
"true"
/>
<FIELD
NAME=
"copynewuser"
TYPE=
"int"
LENGTH=
"1"
DEFAULT=
"0"
NOTNULL=
"true"
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"id"
/>
...
...
@@ -530,6 +531,17 @@
<KEY
NAME=
"viewfk"
TYPE=
"foreign"
FIELDS=
"view"
REFTABLE=
"view"
REFFIELDS=
"id"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"view_autocreate_grouptype"
>
<FIELDS>
<FIELD
NAME=
"view"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
/>
<FIELD
NAME=
"grouptype"
TYPE=
"char"
LENGTH=
"20"
NOTNULL=
"true"
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"view,grouptype"
/>
<KEY
NAME=
"viewfk"
TYPE=
"foreign"
FIELDS=
"view"
REFTABLE=
"view"
REFFIELDS=
"id"
/>
<KEY
NAME=
"grouptypefk"
TYPE=
"foreign"
FIELDS=
"grouptype"
REFTABLE=
"grouptype"
REFFIELDS=
"name"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"block_instance"
>
<FIELDS>
<FIELD
NAME=
"id"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
SEQUENCE=
"true"
/>
...
...
htdocs/lib/db/upgrade.php
View file @
ada7221a
...
...
@@ -1228,6 +1228,14 @@ function xmldb_core_upgrade($oldversion=0) {
execute_sql
(
"ALTER TABLE
{
view
}
ADD COLUMN template SMALLINT NOT NULL DEFAULT 0;"
);
}
if
(
$oldversion
<
2008081102
)
{
execute_sql
(
"ALTER TABLE
{
view
}
ADD COLUMN copynewuser SMALLINT NOT NULL DEFAULT 0;"
);
execute_sql
(
'CREATE TABLE {view_autocreate_grouptype} (
view INTEGER NOT NULL REFERENCES {view}(id),
grouptype VARCHAR(20) NOT NULL REFERENCES {grouptype}(name)
);'
);
}
return
$status
;
}
...
...
htdocs/lib/version.php
View file @
ada7221a
...
...
@@ -27,7 +27,7 @@
defined
(
'INTERNAL'
)
||
die
();
$config
=
new
StdClass
;
$config
->
version
=
200808110
1
;
$config
->
version
=
200808110
2
;
$config
->
release
=
'1.1.0alpha'
;
$config
->
minupgradefrom
=
2007080700
;
$config
->
minupgraderelease
=
'0.8.0 (release tag 0.8.0_RELEASE)'
;
...
...
htdocs/lib/view.php
View file @
ada7221a
...
...
@@ -56,6 +56,8 @@ class View {
private
$tags
;
private
$editingroles
;
private
$template
;
private
$copynewuser
;
private
$copynewgroups
;
public
function
__construct
(
$id
=
0
,
$data
=
null
)
{
if
(
!
empty
(
$id
))
{
...
...
@@ -170,6 +172,13 @@ class View {
insert_record
(
'view_tag'
,
(
object
)
array
(
'view'
=>
$this
->
get
(
'id'
),
'tag'
=>
$tag
));
}
if
(
isset
(
$this
->
copynewgroups
))
{
delete_records
(
'view_autocreate_grouptype'
,
'view'
,
$this
->
get
(
'id'
));
foreach
(
$this
->
copynewgroups
as
$grouptype
)
{
insert_record
(
'view_autocreate_grouptype'
,
(
object
)
array
(
'view'
=>
$this
->
get
(
'id'
),
'grouptype'
=>
$grouptype
));
}
}
db_commit
();
$this
->
dirty
=
false
;
...
...
@@ -387,6 +396,12 @@ class View {
db_commit
();
}
public
function
get_autocreate_grouptypes
()
{
if
(
!
isset
(
$this
->
copynewgroups
))
{
$this
->
copynewgroups
=
get_column
(
'view_autocreate_grouptype'
,
'grouptype'
,
'view'
,
$this
->
id
);
}
return
$this
->
copynewgroups
;
}
public
function
release
(
$groupid
,
$releaseuser
=
null
)
{
if
(
$this
->
get
(
'submittedto'
)
!=
$groupid
)
{
...
...
htdocs/view/access.php
View file @
ada7221a
...
...
@@ -32,8 +32,8 @@ define('SECTION_PAGE', 'editaccess');
require
(
dirname
(
dirname
(
__FILE__
))
.
'/init.php'
);
require_once
(
'pieforms/pieform.php'
);
require_once
(
'pieforms/pieform/elements/calendar.php'
);
require_once
(
get_config
(
'
doc
root'
)
.
'
lib/
view.php'
);
require_once
(
get_config
(
'
doc
root'
)
.
'
lib/
group.php'
);
require_once
(
get_config
(
'
lib
root'
)
.
'view.php'
);
require_once
(
get_config
(
'
lib
root'
)
.
'group.php'
);
$view
=
new
View
(
param_integer
(
'id'
));
$group
=
$view
->
get
(
'group'
);
...
...
@@ -91,48 +91,87 @@ $form = array(
'description'
=>
get_string
(
'templatedescription'
,
'view'
),
'defaultvalue'
=>
$view
->
get
(
'template'
),
),
'accesslist'
=>
array
(
'type'
=>
'viewacl'
,
'defaultvalue'
=>
isset
(
$view
)
?
$view
->
get_access
()
:
null
)
);
if
(
$institution
)
{
if
(
$institution
==
'mahara'
)
{
$form
[
'elements'
][
'copynewuser'
]
=
array
(
'type'
=>
'checkbox'
,
'title'
=>
get_string
(
'copyfornewusers'
,
'view'
),
'description'
=>
get_string
(
'copyfornewusersdescription'
,
'view'
),
'defaultvalue'
=>
$view
->
get
(
'copynewuser'
),
);
$form
[
'elements'
][
'copyfornewgroups'
]
=
array
(
'type'
=>
'html'
,
'value'
=>
'<label>'
.
get_string
(
'copyfornewgroups'
,
'view'
)
.
'</label>'
,
);
$form
[
'elements'
][
'copyfornewgroupsdescription'
]
=
array
(
'type'
=>
'html'
,
'value'
=>
'<div class="description">'
.
get_string
(
'copyfornewgroupsdescription'
,
'view'
)
.
'</div>'
,
);
$createfor
=
$view
->
get_autocreate_grouptypes
();
foreach
(
group_get_grouptypes
()
as
$grouptype
)
{
safe_require
(
'grouptype'
,
$grouptype
);
$form
[
'elements'
][
'copyfornewgroups_'
.
$grouptype
]
=
array
(
'type'
=>
'checkbox'
,
'title'
=>
get_string
(
'name'
,
'grouptype.'
.
$grouptype
),
'defaultvalue'
=>
in_array
(
$grouptype
,
$createfor
),
);
}
}
else
{
$form
[
'elements'
][
'copynewuser'
]
=
array
(
'type'
=>
'checkbox'
,
'title'
=>
get_string
(
'copyfornewmembers'
,
'view'
),
'description'
=>
get_string
(
'copyfornewmembersdescription'
,
'view'
,
get_field
(
'institution'
,
'displayname'
,
'name'
,
$institution
)),
'defaultvalue'
=>
$view
->
get
(
'copynewuser'
),
);
}
}
$form
[
'elements'
][
'accesslist'
]
=
array
(
'type'
=>
'viewacl'
,
'defaultvalue'
=>
isset
(
$view
)
?
$view
->
get_access
()
:
null
);
$form
[
'elements'
][
'overrides'
]
=
array
(
'type'
=>
'fieldset'
,
'legend'
=>
get_string
(
'overridingstartstopdate'
,
'view'
),
'elements'
=>
array
(
'description'
=>
array
(
'type'
=>
'html'
,
'value'
=>
get_string
(
'overridingstartstopdatesdescription'
,
'view'
),
),
'overrides'
=>
array
(
'type'
=>
'fieldset'
,
'legend'
=>
get_string
(
'overridingstartstopdate'
,
'view'
),
'elements'
=>
array
(
'description'
=>
array
(
'type'
=>
'html'
,
'value'
=>
get_string
(
'overridingstartstopdatesdescription'
,
'view'
),
),
'startdate'
=>
array
(
'type'
=>
'calendar'
,
'title'
=>
get_string
(
'startdate'
,
'view'
),
'defaultvalue'
=>
isset
(
$view
)
?
strtotime
(
$view
->
get
(
'startdate'
))
:
null
,
'caloptions'
=>
array
(
'showsTime'
=>
true
,
'ifFormat'
=>
'%Y/%m/%d %H:%M'
),
'help'
=>
true
,
),
'stopdate'
=>
array
(
'type'
=>
'calendar'
,
'title'
=>
get_string
(
'stopdate'
,
'view'
),
'defaultvalue'
=>
isset
(
$view
)
?
strtotime
(
$view
->
get
(
'stopdate'
))
:
null
,
'caloptions'
=>
array
(
'showsTime'
=>
true
,
'ifFormat'
=>
'%Y/%m/%d %H:%M'
),
'help'
=>
true
,
),
'startdate'
=>
array
(
'type'
=>
'calendar'
,
'title'
=>
get_string
(
'startdate'
,
'view'
),
'defaultvalue'
=>
isset
(
$view
)
?
strtotime
(
$view
->
get
(
'startdate'
))
:
null
,
'caloptions'
=>
array
(
'showsTime'
=>
true
,
'ifFormat'
=>
'%Y/%m/%d %H:%M'
),
'help'
=>
true
,
),
'submit'
=>
array
(
'type'
=>
!
empty
(
$new
)
?
'cancelbackcreate'
:
'submitcancel'
,
'value'
=>
!
empty
(
$new
)
?
array
(
get_string
(
'cancel'
),
get_string
(
'back'
,
'view'
),
get_string
(
'save'
))
:
array
(
get_string
(
'save'
),
get_string
(
'cancel'
)),
'confirm'
=>
!
empty
(
$new
)
?
array
(
get_string
(
'confirmcancelcreatingview'
,
'view'
),
null
,
null
)
:
null
,
'stopdate'
=>
array
(
'type'
=>
'calendar'
,
'title'
=>
get_string
(
'stopdate'
,
'view'
),
'defaultvalue'
=>
isset
(
$view
)
?
strtotime
(
$view
->
get
(
'stopdate'
))
:
null
,
'caloptions'
=>
array
(
'showsTime'
=>
true
,
'ifFormat'
=>
'%Y/%m/%d %H:%M'
),
'help'
=>
true
,
),
)
),
);
$form
[
'elements'
][
'submit'
]
=
array
(
'type'
=>
!
empty
(
$new
)
?
'cancelbackcreate'
:
'submitcancel'
,
'value'
=>
!
empty
(
$new
)
?
array
(
get_string
(
'cancel'
),
get_string
(
'back'
,
'view'
),
get_string
(
'save'
))
:
array
(
get_string
(
'save'
),
get_string
(
'cancel'
)),
'confirm'
=>
!
empty
(
$new
)
?
array
(
get_string
(
'confirmcancelcreatingview'
,
'view'
),
null
,
null
)
:
null
,
);
function
editaccess_validate
(
Pieform
$form
,
$values
)
{
...
...
@@ -150,7 +189,7 @@ function editaccess_cancel_submit() {
redirect
(
'/view/groupviews.php?group='
.
$group
);
}
if
(
$institution
)
{
redirect
(
'/view/institutionviews.php?
group
='
.
$institution
);
redirect
(
'/view/institutionviews.php?
institution
='
.
$institution
);
}
redirect
(
'/view'
);
}
...
...
@@ -168,6 +207,17 @@ function editaccess_submit(Pieform $form, $values) {
$view
->
set
(
'startdate'
,
$values
[
'startdate'
]);
$view
->
set
(
'stopdate'
,
$values
[
'stopdate'
]);
$view
->
set
(
'template'
,
(
int
)
$values
[
'template'
]);
$view
->
set
(
'copynewuser'
,
(
int
)
$values
[
'copynewuser'
]);
if
(
$institution
==
'mahara'
)
{
$createfor
=
array
();
foreach
(
group_get_grouptypes
()
as
$grouptype
)
{
if
(
$values
[
'copyfornewgroups_'
.
$grouptype
])
{
$createfor
[]
=
$grouptype
;
}
}
$view
->
set
(
'copynewgroups'
,
$createfor
);
}
$view
->
commit
();
if
(
$values
[
'new'
])
{
...
...
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