3 ["$includepage_channel" ] && return 0
4 includepage_channel="$0"
6 . "$_EXEC/db_channel.sh"
9 read_channel "$channel"
11 [ "$REQUEST_METHOD" = POST ] && case "$(POST action)" in
13 channel="$(POST channel |checkid)"
14 if [ ! "$USER_ID" ]; then
15 REDIRECT "${_BASE}/channel/#ERROR_NEWCHANNEL_NOTALLOWED"
16 elif new_channel "$channel"; then
17 REDIRECT "${_BASE}/channel/$channel/edit"
19 REDIRECT "${_BASE}/channel/#ERROR_NEWCHANNEL_NOLOCK"
24 n="$(POST_COUNT author)"
25 while [ $n -gt 0 ]; do
26 newauthor="$(POST author $n |checkid)"
27 user_idmap "$newauthor" && authors="${authors}${BR}${newauthor}" >&-
30 n="$(POST_COUNT newauthor)"
31 while [ $n -gt 0 ]; do
32 newauthor="$(POST newauthor $n)"
33 newauthor="$(user_idof "$newauthor")" \
34 && authors="${authors}${BR}${newauthor}"
38 if [ ! "$CHANNEL_ID" ]; then
39 REDIRECT "${_BASE}/channel/#ERROR_NOCHANNEL"
40 elif [ ! "$USER_ID" ]; then
41 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_NOTLOGGEDIN"
43 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOTALLOWED"
44 elif update_channel "$CHANNEL_ID" "name=$(POST name)" \
45 "description=$(POST description)" \
46 "authors=${authors}"; then
47 REDIRECT "${_BASE}/channel/$CHANNEL_ID/"
49 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOLOCK"
52 update_channel_cancel)
53 REDIRECT "${_BASE}/channel/$CHANNEL_ID/"
56 . "$_EXEC/db_video.sh"
57 video="$(POST video |checkid)"
60 && mkdir -p -- "${_DATA}/$CHANNEL_ID/"
62 if [ ! "$video" ]; then
63 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_INVALID_ID"
64 elif [ ! "$CHANNEL_ID" ]; then
65 REDIRECT "${_BASE}/channel/#ERROR_NOCHANNEL"
66 elif [ ! "$USER_ID" ]; then
67 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_NOTLOGGEDIN"
69 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOTALLOWED"
70 elif new_video "$video"; then
71 REDIRECT "${_BASE}/channel/$CHANNEL_ID/$video/"
73 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_NEWVIDEO_NOLOCK"
78 if [ "$CHANNEL_ID" -a "$action" = edit ]; then
79 AUTHOR || REDIRECT "${_BASE}/$CHANNEL_ID/#ERROR_EDIT_NOTALLOWED"
80 yield_page "$CHANNEL_NAME - Edit" "channel edit" <<-EOF
81 [datalist #list_authors
82 $(user_idmap |cut -f2 |UNSTRING |while read name; do
83 printf '[option value="%s"]' "$(HTML "$name")"
86 [form .channel .edit method=POST
87 [input name="name" value="$(HTML "$CHANNEL_NAME")" placeholder="Channel Name" autocomplete=off]
88 [textarea name="description" placeholder="Description" . $(HTML "$CHANNEL_DESCRIPTION")]
89 [div .authors [h3 Authors:]
90 $(for each in $CHANNEL_AUTHORS; do
91 printf '[checkbox "author" "%s" id="author_%s" %s %s][label for="author_%s" . %s]\n' \
92 "$each" "$each" "checked=checked" "$([ "$each" = "$USER_ID" ] && printf 'disabled=disabled')" \
93 "$each" "$(user_idmap "$each" |UNSTRING |HTML)"
95 for n in 0 1 2 3 4 5 6 7 8 9; do
96 printf '[checkbox "" "" #newauthor%i][label for=newauthor%i . +]
97 [input name=newauthor value="" placeholder="Author" list=list_authors]' \
101 [submit "action" "update_channel" . Update]
102 [submit "action" "update_channel_cancel" . Cancel]
105 elif [ "$CHANNEL_ID" ]; then
106 yield_page "$CHANNEL_NAME" "channel" <<-EOF
107 [nav [a href="../" Channels] - [span $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")]]
108 [h1 .name $(HTML "$CHANNEL_NAME")]
109 [div .description . ${CHANNEL_DESCR_CACHE}]
110 [div .authors [h3 Authors:]
111 $(for each in $CHANNEL_AUTHORS; do
112 printf '[span .author . %s]\n' "$(user_idmap "$each" |UNSTRING |HTML)"
115 $(AUTHOR && printf '[a .button href="edit" edit]')
119 [form .video .newvideo method=POST
120 [hidden "video" "%s"]
121 [submit "action" "newvideo" New Video]
123 list_videos |while w_video; do :; done
127 yield_page "Channels" "channels" <<-EOF
128 $([ "$USER_ID" ] && printf '
129 [form .channel .newchannel method=POST
130 [hidden "channel" "%s"]
131 [submit "action" "newchannel" New Channel]
134 $([ -f "$chan_db" -a -r "$chan_db" ] \
135 && while w_channel; do :; done <"$chan_db"