1
wcrwcr
Soapbox:Fatal error: Using $this when not in object context in...
  • 2009/11/5 12:45

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Hi all

On an old site, using the old (but good) Soapbox.
Xoops 2016 running PHP Version 5.2.9

Trying to submit or edit an article i´m having this error:

Fatal error: Using $this when not in object context in /home/wwws/public_html/modules/soapbox/admin/article.php on line 303

Follow a chunk of that file:

le="color: #000000"><?php // Save to database if ( !$articleID ) { if ( $xoopsDB -> query( "INSERT INTO " . $xoopsDB -> prefix( "sbarticles" ) . " (articleID, columnID, headline, lead, bodytext, teaser, weight, html, smiley, xcodes, breaks, block, artimage, votes, rating, comments, offline, datesub ) VALUES ('', '$columnID', '$headline', '$lead', '$bodytext', '$teaser', '$weight', '$html', '$smiley', '$xcodes', '$breaks', '$block', '$artimage', '$votes', '$rating', '$comments', '$offline', '$date' )" ) ) { $this -> db = & Database :: getInstance(); $newid = mysql_insert_id(); $result = $xoopsDB -> query( "SELECT columnID FROM " . $xoopsDB -> prefix( "sbarticles" ) . " WHERE articleID = '$newid'" ); list($columnID) = $xoopsDB -> fetchrow($result); $result = $xoopsDB -> query( "SELECT name, total FROM " . $xoopsDB -> prefix( "sbcolumns" ) . " WHERE colid = '$columnID'" ); list( $name, $total ) = $xoopsDB -> fetchrow( $result ); $total++; $tags = array(); $tags['ARTICLE_NAME'] = $headline; $tags['ARTICLE_URL'] = XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/index.php?art&amp;lid=' . $newid; $tags['COLUMN_NAME'] = $name; $tags['COLUMN_URL'] = XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/index.php?op=col&columnID=' . $columnID; $notification_handler = & xoops_gethandler( 'notification' ); $notification_handler -> triggerEvent( 'global', 0, 'new_article', $tags ); $notification_handler -> triggerEvent( 'category', $columnID, 'new_article', $tags ); if ( $xoopsDB -> queryF( "UPDATE " . $xoopsDB -> prefix( "sbcolumns" ) . " SET total = '$total' WHERE columnID = '$columnID'" ) ) redirect_header( "index.php", 1, _AM_SB_ARTCREATEDOK ); } else { redirect_header( "index.php", 1, _AM_SB_ARTNOTCREATED ); } } else // That is, $articleID exists, thus we're editing an article { if ( $xoopsDB -> query( "UPDATE " . $xoopsDB -> prefix( "sbarticles" ) . " SET columnID = '$columnID', headline = '$headline', lead = '$lead', bodytext = '$bodytext', teaser = '$teaser', weight = '$weight', html = '$html', smiley = '$smiley', xcodes = '$xcodes', breaks = '$breaks', block = '$block', artimage = '$artimage', votes = '$votes', rating = '$rating', comments = '$comments', offline = '$offline', datesub = '$date' WHERE articleID = '$articleID'" ) ) { redirect_header( "index.php", 1, _AM_SB_ARTMODIFIED ); } else { redirect_header( "index.php", 1, _AM_SB_ARTNOTUPDATED ); } } exit(); break;


The line spotted in the error is:

le="color: #000000"><?php $this -> db = & Database :: getInstance();


So I ask, any "quick" fix for that fatal error?

I know that Soapbox is pretty old but it has some very interesting features and the site in question has lots of good articles on It...

thank you all in advance

2
wcrwcr
Re: Soapbox:Fatal error: Using $this when not in object context in...
  • 2009/11/5 22:47

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Hi

Doing a search i found:

if you use $this outside of a class.

Note that you were allowed to use $this outside of classes in PHP4, but PHP5 does not allow it.

but as i´m a black hole in PHP.....still need some elightment

Thanks

3
trabis
Re: Soapbox:Fatal error: Using $this when not in object context in...
  • 2009/11/5 23:08

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Try to replace

$this->db =& Database::getInstance();

with

$xoopsDB =& Database::getInstance();

4
wcrwcr
Re: Soapbox:Fatal error: Using $this when not in object context in...
  • 2009/11/6 2:01

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Thank you very much Trabis

That´s fix the fatal error

however i´m still facing problems. Now I can´t assign an article to a column (author)

Just in case, here follows the whole "admin/article.php" file without the nice fix you´ve provided:

<?php /** * $Id: article.php v 1.5 25 April 2004 hsalazar Exp $ * Module: Soapbox * Version: v 1.5 * Release Date: 25 April 2004 * Author: hsalazar * Licence: GNU */ // -- General Stuff -- // include( "admin_header.php" ); $op = ''; foreach ( $_POST as $k => $v ) { ${$k} = $v; } foreach ( $_GET as $k => $v ) { ${$k} = $v; } if ( isset( $_GET['op'] ) ) $op = $_GET['op']; if ( isset( $_POST['op'] ) ) $op = $_POST['op']; // -- Edit function -- // function editarticle( $articleID = '' ) { global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $XOOPS_URL; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; /** * Clear all variables before we start */ if(!isset($block)) { $block = 1; } if(!isset($html)) { $html = 1; } else { $html = intval($html); } if(!isset($smiley)) { $smiley = 1; } else { $smiley = intval($smiley); } if(!isset($xcodes)) { $xcodes = 1; } else { $xcodes = intval($xcodes); } if(!isset($breaks)) { $breaks = 1; } else { $breaks = intval($breaks); } if(!isset($weight)) { $weight = 1; } if(!isset($comments)) { $comments = 1; } if(!isset($offline)) { $offline = 0; } if(!isset($votes)) { $votes = 0; } if(!isset($rating)) { $rating = 0.00; } if(!isset($columnID)) { $columnID = 1; } if(!isset($headline)) { $headline = ""; } if(!isset($lead)) { $lead = ""; } if(!isset($bodytext)) { $bodytext = ""; } if(!isset($teaser)) { $teaser = ""; } if(!isset($title)) { $title = ""; } $artimage = "blank.png"; // If there is a parameter, and the id exists, retrieve data: we're editing an article if ( $articleID ) { $result = $xoopsDB -> query( "SELECT columnID, headline, lead, bodytext, teaser, weight, html, smiley, xcodes, breaks, block, artimage, votes, rating, comments, offline FROM " . $xoopsDB -> prefix( "sbarticles" ) . " WHERE articleID = '$articleID'" ); list( $columnID, $headline, $lead, $bodytext, $teaser, $weight, $html, $smiley, $xcodes, $breaks, $block, $artimage, $votes, $rating, $comments, $offline ) = $xoopsDB -> fetchrow( $result ); if ( !$xoopsDB -> getRowsNum( $result ) ) { redirect_header( "index.php", 1, _AM_SB_NOARTTOEDIT ); exit(); } adminMenu(2, _AM_SB_ARTS._AM_SB_EDITING.$headline."'"); echo "<h3 style='color: #2F5376; '>" . _AM_SB_ADMINARTMNGMT . "</h5>"; $sform = new XoopsThemeForm( _AM_SB_MODART . ": $headline" , "op", xoops_getenv( 'PHP_SELF' ) ); } else // there's no parameter, so we're adding an article { $result01 = $xoopsDB -> query( "SELECT COUNT(*) FROM " . $xoopsDB -> prefix( "sbcolumns" ) . " " ); list( $totalcolumns ) = $xoopsDB -> fetchRow( $result01 ); if ( $totalcolumns == 0 ) { redirect_header( "index.php", 1, _AM_SB_NEEDONECOLUMN ); exit(); } adminMenu(2, _AM_SB_ARTS._AM_SB_CREATINGART); echo "<h3 style='color: #2F5376; '>" . _AM_SB_ADMINARTMNGMT . "</h5>"; $sform = new XoopsThemeForm( _AM_SB_NEWART, "op", xoops_getenv( 'PHP_SELF' ) ); } $sform -> setExtra( 'enctype="multipart/form-data"' ); // COLUMN /* * Get information for pulldown menu using XoopsTree. * First var is the database table * Second var is the unique field ID for the categories * Last one is not set as we do not have sub menus in WF-FAQ */ $mytree = new XoopsTree( $xoopsDB->prefix( "sbcolumns" ), "columnID" , "0" ); ob_start(); $sform -> addElement( new XoopsFormHidden( 'columnID', $columnID ) ); $mytree -> makeMySelBox( "name", "name", $columnID ); $sform -> addElement( new XoopsFormLabel( _AM_SB_COLNAME, ob_get_contents() ) ); ob_end_clean(); // HEADLINE, LEAD, BODYTEXT // This part is common to edit/add $sform -> addElement( new XoopsFormText( _AM_SB_ARTHEADLINE, 'headline', 50, 80, $headline ), true ); $sform -> addElement( new XoopsFormTextArea( _AM_SB_ARTLEAD, 'lead', $lead, 5, 60 ) ); // TEASER $sform -> addElement( new XoopsFormTextArea( _AM_SB_ARTTEASER, 'teaser', $teaser, 5, 60 ) ); $autoteaser_radio = new XoopsFormRadioYN( _AM_SB_AUTOTEASER, 'autoteaser', 0, ' ' . _AM_SB_YES . '', ' ' . _AM_SB_NO . '' ); $sform -> addElement( $autoteaser_radio ); $sform -> addElement( new XoopsFormText( _AM_SB_AUTOTEASERAMOUNT, 'teaseramount', 4, 4, 100 ) ); // BODY $sform -> addElement( new XoopsFormDhtmlTextArea( _AM_SB_ARTBODY, 'bodytext', $bodytext, 15, 60 ) ); // IMAGE // The article CAN have its own image :) // First, if the article's image doesn't exist, set its value to the blank file if (!file_exists(XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['sbuploaddir'] . "/" . $artimage) || !$artimage) { $artimage = "blank.png"; } // Code to create the image selector $graph_array = & XoopsLists :: getImgListAsArray( XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['sbuploaddir'] ); $artimage_select = new XoopsFormSelect( '', 'artimage', $artimage ); $artimage_select -> addOptionArray( $graph_array ); $artimage_select -> setExtra( "onchange='showImgSelected("image5", "artimage", "" . $xoopsModuleConfig['sbuploaddir'] . "", "", "" . XOOPS_URL . "")'" ); $artimage_tray = new XoopsFormElementTray( _AM_SB_SELECT_IMG, '&nbsp;' ); $artimage_tray -> addElement( $artimage_select ); $artimage_tray -> addElement( new XoopsFormLabel( '', "<br /><br /><img src='" . XOOPS_URL . "/" . $xoopsModuleConfig['sbuploaddir'] . "/" . $artimage . "' name='image5' id='image5' alt='' />" ) ); $sform -> addElement( $artimage_tray ); // Code to call the file browser to select an image to upload $sform -> addElement( new XoopsFormFile( _AM_SB_UPLOADIMAGE, 'cimage', $xoopsModuleConfig['maxfilesize'] ), false ); // COMMENTS // Code to allow comments $addcomments_radio = new XoopsFormRadioYN( _AM_SB_ALLOWCOMMENTS, 'comments', $comments, ' ' . _AM_SB_YES . '', ' ' . _AM_SB_NO . '' ); $sform -> addElement( $addcomments_radio ); // OFFLINE // Code to take article offline, for maintenance purposes $offline_radio = new XoopsFormRadioYN(_AM_SB_SWITCHOFFLINE, 'offline', $offline, ' '._AM_SB_YES.'', ' '._AM_SB_NO.''); $sform -> addElement($offline_radio); // ARTICLE IN BLOCK // Code to put article in block $block_radio = new XoopsFormRadioYN( _AM_SB_BLOCK, 'block', $block , ' ' . _AM_SB_YES . '', ' ' . _AM_SB_NO . '' ); $sform -> addElement( $block_radio ); // VARIOUS OPTIONS $options_tray = new XoopsFormElementTray(_AM_SB_OPTIONS,'<br />'); $html_checkbox = new XoopsFormCheckBox( '', 'html', $html ); $html_checkbox -> addOption( 1, _AM_SB_DOHTML ); $options_tray -> addElement( $html_checkbox ); $smiley_checkbox = new XoopsFormCheckBox( '', 'smiley', $smiley ); $smiley_checkbox -> addOption( 1, _AM_SB_DOSMILEY ); $options_tray -> addElement( $smiley_checkbox ); $xcodes_checkbox = new XoopsFormCheckBox( '', 'xcodes', $xcodes ); $xcodes_checkbox -> addOption( 1, _AM_SB_DOXCODE ); $options_tray -> addElement( $xcodes_checkbox ); $breaks_checkbox = new XoopsFormCheckBox( '', 'breaks', $breaks ); $breaks_checkbox -> addOption( 1, _AM_SB_BREAKS ); $options_tray -> addElement( $breaks_checkbox ); $sform -> addElement( $options_tray ); $sform -> addElement( new XoopsFormHidden( 'articleID', $articleID ) ); $button_tray = new XoopsFormElementTray( '', '' ); $hidden = new XoopsFormHidden( 'op', 'addart' ); $button_tray -> addElement( $hidden ); if ( !$articleID ) // there's no articleID? Then it's a new article { $butt_create = new XoopsFormButton( '', '', _AM_SB_CREATE, 'submit' ); $butt_create->setExtra('onclick="this.form.elements.op.value='addart'"'); $button_tray->addElement( $butt_create ); $butt_clear = new XoopsFormButton( '', '', _AM_SB_CLEAR, 'reset' ); $button_tray->addElement( $butt_clear ); $butt_cancel = new XoopsFormButton( '', '', _AM_SB_CANCEL, 'button' ); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement( $butt_cancel ); } else // else, we're editing an existing article { $butt_create = new XoopsFormButton( '', '', _AM_SB_MODIFY, 'submit' ); $butt_create->setExtra('onclick="this.form.elements.op.value='addart'"'); $button_tray->addElement( $butt_create ); $butt_cancel = new XoopsFormButton( '', '', _AM_SB_CANCEL, 'button' ); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement( $butt_cancel ); } $sform -> addElement( $button_tray ); $sform -> display(); unset( $hidden ); } /* -- Available operations -- */ switch ( $op ) { case "mod": xoops_cp_header(); $articleID = isset( $_POST['articleID'] ) ? intval( $_POST['articleID'] ) : intval( $_GET['articleID'] ); editarticle($articleID); break; case "addart": // global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig ; $articleID = (isset($_POST['articleID'])) ? intval($_POST['articleID']) : 0; $columnID = (isset($_POST['columnID'])) ? intval($_POST['columnID']) : 0; $block = (isset($_POST['block'])) ? intval($_POST['block']) : 1; $offline = (isset($_POST['offline'])) ? intval($_POST['offline']) : 0; $breaks = (isset($_POST['breaks'])) ? intval($_POST['breaks']) : 0; $comments = isset( $comments ) ? intval( $comments ) : 0; $html = isset( $html ) ? intval( $html ) : 0; $smiley = isset( $smiley ) ? intval( $smiley ) : 0; $xcodes = isset( $xcodes ) ? intval( $xcodes ) : 0; $weight = (isset($_POST['weight'])) ? intval($_POST['weight']) : 1; $artimage = ($_POST['artimage'] != 'blank.png' ) ? $myts -> addSlashes($_POST['artimage']) : ''; $headline = $myts -> htmlSpecialChars($_POST['headline']); $lead = $myts -> addSlashes($_POST['lead']); $bodytext = $myts -> addSlashes($_POST['bodytext']); $votes = (isset($_POST['votes'])) ? intval($_POST['votes']) : 0; $rating = (isset($_POST['rating'])) ? intval($_POST['rating']) : 0.00; if ( $_POST['autoteaser'] ) { $charlength = $_POST['teaseramount']; $teasertemp = $_POST['bodytext']; if ( !XOOPS_USE_MULTIBYTES ) { $teasertemp = strip_tags( $teasertemp, '' ); $teasertemp = $myts -> addSlashes( substr( $teasertemp, 0, ( $charlength -1 ) ) ) . "..."; } $teaser = $teasertemp; } else { $teaser = $myts -> addSlashes( $_POST['teaser'] ); } $date = time(); // ARTICLE IMAGE // Define variables $error = 0; $word = null; $uid = $xoopsUser -> uid(); $submit = 1; $date = time(); if ( $HTTP_POST_FILES['cimage']['name'] != "" ) { include_once XOOPS_ROOT_PATH . '/class/uploader.php'; if ( file_exists( XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['sbuploaddir'] . "/" . $HTTP_POST_FILES['cimage']['name'] ) ) { redirect_header( "index.php", 1, _AM_SB_FILEEXISTS ); } $allowed_mimetypes = array( 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/png' ); uploading($allowed_mimetypes, $HTTP_POST_FILES['cimage']['name'], "index.php", 0, $xoopsModuleConfig['sbuploaddir']); $artimage = $HTTP_POST_FILES['cimage']['name']; } elseif ($_POST["artimage"] != "blank.png") { $artimage = $myts -> addSlashes( $_POST["artimage"] ); } else { $artimage = ''; } // Save to database if ( !$articleID ) { if ( $xoopsDB -> query( "INSERT INTO " . $xoopsDB -> prefix( "sbarticles" ) . " (articleID, columnID, headline, lead, bodytext, teaser, weight, html, smiley, xcodes, breaks, block, artimage, votes, rating, comments, offline, datesub ) VALUES ('', '$columnID', '$headline', '$lead', '$bodytext', '$teaser', '$weight', '$html', '$smiley', '$xcodes', '$breaks', '$block', '$artimage', '$votes', '$rating', '$comments', '$offline', '$date' )" ) ) { $xoopsDB =& Database::getInstance(); $newid = mysql_insert_id(); $result = $xoopsDB -> query( "SELECT columnID FROM " . $xoopsDB -> prefix( "sbarticles" ) . " WHERE articleID = '$newid'" ); list($columnID) = $xoopsDB -> fetchrow($result); $result = $xoopsDB -> query( "SELECT name, total FROM " . $xoopsDB -> prefix( "sbcolumns" ) . " WHERE colid = '$columnID'" ); list( $name, $total ) = $xoopsDB -> fetchrow( $result ); $total++; $tags = array(); $tags['ARTICLE_NAME'] = $headline; $tags['ARTICLE_URL'] = XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/index.php?art&lid=' . $newid; $tags['COLUMN_NAME'] = $name; $tags['COLUMN_URL'] = XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/index.php?op=col&columnID=' . $columnID; $notification_handler = & xoops_gethandler( 'notification' ); $notification_handler -> triggerEvent( 'global', 0, 'new_article', $tags ); $notification_handler -> triggerEvent( 'category', $columnID, 'new_article', $tags ); if ( $xoopsDB -> queryF( "UPDATE " . $xoopsDB -> prefix( "sbcolumns" ) . " SET total = '$total' WHERE columnID = '$columnID'" ) ) redirect_header( "index.php", 1, _AM_SB_ARTCREATEDOK ); } else { redirect_header( "index.php", 1, _AM_SB_ARTNOTCREATED ); } } else // That is, $articleID exists, thus we're editing an article { if ( $xoopsDB -> query( "UPDATE " . $xoopsDB -> prefix( "sbarticles" ) . " SET columnID = '$columnID', headline = '$headline', lead = '$lead', bodytext = '$bodytext', teaser = '$teaser', weight = '$weight', html = '$html', smiley = '$smiley', xcodes = '$xcodes', breaks = '$breaks', block = '$block', artimage = '$artimage', votes = '$votes', rating = '$rating', comments = '$comments', offline = '$offline', datesub = '$date' WHERE articleID = '$articleID'" ) ) { redirect_header( "index.php", 1, _AM_SB_ARTMODIFIED ); } else { redirect_header( "index.php", 1, _AM_SB_ARTNOTUPDATED ); } } exit(); break; case "del": Global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB; $confirm = ( isset( $confirm ) ) ? 1 : 0; if ( $confirm ) { $xoopsDB->query( "DELETE FROM " . $xoopsDB->prefix( "sbarticles" ) . " WHERE articleID = $articleID" ); xoops_comment_delete($xoopsModule->getVar('mid'), $articleID); redirect_header( "index.php", 1, sprintf( _AM_SB_ARTISDELETED, $headline ) ); exit(); } else { $articleID = ( isset( $_POST['articleID'] ) ) ? intval($_POST['articleID']) : intval($articleID); $result = $xoopsDB -> query( "SELECT articleID, headline FROM " . $xoopsDB -> prefix( "sbarticles" ) . " WHERE articleID = $articleID" ); list( $articleID, $headline ) = $xoopsDB -> fetchrow( $result ); xoops_cp_header(); xoops_confirm( array( 'op' => 'del', 'articleID' => $articleID, 'confirm' => 1, 'headline' => $headline ), 'article.php', _AM_SB_DELETETHISARTICLE . "<br /><br>" . $headline, _AM_SB_DELETE ); xoops_cp_footer(); } exit(); break; case "default": default: xoops_cp_header(); include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig, $xoopsModule; $myts =& MyTextSanitizer::getInstance(); editarticle(); showArticles (0); break; } xoops_cp_footer(); ?>



