MobiMaps - How To Let Authors Save Location

Bugs
Jason
2011-08-28
2013-04-24
  • Jason

    Jason - 2011-08-28

    I needed a way to allow authors to use the mobimaps editor button to save the location to an article when editing the article in the frontend,  so I did a nice little hack and thought I would share.

    It seems to work, but I am not much of a php coder, so please tell me if I opened any security holes or if there is an easier way etc.

    So, here is how I did it…

    First I had to edit the editor button so that it would show in the front-end and not just the back-end…

    I edited  ../plugins/editors-xtd/mobimaps/mobimaps.php

    and on line  88: 

     if($content_id = JRequest::getVar('cid', null, '', 'array'))
            {
                $content_id = $content_id[0];
            }
            else 
            {
                if($content_id = JRequest::getVar('id', null, '', 'int'))
                {
                    // id successfully assigned
                }
                else
                {
                    return $button;
                }
            }
    

    I just commented it out so the button could show…

    /* if($content_id = JRequest::getVar('cid', null, '', 'array'))
            {
                $content_id = $content_id[0];
            }
            else 
            {
                if($content_id = JRequest::getVar('id', null, '', 'int'))
                {
                    // id successfully assigned
                }
                else
                {
                    return $button;
                }
            }
            */
    

    Then I edited

    Finally, now that I could use mobimaps, the only problem is it would not let me save the location, so..

    I  edited ../plugins/editors-ext/mobimaps/controller.php

    changed line 138:

    else
            {
    
                $msg = JText::_('COM_MOBIMAPS_YOU_DO_NOT_HAVE_ENOUGH_RIGHTS_TO').' '.JText::_('COM_MOBIMAPS_SAVE');
    
                     }
    

    to this:

    else
            {
                /*
                $msg = JText::_('COM_MOBIMAPS_YOU_DO_NOT_HAVE_ENOUGH_RIGHTS_TO').' '.JText::_('COM_MOBIMAPS_SAVE');
                */
                //making authors able to save
                require_once JPATH_COMPONENT_ADMINISTRATOR.DS.'helpers'.DS.'mobimaps.php';
                if($sbox == 0)
                {
                    // Coordinates are edited from the component backend
                    // Store the coordinates directly in DB and clear the session variables
                    if(MobimapsHelper::setGeoTagsInDB($lat, $lng, $cid))
                    {
                        $msg = JText::_('COM_MOBIMAPS_POSITION_HAS_BEEN_SAVED');
                    }
                    else
                    {
                        $msg = JText::_('COM_MOBIMAPS_FAILED_SAVING_POSITION');
                    }
                    MobimapsHelper::setGeoTagsInSession(null, null, null);
                }
                else
                {
                    // Coordinates are edited from the editor view
                    // Store the coordinates in session parameters
                    if(MobimapsHelper::setGeoTagsInSession($lat, $lng, $cid))
                    {
                        $msg = JText::_('COM_MOBIMAPS_POSITION_UPDATED_WHICH_IS_SAVED_WHEN_THE_ARTICLE_IS_SAVED');
                    }
                    else
                    {
                        $msg = JText::_('COM_MOBIMAPS_FAILED_UPDATING_POSITION');
                    }
                }
    
            }
    

    and that seemed to do the final trick, allowing the author to save the location on the map.
    cheers,
    Jason

     
  • Jason

    Jason - 2011-09-08

    Well,  I found out that editing the Plugin  for MObiMaps in the manner above created more bugs,  so I reverted my changes.

    I hope that this component can be updated so that it functions on the front-end for authors!

    Cheers
    Jason

     
  • Jason

    Jason - 2011-09-14

    Now i have another question.

    I cannot seem to let Administrator user group save a mobimap, says they don't have access..

    how can we let authors and above use mobimap editor button to save map location when saving article?  seems like maybe only the super admin has this access?

     
  • Johan Ekblad

    Johan Ekblad - 2011-09-15

    Have you tried setting the Author permission in the permission tab for the component?

    Also I have just commited a bug fix release for the MobiMaps-button (there where problem setting the position of an article). I will release 2.0.6 later on today.

     
  • Jason

    Jason - 2011-09-15

    HI,

    There is no permissions tab available for the component… or maybe my admin template is not showing it?

     
  • Johan Ekblad

    Johan Ekblad - 2011-09-16

    Are you using the 2.x releases, made for Joomla 1.6 and 1.7 ? (the 1.x releases does not have a permission tab).

    In that case go to:
    Components->MobiMaps
    Select "Settings" on the right side.
    The select the Permissions tab

     
  • Jason

    Jason - 2011-09-20

    I must have had the wrong version installed,   so I re-installed using the latest 2.0.6 version

    I DO see the permissions tab now!  BUT…

    When I click on the  green tabs, to open the permission settings, there is only the table column headers, and not the rest of the table that would allow me to  check the settings

    Is it possible that i did the install wrong or something?  I have tried several times to un-install and delete all files and DB tables, then re-install but everything I have the same issue..

    thanks for any help you can provide
    cheers
    Jason

     
  • Jason

    Jason - 2011-09-21

    Thought a screenshot might help explain…  its like the permission table is missing in the popup, only the column headers are showing..

     
  • Jason

    Jason - 2011-09-21

     
  • Johan Ekblad

    Johan Ekblad - 2011-09-21

    Strange, it's working for me. The user I'm logged in as is a member of the "Super Users" group. Also I'm using Joomla 1.7

     
  • Jason

    Jason - 2011-09-21

    OK,

    Reinstalled joomla 1.7 on a new dev site… then installed ONLY the mobimaps component and extensions… still same issue.. wierd!?!

    Here is screenshot and source code…


    <div id="permissions-sliders" class="pane-sliders">
    <p class="rule-desc">Manage the permission settings for the user groups below. See notes at the bottom.</p>
    <ul id="rules">
    <li>
    <div class="panel">
    <h3 class="pane-toggler title"><a href="javascript:void(0);"><span>
    Public
    </span></a></h3>
    <div style="padding-top: 0px; border-top: medium none; padding-bottom: 0px; border-bottom: medium none; overflow: hidden; height: 0px;" class="pane-slider content pane-hide">
    <div class="mypanel">
    <table class="group-rules">
    <thead>
    <tr>
    <th class="actions" id="actions-th1">
    <span class="acl-action">Action</span>
    </th>
    <th class="settings" id="settings-th1">
    <span class="acl-action">Select New Setting <sup>1</sup></span>
    </th>
    <th id="aclactionth1">
    <span class="acl-action">Calculated Setting <sup>2</sup></span>
    </th>
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table></div>
    </div></div>
    </li>
    <li><ul>
    <li>
    <div class="panel">
    <h3 class="title pane-toggler"><a href="javascript:void(0);"><span>
    <span class="level">|–</span> Manager
    </span></a></h3>
    <div style="padding-top: 0px; border-top: medium none; padding-bottom: 0px; border-bottom: medium none; overflow: hidden; height: 0px;" class="pane-slider content pane-hide">
    <div class="mypanel">
    <table class="group-rules">
    <thead>
    <tr>
    <th class="actions" id="actions-th6">
    <span class="acl-action">Action</span>
    </th>
    <th class="settings" id="settings-th6">
    <span class="acl-action">Select New Setting <sup>1</sup></span>
    </th>
    <th id="aclactionth6">
    <span class="acl-action">Calculated Setting <sup>2</sup></span>
    </th>
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table></div>
    </div></div>
    </li>
    <li><ul>
    <li>
    <div class="panel">
    <h3 class="title pane-toggler-down"><a href="javascript:void(0);"><span>
    <span class="level">|–</span> <span class="level">|–</span> Administrator
    </span></a></h3>
    <div style="padding-top: 0px; border-top: medium none; padding-bottom: 0px; border-bottom: medium none; overflow: hidden; height: auto;" class="pane-slider content pane-down">
    <div class="mypanel">
    <table class="group-rules">
    <thead>
    <tr>
    <th class="actions" id="actions-th7">
    <span class="acl-action">Action</span>
    </th>
    <th class="settings" id="settings-th7">
    <span class="acl-action">Select New Setting <sup>1</sup></span>
    </th>
    <th id="aclactionth7">
    <span class="acl-action">Calculated Setting <sup>2</sup></span>
    </th>
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table></div>
    </div></div>
    </li>
    </ul></li>
    <li>
    <div class="panel">
    <h3 class="pane-toggler title"><a href="javascript:void(0);"><span>
    <span class="level">|–</span> Registered
    </span></a></h3>
    <div style="padding-top: 0px; border-top: medium none; padding-bottom: 0px; border-bottom: medium none; overflow: hidden; height: 0px;" class="pane-slider content pane-hide">
    <div class="mypanel">
    <table class="group-rules">
    <thead>
    <tr>
    <th class="actions" id="actions-th2">
    <span class="acl-action">Action</span>
    </th>
    <th class="settings" id="settings-th2">
    <span class="acl-action">Select New Setting <sup>1</sup></span>
    </th>
    <th id="aclactionth2">
    <span class="acl-action">Calculated Setting <sup>2</sup></span>
    </th>
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table></div>
    </div></div>
    </li>
    <li><ul>
    <li>
    <div class="panel">
    <h3 class="pane-toggler title"><a href="javascript:void(0);"><span>
    <span class="level">|–</span> <span class="level">|–</span> Author
    </span></a></h3>
    <div style="padding-top: 0px; border-top: medium none; padding-bottom: 0px; border-bottom: medium none; overflow: hidden; height: 0px;" class="pane-slider content pane-hide">
    <div class="mypanel">
    <table class="group-rules">
    <thead>
    <tr>
    <th class="actions" id="actions-th3">
    <span class="acl-action">Action</span>
    </th>
    <th class="settings" id="settings-th3">
    <span class="acl-action">Select New Setting <sup>1</sup></span>
    </th>
    <th id="aclactionth3">
    <span class="acl-action">Calculated Setting <sup>2</sup></span>
    </th>
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table></div>
    </div></div>
    </li>
    <li><ul>
    <li>
    <div class="panel">
    <h3 class="pane-toggler title"><a href="javascript:void(0);"><span>
    <span class="level">|–</span> <span class="level">|–</span> <span class="level">|–</span> Editor
    </span></a></h3>
    <div style="padding-top: 0px; border-top: medium none; padding-bottom: 0px; border-bottom: medium none; overflow: hidden; height: 0px;" class="pane-slider content pane-hide">
    <div class="mypanel">
    <table class="group-rules">
    <thead>
    <tr>
    <th class="actions" id="actions-th4">
    <span class="acl-action">Action</span>
    </th>
    <th class="settings" id="settings-th4">
    <span class="acl-action">Select New Setting <sup>1</sup></span>
    </th>
    <th id="aclactionth4">
    <span class="acl-action">Calculated Setting <sup>2</sup></span>
    </th>
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table></div>
    </div></div>
    </li>
    <li><ul>
    <li>
    <div class="panel">
    <h3 class="pane-toggler title"><a href="javascript:void(0);"><span>
    <span class="level">|–</span> <span class="level">|–</span> <span class="level">|–</span> <span class="level">|–</span> Publisher
    </span></a></h3>
    <div style="padding-top: 0px; border-top: medium none; padding-bottom: 0px; border-bottom: medium none; overflow: hidden; height: 0px;" class="pane-slider content pane-hide">
    <div class="mypanel">
    <table class="group-rules">
    <thead>
    <tr>
    <th class="actions" id="actions-th5">
    <span class="acl-action">Action</span>
    </th>
    <th class="settings" id="settings-th5">
    <span class="acl-action">Select New Setting <sup>1</sup></span>
    </th>
    <th id="aclactionth5">
    <span class="acl-action">Calculated Setting <sup>2</sup></span>
    </th>
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table></div>
    </div></div>
    </li>
    </ul></li>
    <li>
    <div class="panel">
    <h3 class="pane-toggler title"><a href="javascript:void(0);"><span>
    <span class="level">|–</span> <span class="level">|–</span> <span class="level">|–</span> Shop Suppliers (Example)
    </span></a></h3>
    <div style="padding-top: 0px; border-top: medium none; padding-bottom: 0px; border-bottom: medium none; overflow: hidden; height: 0px;" class="pane-slider content pane-hide">
    <div class="mypanel">
    <table class="group-rules">
    <thead>
    <tr>
    <th class="actions" id="actions-th10">
    <span class="acl-action">Action</span>
    </th>
    <th class="settings" id="settings-th10">
    <span class="acl-action">Select New Setting <sup>1</sup></span>
    </th>
    <th id="aclactionth10">
    <span class="acl-action">Calculated Setting <sup>2</sup></span>
    </th>
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table></div>
    </div></div>
    </li>
    </ul></li>
    <li>
    <div class="panel">
    <h3 class="pane-toggler title"><a href="javascript:void(0);"><span>
    <span class="level">|–</span> <span class="level">|–</span> Customer Group (Example)
    </span></a></h3>
    <div style="padding-top: 0px; border-top: medium none; padding-bottom: 0px; border-bottom: medium none; overflow: hidden; height: 0px;" class="pane-slider content pane-hide">
    <div class="mypanel">
    <table class="group-rules">
    <thead>
    <tr>
    <th class="actions" id="actions-th12">
    <span class="acl-action">Action</span>
    </th>
    <th class="settings" id="settings-th12">
    <span class="acl-action">Select New Setting <sup>1</sup></span>
    </th>
    <th id="aclactionth12">
    <span class="acl-action">Calculated Setting <sup>2</sup></span>
    </th>
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table></div>
    </div></div>
    </li>
    </ul></li>
    <li>
    <div class="panel">
    <h3 class="pane-toggler title"><a href="javascript:void(0);"><span>
    <span class="level">|–</span> Super Users
    </span></a></h3>
    <div style="padding-top: 0px; border-top: medium none; padding-bottom: 0px; border-bottom: medium none; overflow: hidden; height: 0px;" class="pane-slider content pane-hide">
    <div class="mypanel">
    <table class="group-rules">
    <thead>
    <tr>
    <th class="actions" id="actions-th8">
    <span class="acl-action">Action</span>
    </th>
    <th class="settings" id="settings-th8">
    <span class="acl-action">Select New Setting <sup>1</sup></span>
    </th>
    <th id="aclactionth8">
    <span class="acl-action">Calculated Setting <sup>2</sup></span>
    </th>
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table></div>
    </div></div>
    </li>
    </ul></li>
    </ul><div class="rule-notes">
    1. If you change the setting, it will apply to this and all child groups, components and content. Note that:<br> <em>Inherited</em> means that the permissions from the parent group will be used.<br> <em>Denied</em> means that no matter what the parent group's setting is, the group being edited cannot take this action.<br> <em>Allowed</em> means that the group being edited will be able to take this action (but if this is in conflict with the parent group it will have no impact; a conflict will be indicated by <em>Not Allowed (Locked)</em> under Calculated Settings).<br> <em>Not Set</em> is used only for the Public group in global configuration. The Public group  is the parent of all other groups. If a permission is not set, it is treated as deny but can be changed for child groups, components, categories and items.<br>2. If you select a new setting, click <em>Save</em> to refresh the calculated settings.
    </div></div>
    

    As you can see in the source, the tables are not complete.. hope this helps as I am not sure and not experienced with PHP etc.

    please contact me by email if you want to login to my site/hosting etc  jasontheman07@gmail.com
    cheers
    Jason

     
  • Jason

    Jason - 2012-01-19

    Hi,

    I doubt this is related to the comonent's permission settings… you see in the congif.xml there is a field for permissions and they are all missing.

    see this article:
    http://www.aclmanager.net/blog/general/31-how-to-add-basic-acl-support-to-your-extension

    I think if permissions can be added to this component, it would be complete!!  Then front-end users could use mobimaps for their articles as opposed to only super-admins being able to use it..

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks