Exemplo n.º 1
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $exporter;
     require_once get_config('docroot') . 'artefact/lib.php';
     safe_require('artefact', 'cpds');
     $configdata = $instance->get('configdata');
     $smarty = smarty_core();
     if (isset($configdata['artefactid'])) {
         $cpd = artefact_instance_from_id($configdata['artefactid']);
         $activities = ArtefactTypeActivity::get_activities($configdata['artefactid']);
         $template = 'artefact:cpds:activityrows.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' => 'activitytable_' . $blockid, 'jsonscript' => 'artefact/cpds/viewactivities.json.php');
         }
         ArtefactTypeActivity::render_activities($activities, $template, $configdata, $pagination);
         if ($exporter && $activities['count'] > $activities['limit']) {
             $artefacturl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view');
             $activities['pagination'] = '<a href="' . $artefacturl . '">' . get_string('allactivities', 'artefact.cpds') . '</a>';
         }
         $smarty->assign('description', $cpd->get('description'));
         $smarty->assign('activities', $activities);
         $smarty->assign('owner', $cpd->get('owner'));
         $smarty->assign('tags', $cpd->get('tags'));
     } else {
         $smarty->assign('nocpds', 'blocktype.cpds/cpds');
     }
     $smarty->assign('blockid', $instance->get('id'));
     return $smarty->fetch('blocktype:cpds:content.tpl');
 }
Exemplo n.º 2
0
 * 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');
 * @author     Geoffrey Rowland
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 *
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('artefact', 'cpds');
require_once get_config('docroot') . 'blocktype/lib.php';
require_once get_config('docroot') . 'artefact/cpds/blocktype/cpds/lib.php';
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 10);
if ($blockid = param_integer('block', null)) {
    $bi = new BlockInstance($blockid);
    $options = $configdata = $bi->get('configdata');
    $activities = ArtefactTypeActivity::get_activities($configdata['artefactid'], $offset, $limit);
    $template = 'artefact:cpds:activityrows.tpl';
    $baseurl = $bi->get_view()->get_url();
    $baseurl .= (false === strpos($baseurl, '?') ? '?' : '&') . 'block=' . $blockid;
    $pagination = array('baseurl' => $baseurl, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'activitytable_' . $blockid, 'jsonscript' => 'artefact/cpds/viewactivities.json.php');
} else {
    $cpdid = param_integer('artefact');
    $viewid = param_integer('view');
    $options = array('viewid' => $viewid);
    $activities = ArtefactTypeActivity::get_activities($cpdid, $offset, $limit);
    $template = 'artefact:cpds:activityrows.tpl';
    $baseurl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $cpdid . '&view=' . $options['viewid'];
    $pagination = array('baseurl' => $baseurl, 'id' => 'activity_pagination', 'datatable' => 'activitylist', 'jsonscript' => 'artefact/cpds/viewactivities.json.php');
}
ArtefactTypeActivity::render_activities($activities, $template, $options, $pagination);
json_reply(false, (object) array('message' => false, 'data' => $activities));
Exemplo n.º 4
0
 public static function submit(Pieform $form, $values)
 {
     global $USER, $SESSION;
     if (!empty($values['activity'])) {
         $id = (int) $values['activity'];
         $artefact = new ArtefactTypeActivity($id);
     } else {
         $artefact = new ArtefactTypeActivity();
         $artefact->set('owner', $USER->get('id'));
         $artefact->set('parent', $values['parent']);
     }
     $artefact->set('title', $values['title']);
     $artefact->set('location', $values['location']);
     $artefact->set('description', $values['description']);
     $artefact->set('tags', $values['tags']);
     $artefact->set('hours', $values['hours']);
     $artefact->set('startdate', $values['startdate']);
     $artefact->set('enddate', $values['enddate']);
     $artefact->commit();
     $SESSION->add_ok_msg(get_string('cpdsavedsuccessfully', 'artefact.cpds'));
     redirect('/artefact/cpds/cpd.php?id=' . $values['parent']);
 }
Exemplo n.º 5
0
define('MENUITEM', 'content/cpds');
define('SECTION_PLUGINTYPE', 'artefact');
define('SECTION_PLUGINNAME', 'cpds');
define('SECTION_PAGE', 'cpds');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('artefact', 'cpds');
define('TITLE', get_string('activities', 'artefact.cpds'));
$id = param_integer('id');
// offset and limit for pagination
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 10);
$cpd = new ArtefactTypeCPD($id);
if (!$USER->can_edit_artefact($cpd)) {
    throw new AccessDeniedException(get_string('accessdenied', 'error'));
}
$activities = ArtefactTypeActivity::get_activities($cpd->get('id'), $offset, $limit);
ArtefactTypeActivity::build_activities_list_html($activities);
$js = <<<EOF
addLoadEvent(function () {
    {$activities['pagination_js']}
});
EOF;
$smarty = smarty(array('paginator'));
$smarty->assign_by_ref('activities', $activities);
$smarty->assign_by_ref('cpd', $id);
$smarty->assign_by_ref('tags', $cpd->get('tags'));
$smarty->assign_by_ref('owner', $cpd->get('owner'));
$smarty->assign('strnoactivitiesaddone', get_string('noactivitiesaddone', 'artefact.cpds', '<a href="' . get_config('wwwroot') . 'artefact/cpds/new.php?id=' . $cpd->get('id') . '">', '</a>'));
$smarty->assign('PAGEHEADING', get_string("cpdsactivities", "artefact.cpds", $cpd->get('title')));
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->display('artefact:cpds:cpd.tpl');
Exemplo n.º 6
0
 /**
  * Set activity 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, 'activity artefact not found: ' . (string) $entry->id);
         }
         if (empty($ancestorids[0])) {
             throw new ImportException($importer, 'cpd artefact not found: ' . $ancestorid);
         }
         $artefact = new ArtefactTypeActivity($artefactids[0]);
         $artefact->set('parent', $ancestorids[0]);
         $artefact->commit();
     }
 }
Exemplo n.º 7
0
 * 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('editactivity', 'artefact.cpds'));
$id = param_integer('id');
$activity = new ArtefactTypeActivity($id);
if (!$USER->can_edit_artefact($activity)) {
    throw new AccessDeniedException(get_string('accessdenied', 'error'));
}
$form = ArtefactTypeActivity::get_form($activity->get('parent'), $activity);
$smarty = smarty();
$smarty->assign('editform', $form);
$smarty->assign('PAGEHEADING', hsc(get_string("editactivity", "artefact.cpds")));
$smarty->display('artefact:cpds:edit.tpl');