Commit 65120071 authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review
Browse files

Getting rid of the placeholder "Social" artefact plugin

Bug 1259538: We created a new artefact plugin called "social" to hold
three of the profile completion tasks. But I think this is too much
overhead just for that, so I'm folding them into the "internal" and
"comment" plugins.

(In the long run, we should probably make it possible for *any* plugin
type to add progress bar tasks, and then add these as local plugins or
something.)

Change-Id: I7d129069325f45409be0c73dedd6ddcc3db17489
parent bee8db63
......@@ -59,6 +59,10 @@ $string['moderatecomments'] = 'Moderate comments';
$string['moderatecommentsdescription'] = 'Comments will remain private until they are approved by you.';
$string['newfeedbacknotificationsubject'] = 'New feedback on %s';
$string['placefeedback'] = 'Place feedback';
$string['progress_feedback'] = array(
'Comment on another user\'s page',
'Comment on %s other users\' pages',
);
$string['rating'] = 'Rating';
$string['reallydeletethiscomment'] = 'Are you sure you want to delete this comment?';
$string['thiscommentisprivate'] = 'This comment is private';
......
......@@ -125,8 +125,45 @@ class PluginArtefactComment extends PluginArtefact {
PluginNotificationInternal::clean_notifications(array('feedback'));
}
public static function has_progressbar_options() {
return false;
public static function progressbar_link($artefacttype) {
switch ($artefacttype) {
case 'feedback':
return 'view/sharedviews.php';
break;
}
}
public static function progressbar_additional_items() {
return array(
(object)array(
'name' => 'feedback',
'title' => get_string('placefeedback', 'artefact.comment'),
'plugin' => 'comment',
'active' => true,
'iscountable' => true,
'is_metaartefact' => true,
)
);
}
public static function progressbar_metaartefact_count($name) {
global $USER;
$meta = new stdClass();
$meta->artefacttype = $name;
$meta->completed = 0;
switch ($name) {
case 'feedback':
$sql = "SELECT COUNT(*) AS completed
FROM {artefact}
WHERE artefacttype='comment'
AND owner <> ? AND author = ?";
$count = get_records_sql_array($sql, array($USER->get('id'), $USER->get('id')));
$meta->completed = $count[0]->completed;
break;
default:
return false;
}
return $meta;
}
}
......@@ -152,6 +189,10 @@ class ArtefactTypeComment extends ArtefactType {
}
}
public static function is_allowed_in_progressbar() {
return false;
}
/**
* For comments, the artefact.mtime property is displayed to users, as the "Update on" date,
......
......@@ -130,6 +130,9 @@ $string['html'] = 'Note';
$string['duplicatedprofilefieldvalue'] = 'Duplicated value';
$string['existingprofilefieldvalues'] = 'Existing values';
$string['progressbaritem_messaging'] = 'Messaging';
$string['progressbaritem_joingroup'] = 'Join a group';
$string['progressbaritem_makefriend'] = 'Make a friend';
$string['progress_firstname'] = 'Add your first name';
$string['progress_lastname'] = 'Add your last name';
$string['progress_studentid'] = 'Add your student ID';
......@@ -149,4 +152,12 @@ $string['progress_mobilenumber'] = 'Add your mobile phone';
$string['progress_faxnumber'] = 'Add your fax number';
$string['progress_messaging'] = 'Add messaging information';
$string['progress_occupation'] = 'Add your occupation';
$string['progress_industry'] = 'Add your industry';
\ No newline at end of file
$string['progress_industry'] = 'Add your industry';
$string['progress_joingroup'] = array(
'Join a group',
'Join %s groups',
);
$string['progress_makefriend'] = array(
'Make a friend',
'Make %s friends',
);
\ No newline at end of file
......@@ -281,19 +281,32 @@ class PluginArtefactInternal extends PluginArtefact {
}
public static function progressbar_additional_items() {
$specials = array('messaging');
$records = false;
foreach ($specials as $special) {
$record = new StdClass();
$record->name = $special;
$record->title = get_string($special, 'artefact.internal');
$record->plugin = 'internal';
$record->active = true;
$record->iscountable = false;
$record->is_metaartefact = true;
$records[] = $record;
}
return $records;
return array(
(object)array(
'name' => 'messaging',
'title' => get_string('progressbaritem_messaging', 'artefact.internal'),
'plugin' => 'internal',
'active' => true,
'iscountable' => false,
'is_metaartefact' => true,
),
(object)array(
'name' => 'joingroup',
'title' => get_string('progressbaritem_joingroup', 'artefact.internal'),
'plugin' => 'internal',
'active' => true,
'iscountable' => true,
'is_metaartefact' => true,
),
(object)array(
'name' => 'makefriend',
'title' => get_string('progressbaritem_makefriend', 'artefact.internal'),
'plugin' => 'internal',
'active' => true,
'iscountable' => true,
'is_metaartefact' => true,
)
);
}
public static function progressbar_metaartefact_count($name) {
......@@ -313,6 +326,20 @@ class PluginArtefactInternal extends PluginArtefact {
$count = get_records_sql_array($sql, array($USER->get('id')));
$meta->completed = $count[0]->completed;
break;
case 'joingroup':
$sql = "SELECT COUNT(*) AS completed
FROM {group_member}
WHERE member = ?";
$count = get_records_sql_array($sql, array($USER->get('id')));
$meta->completed = $count[0]->completed;
break;
case 'makefriend':
$sql = "SELECT COUNT(*) AS completed
FROM {usr_friend}
WHERE usr1 = ?";
$count = get_records_sql_array($sql, array($USER->get('id')));
$meta->completed = $count[0]->completed;
break;
default:
return false;
}
......@@ -321,36 +348,42 @@ class PluginArtefactInternal extends PluginArtefact {
public static function progressbar_link($artefacttype) {
switch ($artefacttype) {
case 'firstname':
case 'lastname':
case 'studentid':
case 'preferredname':
case 'introduction':
return 'artefact/internal/index.php';
break;
case 'email':
case 'officialwebsite':
case 'personalwebsite':
case 'blogaddress':
case 'address':
case 'town':
case 'city':
case 'country':
case 'homenumber':
case 'businessnumber':
case 'mobilenumber':
case 'faxnumber':
return 'artefact/internal/index.php?fs=contact';
break;
case 'messaging':
return 'artefact/internal/index.php?fs=messaging';
break;
case 'occupation':
case 'industry':
return 'artefact/internal/index.php?fs=general';
break;
default:
return 'view/index.php';
case 'firstname':
case 'lastname':
case 'studentid':
case 'preferredname':
case 'introduction':
return 'artefact/internal/index.php';
break;
case 'email':
case 'officialwebsite':
case 'personalwebsite':
case 'blogaddress':
case 'address':
case 'town':
case 'city':
case 'country':
case 'homenumber':
case 'businessnumber':
case 'mobilenumber':
case 'faxnumber':
return 'artefact/internal/index.php?fs=contact';
break;
case 'messaging':
return 'artefact/internal/index.php?fs=messaging';
break;
case 'occupation':
case 'industry':
return 'artefact/internal/index.php?fs=general';
break;
case 'joingroup':
return 'group/find.php';
break;
case 'makefriend':
return 'user/find.php';
break;
default:
return 'view/index.php';
}
}
}
......
<?php
/**
*
* @package mahara
* @subpackage lang
* @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.
*
*/
defined('INTERNAL') || die();
$string['pluginname'] = 'Social';
$string['Social'] = 'Social actions';
$string['feedback'] = 'Place feedback';
$string['joingroup'] = 'Join a group';
$string['makefriend'] = 'Make a friend';
$string['progress_feedback'] = array(
'Comment on another user\'s page',
'Comment on %s other users\' pages',
);
$string['progress_joingroup'] = array(
'Join a group',
'Join %s groups',
);
$string['progress_makefriend'] = array(
'Make a friend',
'Make %s friends',
);
\ No newline at end of file
<?php
/**
*
* @package mahara
* @subpackage artefact-internal
* @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.
*
*/
defined('INTERNAL') || die();
class PluginArtefactSocial extends PluginArtefact {
public static function get_artefact_types() {
return array('feedback',
'joingroup',
'makefriend',
);
}
public static function get_block_types() {
return array();
}
public static function get_plugin_name() {
return 'social';
}
public static function can_be_disabled() {
return true;
}
public static function progressbar_link($artefacttype) {
switch ($artefacttype) {
case 'feedback':
return 'view/sharedviews.php';
break;
case 'joingroup':
return 'group/find.php';
break;
case 'makefriend':
return 'user/find.php';
break;
default:
return '';
}
}
public static function progressbar_metaartefact_count($name) {
global $USER;
$meta = new StdClass();
$meta->artefacttype = $name;
$meta->completed = 0;
switch ($name) {
case 'feedback':
$sql = "SELECT COUNT(*) AS completed
FROM {artefact}
WHERE artefacttype='comment'
AND owner <> ? AND author = ?";
$count = get_records_sql_array($sql, array($USER->get('id'), $USER->get('id')));
$meta->completed = $count[0]->completed;
break;
case 'joingroup':
$sql = "SELECT COUNT(*) AS completed
FROM {group_member}
WHERE member = ?";
$count = get_records_sql_array($sql, array($USER->get('id')));
$meta->completed = $count[0]->completed;
break;
case 'makefriend':
$sql = "SELECT COUNT(*) AS completed
FROM {usr_friend}
WHERE usr1 = ?";
$count = get_records_sql_array($sql, array($USER->get('id')));
$meta->completed = $count[0]->completed;
break;
default:
return false;
}
return $meta;
}
}
class ArtefactTypeFeedback extends ArtefactType {
public static function get_icon($options=null) {
}
public static function is_singular() {
}
public static function get_links($id) {
return array();
}
public static function is_countable_progressbar() {
return true;
}
public static function is_metaartefact() {
return true;
}
}
class ArtefactTypeJoingroup extends ArtefactType {
public static function get_icon($options=null) {
}
public static function is_singular() {
}
public static function get_links($id) {
return array();
}
public static function is_countable_progressbar() {
return true;
}
public static function is_metaartefact() {
return true;
}
}
class ArtefactTypeMakefriend extends ArtefactType {
public static function get_icon($options=null) {
}
public static function is_singular() {
}
public static function get_links($id) {
return array();
}
public static function is_countable_progressbar() {
return true;
}
public static function is_metaartefact() {
return true;
}
}
<?php
/**
*
* @package mahara
* @subpackage artefact-resume
* @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.
*
*/
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2014031800;
$config->release = '1.0.0';
......@@ -3014,6 +3014,9 @@ function progressbar_sideblock($preview=false) {
AND artefacttype in ({$insql})
GROUP BY artefacttype";
$normalartefacts = get_records_sql_array($sql, array($USER->get('id')));
if (!$normalartefacts) {
$normalartefacts = array();
}
}
else {
// No basic artefacts in this one, so we just use an empty array for this.
......
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