public static function get_instance_title(BlockInstance $bi) { $configdata = $bi->get('configdata'); if (!empty($configdata['artefactid'])) { safe_require('artefact', 'cpds'); $cpd = new ArtefactTypeCPD($configdata['artefactid']); $title = $cpd->get('title'); return $title; } return ''; }
* 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-cpds * @author James Kerrigan * @author Geoffrey Rowland * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * */ define('INTERNAL', true); define('MENUITEM', 'content/cpds'); 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', 'cpds'); define('TITLE', get_string('editcpd', 'artefact.cpds')); $id = param_integer('id'); $artefact = new ArtefactTypeCPD($id); if (!$USER->can_edit_artefact($artefact)) { throw new AccessDeniedException(get_string('accessdenied', 'error')); } $editform = ArtefactTypeCPD::get_form($artefact); $smarty = smarty(); $smarty->assign('editform', $editform); $smarty->assign('PAGEHEADING', hsc(get_string("editcpd", "artefact.cpds"))); $smarty->display('artefact:cpds:edit.tpl');
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package mahara * @subpackage artefact-cpds * @author James Kerrigan * @author Geoffrey Rowland * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * */ define('INTERNAL', 1); define('MENUITEM', 'content/cpds'); define('SECTION_PLUGINTYPE', 'artefact'); define('SECTION_PLUGINNAME', 'cpds'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; safe_require('artefact', 'cpds'); $id = param_integer('id', 0); if ($id) { $cpd = new ArtefactTypeCPD($id); if (!$USER->can_edit_artefact($cpd)) { throw new AccessDeniedException(get_string('accessdenied', 'error')); } define('TITLE', get_string('newactivity', 'artefact.cpds')); $form = ArtefactTypeActivity::get_form($id); } else { define('TITLE', get_string('newcpd', 'artefact.cpds')); $form = ArtefactTypeCPD::get_form(); } $smarty =& smarty(); $smarty->assign_by_ref('form', $form); $smarty->assign_by_ref('PAGEHEADING', hsc(TITLE)); $smarty->display('artefact:cpds:new.tpl');
public static function submit(Pieform $form, $values) { global $USER, $SESSION; $new = false; if (!empty($values['cpd'])) { $id = (int) $values['cpd']; $artefact = new ArtefactTypeCPD($id); } else { $new = true; $artefact = new ArtefactTypeCPD(); $artefact->set('owner', $USER->get('id')); } $artefact->set('title', $values['title']); $artefact->set('description', $values['description']); $artefact->set('tags', $values['tags']); $artefact->commit(); $SESSION->add_ok_msg(get_string('cpdsavedsuccessfully', 'artefact.cpds')); if ($new) { redirect('/artefact/cpds/cpd.php?id=' . $artefact->get('id')); } else { redirect('/artefact/cpds/index.php'); } }
* @package mahara * @subpackage artefact-cpds * @author James Kerrigan * @author Geoffrey Rowland * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * */ define('INTERNAL', 1); define('MENUITEM', 'content/cpds'); define('SECTION_PLUGINTYPE', 'artefact'); define('SECTION_PLUGINNAME', 'cpds'); define('SECTION_PAGE', 'index'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; safe_require('artefact', 'cpds'); define('TITLE', get_string('mycpds', 'artefact.cpds')); // offset and limit for pagination $offset = param_integer('offset', 0); $limit = param_integer('limit', 10); $cpds = ArtefactTypeCPD::get_cpds($offset, $limit); ArtefactTypeCPD::build_cpds_list_html($cpds); $js = <<<EOF addLoadEvent(function () { {$cpds['pagination_js']} }); EOF; $smarty = smarty(array('paginator')); $smarty->assign_by_ref('cpds', $cpds); $smarty->assign('strnocpdsaddone', get_string('nocpdsaddone', 'artefact.cpds', '<a href="' . get_config('wwwroot') . 'artefact/cpds/new.php">', '</a>')); $smarty->assign('PAGEHEADING', hsc(get_string("mycpds", "artefact.cpds"))); $smarty->assign('INLINEJAVASCRIPT', $js); $smarty->display('artefact:cpds:index.tpl');
/** * Creates a cpd or activity from the given entry * * @param SimpleXMLElement $entry The entry to create the cpd or activity from * @param PluginImportLeap $importer The importer * @return array A list of artefact IDs created, to be used with the artefact mapping. */ private static function create_cpd(SimpleXMLElement $entry, PluginImportLeap $importer) { // First decide if it's going to be a cpd or a activity depending // on whether it has any ancestral cpds. if (self::get_ancestor_entryid($entry, $importer)) { $artefact = new ArtefactTypeActivity(); } else { $artefact = new ArtefactTypeCPD(); } $artefact->set('title', (string) $entry->title); $artefact->set('description', PluginImportLeap::get_entry_content($entry, $importer)); $artefact->set('owner', $importer->get('usr')); if (isset($entry->author->name) && strlen($entry->author->name)) { $artefact->set('authorname', $entry->author->name); } else { $artefact->set('author', $importer->get('usr')); } if ($published = strtotime((string) $entry->published)) { $artefact->set('ctime', $published); } if ($updated = strtotime((string) $entry->updated)) { $artefact->set('mtime', $updated); } $artefact->set('tags', PluginImportLeap::get_entry_tags($entry)); // Set startdate and hours status if we can find them if ($artefact instanceof ArtefactTypeActivity) { $namespaces = $importer->get_namespaces(); $ns = $importer->get_leap2a_namespace(); $startdate = $enddate = null; $dates = PluginImportLeap::get_leap_dates($entry, $namespaces, $ns); if (!empty($dates['start']['value'])) { $startdate = strtotime($dates['start']['value']); } if (!empty($dates['end']['value'])) { $enddate = strtotime($dates['end']['value']); } $artefact->set('startdate', empty($startdate) ? $artefact->get('mtime') : $startdate); $artefact->set('enddate', $enddate); $location = $entry->xpath($namespaces[$ns] . ':spatial'); if (is_array($location) && count($location) == 1) { $artefact->set('location', $location[0]); } $hours = $entry->xpath($namespaces[PluginImportLeap::NS_MAHARA] . ':hours'); if (is_array($hours) && count($hours) == 1) { $artefact->set('hours', $hours[0]); } } $artefact->commit(); return array($artefact->get('id')); }