event publish

This commit is contained in:
Friendika 2011-06-09 21:23:45 -07:00
parent 8aaf55c1e6
commit b857a49bfe
3 changed files with 92 additions and 10 deletions

View File

@ -2,6 +2,7 @@
require_once('include/datetime.php');
require_once('include/event.php');
require_once('include/items.php');
function events_post(&$a) {
@ -44,18 +45,27 @@ function events_post(&$a) {
}
$desc = escape_tags($_POST['desc']);
$location = escape_tags($_POST['location']);
$desc = escape_tags(trim($_POST['desc']));
$location = escape_tags(trim($_POST['location']));
$type = 'event';
$str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']);
$str_group_deny = perms2str($_POST['group_deny']);
$str_contact_deny = perms2str($_POST['contact_deny']);
if((! $desc) || (! $start)) {
notice('Event description and start time are required.');
goaway($a->get_baseurl() . '/events/new');
}
$share = ((intval($_POST['share'])) ? intval($_POST['share']) : 0);
// until publishing is ready
$str_contact_allow = '<' . local_user() . '>';
if($share) {
$str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']);
$str_group_deny = perms2str($_POST['group_deny']);
$str_contact_deny = perms2str($_POST['contact_deny']);
}
else {
$str_contact_allow = '<' . local_user() . '>';
$str_group_allow = $str_contact_deny = $str_group_deny = '';
}
if($event_id) {
$r = q("UPDATE `event` SET
@ -158,7 +168,7 @@ function events_post(&$a) {
q("UPDATE `item` SET `plink` = '%s', `event-id` = %d WHERE `uid` = %d AND `id` = %d LIMIT 1",
dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
intval($event['id']),
intval($local_user()),
intval(local_user()),
intval($item_id)
);
proc_run('php',"include/notifier.php","tag","$item_id");
@ -265,7 +275,7 @@ function events_content(&$a) {
}
if($mode === 'edit' || $mode === 'new') {
$htpl = get_markup_template('profed_head.tpl');
$htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl,array('$baseurl' => $a->get_baseurl()));
$tpl = get_markup_template('event_form.tpl');
@ -274,6 +284,8 @@ function events_content(&$a) {
$month = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
$day = datetime_convert('UTC', date_default_timezone_get(), 'now', 'd');
require_once('include/acl_selectors.php');
$o .= replace_macros($tpl,array(
'$post' => $a->get_baseurl() . '/events',
'$e_text' => t('Event details'),
@ -292,6 +304,9 @@ function events_content(&$a) {
'$d_orig' => '',
'$l_text' => t('Location:'),
'$l_orig' => '',
'$sh_text' => t('Share this event'),
'$sh_checked' => '',
'$acl' => populate_acl($a->user,false),
'$submit' => t('Submit')
));

View File

@ -29,6 +29,11 @@ $f_dsel $f_tsel
<div id="event-location-text">$l_text</div>
<textarea id="event-location-textarea" name="location">$l_orig</textarea>
<input type="checkbox" name="share" value="1" id="event-share-checkbox" $sh_checked /> <div id="event-share-text">$sh_text</div>
<div id="event-share-break"></div>
$acl
<input id="event-submit" type="submit" name="submit" value="$submit" />
</form>

62
view/event_head.tpl Normal file
View File

@ -0,0 +1,62 @@
<script language="javascript" type="text/javascript"
src="$baseurl/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
theme : "advanced",
mode : "textareas",
plugins : "bbcode,paste",
theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
theme_advanced_blockformats : "blockquote,code",
paste_text_sticky : true,
entity_encoding : "raw",
add_unload_trigger : false,
remove_linebreaks : false,
force_p_newlines : false,
force_br_newlines : true,
forced_root_block : '',
content_css: "$baseurl/view/custom_tinymce.css",
theme_advanced_path : false,
setup : function(ed) {
ed.onInit.add(function(ed) {
ed.pasteAsPlainText = true;
});
}
});
$(document).ready(function() {
$('#event-share-checkbox').change(function() {
if ($('#event-share-checkbox').is(':checked')) {
$('#acl-wrapper').show();
}
else {
$('#acl-wrapper').hide();
}
}).trigger('change');
$('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
var selstr;
$('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
selstr = $(this).text();
$('#jot-public').hide();
});
if(selstr == null) {
$('#jot-public').show();
}
}).trigger('change');
});
</script>