view.php

Go to the documentation of this file.
00001 <?php
00002   /*
00003    This file is part of DocBookWiki.  DocBookWiki is a web application
00004    that displays and edits DocBook documents.
00005 
00006    Copyright (C) 2004, 2005, 2006, 2007
00007    Dashamir Hoxha, dashohoxha@users.sourceforge.net
00008 
00009    DocBookWiki is free software; you can redistribute it and/or modify
00010    it under the  terms of the GNU General  Public License as published
00011    by the Free  Software Foundation; either version 2  of the License,
00012    or (at your option) any later version.
00013 
00014    DocBookWiki is distributed in the  hope that it will be useful, but
00015    WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
00016    MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
00017    General Public License for more details.
00018 
00019    You should have  received a copy of the  GNU General Public License
00020    along  with  DocBookWiki;  if  not,  write  to  the  Free  Software
00021    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022    USA
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     //get the book settings
00063     $book_id = WebApp::getSVar('docbook->book_id');
00064     $lng = WebApp::getSVar('docbook->lng');
00065     $node_path = WebApp::getSVar('docbook->node_path');
00066 
00067     //generate a page_id for the current node
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         //notify admins of the book about the new notes;
00075         $notify = 'true';
00076         //get a list of emails of the admins of the book
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     //notes are approved immediatly
00090     $unmoderated = (WEBNOTES_APPROVE=='true' ? 'false' : 'true');
00091 
00092     //a user can moderate the notes of the node
00093     //if he has approve rights on the node
00094     $approve = WebApp::getVar('can_approve');
00095 
00096     //a user can admin webnotes if he is admin of the book
00097     $admin = WebApp::getVar('is_admin'); 
00098 
00099     //he can admin the notes for all the nodes of the book 
00100     $admin_pageid_filter = "page_id LIKE '$book_id/%'";
00101 
00102     //set the parameters of the webnotes
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     //set the database parameters
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 ?>

Generated on Wed Jan 9 08:27:32 2008 for DokBookWiki by  doxygen 1.5.2