Chococookies has uploaded a new change for review.
https://gerrit.wikimedia.org/r/120361
Change subject: Merges and inits db schema, add special pages.
......................................................................
Merges and inits db schema, add special pages.
Change-Id: I26f4e697bd170bd5a742e4cb7860cf62482bdbb9
---
M OpenBadges.i18n.php
M OpenBadges.php
A OpenBadgesAssertion.sql
A OpenBadgesClass.sql
A OpenBadgesLog.sql
A manage/AddBadge.php
A manage/AddBadge.php~
A manage/BadgeManager.php
A manage/BadgeManager.php~
A manage/ViewBadges.php
A manage/ViewBadges.php~
11 files changed, 372 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenBadges
refs/changes/61/120361/1
diff --git a/OpenBadges.i18n.php b/OpenBadges.i18n.php
index 68829bb..41760b7 100644
--- a/OpenBadges.i18n.php
+++ b/OpenBadges.i18n.php
@@ -5,22 +5,27 @@
* @file
* @ingroup Extensions
*/
+// Use ob- for all OpenBadges related messages.
$messages = array();
/** English
*/
$messages['en'] = array(
- 'openbadges-desc' => 'Extension to implement Mozilla OpenBadges.',
- 'choco-washere' => 'choco was here',
+ 'ob-desc' => 'Extension to implement Mozilla OpenBadges.',
+ 'ob-addbadge-header' => 'Use this page to add new types of badges to
the database.',
+ 'ob-addbadge-submit' => 'Add Badge to Database',
'ob-manager-header' => 'Use this special page to add/edit/modify badge
assignments to users.',
-);
+ 'ob-viewbadges-header' => 'Use this page to view the badges a user
has.',
+);
/** Message documentation (Message documentation)
* @author chococookies
*/
$messages['qqq'] = array(
- 'openbadges-desc' => 'Short description of the openbadges extension.',
- 'choco-washere' => 'To indicate chocos presence (debug string please
ignore)',
+ 'ob-desc' => 'Short description of the openbadges extension.',
+ 'ob-addbadge-header' => 'Describe that the page is to add a new type of
badge.',
+ 'ob-addbadge-submit' => 'Button that adds badge to database',
'ob-manager-header' => 'Describe that this special page is to
add/edit/remove badges.',
+ 'ob-viewbadges-header' => 'Describe that the page is to view the badges
a user has.',
);
diff --git a/OpenBadges.php b/OpenBadges.php
index 6928b15..2587a5f 100644
--- a/OpenBadges.php
+++ b/OpenBadges.php
@@ -2,7 +2,7 @@
/**
* OpenBadges Extension. Based on Mozilla OpenBadges
*
- *
+ *
*
* @file
* @ingroup Extensions
@@ -18,23 +18,40 @@
),
'version' => '0.1',
'url' => 'https://www.mediawiki.org/wiki/OpenBadges',
- 'descriptionmsg' => 'openbadges-desc',
+ 'descriptionmsg' => 'ob-desc',
);
-
/* Setup */
-$dir = dirname( __FILE__ );
+$dir = __DIR__;
// Register files
-$wgAutoloadClasses['BadgeManager'] = $dir . '/manager/BadgeManager.php';
+$wgAutoloadClasses['BadgeManager'] = $dir . '/manage/BadgeManager.php';
+$wgAutoloadClasses['AddBadge'] = $dir . '/manage/AddBadge.php';
+$wgAutoloadClasses['ViewBadges'] = $dir . '/manage/ViewBadges.php';
$wgExtensionMessagesFiles['OpenBadges'] = $dir . '/OpenBadges.i18n.php';
$wgExtensionMessagesFiles['OpenBadgesAlias'] = $dir .
'/OpenBadges.i18n.alias.php';
// Register special pages
$wgSpecialPages['BadgeManager'] = 'BadgeManager';
$wgSpecialPageGroups['BadgeManager'] = 'other';
+$wgSpecialPages['AddBadge'] = 'AddBadge';
+$wgSpecialPageGroups['AddBadge'] = 'other';
+$wgSpecialPages['ViewBadges'] = 'ViewBadges';
+$wgSpecialPageGroups['ViewBadges'] = 'other';
+// Register hooks
+$wgHooks['LoadExtensionSchemaUpdates'][] = 'createTable';
+
+// Function to hook up our tables
+function createTable( DatabaseUpdater $dbU ) {
+ $dbU->addExtensionTable( 'openbadges_assertion', __DIR__ .
+ '/OpenBadgesAssertion.sql', true );
+ $dbU->addExtensionTable( 'openbadges_class', __DIR__ .
+ '/OpenBadgesClass.sql', true );
+ return true;
+}
+
/* Configuration */
diff --git a/OpenBadgesAssertion.sql b/OpenBadgesAssertion.sql
new file mode 100644
index 0000000..13b02a3
--- /dev/null
+++ b/OpenBadgesAssertion.sql
@@ -0,0 +1,17 @@
+--
+-- OpenBadges logging schema
+-- Records relevant information regarding issuing of badges
+--
+
+CREATE TABLE /*_*/openbadges_assertion (
+ obl_id int NOT NULL PRIMARY KEY auto_increment,
-- unique id
+ obl_timestamp binary(14) NOT NULL,
-- timestamp
+ obl_receiver int NOT NULL,
-- user id of the receiver
+ obl_badge_id int NOT NULL REFERENCES openbadges_class(obl_badge_id),
-- url of the badge for the receiver
+ obl_badge_title varchar(255) REFERENCES page(page_title),
-- image of the badge
+ obl_badge_evidence varchar(255) NOT NULL,
-- criteria for receiving the
badge
+ obl_expiration binary(14)
-- expiration
of the badge if any
+)
+
+CREATE INDEX /*i*/obl_timestamp ON /*_*/openbadges_assertion (obl_timestamp);
+CREATE INDEX /*i*/obl_receiver ON /*_*/openbadges_assertion (obl_receiver);
diff --git a/OpenBadgesClass.sql b/OpenBadgesClass.sql
new file mode 100644
index 0000000..fa4c1ce
--- /dev/null
+++ b/OpenBadgesClass.sql
@@ -0,0 +1,14 @@
+--
+-- OpenBadges logging schema
+-- Records relevant information regarding issuing of badges
+--
+
+CREATE TABLE IF NOT EXISTS /*_*/openbadges_class (
+ obl_badge_id int NOT NULL PRIMARY KEY auto_increment,
-- unique id
+ obl_name varchar(64) NOT NULL,
-- name of the achievement
+ obl_description blob NOT NULL,
-- description of the badge
+ obl_badge_image blob NOT NULL,
-- image of the badge
+ obl_criteria varchar(255) NOT NULL,
-- criteria for earning the badge; might be URL
+ obl_issuer int NOT NULL,
-- id of the issuer
+ obl_tags blob NOT NULL
-- list of tags that describe the achievement
+)/*$wgDBTableOptions*/;
diff --git a/OpenBadgesLog.sql b/OpenBadgesLog.sql
new file mode 100644
index 0000000..da275c8
--- /dev/null
+++ b/OpenBadgesLog.sql
@@ -0,0 +1,27 @@
+--
+-- OpenBadges logging schema
+-- Records relevant information regarding issuing of badges
+--
+
+CREATE TABLE /*_*/openbadges_assertion (
+ obl_id int NOT NULL PRIMARY KEY auto_increment,
-- unique id
+ obl_timestamp binary(14) NOT NULL,
-- timestamp
+ obl_receiver int NOT NULL,
-- user id of the receiver
+ obl_badge_id int NOT NULL REFERENCES openbadges_class(obl_badge_id),
-- url of the badge for the receiver
+ obl_badge_title varchar(255) REFERENCES page(page_title),
-- image of the badge
+ obl_badge_evidence varchar(255) NOT NULL,
-- criteria for receiving the
badge
+ obl_expiration binary(14)
-- expiration
of the badge if any
+)
+
+CREATE TABLE IF NOT EXISTS /*_*/openbadges_class (
+ obl_badge_id int NOT NULL PRIMARY KEY auto_increment,
-- unique id
+ obl_name varchar(64) NOT NULL,
-- name of the achievement
+ obl_description blob NOT NULL,
-- description of the badge
+ obl_badge_image blob NOT NULL,
-- image of the badge
+ obl_criteria varchar(255) NOT NULL,
-- criteria for earning the badge; might be URL
+ obl_issuer int NOT NULL,
-- id of the issuer
+ obl_tags blob NOT NULL
-- list of tags that describe the achievement
+)/*$wgDBTableOptions*/;
+
+CREATE INDEX /*i*/obl_timestamp ON /*_*/openbadges_assertion (obl_timestamp);
+CREATE INDEX /*i*/obl_receiver ON /*_*/openbadges_assertion (obl_receiver);
\ No newline at end of file
diff --git a/manage/AddBadge.php b/manage/AddBadge.php
new file mode 100644
index 0000000..f837abf
--- /dev/null
+++ b/manage/AddBadge.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * OpenBadges special page to add new badge types to the database.
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+class AddBadge extends SpecialPage {
+ public function __construct() {
+ parent::__construct( 'AddBadge' );
+ }
+
+ /**
+ * Shows the page to the user.
+ * @param string $sub: The subpage string argument (if any).
+ * [[Special:BadgeManager/subpage]].
+ */
+ public function execute( $sub ) {
+ $out = $this->getOutput();
+ $out->setPageTitle( $this->msg( 'AddBadge' ) );
+ $out->addWikiMsg( 'ob-addbadge-header' );
+ $formFields = array(
+ 'userfield' => array('label' => 'Name of Badge
to Add',
+ 'class' => 'HTMLTextField',
+ 'required' => true,
+ ),
+ 'badgefield' => array('label' => 'More badge
info',
+ 'class' => 'HTMLTextField',
+ 'required' => true,
+ ),
+ );
+ $htmlForm = new HTMLForm($formFields, $this->getContext() );
+ $htmlForm->setSubmitText( 'Add Badge to Database');
+ $htmlForm->setSubmitCallback( array( 'AddBadge',
'addBadgeType'));
+ $htmlForm->show();
+
+ }
+
+ # TODO: Load Database table, then:
+ # TODO: Add DB logic to add a new badge to the database
+ static function addBadgeType( $formInput ) {
+ #return false to redisplay the form, not sure how to 'refresh'
the page
+ return false;
+ }
+
+
+}
diff --git a/manage/AddBadge.php~ b/manage/AddBadge.php~
new file mode 100644
index 0000000..ae1a733
--- /dev/null
+++ b/manage/AddBadge.php~
@@ -0,0 +1,48 @@
+<?php
+/**
+ * OpenBadges special page to add new badge types to the database.
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+class AddBadge extends SpecialPage {
+ public function __construct() {
+ parent::__construct( 'AddBadge' );
+ }
+
+ /**
+ * Shows the page to the user.
+ * @param string $sub: The subpage string argument (if any).
+ * [[Special:BadgeManager/subpage]].
+ */
+ public function execute( $sub ) {
+ $out = $this->getOutput();
+ $out->setPageTitle( $this->msg( 'AddBadge' ) );
+ $out->addWikiMsg( 'ob-addbadge-header' );
+ $formFields = array(
+ 'userfield' => array('label' => 'Name of Badge
to Add',
+ 'class' => 'HTMLTextField',
+ 'required' => true,
+ ),
+ 'badgefield' => array('label' => 'More badge
info',
+ 'class' => 'HTMLTextField',
+ 'required' => true,
+ ),
+ );
+ $htmlForm = new HTMLForm($formFields, $this->getContext() );
+ $htmlForm->setSubmitText( 'Add Badge to Database');
+ $htmlForm->setSubmitCallback( array( 'AddBadge',
'addBadgeType'));
+ $htmlForm->show();
+
+ }
+
+ # TODO: Load Database table, then:
+ # TODO: Add DB logic to give a new badge to a new user.
+ static function addBadgeType( $formInput ) {
+ #return false to redisplay the form, not sure how to 'refresh'
the page
+ return false;
+ }
+
+
+}
diff --git a/manage/BadgeManager.php b/manage/BadgeManager.php
new file mode 100644
index 0000000..81cccb2
--- /dev/null
+++ b/manage/BadgeManager.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * OpenBadges special page to assign new badges to users
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+class BadgeManager extends SpecialPage {
+ public function __construct() {
+ parent::__construct( 'BadgeManager' );
+ }
+
+ /**
+ * Shows the page to the user.
+ * @param string $sub: The subpage string argument (if any).
+ * [[Special:BadgeManager/subpage]].
+ */
+ public function execute( $sub ) {
+ $out = $this->getOutput();
+ $out->setPageTitle( $this->msg( 'BadgeManager' ) );
+ $out->addWikiMsg( 'ob-manager-header' );
+ $formFields = array(
+ 'userfield' => array('label' => 'Username to
Add',
+ 'class' => 'HTMLTextField',
+ 'required' => true,
+ ),
+ 'badgefield' => array('label' => 'Name/Type of
badge',
+ 'class' => 'HTMLTextField',
+ 'required' => true,
+ ),
+ );
+ $htmlForm = new HTMLForm($formFields, $this->getContext() );
+ $htmlForm->setSubmitText( 'Award Badge to User');
+ $htmlForm->setSubmitCallback( array( 'BadgeManager',
'addBadge'));
+ $htmlForm->show();
+
+ }
+
+ # TODO: Load Database table, then:
+ # TODO: Add DB logic to give a new badge to a new user.
+ static function addBadge( $formInput ) {
+ #return false to redisplay the form, not sure how to 'refresh'
the page
+ return false;
+ }
+
+
+}
diff --git a/manage/BadgeManager.php~ b/manage/BadgeManager.php~
new file mode 100644
index 0000000..cc3e3bc
--- /dev/null
+++ b/manage/BadgeManager.php~
@@ -0,0 +1,52 @@
+<?php
+/**
+ * OpenBadges special page to assign new badges to users
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+class BadgeManager extends SpecialPage {
+ public function __construct() {
+ parent::__construct( 'BadgeManager' );
+ }
+
+ /**
+ * Shows the page to the user.
+ * @param string $sub: The subpage string argument (if any).
+ * [[Special:BadgeManager/subpage]].
+ */
+ public function execute( $sub ) {
+ $out = $this->getOutput();
+ $out->setPageTitle( $this->msg( 'BadgeManager' ) );
+ $out->addWikiMsg( 'ob-manager-header' );
+ $formFields = array(
+ 'userfield' => array('label' => 'Username to
Add',
+ 'class' => 'HTMLTextField',
+ 'required' => true,
+ ),
+ 'badgefield' => array('label' => 'Name/Type of
badge',
+ 'class' => 'HTMLTextField',
+ 'required' => true,
+ ),
+ );
+ $htmlForm = new HTMLForm($formFields, $this->getContext() );
+ $htmlForm->setSubmitText( 'Award Badge to User');
+ $htmlForm->setSubmitCallback( array( 'BadgeManager',
'addBadge'));
+ $htmlForm->show();
+
+ }
+
+ # TODO: Load Database table, then:
+ # TODO: Add DB logic to give a new badge to a new user.
+ static function addBadge( $formInput ) {
+ #return false to redisplay the form, not sure how to 'refresh'
the page
+ return false;
+ }
+
+ # TODO: Add DB logic to add a new type of badge to the database.
+ static function addBadgeType( $formInput ) {
+ return false;
+ }
+
+}
diff --git a/manage/ViewBadges.php b/manage/ViewBadges.php
new file mode 100644
index 0000000..39e9dc0
--- /dev/null
+++ b/manage/ViewBadges.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * OpenBadges special page to view all the badges assigned to a user.
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+class ViewBadges extends SpecialPage {
+ public function __construct() {
+ parent::__construct( 'ViewBadges' );
+ }
+
+ /**
+ * Shows the page to the user.
+ * @param string $sub: The subpage string argument (if any).
+ * [[Special:BadgeManager/subpage]].
+ */
+ public function execute( $sub ) {
+ $out = $this->getOutput();
+ $out->setPageTitle( $this->msg( 'ViewBadges' ) );
+ $out->addWikiMsg( 'ob-viewbadges-header' );
+ $formFields = array(
+ 'userfield' => array('label' => 'Username',
+ 'class' => 'HTMLTextField',
+ 'required' => true,),
+ );
+ $htmlForm = new HTMLForm($formFields, $this->getContext() );
+ $htmlForm->setSubmitText( 'Display Badges');
+ $htmlForm->setSubmitCallback( array( 'ViewBadges',
'viewBadges'));
+ $htmlForm->show();
+
+ }
+
+ # TODO: Load Database table, then:
+ # TODO: Display all the badges a user has.
+ static function viewBadges( $formInput ) {
+ #return false to redisplay the form, not sure how to 'refresh'
the page
+ return false;
+ }
+
+
+}
diff --git a/manage/ViewBadges.php~ b/manage/ViewBadges.php~
new file mode 100644
index 0000000..39e9dc0
--- /dev/null
+++ b/manage/ViewBadges.php~
@@ -0,0 +1,43 @@
+<?php
+/**
+ * OpenBadges special page to view all the badges assigned to a user.
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+class ViewBadges extends SpecialPage {
+ public function __construct() {
+ parent::__construct( 'ViewBadges' );
+ }
+
+ /**
+ * Shows the page to the user.
+ * @param string $sub: The subpage string argument (if any).
+ * [[Special:BadgeManager/subpage]].
+ */
+ public function execute( $sub ) {
+ $out = $this->getOutput();
+ $out->setPageTitle( $this->msg( 'ViewBadges' ) );
+ $out->addWikiMsg( 'ob-viewbadges-header' );
+ $formFields = array(
+ 'userfield' => array('label' => 'Username',
+ 'class' => 'HTMLTextField',
+ 'required' => true,),
+ );
+ $htmlForm = new HTMLForm($formFields, $this->getContext() );
+ $htmlForm->setSubmitText( 'Display Badges');
+ $htmlForm->setSubmitCallback( array( 'ViewBadges',
'viewBadges'));
+ $htmlForm->show();
+
+ }
+
+ # TODO: Load Database table, then:
+ # TODO: Display all the badges a user has.
+ static function viewBadges( $formInput ) {
+ #return false to redisplay the form, not sure how to 'refresh'
the page
+ return false;
+ }
+
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/120361
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I26f4e697bd170bd5a742e4cb7860cf62482bdbb9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OpenBadges
Gerrit-Branch: master
Gerrit-Owner: Chococookies <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits