Module: nagvis
Branch: master
Commit: c86ea776d1af88199426054272bf14bc9e5304f9
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=c86ea776d1af88199426054272bf14bc9e5304f9

Author: LaMi <[email protected]>
Date:   Fri Jan 15 15:07:00 2010 +0100

Added missing shape mangement files

---

 share/server/core/classes/CoreModManageShapes.php  |  116 ++++++++++++++++++++
 share/server/core/classes/WuiViewManageShapes.php  |   70 ++++++++++++
 .../templates/default.wuiManageShapes.html         |   30 +++++
 3 files changed, 216 insertions(+), 0 deletions(-)

diff --git a/share/server/core/classes/CoreModManageShapes.php 
b/share/server/core/classes/CoreModManageShapes.php
new file mode 100644
index 0000000..04d9351
--- /dev/null
+++ b/share/server/core/classes/CoreModManageShapes.php
@@ -0,0 +1,116 @@
+<?php
+/*******************************************************************************
+ *
+ * CoreModManageShapes.php - Core Map module to manage shapes in WUI
+ *
+ * Copyright (c) 2004-2010 NagVis Project (Contact: [email protected])
+ *
+ * License:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ 
******************************************************************************/
+
+/**
+ * @author Lars Michelsen <[email protected]>
+ */
+class CoreModManageShapes extends CoreModule {
+       private $name = null;
+       
+       public function __construct(GlobalCore $CORE) {
+               $this->CORE = $CORE;
+               
+               // Register valid actions
+               $this->aActions = Array(
+                       // WUI specific actions
+                       'view' => REQUIRES_AUTHORISATION,
+                       'doUpload' => REQUIRES_AUTHORISATION,
+                       'doDelete' => REQUIRES_AUTHORISATION,
+               );
+       }
+       
+       public function handleAction() {
+               $sReturn = '';
+               
+               if($this->offersAction($this->sAction)) {
+                       switch($this->sAction) {
+                               case 'view':
+                                       $VIEW = new 
WuiViewManageShapes($this->AUTHENTICATION, $this->AUTHORISATION);
+                                       $sReturn = json_encode(Array('code' => 
$VIEW->parse()));
+                               break;
+                               case 'doDelete':
+                                       $aReturn = 
$this->handleResponseDelete();
+                                       
+                                       if($aReturn !== false) {
+                                               // Try to create the map
+                                               if($this->doDelete($aReturn)) {
+                                                       new 
GlobalMessage('NOTE', $this->CORE->getLang()->getText('The shape has been 
deleted.'),
+                                                                         null,
+                                                                         null,
+                                                                         1);
+                                                       $sReturn = '';
+                                               } else {
+                                                       new 
GlobalMessage('ERROR', $this->CORE->getLang()->getText('The shape could not be 
deleted.'));
+                                                       $sReturn = '';
+                                               }
+                                       } else {
+                                               new GlobalMessage('ERROR', 
$this->CORE->getLang()->getText('You entered invalid information.'));
+                                               $sReturn = '';
+                                       }
+                               break;
+                       }
+               }
+               
+               return $sReturn;
+       }
+       
+       private function doDelete($a) {
+               if(file_exists($this->CORE->getMainCfg()->getValue('paths', 
'shape').$a['image'])) {
+                       if(unlink($this->CORE->getMainCfg()->getValue('paths', 
'shape').$a['image'])) {
+                               return true;
+                       } else {
+                               return false;
+                       }
+               } else {
+                       return false;
+               }
+       }
+       
+       private function handleResponseDelete() {
+               $bValid = true;
+               // Validate the response
+               
+               $FHANDLER = new CoreRequestHandler($_POST);
+               
+               // Check for needed params
+               if($bValid && !$FHANDLER->isSetAndNotEmpty('image')) {
+                       $bValid = false;
+               }
+               
+               // Check if the map exists
+               if($bValid && !in_array($FHANDLER->get('image'), 
$this->CORE->getAvailableShapes())) {
+                       new GlobalMessage('ERROR', 
$this->CORE->getLang()->getText('The shape does not exist.'));
+                       $bValid = false;
+               }
+               
+               // Store response data
+               if($bValid === true) {
+                       // Return the data
+                       return Array('image' => $FHANDLER->get('image'));
+               } else {
+                       return false;
+               }
+       }
+}
+?>
diff --git a/share/server/core/classes/WuiViewManageShapes.php 
b/share/server/core/classes/WuiViewManageShapes.php
new file mode 100644
index 0000000..c86894c
--- /dev/null
+++ b/share/server/core/classes/WuiViewManageShapes.php
@@ -0,0 +1,70 @@
+<?php
+/*****************************************************************************
+ *
+ * WuiViewManageShapes.php - Class to manage shapes
+ *
+ * Copyright (c) 2004-2010 NagVis Project (Contact: [email protected])
+ *
+ * License:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *****************************************************************************/
+ 
+/**
+ * @author     Lars Michelsen <[email protected]>
+ */
+class WuiViewManageShapes {
+       private $CORE;
+       private $AUTHENTICATION;
+       private $AUTHORISATION;
+       
+       /**
+        * Class Constructor
+        *
+        * @param       GlobalCore      $CORE
+        * @author      Lars Michelsen <[email protected]>
+        */
+       public function __construct(CoreAuthHandler $AUTHENTICATION, 
CoreAuthorisationHandler $AUTHORISATION) {
+               $this->CORE = GlobalCore::getInstance();
+               $this->AUTHENTICATION = $AUTHENTICATION;
+               $this->AUTHORISATION = $AUTHORISATION;
+       }
+       
+       /**
+        * Parses the information in html format
+        *
+        * @return      String  String with Html Code
+        * @author      Lars Michelsen <[email protected]>
+        */
+       public function parse() {
+               // Initialize template system
+               $TMPL = New CoreTemplateSystem($this->CORE);
+               $TMPLSYS = $TMPL->getTmplSys();
+               
+               $aData = Array(
+                       'htmlBase' => 
$this->CORE->getMainCfg()->getValue('paths', 'htmlbase'),
+                       'langUploadShape' => 
$this->CORE->getLang()->getText('uploadShape'),
+                       'langChoosePngImage' => 
$this->CORE->getLang()->getText('choosePngImage'),
+                       'langUpload' => 
$this->CORE->getLang()->getText('upload'),
+                       'langDeleteShape' => 
$this->CORE->getLang()->getText('deleteShape'),
+                       'langDelete' => 
$this->CORE->getLang()->getText('delete'),
+                       'shapes' => $this->CORE->getAvailableShapes(),
+               );
+               
+               // Build page based on the template file and the data array
+               return $TMPLSYS->get($TMPL->getTmplFile('default', 
'wuiManageShapes'), $aData);
+       }
+}
+?>
diff --git a/share/userfiles/templates/default.wuiManageShapes.html 
b/share/userfiles/templates/default.wuiManageShapes.html
new file mode 100644
index 0000000..86b3124
--- /dev/null
+++ b/share/userfiles/templates/default.wuiManageShapes.html
@@ -0,0 +1,30 @@
+<script type="text/javascript" 
src="{$htmlBase}/frontend/wui/js/ManageShapes.js"></script>
+
+<form name="shape_add" id="shape_add" method="POST" 
action="./form_handler.php?myaction=mgt_shape_add" 
enctype="multipart/form-data" onsubmit="return check_image_add();">
+<table name="mytable" class="mytable" id="table_shape_add">
+       <tr><th class="cat" colspan="2"><h2>{$langUploadShape}</h2></th></tr>
+       <input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" 
value="1000000" />
+       <tr><td class="tdlabel">{$langChoosePngImage}</td>
+       <td class="tdfield"><input type="file" name="shape_image" value="" 
/></td></tr>
+       <tr><td class="tdlabel" colspan="2" align="center"><input 
class="submit" type="submit" name="submit" id="commit" value="{$langUpload}" 
/></td></tr>
+</table>
+</form>
+
+<form name="shape_delete" id="shape_delete" method="POST" 
action="javascript:submitFrontendForm('{$htmlBase}/server/core/ajax_handler.php?mod=ManageShapes&amp;act=doDelete',
 'shape_delete');" enctype="" onsubmit="return check_image_delete();">
+<table name="mytable" class="mytable" id="table_shape_delete">
+       <tr><th class="cat" colspan="2"><h2>{$langDeleteShape}</h2></th></tr>
+       <tr>
+               <td class="tdlabel">{$langChoosePngImage}</td>
+               <td class="tdfield">
+                       <select id="image" name="image" onChange="" onBlur="">
+                               <option value=""></option>
+                               {foreach $shapes shape}
+                               <option value="{$shape}">{$shape}</option>
+                               {/foreach}
+                       </select>
+               </td>
+       </tr>
+       <script>toggleDefaultOption('image');</script>
+       <tr><td class="tdlabel" colspan="2" align="center"><input 
class="submit" type="submit" name="submit" id="commit" value="{$langDelete}" 
/></td></tr>
+</table>
+</form>


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to