<?php elgg_load_library('elgg:webinar'); $variables = webinar_prepare_form_vars(); $input = array(); foreach (array_keys($variables) as $field) { $input[$field] = get_input($field); if ($field == 'title') { $input[$field] = strip_tags($input[$field]); } if ($field == 'tags') { $input[$field] = string_to_tag_array($input[$field]); } } elgg_make_sticky_form('webinar'); if (!$input['title']) { register_error(elgg_echo('webinar:error:no_title')); forward(REFERER); } if (sizeof($input) > 0) { if (isset($input[guid]) && !empty($input[guid])) { $webinar = get_entity($input[guid]); if (!$webinar || !$webinar->canEdit()) { register_error(elgg_echo('webinar:error:no_save')); forward(REFERER); } $new_webinar = false; } else { $webinar = new ElggWebinar(); $new_webinar = true; }
/** * Get page components to edit/create a webinar. * * @param string $action_type 'edit' or 'new' * @param int $guid GUID of webinar or container * @return array */ function webinar_get_page_content_edit($action_type, $guid = 0) { $return = array('filter' => ''); if ($action_type == 'edit') { $title = elgg_echo("webinar:edit"); $webinar = get_entity($guid); if (elgg_instanceof($webinar, 'object', 'webinar') && $webinar->canEdit()) { $container = $webinar->getContainerEntity(); $crumbs_title = $container->name; if (elgg_instanceof($container, 'group')) { elgg_push_breadcrumb($crumbs_title, "webinar/group/{$container->guid}/all"); } else { elgg_push_breadcrumb($crumbs_title, "webinar/owner/{$container->username}"); } elgg_push_breadcrumb($webinar->title, $webinar->getURL()); elgg_push_breadcrumb(elgg_echo('edit')); $body_vars = webinar_prepare_form_vars($webinar); $content = elgg_view_form('webinar/save', array(), $body_vars); } else { register_error(elgg_echo('webinar:error:cannot_edit')); forward($webinar->getURL()); } } else { if (!$guid) { $container = elgg_get_logged_in_user_entity(); } else { $container = get_entity($guid); if (!$container->canWriteToContainer(0, 'object', 'webinar')) { register_error(elgg_echo('webinar:error:cannot_edit')); forward($container->getURL()); } } $crumbs_title = $container->name; if (elgg_instanceof($container, 'group')) { $title = elgg_echo('webinar:new:group', array($container->name)); elgg_push_breadcrumb($crumbs_title, "webinar/group/{$container->guid}/all"); } else { $title = elgg_echo('webinar:new:user'); elgg_push_breadcrumb($crumbs_title, "webinar/owner/{$container->username}"); } elgg_push_breadcrumb(elgg_echo('webinar:add')); $body_vars = webinar_prepare_form_vars(); $content = elgg_view_form('webinar/save', array(), $body_vars); } $return['title'] = $title; $return['content'] = $content; return $return; }