And here follows the "admin/column.php" file
<?php /** * $Id: column.php v 1.5 25 April 2004 hsalazar Exp $ * Module: Soapbox * Version: v 1.5 * Release Date: 25 April 2004 * Author: hsalazar * Licence: GNU */ // -- General Stuff -- // include( "admin_header.php" ); $op = ''; foreach ( $_POST as $k => $v ) { ${$k} = $v; } foreach ( $_GET as $k => $v ) { ${$k} = $v; } if ( isset( $_GET['op'] ) ) $op = $_GET['op']; if ( isset( $_POST['op'] ) ) $op = $_POST['op']; function editcol( $columnID = '' ) { $weight = 1; $name = ''; $author = ''; $description = ''; $colimage = 'blank.png'; Global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $_GET; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a column if ( $columnID ) { $result = $xoopsDB -> query( "SELECT columnID, author, name, description, total, weight, colimage, created FROM " . $xoopsDB -> prefix( "sbcolumns" ) . " WHERE columnID = '$columnID'" ); list( $columnID, $author, $name, $description, $total, $weight, $colimage, $created ) = $xoopsDB -> fetchrow( $result ); if ( $xoopsDB -> getRowsNum( $result ) == 0 ) { redirect_header( "column.php", 1, _AM_SB_NOCOLTOEDIT ); exit(); } xoops_cp_header(); adminMenu(1, _AM_SB_COLS._AM_SB_EDITING.$name."'"); echo "<h3 style='color: #2F5376; '>" . _AM_SB_ADMINCOLMNGMT . "</h3>"; $sform = new XoopsThemeForm( _AM_SB_MODCOL . ": $name" , "op", xoops_getenv( 'PHP_SELF' ) ); } else { xoops_cp_header(); adminMenu(1, _AM_SB_COLS._AM_SB_CREATINGCOL); echo "<h3 style='color: #2F5376; '>" . _AM_SB_ADMINCOLMNGMT . "</h3>"; $sform = new XoopsThemeForm( _AM_SB_NEWCOL, "op", xoops_getenv( 'PHP_SELF' ) ); } $sform -> setExtra( 'enctype="multipart/form-data"' ); $sform -> addElement( new XoopsFormText( _AM_SB_COLNAME, 'name', 50, 80, stripslashes($name) ), true ); // Selector to get author if (is_numeric($author)) { $authorinput = ''; } else { $authorinput = $author; } ob_start(); getuserForm( intval($author) ); $sform -> addElement( new XoopsFormLabel( _AM_SB_AUTHOR, ob_get_contents() ) ); ob_end_clean(); $sform -> addElement( new XoopsFormTextArea( _AM_SB_COLDESCRIPT, 'description', $description, 7, 60 ) ); $sform -> addElement( new XoopsFormText( _AM_SB_COLPOSIT, 'weight', 4, 4, $weight ) ); if ( !$colimage ) $colimage = "nopicture.png"; $graph_array = & XoopsLists :: getImgListAsArray( XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['sbuploaddir'] ); $colimage_select = new XoopsFormSelect( '', 'colimage', $colimage ); $colimage_select -> addOptionArray( $graph_array ); $colimage_select -> setExtra( "onchange='showImgSelected("image3", "colimage", "" . $xoopsModuleConfig['sbuploaddir'] . "", "", "" . XOOPS_URL . "")'" ); $colimage_tray = new XoopsFormElementTray( _AM_SB_COLIMAGE, '&nbsp;' ); $colimage_tray -> addElement( $colimage_select ); $colimage_tray -> addElement( new XoopsFormLabel( '', "<br /><br /><img src='" . XOOPS_URL . "/" . $xoopsModuleConfig['sbuploaddir'] . "/" . $colimage . "' name='image3' id='image3' alt='' />" ) ); $sform -> addElement( $colimage_tray ); // Code to call the file browser to select an image to upload $sform -> addElement( new XoopsFormFile( _AM_SB_COLIMAGEUPLOAD, 'cimage', $xoopsModuleConfig['maxfilesize'] ), false ); $sform -> addElement( new XoopsFormHidden( 'columnID', $columnID ) ); $button_tray = new XoopsFormElementTray( '', '' ); $hidden = new XoopsFormHidden( 'op', 'addcol' ); $button_tray -> addElement( $hidden ); // No ID for column -- then it's new column, button says 'Create' if ( !$columnID ) { $butt_create = new XoopsFormButton( '', '', _AM_SB_CREATE, 'submit' ); $butt_create->setExtra('onclick="this.form.elements.op.value='addcol'"'); $button_tray->addElement( $butt_create ); $butt_clear = new XoopsFormButton( '', '', _AM_SB_CLEAR, 'reset' ); $button_tray->addElement( $butt_clear ); $butt_cancel = new XoopsFormButton( '', '', _AM_SB_CANCEL, 'button' ); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement( $butt_cancel ); } else // button says 'Update' { $butt_create = new XoopsFormButton( '', '', _AM_SB_MODIFY, 'submit' ); $butt_create->setExtra('onclick="this.form.elements.op.value='addcol'"'); $button_tray->addElement( $butt_create ); $butt_cancel = new XoopsFormButton( '', '', _AM_SB_CANCEL, 'button' ); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement( $butt_cancel ); } $sform -> addElement( $button_tray ); $sform -> display(); unset( $hidden ); } switch ( $op ) { case "mod": $columnID = isset( $_POST['columnID'] ) ? intval( $_POST['columnID'] ) : intval( $_GET['columnID'] ); editcol( $columnID ); break; case "addcol": Global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $modify, $myts, $columnID; if ( isset( $_POST['columnID'] ) ) $columnID = $_POST['columnID']; if ( ( $_POST['weight'] ) && is_numeric( $_POST['weight'] ) ) { $weight = $myts -> addSlashes( $_POST['weight'] ); } else { $weight = 1; } $name = $myts -> htmlSpecialChars( $_POST['name'] ); $description = $myts -> addslashes( $_POST['description'] ); $description = $myts->xoopsCodeDecode($description, $allowimage = 1); if ($_POST['author'] == '-1') { $author = $myts->makeTboxData4Save($_POST['authorinput']); } else { $author = $myts->makeTboxData4Save($_POST['author']); } if ( $HTTP_POST_FILES['cimage']['name'] != "" ) { if ( file_exists( XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['sbuploaddir'] . "/" . $HTTP_POST_FILES['cimage']['name'] ) ) { redirect_header( "column.php", 1, _AM_SB_FILEEXISTS ); } $allowed_mimetypes = array( 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/png' ); uploading( $allowed_mimetypes, $HTTP_POST_FILES['cimage']['name'], "index.php", 0, $xoopsModuleConfig['sbuploaddir'] ); $colimage = $HTTP_POST_FILES['cimage']['name']; } elseif ( $_POST["colimage"] != "blank.png" ) { $colimage = $myts -> addSlashes( $_POST["colimage"] ); } else { $colimage = ''; } // Run the query and update the data if ( !$_POST['columnID'] ) { if ( $xoopsDB -> query( "INSERT INTO " . $xoopsDB -> prefix( "sbcolumns" ) . " (columnID, name, author, description, weight, total, colimage) VALUES ('', '$name', '$author', '$description', '$weight', '0', '$colimage')" ) ) { redirect_header( "permissions.php", 1, _AM_SB_COLCREATED ); $newid = $xoopsDB -> getInsertId(); // Notify of new column global $xoopsModule; $tags = array(); $tags['COLUMN_NAME'] = $name; $tags['COLUMN_URL'] = XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/index.php?op=col&columnID=' . $newid; $notification_handler = & xoops_gethandler( 'notification' ); $notification_handler -> triggerEvent( 'global', 0, 'new_column', $tags ); } else { redirect_header( "index.php", 1, _AM_SB_NOTUPDATED ); } } else { if ( $xoopsDB -> queryF( "UPDATE " . $xoopsDB -> prefix( "sbcolumns" ) . " SET name = '$name', author = '$author', description = '$description', weight = '$weight', colimage = '$colimage' WHERE columnID = '$columnID'" ) ) { redirect_header( "index.php", 1, _AM_SB_COLMODIFIED ); } else { redirect_header( "index.php", 1, _AM_SB_NOTUPDATED ); } } exit(); break; case "del": global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB; $groups = ( $xoopsUser ) ? $xoopsUser -> getGroups() : XOOPS_GROUP_ANONYMOUS; $module_id = $xoopsModule -> getVar( 'mid' ); $gperm_handler = & xoops_gethandler( 'groupperm' ); $confirm = ( isset( $confirm ) ) ? 1 : 0; if ( $confirm ) { $xoopsDB -> query( "DELETE FROM " . $xoopsDB -> prefix( "sbcolumns" ) . " WHERE columnID = '$columnID'" ); $xoopsDB -> query( "DELETE FROM " . $xoopsDB -> prefix( "sbarticles" ) . " WHERE columnID = '$columnID'" ); xoops_groupperm_deletebymoditem ($module_id, _AM_SB_COLPERMS, $columnID); redirect_header( "index.php", 1, sprintf( _AM_SB_COLISDELETED, $name ) ); exit(); } else { $columnID = ( isset( $_POST['columnID'] ) ) ? $_POST['columnID'] : $columnID; $result = $xoopsDB -> query( "SELECT columnID, name FROM " . $xoopsDB -> prefix( "sbcolumns" ) . " WHERE columnID = '$columnID'" ); list( $colid, $name ) = $xoopsDB -> fetchrow( $result ); xoops_cp_header(); xoops_confirm( array( 'op' => 'del', 'columnID' => $columnID, 'confirm' => 1, 'name' => $name ), 'column.php', _AM_SB_DELETETHISCOL . "<br /><br>" . $name, _AM_SB_DELETE ); xoops_cp_footer(); } exit(); break; case "cancel": redirect_header( "index.php", 1, sprintf( _AM_SB_BACK2IDX, '' ) ); exit(); case "default": default: editcol(); showColumns( 0 ); break; } xoops_cp_footer(); ?>


