00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00030 class view extends WebObject
00031 {
00032 function init()
00033 {
00034 WebApp::setSVar('webnotes->visible', 'false');
00035 }
00036
00037 function onParse()
00038 {
00039 $book_id = WebApp::getSVar('docbook->book_id');
00040 $node_path = WebApp::getSVar('docbook->node_path');
00041 $lng = WebApp::getSVar('docbook->lng');
00042
00043 $cache = (defined('EDIT') ? WS_CACHE : CACHE);
00044 $book_path = $cache.$book_id.'/'.$lng.'/';
00045 $content_html = $book_path.$node_path."content.html";
00046 $subnodes_html = $book_path.$node_path."subnodes.html";
00047
00048 WebApp::addVars(compact('content_html', 'subnodes_html'));
00049
00050 $this->setup_webnotes();
00051 }
00052
00054 function setup_webnotes()
00055 {
00056 if (WEBNOTES_ENABLE=='false')
00057 {
00058 WebApp::setSVar('webnotes->page_id', '');
00059 return;
00060 }
00061
00062
00063 $book_id = WebApp::getSVar('docbook->book_id');
00064 $lng = WebApp::getSVar('docbook->lng');
00065 $node_path = WebApp::getSVar('docbook->node_path');
00066
00067
00068 ereg('([^/]+)/$', $node_path, $regs);
00069 $node_id = $regs[1];
00070 $page_id = "$book_id/$lng/$node_id";
00071
00072 if (WEBNOTES_NOTIFY=='true')
00073 {
00074
00075 $notify = 'true';
00076
00077 $users = ADMIN.'access_rights/users';
00078 $cmd = "gawk -F: '(\$5 ~ \"$book_id\") {print \$4}' $users";
00079 $output = shell($cmd);
00080 $arr_emails = explode("\n", trim($output));
00081 $admin_emails = implode(',', $arr_emails);
00082 }
00083 else
00084 {
00085 $notify = 'false';
00086 $admin_emails = '';
00087 }
00088
00089
00090 $unmoderated = (WEBNOTES_APPROVE=='true' ? 'false' : 'true');
00091
00092
00093
00094 $approve = WebApp::getVar('can_approve');
00095
00096
00097 $admin = WebApp::getVar('is_admin');
00098
00099
00100 $admin_pageid_filter = "page_id LIKE '$book_id/%'";
00101
00102
00103 WebApp::setSVar('webnotes->page_id', $page_id);
00104 WebApp::setSVar('webnotes->notify', $notify);
00105 WebApp::setSVar('webnotes->emails', $admin_emails);
00106 WebApp::setSVar('webnotes->unmoderated', $unmoderated);
00107 WebApp::setSVar('webnotes->approve', $approve);
00108 WebApp::setSVar('webnotes->admin', $admin);
00109 WebApp::setSVar('webnotes->admin_pageid_filter', $admin_pageid_filter);
00110
00111
00112 WebApp::setSVar('webnotes->dbhost', WEBNOTES_DBHOST);
00113 WebApp::setSVar('webnotes->dbuser', WEBNOTES_DBUSER);
00114 WebApp::setSVar('webnotes->dbpasswd', WEBNOTES_DBPASS);
00115 WebApp::setSVar('webnotes->dbname', WEBNOTES_DBNAME);
00116 }
00117 }
00118 ?>