public static function render_instance(BlockInstance $instance, $editing = false) { global $exporter; require_once get_config('docroot') . 'artefact/lib.php'; safe_require('artefact', 'ilps'); $configdata = $instance->get('configdata'); $smarty = smarty_core(); if (isset($configdata['artefactid'])) { $units = ArtefactTypeunit::get_units($configdata['artefactid']); $template = 'artefact:ilps:unitrows.tpl'; $blockid = $instance->get('id'); if ($exporter) { $pagination = false; } else { $pagination = array('baseurl' => $instance->get_view()->get_url() . '&block=' . $blockid, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'unittable_' . $blockid, 'jsonscript' => 'artefact/ilps/viewunits.json.php'); } ArtefactTypeUnit::render_units($units, $template, $configdata, $pagination); if ($exporter && $units['count'] > $units['limit']) { $artefacturl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view'); $units['pagination'] = '<a href="' . $artefacturl . '">' . get_string('allunits', 'artefact.ilps') . '</a>'; } $smarty->assign('units', $units); } else { $smarty->assign('noilps', 'blocktype.ilps/ilps'); } $smarty->assign('blockid', $instance->get('id')); return $smarty->fetch('blocktype:ilps:content.tpl'); }
* 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-ilps * @author Ross Dash * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2012 Ross Dash * */ define('INTERNAL', true); define('MENUITEM', 'content/ilps'); 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', 'ilps'); define('TITLE', get_string('editunit', 'artefact.ilps')); $id = param_integer('id'); $unit = new ArtefactTypeUnit($id); if (!$USER->can_edit_artefact($unit)) { throw new AccessDeniedException(get_string('accessdenied', 'error')); } $form = ArtefactTypeunit::get_form($unit->get('parent'), $unit); $smarty = smarty(); $smarty->assign('editform', $form); $smarty->assign('PAGEHEADING', hsc(get_string("editingunit", "artefact.ilps"))); $smarty->display('artefact:ilps:edit.tpl');
/** * Set unit parents */ public static function setup_relationships(SimpleXMLElement $entry, PluginImportLeap $importer) { if ($ancestorid = self::get_ancestor_entryid($entry, $importer)) { $ancestorids = $importer->get_artefactids_imported_by_entryid($ancestorid); $artefactids = $importer->get_artefactids_imported_by_entryid((string) $entry->id); if (empty($artefactids[0])) { throw new ImportException($importer, 'unit artefact not found: ' . (string) $entry->id); } if (empty($ancestorids[0])) { throw new ImportException($importer, 'ilp artefact not found: ' . $ancestorid); } $artefact = new ArtefactTypeunit($artefactids[0]); $artefact->set('parent', $ancestorids[0]); $artefact->commit(); } }
public static function submit(Pieform $form, $values) { global $USER, $SESSION; if (!empty($values['unit'])) { $id = (int) $values['unit']; $artefact = new ArtefactTypeUnit($id); } else { $artefact = new ArtefactTypeunit(); $artefact->set('owner', $USER->get('id')); $artefact->set('parent', $values['parent']); } $artefact->set('title', $values['title']); $artefact->set('status', $values['status']); $artefact->set('points', $values['points']); $artefact->set('targetcompletion', $values['targetcompletion']); $artefact->set('datecompleted', $values['datecompleted']); $artefact->commit(); $SESSION->add_ok_msg(get_string('ilpsavedsuccessfully', 'artefact.ilps')); redirect('/artefact/ilps/ilp.php?id=' . $values['parent']); }