As I told you before "just in case, ok?
I know that a pretty old module and I don´t want to boring you with that

BTW > Do you ever used soapbox?

thanks

5
wcrwcr
Re: Soapbox:Fatal error: Using $this when not in object context in...
  • 2009/11/9 12:55

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Hi all

just a very very little bump

Thanks

6
wcrwcr
Re: Soapbox:Fatal error: Using $this when not in object context in...
  • 2009/11/12 13:54

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Anyone?

7
ghia
Re: Soapbox:Fatal error: Using $this when not in object context in...
  • 2009/11/13 0:58

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Were there debug messages or what happens?

8
wcrwcr
Re: Soapbox:Fatal error: Using $this when not in object context in...
  • 2009/11/13 12:21

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Ghia

The only debug message(fatal error) was that one fixed by trabis´ suggestion.

Now when I try to assign an article to an author(column), the author´s field remains empty and the article is only accessible in the admin´s side, not in the front end:

ID || column || Article ||
22 --empty-- title is ok!



did i make things more clear?
let me know if you want the module for testing, ok?

Thanks

9
trabis
Re: Soapbox:Fatal error: Using $this when not in object context in...
  • 2009/11/13 14:04

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Look at debug->queries, see if you get some error in queries like "xxxx has no default value"

10
wcrwcr
Re: Soapbox:Fatal error: Using $this when not in object context in...
  • 2009/11/16 13:07

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Here follows the queries on the admin´s edit page before the try of author´s (column)assignement:

