Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Pkg.php with up and down function - almost there

    Scheduled Pinned Locked Moved pfSense Packages
    39 Posts 5 Posters 9.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dvserg
      last edited by

      I think you need to add the top bar with the button APPLY, as in the firewall rules when exists the changes.
      Such changes must be considered independently for each xml package ( If I understand correctly )

      Resunc function possible take from the 'custom_php_resync_config_command' section of current xml file ( as ?xml=squid_nac.xml )

      SquidGuardDoc EN  RU Tutorial
      Localization ru_PFSense

      1 Reply Last reply Reply Quote 0
      • marcellocM
        marcelloc
        last edited by

        @dvserg:

        Resunc function possible take from the 'custom_php_resync_config_command' section of current xml file ( as ?xml=squid_nac.xml )

        Yes, i saw that.
        The part I could not get is how read it or call it on pkg.php

        Thanks for your help.

        Treinamentos de Elite: http://sys-squad.com

        Help a community developer! ;D

        1 Reply Last reply Reply Quote 0
        • D
          dvserg
          last edited by

          This is XML already imported to the $pkg value

          $xml = $_REQUEST['xml'];
          
          if($xml == "") {
          	print_info_box_np(gettext("ERROR: No package defined."));
          	exit;
          } else {
          	if(file_exists("/usr/local/pkg/" . $xml))
          		$pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
          	else {
          		echo "File not found " . htmlspecialchars($xml);
          		exit;
          	}
          }
          

          And all sources from this package must be already included

          if ($pkg['include_file'] != "") {
          	require_once($pkg['include_file']);
          }
          

          You can call resync function probable as

          
          if ($pkg['custom_php_resync_config_command']) eval ("{$pkg['custom_php_resync_config_command']}");
          
          

          This information is suitable to this topic?

          SquidGuardDoc EN  RU Tutorial
          Localization ru_PFSense

          1 Reply Last reply Reply Quote 0
          • marcellocM
            marcelloc
            last edited by

            @dvserg:

            This information is suitable to this topic?

            If helps me finishing it, yes  :)

            I'll try it.

            thanks a lot.

            Treinamentos de Elite: http://sys-squad.com

            Help a community developer! ;D

            1 Reply Last reply Reply Quote 0
            • N
              Nachtfalke
              last edited by

              If this will work and is then automatically available for every package I love it!
              This is really really usefull for freeradius package because you sometimes have to rearrange the entries in users file.

              Greate job marcello and thank you very much for the help dvserg ! :)

              That is one of many points because I love pfsense and the community!

              1 Reply Last reply Reply Quote 0
              • D
                dvserg
                last edited by

                I think it is useful to introduce it as an 'order' option in the xml for pkg tables.

                SquidGuardDoc EN  RU Tutorial
                Localization ru_PFSense

                1 Reply Last reply Reply Quote 0
                • marcellocM
                  marcelloc
                  last edited by

                  @dvserg:

                  I think it is useful to introduce it as an 'order' option in the xml for pkg tables.

                  Second great idea  :)

                  Treinamentos de Elite: http://sys-squad.com

                  Help a community developer! ;D

                  1 Reply Last reply Reply Quote 0
                  • marcellocM
                    marcelloc
                    last edited by

                    @dvserg:

                    I think it is useful to introduce it as an 'order' option in the xml for pkg tables.

                    Included on this version  :)

                    To use it, set one of them on  <adddeleteeditpagefields>xml part
                    <movable>arrow</movable> to show arrow characters
                    or
                    <movable>text</movable> to show text

                    sample:

                    	 <adddeleteeditpagefields><columnitem><fielddescr>Status</fielddescr>
                    			<fieldname>enable</fieldname></columnitem> 
                    		 <columnitem><fielddescr>action</fielddescr>
                    			<fieldname>action</fieldname></columnitem> 
                    		 <columnitem><fielddescr>local ID</fielddescr>
                    			<fieldname>localid</fieldname></columnitem> 
                    		 <columnitem><fielddescr>Description</fielddescr>
                    			<fieldname>description</fieldname></columnitem> 
                    		<movable>arrow</movable>
                    
                    Still missing the save part.</adddeleteeditpagefields> 
                    ```</adddeleteeditpagefields>

                    Treinamentos de Elite: http://sys-squad.com

                    Help a community developer! ;D

                    1 Reply Last reply Reply Quote 0
                    • marcellocM
                      marcelloc
                      last edited by

                      save part included  :)

                      Backup your pkg.php file and download pkg.php modified from here(renamed to pkg.txt)

                      the xml new args for adddeleteeditpagefields

                      are <movable>arrow</movable> or <movable>text</movable>

                      inside <columnitem>, you can include <encoding>base64</encoding> to show base64 fields.

                      All test are wellcome</columnitem>

                      Treinamentos de Elite: http://sys-squad.com

                      Help a community developer! ;D

                      1 Reply Last reply Reply Quote 0
                      • N
                        Nachtfalke
                        last edited by

                        Hi Marcello,

                        I tried with your new pkg.php file and modified some of my .xml in freeradius.
                        The GUI is working, moving the lines is working, too - but - how can I save it !?!

                        Thank you. :)

                        clients.jpg
                        clients.jpg_thumb

                        1 Reply Last reply Reply Quote 0
                        • C
                          ccesario
                          last edited by

                          Hi Marcello..

                          I tested this in others browser too… And all working!

                          • Chromium 18.0.1025.151

                          • Firefox 12.0

                          • IE 9.0.8112.16421

                          • Nokia BrowserNG/1.1.4

                          • Chrome 19.0.1084.46

                          att,

                          order.png
                          order.png_thumb

                          Carlos

                          1 Reply Last reply Reply Quote 0
                          • C
                            ccesario
                            last edited by

                            @Nachtfalke:

                            Hi Marcello,

                            I tried with your new pkg.php file and modified some of my .xml in freeradius.
                            The GUI is working, moving the lines is working, too - but - how can I save it !?!

                            Thank you. :)

                            Nachtfalke,

                            Its  attached the image with save button detail :)

                            order.png
                            order.png_thumb

                            Carlos

                            1 Reply Last reply Reply Quote 0
                            • N
                              Nachtfalke
                              last edited by

                              @ccesario:

                              (…)
                              Nachtfalke,

                              Its  attached the image with save button detail :)

                              Ooops  ::)
                              Now I got it! And it is working as it should. Really nice to see that feature working :-)

                              Some questions: ;)
                              I know, it depends on the number of entries but is there a plan to improve this feature so that I am able to move a line faster to the top than just always one line after another ? I think about something like it is done in firewall rules ?

                              Is it possible to implement a feature that allows us to sort the entries (descending, ascending by name, or by IP or something else ?) Just sorting on the GUI - not re-arrange them it the config-files ?

                              1 Reply Last reply Reply Quote 0
                              • marcellocM
                                marcelloc
                                last edited by

                                The sort feature is already on original pkg.PHP code.
                                The movable feature is different from rules code. I will need some rewrites and time

                                Treinamentos de Elite: http://sys-squad.com

                                Help a community developer! ;D

                                1 Reply Last reply Reply Quote 0
                                • N
                                  Nachtfalke
                                  last edited by

                                  @marcelloc:

                                  The sort feature is already on original pkg.PHP code.

                                  It's not working for me. Do I have to add some XML code to use it ?
                                  For example on freeradius users I want to click on "username" and then get all the usernames sorted ascending. Same with VLAN ID and so on.

                                  @marcelloc:

                                  The movable feature is different from rules code. I will need some rewrites and time

                                  Great. The most important and most helpful thing for me is the possibility to move items up and down.
                                  The rest is just for better handling :-)

                                  1 Reply Last reply Reply Quote 0
                                  • marcellocM
                                    marcelloc
                                    last edited by

                                    @Nachtfalke:

                                    It's not working for me. Do I have to add some XML code to use it ?

                                    Include this field on your xml

                                     <field><fielddescr>sortable</fielddescr>
                                    		<fieldname>sortable</fieldname>
                                    		<display_maximum_rows>10</display_maximum_rows>
                                    		<type>sorting</type>
                                    		 <include_filtering_inputbox><sortablefields><name>Local id</name>
                                    				<fieldname>localid</fieldname> 
                                    			 <name>Action</name>
                                    				<fieldname>action</fieldname></sortablefields></include_filtering_inputbox></field> 
                                    

                                    In this example, I'm filtering localid and action fields.

                                    Update the pkg.php again, I`ve pushed a fix to avoid movable and sortable enabled on the same xml until I find a way to use both together .

                                    EDIT:

                                    All features are working together :)
                                    I've include the to adddeleteeditpagefields as well domtt tittles.

                                    I think it's done!

                                    att,
                                    Marcello Coutinho

                                    Treinamentos de Elite: http://sys-squad.com

                                    Help a community developer! ;D

                                    1 Reply Last reply Reply Quote 0
                                    • marcellocM
                                      marcelloc
                                      last edited by

                                      I think we got it!  :D

                                      latest code using template images.

                                      **<adddeleteeditpagefields></adddeleteeditpagefields>**new features on this code:

                                      • To enable movable table and buttons, just add <movable>on</movable>

                                      • To add a ? button besides + button with a description for this list, include <description>My list description</description>

                                      new features on this code:

                                      • To customize checkbox display info on list, use <listmodeon>enable or selected text here</listmodeon> and <listmodeoff>disable or off text here</listmodeoff>

                                      • To show base64 fields on list, use <encoding>base64</encoding>

                                      gui_movable_1.png
                                      gui_movable_1.png_thumb
                                      gui_movable_2.png
                                      gui_movable_2.png_thumb

                                      Treinamentos de Elite: http://sys-squad.com

                                      Help a community developer! ;D

                                      1 Reply Last reply Reply Quote 0
                                      • D
                                        dvserg
                                        last edited by

                                        Great job, marcelloc !
                                        Do you think it might be better to increase the interval between e/x, and arrows?

                                        SquidGuardDoc EN  RU Tutorial
                                        Localization ru_PFSense

                                        1 Reply Last reply Reply Quote 0
                                        • marcellocM
                                          marcelloc
                                          last edited by

                                          @dvserg:

                                          Great job, marcelloc !
                                          Do you think it might be better to increase the interval between e/x, and arrows?

                                          Thanks, you've helped a lot explaining the code  :)

                                          I've included all buttons on a single < td > to leave more space to fields.
                                          The remove button has an alert to prevent mistakes.

                                          what do you think? Did you had time to test it on squidguard?

                                          Treinamentos de Elite: http://sys-squad.com

                                          Help a community developer! ;D

                                          1 Reply Last reply Reply Quote 0
                                          • D
                                            dvserg
                                            last edited by

                                            @marcelloc:

                                            Thanks, you've helped a lot explaining the code  :)
                                            I've included all buttons on a single < td > to leave more space to fields.
                                            The remove button has an alert to prevent mistakes.
                                            what do you think? Did you had time to test it on squidguard?

                                            I want to do it in the next few days as soon as I find free time

                                            SquidGuardDoc EN  RU Tutorial
                                            Localization ru_PFSense

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.