cvs: bugtracker /template/generic/admin index.php /template/generic/admin/user index.php karma.php
| From: | Barry Carlyon | Date: | Fri, 15 Aug 2008 14:58:45 +0000 |
| Subject: | cvs: bugtracker /template/generic/admin index.php /template/generic/admin/user index.php karma.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-2438@lists.php.net to get a copy of this message | ||
bcarlyon Fri Aug 15 14:58:45 2008 UTC
Added files:
/bugtracker/template/generic/admin/user index.php karma.php
Modified files:
/bugtracker/template/generic/admin index.php
Log:
You can now alter karma in the admin control.
Need to add email related user about promotion/new karma
http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/index.php?r1=1.10&r2=1.11&diff_format=u Index: bugtracker/template/generic/admin/index.php diff -u bugtracker/template/generic/admin/index.php:1.10 bugtracker/template/generic/admin/index.php:1.11 --- bugtracker/template/generic/admin/index.php:1.10 Thu Aug 14 14:41:53 2008 +++ bugtracker/template/generic/admin/index.php Fri Aug 15 14:58:45 2008 @@ -37,7 +37,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: index.php,v 1.10 2008/08/14 14:41:53 bcarlyon Exp $ +* @version CVS: $Id: index.php,v 1.11 2008/08/15 14:58:45 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ @@ -51,7 +51,7 @@ $content = 'What would you like to do today?'; $content .= '<ul> -<li>Update Karma</li> +<li><a href="/admin/user/karma/" title="Karma">Update Karma</a></li> <li>Edit User</li> <li><a href="/admin/cache/alter/" title="Change">Change Cache</a></li> <li><a href="/admin/cache/purge/" title="Purge">Purge and Regenerate the Cache</a></li> http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/user/index.php?view=markup&rev=1.1 Index: bugtracker/template/generic/admin/user/index.php +++ bugtracker/template/generic/admin/user/index.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:*/ /** * template/generic/admin/user/index.php * User edit stuff * * Copyright (c) 2008, Barry Carlyon <bcarlyon@php.net> * All rights reserved. * * PHP versions 5 * * LICENSE: Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @category BugTracking * @package GSoC Bugtracker * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: index.php,v 1.1 2008/08/15 14:58:45 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ $method = loadvar('method'); $method = str_replace('/','',$method); if (empty($method)) { $template->meta_refresh(); trigger_error('No method',E_USER_ERROR); } elseif ($user->logged_in && $user->check_karma('bugz_admin')) { if (is_file(dirname(__FILE__) . '/' . $method . '.php')) { $content = '<a href="/admin/" title="Admin Index" style="display: block; text-align: right;">Admin Index</a>'; include($method . '.php'); } else { $template->meta_refresh(); trigger_error('No valid method file', E_USER_ERROR); } } else { $session->end_session(); } http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/user/karma.php?view=markup&rev=1.1 Index: bugtracker/template/generic/admin/user/karma.php +++ bugtracker/template/generic/admin/user/karma.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:*/ /** * template/generic/admin/user/karma.php * Its the karma control for adding karma to users * * Copyright (c) 2008, Barry Carlyon <bcarlyon@php.net> * All rights reserved. * * PHP versions 5 * * LICENSE: Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @category BugTracking * @package GSoC Bugtracker * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: karma.php,v 1.1 2008/08/15 14:58:45 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ $resource = loadvar('resource'); $resource = str_replace('/','',$resource); $method = loadvar('method'); $method = str_replace('/','',$method); $template->page_title .= 'Karma!'; $template->content_title = 'Karma Updates'; $content = ''; if ($resource == 'add') { $add_handle = loadvar('addhandle'); $add_level = loadvar('addlevel'); if ($add_handle && $add_level) { $query = 'SELECT handle FROM ' . KARMA_TABLE . ' WHERE handle = \'' . $db->protect_data($add_handle) . '\' AND level = \'' . $db->protect_data($add_level) . '\''; $db->get_data($query); if ($db->total_rows) { $template->meta_refresh(); trigger_error('The Karma Level has already been assigned to this user', E_USER_ERROR); } $query = 'INSERT INTO ' . KARMA_TABLE . '(handle,level,granted_by,granted_at) VALUES (\'' . $db->protect_data($add_handle) . '\', \'' . $db->protect_data($add_level) . '\', \'' . $user->handle . '\', NOW())'; $db->get_data($query); if ($db->affected_rows) { $content .= '<div id="success">Karma Added Successully</div>'; } else { $template->meta_refresh(); trigger_error('The Karma Level failed to be assinged', E_USER_ERROR); } } } elseif ($method == 'del' && $method) { $query = 'DELETE FROM ' . KARMA_TABLE . ' WHERE ref_id = ' . $resource; $db->get_data($query); if ($db->affected_rows) { $content .= '<div id="success">Karma Removed Successfully</div>'; } else { $content .= '<div id="error">Karma Remove Error</div>'; } } $content .= '<form action="/admin/user/karma/add/" method="post" >'; $content .= 'Assign New Karma<br /><table>'; $content .= '<tr><td><select name="addhandle">'; $content .= '<option value="">--Select--</option>'; $content .= $cache->convert('users','selectvar',''); $content .= '</select></td><td><select name="addlevel">'; $content .= '<option value="">--Select--</option>'; $content .= $cache->convert('karma_type','selectvar',''); $content .= '</select></td><td><input type="submit" value="Go" /></tr>'; $content .= '</table></form>'; //cant use the cache we're doing a left join $query = 'SELECT k.ref_id, u.handle, k.level, k.granted_by, k.granted_at FROM ' . USER_TABLE . ' u LEFT JOIN ' . KARMA_TABLE . ' k on (u.handle = k.handle) WHERE u.account_type = ' . USER . ' ORDER BY handle ASC'; $db->get_data($query); $content .= '<br />Currently assigned Karma<br />'; $content .= '<table>'; $content .= '<tr><th>Handle</th><th>Level</th></tr>'; $prev = ''; $loop = '<tr><td>{DSP_HANDLE}</td><td>{DSP_LEVEL}</td><td>{DSP_GRANTED_BY}</td><td>{DSP_GRANTED_AT}</td><td><a href="/admin/user/karma/del/{DSP_REF_ID}" title="Delete">Delete</a></td></tr>'; $rows = array(); while ($row = $db->fetch_row()) { $rows[] = $row; } $content .= $template->loop($rows, $loop); $content .= '</table>'; $template->prehtml = $content;
http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/index.php?r1=1.10&r2=1.11&diff_format=u Index: bugtracker/template/generic/admin/index.php diff -u bugtracker/template/generic/admin/index.php:1.10 bugtracker/template/generic/admin/index.php:1.11 --- bugtracker/template/generic/admin/index.php:1.10 Thu Aug 14 14:41:53 2008 +++ bugtracker/template/generic/admin/index.php Fri Aug 15 14:58:45 2008 @@ -37,7 +37,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: index.php,v 1.10 2008/08/14 14:41:53 bcarlyon Exp $ +* @version CVS: $Id: index.php,v 1.11 2008/08/15 14:58:45 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ @@ -51,7 +51,7 @@ $content = 'What would you like to do today?'; $content .= '<ul> -<li>Update Karma</li> +<li><a href="/admin/user/karma/" title="Karma">Update Karma</a></li> <li>Edit User</li> <li><a href="/admin/cache/alter/" title="Change">Change Cache</a></li> <li><a href="/admin/cache/purge/" title="Purge">Purge and Regenerate the Cache</a></li> http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/user/index.php?view=markup&rev=1.1 Index: bugtracker/template/generic/admin/user/index.php +++ bugtracker/template/generic/admin/user/index.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:*/ /** * template/generic/admin/user/index.php * User edit stuff * * Copyright (c) 2008, Barry Carlyon <bcarlyon@php.net> * All rights reserved. * * PHP versions 5 * * LICENSE: Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @category BugTracking * @package GSoC Bugtracker * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: index.php,v 1.1 2008/08/15 14:58:45 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ $method = loadvar('method'); $method = str_replace('/','',$method); if (empty($method)) { $template->meta_refresh(); trigger_error('No method',E_USER_ERROR); } elseif ($user->logged_in && $user->check_karma('bugz_admin')) { if (is_file(dirname(__FILE__) . '/' . $method . '.php')) { $content = '<a href="/admin/" title="Admin Index" style="display: block; text-align: right;">Admin Index</a>'; include($method . '.php'); } else { $template->meta_refresh(); trigger_error('No valid method file', E_USER_ERROR); } } else { $session->end_session(); } http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/user/karma.php?view=markup&rev=1.1 Index: bugtracker/template/generic/admin/user/karma.php +++ bugtracker/template/generic/admin/user/karma.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:*/ /** * template/generic/admin/user/karma.php * Its the karma control for adding karma to users * * Copyright (c) 2008, Barry Carlyon <bcarlyon@php.net> * All rights reserved. * * PHP versions 5 * * LICENSE: Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @category BugTracking * @package GSoC Bugtracker * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: karma.php,v 1.1 2008/08/15 14:58:45 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ $resource = loadvar('resource'); $resource = str_replace('/','',$resource); $method = loadvar('method'); $method = str_replace('/','',$method); $template->page_title .= 'Karma!'; $template->content_title = 'Karma Updates'; $content = ''; if ($resource == 'add') { $add_handle = loadvar('addhandle'); $add_level = loadvar('addlevel'); if ($add_handle && $add_level) { $query = 'SELECT handle FROM ' . KARMA_TABLE . ' WHERE handle = \'' . $db->protect_data($add_handle) . '\' AND level = \'' . $db->protect_data($add_level) . '\''; $db->get_data($query); if ($db->total_rows) { $template->meta_refresh(); trigger_error('The Karma Level has already been assigned to this user', E_USER_ERROR); } $query = 'INSERT INTO ' . KARMA_TABLE . '(handle,level,granted_by,granted_at) VALUES (\'' . $db->protect_data($add_handle) . '\', \'' . $db->protect_data($add_level) . '\', \'' . $user->handle . '\', NOW())'; $db->get_data($query); if ($db->affected_rows) { $content .= '<div id="success">Karma Added Successully</div>'; } else { $template->meta_refresh(); trigger_error('The Karma Level failed to be assinged', E_USER_ERROR); } } } elseif ($method == 'del' && $method) { $query = 'DELETE FROM ' . KARMA_TABLE . ' WHERE ref_id = ' . $resource; $db->get_data($query); if ($db->affected_rows) { $content .= '<div id="success">Karma Removed Successfully</div>'; } else { $content .= '<div id="error">Karma Remove Error</div>'; } } $content .= '<form action="/admin/user/karma/add/" method="post" >'; $content .= 'Assign New Karma<br /><table>'; $content .= '<tr><td><select name="addhandle">'; $content .= '<option value="">--Select--</option>'; $content .= $cache->convert('users','selectvar',''); $content .= '</select></td><td><select name="addlevel">'; $content .= '<option value="">--Select--</option>'; $content .= $cache->convert('karma_type','selectvar',''); $content .= '</select></td><td><input type="submit" value="Go" /></tr>'; $content .= '</table></form>'; //cant use the cache we're doing a left join $query = 'SELECT k.ref_id, u.handle, k.level, k.granted_by, k.granted_at FROM ' . USER_TABLE . ' u LEFT JOIN ' . KARMA_TABLE . ' k on (u.handle = k.handle) WHERE u.account_type = ' . USER . ' ORDER BY handle ASC'; $db->get_data($query); $content .= '<br />Currently assigned Karma<br />'; $content .= '<table>'; $content .= '<tr><th>Handle</th><th>Level</th></tr>'; $prev = ''; $loop = '<tr><td>{DSP_HANDLE}</td><td>{DSP_LEVEL}</td><td>{DSP_GRANTED_BY}</td><td>{DSP_GRANTED_AT}</td><td><a href="/admin/user/karma/del/{DSP_REF_ID}" title="Delete">Delete</a></td></tr>'; $rows = array(); while ($row = $db->fetch_row()) { $rows[] = $row; } $content .= $template->loop($rows, $loop); $content .= '</table>'; $template->prehtml = $content;