Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
ac6b58e3
Commit
ac6b58e3
authored
Oct 25, 2006
by
Nigel McNie
Committed by
Nigel McNie
Oct 25, 2006
Browse files
Merge with
git+ssh://git.catalyst.net.nz/var/git/mahara.git#master
parents
af832de7
c677c018
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/lib.php
0 → 100644
View file @
ac6b58e3
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage core
* @author Your Name <you@example.org>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined
(
'INTERNAL'
)
||
die
();
/**
* Exception - artefact not found
*/
class
ArtefactNotFoundException
extends
Exception
{}
/**
* Exception - trying to get/set a field that doesn't exist
*/
class
UndefinedArtefactFieldException
extends
Exception
{}
/**
* Base artefact plugin class
* @abstract
*/
abstract
class
ArtefactPlugin
{
/**
* This function returns a list of classnames
* of artefact types this plugin provides.
* @return array
*/
public
static
abstract
function
get_artefact_types
();
/**
* This function returns an array of menu items
* to be displayed
* Each item should be a StdClass object containing -
* - name language pack key
* - url relative to wwwroot
* @return array
*/
public
static
function
menu_items
()
{
return
array
();
}
/**
* This function handles an event that has been
* generated, that the plugin has asked to be
* subscribed to
* @param object $event
* @param array $options
* @todo finish documenting the args when we have some egs.
*/
public
static
function
handle_event
(
$event
,
$options
)
{
}
/**
* This function returns an array of crons it wants to have run
* Each item should be a StdtClass object containing -
* - name (will have artefact.$pluginname added for uniqueness)
* - script to hit relative to the documentroot
* NOTE THAT each plugin that implements this should ship with a
* .htaccess that denies access to all cron scripts
*/
public
static
function
get_cron_options
()
{
return
array
();
}
/**
* This function returns an array of events to subscribe to
* by unique name.
* If an event the plugin is trying to subscribe to is unknown by the
* core, an exception will be thrown.
* @return array
*/
public
static
function
get_event_subscriptions
()
{
return
array
();
}
}
/**
* Base artefact type class
* @abstract
*/
abstract
class
ArtefactType
{
private
$_dirty
;
protected
$id
;
protected
$type
;
protected
$container
;
protected
$parentid
;
protected
$ctime
;
protected
$mtime
;
protected
$vtime
;
protected
$locked
;
protected
$title
;
protected
$description
;
protected
$note
;
/**
* Constructer.
* If an id is supplied, will query the database
* to build up the basic information about the object.
* If an id is not supplied, we just create an empty
* artefact, ready to be filled up
* @param int $id artefact.id
*/
public
function
__construct
(
$id
=
0
)
{
if
(
!
empty
(
$id
))
{
if
(
!
$record
=
get_record
(
'artefact'
,
'id'
,
$id
))
{
throw
new
ArtefactNotFoundException
(
"Artefact with id
$id
not found"
);
}
foreach
((
array
)
$record
as
$field
=>
$value
)
{
if
(
property_exists
(
$field
))
{
$this
->
{
$field
}
=
$value
;
}
}
}
else
{
$this
->
ctime
=
time
();
}
}
public
function
get_views_instances
()
{
// @todo
}
public
function
get_views_metadata
()
{
// @todo
}
public
function
get_children_instances
()
{
// @todo
}
public
function
get_children_metadata
()
{
// @todo
}
public
function
get_parent_instance
()
{
// @todo
}
public
function
get_parent_metadata
()
{
// @todo
}
public
function
get
(
$field
)
{
if
(
!
property_exists
(
$field
))
{
throw
new
UndefinedArtefactFieldException
(
"Field
$field
wasn't found in class "
.
get_class
(
$this
));
}
return
$this
->
{
$field
};
}
public
function
set
(
$field
,
$value
)
{
if
(
property_exists
(
$field
))
{
$this
->
{
$field
}
=
$value
;
$this
->
_dirty
=
true
;
return
true
;
}
throw
new
UndefinedArtefactFieldException
(
"Field
$field
wasn't found in class "
.
get_class
(
$this
));
}
public
function
__destruct
()
{
$this
->
commit
();
}
public
function
is_container
()
{
return
false
;
}
public
abstract
function
commit
();
public
abstract
function
delete
();
public
abstract
function
render
(
$format
,
$options
);
public
abstract
function
get_icon
();
// ******************** STATIC FUNCTIONS ******************** //
public
static
function
get_instances_by_userid
(
$userid
,
$order
,
$offset
,
$limit
)
{
// @todo
}
public
static
function
get_metadata_by_userid
(
$userid
,
$order
,
$offset
,
$limit
)
{
// @todo
}
public
static
abstract
function
get_render_list
(
$format
);
public
static
abstract
function
can_render_to
(
$format
);
}
?>
htdocs/lib/db/install.xml
View file @
ac6b58e3
...
...
@@ -54,10 +54,10 @@
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"plugin,field"
COMMENT=
"Primary key for config_artefact"
NEXT=
"pluginfk"
/>
<KEY
NAME=
"pluginfk"
TYPE=
"foreign"
FIELDS=
"plugin"
REFTABLE=
"installed_a
rtefact
"
REFFIELDS=
"name"
PREVIOUS=
"primary"
/>
<KEY
NAME=
"pluginfk"
TYPE=
"foreign"
FIELDS=
"plugin"
REFTABLE=
"installed_a
uth
"
REFFIELDS=
"name"
PREVIOUS=
"primary"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"usr"
COMMENT=
"Basic user information for all system users"
PREVIOUS=
"config_auth"
>
<TABLE
NAME=
"usr"
COMMENT=
"Basic user information for all system users"
PREVIOUS=
"config_auth"
NEXT=
"artefact"
>
<FIELDS>
<FIELD
NAME=
"id"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
UNSIGNED=
"false"
SEQUENCE=
"true"
ENUM=
"false"
NEXT=
"username"
/>
<FIELD
NAME=
"username"
TYPE=
"char"
LENGTH=
"100"
NOTNULL=
"true"
SEQUENCE=
"false"
ENUM=
"false"
PREVIOUS=
"id"
NEXT=
"password"
/>
...
...
@@ -72,6 +72,25 @@
<INDEX
NAME=
"usernameuk"
UNIQUE=
"true"
FIELDS=
"LOWER(username)"
/>
</INDEXES>
</TABLE>
<TABLE
NAME=
"artefact"
COMMENT=
"Basic information common to all artefact plugin instances"
PREVIOUS=
"usr"
>
<FIELDS>
<FIELD
NAME=
"id"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
UNSIGNED=
"false"
SEQUENCE=
"true"
ENUM=
"false"
NEXT=
"type"
/>
<FIELD
NAME=
"type"
TYPE=
"char"
LENGTH=
"255"
NOTNULL=
"true"
ENUM=
"false"
PREVIOUS=
"id"
NEXT=
"container"
/>
<FIELD
NAME=
"container"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"true"
DEFAULT=
"0"
UNSIGNED=
"false"
SEQUENCE=
"false"
ENUM=
"false"
PREVIOUS=
"type"
NEXT=
"parentid"
/>
<FIELD
NAME=
"parentid"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"false"
UNSIGNED=
"false"
SEQUENCE=
"false"
ENUM=
"false"
PREVIOUS=
"container"
NEXT=
"ctime"
/>
<FIELD
NAME=
"ctime"
TYPE=
"datetime"
NOTNULL=
"true"
PREVIOUS=
"parentid"
NEXT=
"mtime"
/>
<FIELD
NAME=
"mtime"
TYPE=
"datetime"
NOTNULL=
"true"
PREVIOUS=
"ctime"
NEXT=
"vtime"
/>
<FIELD
NAME=
"vtime"
TYPE=
"datetime"
NOTNULL=
"true"
PREVIOUS=
"mtime"
NEXT=
"locked"
/>
<FIELD
NAME=
"locked"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"true"
DEFAULT=
"0"
PREVIOUS=
"vtime"
NEXT=
"title"
/>
<FIELD
NAME=
"title"
TYPE=
"text"
NOTNULL=
"true"
PREVIOUS=
"locked"
NEXT=
"description"
/>
<FIELD
NAME=
"description"
TYPE=
"text"
NOTNULL=
"false"
PREVIOUS=
"title"
NEXT=
"note"
/>
<FIELD
NAME=
"note"
TYPE=
"text"
NOTNULL=
"false"
PREVIOUS=
"description"
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"id"
NEXT=
"pluginfk"
/>
<KEY
NAME=
"pluginfk"
TYPE=
"foreign"
FIELDS=
"type"
REFTABLE=
"installed_artefact"
REFFIELDS=
"name"
PREVIOUS=
"primary"
/>
</KEYS>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT
NAME=
"insert config"
TYPE=
"insert"
TABLE=
"config"
COMMENT=
"Initial insert of records on table config"
NEXT=
"insert root user"
>
...
...
Write
Preview
Supports
Markdown
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