database query confusion

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
N6REJ
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun Nov 27, 2005 9:25 am
Location: Knoxville, Iowa
Contact:

database query confusion

Post by N6REJ » Tue Aug 28, 2007 10:52 pm

I'm having a heck of a time updating a record in the jos__moduels database.
I want to look for mod_quickicon and set its published status to false and then after my module has installed set its status to published. and its position to icon.
Everything I've tried so far hasn't worked.  I don't understand what I'm doing wrong.
Can someone please help?
Here's my code...

Code: Select all

<?php
/**
* @version $Id: mod_vmquickicon.php 5571 2006-10-26 05:20:13Z N6REJ $
* @package Virtuemart Quick Icons
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

if (!defined( '_JOS_vmquickicon_MODULE' )) {
   /** ensure that functions are declared only once */
   define( '_JOS_vmquickicon_MODULE', 1 );

   function quickiconButton( $link, $image, $text ) {
      ?>
      <div style="float:left;">
         <div class="icon">
            <a href="<?php echo $link; ?>">
               <?php echo mosAdminMenus::imageCheckAdmin( $image, '/administrator/modules/images/', NULL, NULL, $text ); ?>
               <span><?php echo $text; ?></span>
            </a>
         </div>
      </div>
      <?php
   }

   $securitycheck    = intval( $params->get( 'securitycheck', 1 ) );
   ?>
   <div id="cpanel">
      <?php      
      $link = 'index2.php?option=com_content&sectionid=0&task=new';
      quickiconButton( $link, 'module.png', 'Add New Content' );

       $link = 'index2.php?option=com_content§ionid=0';
      quickiconButton( $link, 'addedit.png', 'Content Items Manager' );

      $link = 'index2.php?option=com_typedcontent';
      quickiconButton( $link, 'addedit.png', 'Static Content Manager' );

      $link = 'index2.php?option=com_frontpage';
      quickiconButton( $link, 'frontpage.png', 'Frontpage Manager' );

      $link = 'index2.php?option=com_sections&scope=content';
      quickiconButton( $link, 'sections.png', 'Section Manager' );
   
       $link = 'index2.php?option=com_categories&section=content';
      quickiconButton( $link, 'categories.png', 'Category Manager' );

       $link = 'index2.php?option=com_media';
      quickiconButton( $link, 'mediamanager.png', 'Media Manager' );
 
      if ( $my->gid > 23 ) {
         $link = 'index2.php?option=com_trash';
         quickiconButton( $link, 'trash.png', 'Trash Manager' );
      }

      if ( $my->gid > 23 ) {
         $link = 'index2.php?option=com_menumanager';
         quickiconButton( $link, 'menu.png', 'Menu Manager' );
      }

       if ( $my->gid > 24 ) {
         $link = 'index2.php?option=com_languages';
         quickiconButton( $link, 'langmanager.png', 'Language Manager' );
      }

       if ( $my->gid > 23 ) {
         $link = 'index2.php?option=com_users';
         quickiconButton( $link, 'user.png', 'User Manager' );
      }

       if ( $my->gid > 24 ) {
         $link = 'index2.php?option=com_config&hidemainmenu=1';
         quickiconButton( $link, 'config.png', 'Global Configuration' );
      }
       
      $link = 'index2.php?option=com_joomlaxplorer';
        quickiconButton( $link, 'jxplorer.png', 'JoomlaXplorer' );

      $link = 'index2.php?option=com_virtuemart';
      quickiconButton( $link, 'vm_logo.gif', 'Store' );

      $link = 'index2.php?pshop_mode=admin&page=admin.user_list&option=com_virtuemart';
      quickiconButton( $link, 'shop_users.png', 'Customers' );

      $link = 'index2.php?pshop_mode=admin&page=order.order_list&option=com_virtuemart';
      quickiconButton( $link, 'shop_orders.png', 'Orders' );
      
      $link = 'index2.php?pshop_mode=admin&page=product.product_list&option=com_virtuemart';
      quickiconButton( $link, 'shop_products.png', 'Products' );

      $link = 'index2.php?pshop_mode=admin&page=product.product_category_list&option=com_virtuemart';
      quickiconButton( $link, 'shop_categories.png', 'Categories' );
      
      if ($securitycheck) {
      // show security setting check
         josSecurityCheck('88%');
      }
     ?>
   </div>
   <div style="clear:both;"> </div>
   <?php
}
      // set original module inactive (if not deleted)
   $database->setQuery("SELECT id FROM #__modules WHERE module = 'mod_quickicon'");
   $database->query();
   echo $database:
   
//   $query = "SELECT id"
//   . "\n FROM #__modules"
//   . "\n WHERE module = 'mod_quickicon'"
//   ;

   $id = $database->loadResult();

   echo $id;

   if( $id ) {
      $query = "UPDATE #__modules"
      . "\n SET published = false
      . "\n WHERE id = " . $id
      . "\n LIMIT 1"
      ;
      $database->setQuery( $query );
      $database->query();
   }

   // Now set VMQuickIcon active

   $database->setQuery("SELECT id FROM #__modules WHERE module = 'mod_vmquickicon'");
   $database->query();
   echo $database;
   $id = $database->loadResult();

   echo $id;

   if( $id ) {
      $query = "UPDATE #__modules"
      . "\n SET published = true"
      . "\n SET position = 'icon'"
      . "\n SET client_id = '0'"
      . "\n WHERE id = " . $id"
      . "\n LIMIT 1"
      ;
      $database->setQuery( $query );
      $database->query();
   }
?>
Troy aka N6REJ

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: database query confusion

Post by ianmac » Tue Aug 28, 2007 11:11 pm

This just won't work...

Your module code will not get executed unless it is published, so there is no way for a module to autopublish itself.

Ian
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

User avatar
N6REJ
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun Nov 27, 2005 9:25 am
Location: Knoxville, Iowa
Contact:

Re: database query confusion

Post by N6REJ » Tue Aug 28, 2007 11:25 pm

GOSH, I wish this was in the dev stuff somewhere.  I looked all night.  Would've saved me a ton of work.
Ok, well thats fine.  Then its as mature as I can make it.  I'll clean the code a bit tomorrow and call that that :D
Thanks Ian.
Troy aka N6REJ

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: database query confusion

Post by ianmac » Tue Aug 28, 2007 11:31 pm

Never thought to include it...  seemed obvious :)

Ian
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!


Post Reply