Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
SQLBuilder AddFieldNameValue
ok here is the code and renders
The function Render_DiscussionImageForm renders this input field in the DiscussionForm Control on post.php
When I click save I need the url to be saved in a Field called DiscussionImage which is inside the Table LUM_Discussion. Can anyone tell me how to do that. what I'm doing isn't working,
if($Context->SelfUrl == 'post.php' && $Context->Session->UserID > 0 ){
function Render_DiscussionImageForm () {
echo '<ul><li>
<label for="txtDiscussionImage">Enter an image url to be used as Discussion Image <small>(optional)</small></label>
<input type="text" value="" maxlength="255" class="DiscussionBox" name="DiscussionImageURL" id="txtDiscussionImage"/>
</li></ul>';
}
function DiscussionForm_SaveDiscussionImage (&$DiscussionForm) {
$s = $DiscussionForm->Context->ObjectFactory->NewContextObject($DiscussionForm->Context, 'SqlBuilder');
$s->SetMainTable('Discussion', 'u');
$s->AddFieldNameValue('DiscussionImage', $_POST['DiscussionImageURL']);
}
$Context->AddToDelegate('DiscussionForm', 'DiscussionForm_PreButtonsRender', 'Render_DiscussionImageForm');
$Context->AddToDelegate('DiscussionForm', 'PostSaveDiscussion', 'DiscussionForm_SaveDiscussionImage');
}
The function Render_DiscussionImageForm renders this input field in the DiscussionForm Control on post.php
When I click save I need the url to be saved in a Field called DiscussionImage which is inside the Table LUM_Discussion. Can anyone tell me how to do that. what I'm doing isn't working,
0
This discussion has been closed.
Comments
Here is a snippet taken from the bottom of SaveDiscussion() in Vanilla.Class.DiscussionManager.php, rewritten a bit to work in your function:
function DiscussionForm_SaveDiscussionImage (&$DiscussionForm) { $s = $DiscussionForm->Context->ObjectFactory->NewContextObject($DiscussionForm->Context, 'SqlBuilder'); $Discussion = $DiscussionForm->DelegateParameters['Discussion']; // We need the discussion ID from this $s->SetMainTable('Discussion', 'd'); $s->AddFieldNameValue('DiscussionImage', ForceIncomingString('DiscussionImageURL', '')); $s->AddWhere('d', 'DiscussionID', '', $Discussion->Comment->DiscussionID, '='); $DiscussionForm->Context->Database->Update($s, 'SaveDiscussionImage', 'NewDiscussion', 'An error occurred while updating discussion properties.'); }
what is the SQlbuilder equivalent of this
$query = mysql_query("SHOW COLUMNS FROM LUM_Discussion LIKE 'DiscussionImage'"); if (mysql_num_rows($query) == 0) { mysql_query("ALTER TABLE `LUM_Discussion` ADD `DiscussionImage` text NOT NULL ;"); }
$query = $Context->Database->Execute($query); if ($Context->Database->RowCount($query) == 0) { $Context->Database->Execute("ALTER TABLE `LUM_Discussion` ADD `DiscussionImage` text NOT NULL ;"); }
For best results, you should also look up the database table prefix and the table names from where they are defined in appg/database.php