Commit 53b57587 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Merge branch 'plans'

parents 3b6d9b8f a3eba3a6
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage blocktype-plans
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$string['title'] = 'Your Plans';
$string['description'] = 'Display your plans list';
$string['defaulttitledescription'] = 'If this is left empty the title of the plan will be used.';
$string['newerplans'] = 'Newer plans';
$string['noplansaddone'] = 'No plans yet. %sAdd one%s!';
$string['olderplans'] = 'Older plans';
$string['planstoshow'] = 'Plan to show';
?>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage blocktype-plans
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
class PluginBlocktypePlans extends PluginBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.plans/plans');
}
public static function get_description() {
return get_string('description', 'blocktype.plans/plans');
}
public static function get_categories() {
return array('general');
}
/**
* Optional method. If exists, allows this class to decide the title for
* all blockinstances of this type
*/
public static function get_instance_title(BlockInstance $bi) {
$configdata = $bi->get('configdata');
if (!empty($configdata['artefactid'])) {
safe_require('artefact','plans');
$plan = new ArtefactTypePlan($configdata['artefactid']);
$title = $plan->get('title');
return $title;
}
return '';
}
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
safe_require('artefact','plans');
$configdata = $instance->get('configdata');
$smarty = smarty_core();
if (isset($configdata['artefactid'])) {
$tasks = ArtefactTypeTask::get_tasks($configdata['artefactid']);
self::build_plans_html($tasks, $editing, $instance);
$smarty->assign('tasks',$tasks);
}
else {
$smarty->assign('noplans','blocktype.plans/plans');
}
$smarty->assign('blockid', $instance->get('id'));
return $smarty->fetch('blocktype:plans:content.tpl');
}
public static function build_plans_html(&$tasks, $editing=false, BlockInstance $instance) {
$smarty = smarty_core();
$smarty->assign_by_ref('tasks', $tasks);
$tasks['tablerows'] = $smarty->fetch('blocktype:plans:taskrows.tpl');
if ($editing) {
return;
}
$blockid = $instance->get('id');
$baseurl = $instance->get_view()->get_url() . '&block=' . $blockid;
$pagination = build_pagination(array(
'id' => 'block' . $blockid . '_pagination',
'class' => 'center nojs-hidden-block',
'datatable' => 'tasktable_' . $blockid,
'url' => $baseurl,
'jsonscript' => 'artefact/plans/blocktype/plans/tasks.json.php',
'count' => $tasks['count'],
'limit' => $tasks['limit'],
'offset' => $tasks['offset'],
'numbersincludefirstlast' => false,
'resultcounttextsingular' => get_string('task', 'artefact.plans'),
'resultcounttextplural' => get_string('tasks', 'artefact.plans'),
));
$tasks['pagination'] = $pagination['html'];
$tasks['pagination_js'] = 'var paginator' . $blockid . ' = ' . $pagination['javascript'];
}
// My Plans blocktype only has 'title' option so next two functions return as normal
public static function has_instance_config() {
return true;
}
public static function instance_config_form($instance) {
$configdata = $instance->get('configdata');
$form = array();
// Which resume field does the user want
$form[] = self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null);
return $form;
}
public static function artefactchooser_element($default=null) {
safe_require('artefact', 'plans');
return array(
'name' => 'artefactid',
'type' => 'artefactchooser',
'title' => get_string('planstoshow', 'blocktype.plans/plans'),
'defaultvalue' => $default,
'blocktype' => 'plans',
'selectone' => true,
'search' => false,
'artefacttypes' => array('plan'),
'template' => 'artefact:plans:artefactchooser-element.tpl',
);
}
}
?>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-plans
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/init.php');
safe_require('artefact', 'plans');
require_once(get_config('docroot') . 'blocktype/lib.php');
require_once(get_config('docroot') . 'artefact/plans/blocktype/plans/lib.php');
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$bi = new BlockInstance(param_integer('block'));
$configdata = $bi->get('configdata');
$tasks = ArtefactTypeTask::get_tasks($configdata['artefactid'], $offset, $limit);
PluginBlocktypePlans::build_plans_html($tasks, false, $bi);
json_reply(false, (object) array('message' => false, 'data' => $tasks));
<div class="blockinstance-content">
{if $tasks.data}
<table id="tasktable_{$blockid}">
<colgroup width="50%" span="2"></colgroup>
<thead>
<tr>
<th class="c1">{str tag='completiondate' section='artefact.plans'}</th>
<th class="c2">{str tag='title' section='artefact.plans'}</th>
<th class="c3">{str tag='completed' section='artefact.plans'}</th>
</tr>
</thead>
<tbody>
{$tasks.tablerows|safe}
</tbody>
</table>
<div id="plans_page_container">{$tasks.pagination|safe}</div>
<script>
{literal}
function rewriteTaskTitles() {
forEach(
{/literal}
getElementsByTagAndClassName('a', 'task-title','tasktable_{$blockid}'),
{literal}
function(element) {
connect(element, 'onclick', function(e) {
e.stop();
var description = getFirstElementByTagAndClassName('div', 'task-desc', element.parentNode);
toggleElementClass('hidden', description);
});
}
);
}
addLoadEvent(function() {{/literal}
{$tasks.pagination_js|safe}
removeElementClass('plans_page_container', 'hidden');
{literal}}{/literal});
function TaskPager_{$blockid}() {literal}{
var self = this;
paginatorProxy.addObserver(self);
connect(self, 'pagechanged', rewriteTaskTitles);
}
{/literal}
var taskPager_{$blockid} = new TaskPager_{$blockid}();
addLoadEvent(rewriteTaskTitles);
</script>
{else}
<p>{str tag='notasks' section='artefact.plans'}</p>
{/if}
</div>
{foreach from=$tasks.data item=task}
{if $task->completed == -1}
<tr class="plan_incomplete">
<td class="c1">{$task->completiondate}</td>
{if $task->description}
<td class="c2"><a class="task-title" href="">{$task->title}</a>
<div class="task-desc hidden">{$task->description}</div></td>
{else}
<td class="c2">{$task->title}</td>
{/if}
<td class="c3">&nbsp;</td>
</tr>
{else}
<tr class="{cycle values='r0,r1'}">
<td class="c1">{$task->completiondate}</td>
{if $task->description}
<td class="c2"><a class="task-title" href="">{$task->title}</a>
<div class="task-desc hidden" id="task-desc-{$task->id}">{$task->description}</div></td>
{else}
<td class="c2">{$task->title}</td>
{/if}
{if $task->completed == 1}
<td class="c3"><div class="plan_completed"><img src="{$WWWROOT}theme/raw/static/images/success.gif" alt="" /></div></td>
{else}
<td class="c3">&nbsp;</td>
{/if}
</tr>
{/if}
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage blocktype-plans
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010051700;
$config->release = '1.0.0';
?>
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="artefact/plans/db" VERSION="20100525" COMMENT="XMLDB file for MyPlans Artefact Mahara tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<!-- This table is supposed to have a 1-1 relation with every row in the
artefact table with artefacttype = 'task'. It contains additional data
that isn't in the artefact table. -->
<TABLE NAME="artefact_plans_task">
<FIELDS>
<FIELD NAME="artefact" TYPE="int" LENGTH="10" SEQUENCE="true" NOTNULL="true" />
<FIELD NAME="completiondate" TYPE="datetime" NOTNULL="false" />
<FIELD NAME="completed" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="artefact" />
<KEY NAME="artefactfk" TYPE="foreign" FIELDS="artefact" REFTABLE="artefact" REFFIELDS="id" />
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-plans
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
function xmldb_artefact_plans_upgrade($oldversion=0) {
return true;
}
?>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-plans
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', true);
define('MENUITEM', 'profile/plans');
require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
require_once('pieforms/pieform.php');
safe_require('artefact','plans');
define('TITLE', get_string('deleteplan','artefact.plans'));
$id = param_integer('id');
$todelete = artefact_instance_from_id($id);
$USER->can_edit_artefact($todelete);
$deleteform = array(
'name' => 'deleteplanform',
'plugintype' => 'artefact',
'pluginname' => 'plan',
'renderer' => 'div',
'elements' => array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('deleteplan','artefact.plans'), get_string('cancel')),
'goto' => get_config('wwwroot') . '/artefact/plans/',
),
)
);
$form = pieform($deleteform);
$smarty = smarty();
$smarty->assign('form', $form);
$smarty->assign('PAGEHEADING', $todelete->get('title'));
$smarty->assign('subheading', get_string('deletethisplan','artefact.plans',$todelete->get('title')));
$smarty->assign('message', get_string('deleteplanconfirm','artefact.plans'));
$smarty->display('artefact:plans:delete.tpl');
// calls this function first so that we can get the artefact and call delete on it
function deleteplanform_submit(Pieform $form, $values) {
global $SESSION, $todelete;
$todelete->delete();
$SESSION->add_ok_msg(get_string('plandeletedsuccessfully', 'artefact.plans'));
redirect('/artefact/plans/');
}
?>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-plans
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', true);
define('MENUITEM', 'profile/plans');
require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
require_once('pieforms/pieform.php');
safe_require('artefact','plans');
define('TITLE', get_string('deletetask','artefact.plans'));
$id = param_integer('id');
$todelete = artefact_instance_from_id($id);
$USER->can_edit_artefact($todelete);
$deleteform = array(
'name' => 'deletetaskform',
'plugintype' => 'artefact',
'pluginname' => 'plans',
'renderer' => 'div',
'elements' => array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('deletetask','artefact.plans'), get_string('cancel')),
'goto' => get_config('wwwroot') . '/artefact/plans/plan.php?id='.$todelete->get('parent'),
),
)
);
$form = pieform($deleteform);
$smarty = smarty();
$smarty->assign('form', $form);
$smarty->assign('PAGEHEADING', $todelete->get('title'));
$smarty->assign('subheading', get_string('deletethistask','artefact.plans',$todelete->get('title')));
$smarty->assign('message', get_string('deletetaskconfirm','artefact.plans'));
$smarty->display('artefact:plans:delete.tpl');
// calls this function first so that we can get the artefact and call delete on it
function deletetaskform_submit(Pieform $form, $values) {
global $SESSION, $todelete;
$todelete->delete();
$SESSION->add_ok_msg(get_string('taskdeletedsuccessfully', 'artefact.plans'));
redirect('/artefact/plans/plan.php?id='.$todelete->get('parent'));
}
?>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-plans
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', true);
define('MENUITEM', 'profile/myplans');
require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
require_once('pieforms/pieform.php');
require_once('pieforms/pieform/elements/calendar.php');
require_once(get_config('docroot') . 'artefact/lib.php');
safe_require('artefact','plans');
define('TITLE', get_string('editplan','artefact.plans'));
$id = param_integer('id');
$artefact = artefact_instance_from_id($id);
$USER->can_edit_artefact($id);
$editform = ArtefactTypePlan::get_form($artefact);
$smarty = smarty();
$smarty->assign('editform', $editform);
$smarty->assign('PAGEHEADING', hsc(get_string("editingplan", "artefact.plans")));