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 uEdit extends WebObject
00031 {
00033 function on_save($event_args)
00034 {
00035 $edit_rights = $event_args['edit_rights'];
00036
00037
00038
00039
00040
00041 $username = WebApp::getSVar('uList->currentUser');
00042 $book_id = WebApp::getSVar('books->selected_book');
00043 $fname = "templates/admin/access_rights/$book_id/$username";
00044 write_file($fname, $edit_rights);
00045 }
00046
00047 function onRender()
00048 {
00049 $this->add_user_data();
00050 $this->add_edit_rights();
00051 $this->add_rs_langs();
00052 $this->add_rs_nodes();
00053 }
00054
00056 function add_user_data()
00057 {
00058 include_once SCRIPTS.'user_data.php';
00059 $username = WebApp::getSVar('uList->currentUser');
00060 $user_data = get_user_data($username);
00061 unset($user_data['password']);
00062 WebApp::addVars($user_data);
00063 }
00064
00065 function add_edit_rights()
00066 {
00067 $username = WebApp::getSVar('uList->currentUser');
00068 if ($username==UNDEFINED)
00069 {
00070 $edit_rights = '';
00071 }
00072 else
00073 {
00074
00075 $book_id = WebApp::getSVar('books->selected_book');
00076 $cmd = SCRIPTS."books/get_user_rights.sh $book_id $username";
00077 $edit_rights = shell($cmd);
00078 if (ereg('No such file or directory', $edit_rights))
00079 $edit_rights = '';
00080 }
00081 if ($edit_rights=='') $edit_rights = ' ';
00082 WebApp::addVar('edit_rights', $edit_rights);
00083 }
00084
00085 function add_rs_langs()
00086 {
00087 $rs = new EditableRS('langs');
00088
00089 $book_id = WebApp::getSVar('books->selected_book');
00090 $arr_langs = $this->get_langs($book_id);
00091
00092 for ($i=0; $i < sizeof($arr_langs); $i++)
00093 {
00094 $lng = $arr_langs[$i];
00095 $rs->addRec(array('lng'=>$lng));
00096 }
00097
00098 global $webPage;
00099 $webPage->addRecordset($rs);
00100 }
00101
00102 function add_rs_nodes()
00103 {
00104
00105 $book_id = WebApp::getSVar('books->selected_book');
00106 $arr_langs = $this->get_langs($book_id);
00107 $lng = $arr_langs[0];
00108 $index_xml = BOOKS."$book_id/$lng/index.xml";
00109 $nodes = shell(SCRIPTS."books/get_book_nodes.sh '$index_xml'");
00110
00111
00112 $rs = new EditableRS('nodes');
00113 $arr_nodes = explode("\n", $nodes);
00114 for ($i=0; $i < sizeof($arr_nodes); $i++)
00115 {
00116 $node_id = $arr_nodes[$i];
00117 $rs->addRec(array('node_id'=>$node_id));
00118 }
00119
00120
00121 global $webPage;
00122 $webPage->addRecordset($rs);
00123 }
00124
00129 function get_langs($book_id)
00130 {
00131 $book_path = BOOKS.$book_id.'/';
00132 if (!file_exists($book_path)) return array();
00133
00134 $langs = shell("ls $book_path");
00135 $arr_langs = explode("\n", chop($langs));
00136
00137 return $arr_langs;
00138 }
00139 }
00140 ?>