[phpwebapp-commits] CVS: top10/templates/edituser edituser.php,NONE,1.1.2.1 edituser.js,NONE,1.1.2.1
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2004-02-02 13:57:00
|
Update of /cvsroot/phpwebapp/top10/templates/edituser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3389/templates/edituser Added Files: Tag: maisp edituser.php edituser.js edituser.html edituser.db edituser.css Log Message: --- NEW FILE: edituser.php --- <?php /* This file is part of Top10. Top10 is a web application for ranking and evaluating free software projects. Copyright (C) 2003, 2004 Dashamir Hoxha, das...@us... Top10 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Top10 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Top10; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ class edituser extends WebObject { function init() { $this->addSVar("mode", "add"); //'add'|'edit' $this->addSVar("username", UNDEFINED); } function on_add($event_args) { WebApp::execDBCmd("adduser", $event_args); WebApp::setSVar("users_rs->recount", "true"); } function on_save($event_args) { WebApp::execDBCmd("saveuserdata", $event_args); } function onRender() { $mode = $this->getSVar("mode"); if ($mode=='edit') { $rs = WebApp::openRS("getuser"); WebApp::addVars($rs->Fields()); } else { WebApp::addVars(array("realname" => "", "email" => "", "homepage" => "", "status" => "private")); } } } ?> --- NEW FILE: edituser.js --- // -*-C-*- //tell emacs to use C mode /* This file is part of Top10. Top10 is a web application for ranking and evaluating free software projects. Copyright (C) 2003, 2004 Dashamir Hoxha, das...@us... Top10 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Top10 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Top10; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ function adduser() { var form = document.edituser; var username = form.username.value; var realname = form.realname.value; var email = form.email.value; var homepage = form.homepage.value; var status = form.status.value; if (username=='') { alert("Please give a username."); form.username.focus(); return; } var event_args = "username=" + username + ";" + "realname=" + realname + ";" + "email=" + email + ";" + "homepage=" + homepage + ";" + "status=" + status; SendEvent("edituser", "add", event_args); } function saveuser() { var form = document.edituser; var realname = form.realname.value; var email = form.email.value; var homepage = form.homepage.value; var status = form.status.value; var event_args = "realname=" + realname + ";" + "email=" + email + ";" + "homepage=" + homepage + ";" + "status=" + status; SendEvent("edituser", "save", event_args); } --- NEW FILE: edituser.html --- <WebBox ID="edituser"> <If condition="'{{mode}}'=='add'"> <h4>Add New User:</h4> </If> <If condition="'{{mode}}'=='edit'"> <h4>Edit User Data:</h4> </If> <table width="100%" cellspacing="1" cellpadding="2" bgcolor="#dddddd"> <form name="edituser" onsubmit="return false;"> <tr> <td bgcolor="#eeeeee" align="center">username</td> <td bgcolor="#eeeeee" align="center">Real Name</td> <td bgcolor="#eeeeee" align="center">E-mail</td> <td bgcolor="#eeeeee" align="center">Homepage</td> <td bgcolor="#eeeeee" align="center">Status</td> <td bgcolor="#eeeeee" align="center"></td> </tr> <tr> <td bgcolor="white"> <If condition="'{{mode}}'=='add'"> <input type="text" name="username" value="" class="textbox" size="10" onfocus="select()" /> </If> <If condition="'{{mode}}'=='edit'"> {{username}} </If> </td> <td bgcolor="white"> <input type="text" name="realname" value="{{realname}}" class="textbox" size="20" onfocus="select()" /> </td> <td bgcolor="white"> <input type="text" name="email" value="{{email}}" class="textbox" size="20" onfocus="select()" /> </td> <td bgcolor="white"> <input type="text" name="homepage" value="{{homepage}}" class="textbox" size="20" onfocus="select()" /> </td> <td bgcolor="white" align="center"> <input type="text" name="status" value="{{status}}" class="textbox" size="5" onfocus="select()" /> </td> <td bgcolor="white" align="center"> <If condition="'{{mode}}'=='add'"> <a class="button" href="javascript:adduser()">Add</a> </If> <If condition="'{{mode}}'=='edit'"> <a class="button" href="javascript:saveuser()">Save</a> </If> </td> </tr> </form> </table> </WebBox> --- NEW FILE: edituser.db --- <!--# -*-SQL-*- #tell emacs to use the SQL mode #--> <Recordset ID="getuser"> <Query> SELECT * FROM users WHERE username = '{{username}}' </Query> </Recordset> <dbCommand ID="adduser"> <Query> INSERT INTO users SET username = '{{username}}', realname = '{{realname}}', email = '{{email}}', homepage = '{{homepage}}', status = '{{status}}' </Query> </dbCommand> <dbCommand ID="saveuserdata"> <Query> UPDATE users SET realname = '{{realname}}', email = '{{email}}', homepage = '{{homepage}}', status = '{{status}}' WHERE username = '{{username}}' </Query> </dbCommand> --- NEW FILE: edituser.css --- .textbox { border: none; font-family: arial, helvetica, sans-se; font-size: 12pt; color: #000044; } |