Exemplo n.º 1
0
 public static function load_from_request()
 {
     $diagram = NULL;
     if (!isset($_POST['diagram']) && isset($_GET['erdiagram_id'])) {
         $diagram = ERDiagram::load($_GET['erdiagram_id']);
     } else {
         $diagram = new ERDiagram();
         if (isset($_POST['diagram']['id'])) {
             $diagram->id = (int) $_POST['diagram']['id'];
         }
         if (isset($_POST['diagram']['name'])) {
             $diagram->name = trim($_POST['diagram']['name']);
         }
         if (isset($_POST['diagram']['granted_groups'])) {
             $diagram->roles_with_privileges = array_merge($diagram->roles_with_privileges, $_POST['diagram']['granted_groups']);
         }
         if (isset($_POST['diagram']['granted_users'])) {
             $diagram->roles_with_privileges = array_merge($diagram->roles_with_privileges, $_POST['diagram']['granted_users']);
         }
         if (isset($_POST['diagram']['comment'])) {
             $diagram->comment = trim($_POST['diagram']['comment']);
         }
     }
     return $diagram;
 }
Exemplo n.º 2
0
 function drop()
 {
     global $misc;
     if (isset($_POST['cancel'])) {
         $this->redirect_action('default_action');
     }
     $this->connect_or_redirect();
     if (isset($_POST['erdiagram_id'])) {
         if (is_array($_POST['erdiagram_id'])) {
             $id_list = $_POST['erdiagram_id'];
         } else {
             $id_list = array($_POST['erdiagram_id']);
         }
         foreach ($id_list as $id) {
             $diagram = ERDiagram::load($id);
             if (!is_null($diagram)) {
                 $status = $diagram->drop();
                 if ($status == 0) {
                     $this->set_update_tree();
                     $this->add_message(sprintf('%s: %s<br />', htmlentities($diagram->name), $this->_('strerdiagramdropped')));
                 } else {
                     $this->add_message(sprintf('%s: %s<br />', htmlentities($diagram->name), $this->_('strerdiagramdroppedbad')));
                 }
             }
         }
         $this->redirect_action('default_action');
     }
     if (empty($_REQUEST['erdiagram_id']) && empty($_REQUEST['ma'])) {
         $this->add_message($this->_('strspecifyerdiagramtodrop'));
         $this->redirect_action('default_action');
     }
     $misc->printHeader($this->_('strerdiagrams'));
     $misc->printBody();
     $misc->printTrail('schema');
     $misc->printTabs('schema', 'default_action');
     $misc->printTitle($this->_('strdroperdiagram'));
     echo '<form action="plugin.php?plugin=' . $this->name . '" method="post">';
     if (isset($_REQUEST['ma'])) {
         foreach ($_REQUEST['ma'] as $v) {
             $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES));
             $diagram = ERDiagram::load($a['erdiagram_id']);
             if (!is_null($diagram)) {
                 echo '<p>' . sprintf($this->_('strconfdroperdiagram'), $misc->printVal($diagram->name)) . '</p>';
                 printf('<input type="hidden" name="erdiagram_id[]" value="%s" />', htmlspecialchars($a['erdiagram_id']));
             }
         }
     } else {
         $diagram = ERDiagram::load($_REQUEST['erdiagram_id']);
         if (!is_null($diagram)) {
             echo '<p>' . sprintf($this->_('strconfdroperdiagram'), $misc->printVal($diagram->name)) . '</p>';
             printf('<input type="hidden" name="erdiagram_id" value="%s" />', htmlspecialchars($_REQUEST['erdiagram_id']));
         }
     }
     // END if multi drop
     echo '<input type="hidden" name="action" value="drop" />';
     echo $misc->form;
     echo '<input type="submit" name="drop" value="' . $this->_('strdrop') . '" />';
     echo '<input type="submit" name="cancel" value="' . $this->_('strcancel') . '" />';
     echo '</form>';
 }