le="color: #000000"><?php SELECT * FROM xoops_config WHERE (conf_modid = '0' AND conf_catid = '1') ORDER BY conf_order ASC SELECT sess_data FROM xoops_session WHERE sess_id = '3bf84a47cc0cab2c4b3a2895767867b7' SELECT * FROM xoops_users WHERE uid=1 SELECT * FROM xoops_modules WHERE dirname = 'soapbox' SELECT * FROM xoops_config WHERE (conf_modid = '12') ORDER BY conf_order ASC SELECT * FROM xoops_group_permission WHERE (gperm_name = 'module_admin' AND gperm_modid = '1' AND (gperm_groupid = '1' OR gperm_groupid = '2')) SELECT columnID, headline, lead, bodytext, teaser, weight, html, smiley, xcodes, breaks, block, artimage, votes, rating, comments, offline FROM xoops_sbarticles WHERE articleID = '67' SELECT columnID, name FROM xoops_sbcolumns WHERE 0=0 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=11 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=6 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=5 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=7 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=4 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=13 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=8 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=10 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=3 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=12 ORDER BY name SELECT * FROM xoops_sbcolumns WHERE 0=9 ORDER BY name SELECT * FROM xoops_smiles WHERE display=1


and here follows the queries after the try:

le="color: #000000"><?php Queries SELECT * FROM xoops_config WHERE (conf_modid = '0' AND conf_catid = '1') ORDER BY conf_order ASC SELECT sess_data FROM xoops_session WHERE sess_id = '3bf84a47cc0cab2c4b3a2895767867b7' SELECT * FROM xoops_users WHERE uid=1 SELECT * FROM xoops_modules WHERE dirname = 'soapbox' SELECT * FROM xoops_config WHERE (conf_modid = '12') ORDER BY conf_order ASC SELECT * FROM xoops_group_permission WHERE (gperm_name = 'module_admin' AND gperm_modid = '1' AND (gperm_groupid = '1' OR gperm_groupid = '2')) SELECT COUNT(*) FROM xoops_sbcolumns SELECT COUNT(*) FROM xoops_sbarticles WHERE submit = 0 SELECT COUNT(*) FROM xoops_sbarticles WHERE submit = 1 SELECT COUNT(*) FROM xoops_sbarticles WHERE submit = 0 SELECT articleID, columnID, headline, datesub, offline FROM xoops_sbarticles WHERE submit = 0 ORDER BY articleID DESC LIMIT 0, 5 SELECT name FROM xoops_sbcolumns WHERE columnID = '1' SELECT name FROM xoops_sbcolumns WHERE columnID = '12' SELECT name FROM xoops_sbcolumns WHERE columnID = '7' SELECT name FROM xoops_sbcolumns WHERE columnID = '7' SELECT name FROM xoops_sbcolumns WHERE columnID = '13' SELECT COUNT(*) FROM xoops_sbcolumns SELECT * FROM xoops_sbcolumns ORDER BY weight LIMIT 0, 5 SELECT * FROM xoops_users WHERE uid=425 SELECT * FROM xoops_users WHERE uid=9 SELECT * FROM xoops_users WHERE uid=8 SELECT * FROM xoops_users WHERE uid=10 SELECT * FROM xoops_users WHERE uid=18 SELECT COUNT(*) FROM xoops_sbarticles WHERE submit = 1 SELECT articleID, columnID, headline, datesub FROM xoops_sbarticles WHERE submit = 1 ORDER BY datesub DESC LIMIT 0, 5


thanks for your interest

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits