Given code like this:
IContent part = ....; // some part object like IUser
var fieldValues = part.ContentItem.Parts
.SelectMany(p => p.Fields)
.Where(f => f.Name == "some field name");
Which table are the field values stored in, or are they stored somewhere else?
I'm using SQL Server as the back-end database for Orchard. I see the fields are defined in table Settings_ContentPartFieldDefinitionRecord but I don't know where the actual values are stored.
Orchard_Framework_ContentItemVersionRecord
Check out this blog post by the lead developer on Orchard, Sebastien Ros, who talks a little about the database structure. http://sebastienros.com/understanding-orchard-s-database
Related
I am building a CMS that supports a website which also contains an SMF forum (2.0.11). One of the modules in the CMS involves a "report" that tracks attendance. That data is queried to tables outside of smf, but in the same database. In addition to what it does now, I would also like for a post to be made in a specific board on the SMF forum containing the formatted content. As all of the posts are contained by the database, surely this is possible, but it seems there is more to it than a single row in a table.
To put it in the simplest code possible, below is what I want to happen when I click Submit on my page.
$title = "2015-03-04 - Attendance";
$author = "KGrimes";
$body = "Attendance was good.";
$SQL = "INSERT INTO smf_some_table (title, author, body) VALUES ($title, $author, $body)";
$result = mysqli_query($db_handle, $SQL);
Having dug through the smf DB tables and the post() and post2() functions, it seems there is more than one table involved when a post is made. Has anyone outlined this before?
I've looked into solutions such as the Custom Form Mod, but these forms and templates are not what I am looking for. I already have the data inputted and POST'ed to variables, I just need the right table(s) to INSERT it into so that it appears on the forum.
Thank you in advance for any help!
Source: http://www.simplemachines.org/community/index.php?topic=542521.0
Code where you want to create post:
//Define variables
//msgOptions
$smf_subject = "Test Title";
//Handle & escape
$smf_subject = htmlspecialchars($smf_subject);
$smf_subject = quote_smart($smf_subject, $db_handle);
$smf_body = "This is a test.";
//Handle & escape
$smf_body = htmlspecialchars($smf_body);
$smf_body = quote_smart($smf_body, $db_handle);
//topicOptions
$smf_board = 54; //Any board id, found in URL
//posterOptions
$smf_id = 6; //any id, this is found as ID in memberlist
//SMF Post function
require_once('../../forums/SSI.php');
require_once('../../forums/Sources/Subs-Post.php');
//createPost($msgOptions, $topicOptions, $posterOptions);
// Create a post, either as new topic (id_topic = 0) or in an existing one.
// The input parameters of this function assume:
// - Strings have been escaped.
// - Integers have been cast to integer.
// - Mandatory parameters are set.
// Collect all parameters for the creation or modification of a post.
$msgOptions = array(
'subject' => $smf_subject,
'body' => $smf_body,
//'smileys_enabled' => !isset($_POST['ns']),
);
$topicOptions = array(
//'id' => empty($topic) ? 0 : $topic,
'board' => $smf_board,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => $smf_id,
);
//Execute SMF post
createPost($msgOptions, $topicOptions, $posterOptions);
This will create the simplest of posts with title and body defined by you, along with location and who the author is. More parameters can be found in the SMF functions database for createPost. The SSI and Subs-Post.php includes must be the original directly, copying them over doesn't do the trick.
Hi guys can anyone shed some light on how to do this please.
I have a userRecord object with various sub-objects in including things like their skills-sets, contracts etc.
I get the record by querying the store for the userId as below.
var userRecord = userStore.findRecord('id', userId);
Next I have a variety of forms with checkboxes in a tabpanel relating to each of the user's sub-objects e.g. Skillsets and Contracts. I am trying to overwrite these on the userRecord with an array on checkboxes that have been checked.
var skillsetCheckBoxes = skillsetPanel.query('checkboxfield[checked=true]');
var skillsets = new Array();
Ext.each(skillsetCheckBoxes, function (skillset)
{
console.log(skillset);
skillsets.push(skillset);
});
I have tried to set the userRecord's engineer's skillset object to be the new array:
userRecord.set(('engineer').skillsets, skillsets);
But when I log the record after doing this it is still the same record I retrieved from findRecord() with no edited fields.
Any help much appreciated,
Thanks!
Hard to say without knowing your model's structure, but your line is clearly wrong. You are using ('engineer').skillsets as the key argument for the set method. Since it's not a string but an array, it won't do anything good.
Your line should rather be something like that:
// You should probably test that there is something in there, or the
// next line could crash...
var engineer = userRecord.get('engineer');
if (engineer) {
userRecord.get('engineer').skillsets = skillsets;
}
I have a product entity and it has an images field that store the images names from the product but the images names depends of a part_number field that is unique, so if the user make a mistake in the part number and he wants to edit it then I also have to change the images names
I tried this but it does not works:
// class ProductsAdmin extends Admin
public function preUpdate($product) {
$old_product = $this->getSubject();
if ($old_product->getPartNumber() != $product->getPartNumber)
{
// change file names
}
$this->saveFile($product);
}
How I get the original row in preUpdate() function?
According to the topic taken from the official SonataAdmin google forum:
https://groups.google.com/forum/#!topic/sonata-devs/0zML6N13i3U
you need to make use of the class UnitOfWork:
http://www.doctrine-project.org/api/orm/2.3/class-Doctrine.ORM.UnitOfWork.html
Do this way:
public function preUpdate($object)
{
$em = $this->getModelManager()->getEntityManager($this->getClass());
$original = $em->getUnitOfWork()->getOriginalDocumentData($object);
}
Thus you get an array of values of your database entity.
E.g: to get access to the value password of your entity do:
$password = $original['password'];
That's all.
Enjoy :)
If you just do a doctrine query in the preUpdate function to get the product from the database you'll have the old object. Then do the comparison and you're good to go.
I am trying to add fields to com.liferay.portal.model.User, an extra attribute using Expando. Can someone explain to me how this method is adding a field because docs don't have much description.
private void addUserCustomAttribute(long companyId, ExpandoTable userExpandoTable, String attributeName, int type) throws PortalException, SystemException {
ExpandoColumnLocalServiceUtil.getColumn(userExpandoTable.getTableId(), attributeName); //should be addColumn(long tableId, String name, int type) ???
} //and where can find type description couse i have very specific type, Map(String,Object) couse in ExpandoColumnConstants didn't see it
I have taken this from Liferay Expando Wiki's Adding User Custom Attributes.
When should I call this all? Where to put this in my project? What change is required or everything needs to be changed to call it.
Some good tutorial will be nice because it's hard to find something from 0 to end, always found only some part with no explanation.
The question is not very clear. But if you simply want to add a custom attribute for your User then you can refer to my answer here and reproduced for your reference:
Custom field for the user-entity can be created through:
Control Panel -> Portal -> Custom Fields -> User.
And programmatically can be created as follows:
user.getExpandoBridge().addAttribute("yourCustomFieldKey");
Then set the value as:
user.getExpandoBridge().setAttribute("yourCustomFieldKey", "valueForCustomField");
If your custom field is already present you can check like this:
if (user.getExpandoBridge().hasAttribute("yourCustomFieldKey")) { ... };
The data is stored in tables prefixed with "EXPANDO":
EXPANDOCOLUMN: stores the custom field key and other settings
(contains the tableId refrences)
EXPANDODATA: stores the custom field value for the key (contains the
columnId and tableId refrences)
EXPANDOTABLE: stores for which liferay entity (user) are you adding
the custom field
EXPANDOROW: stores linking information between a user and its values
(contains tableId and userId refrences)
Hope this helps.
If your custom field is multivalue, you can use this:
String customVal = "yourCustomFieldValue";
user.getExpandoBridge().setAttribute("yourCustomFieldKey", new String[] {customVal }, false);
The last parameter set to "false" avoids permission check.
I want to get all conflict documents from a Notes database. So far, i've got this:
Domino.NotesSession notesSession;
Domino.NotesDatabase notesDatabase = this.OpenDatabase(out notesSession);
Domino.NotesDateTime dateTime = notesSession.CreateDateTime(String.Empty);
Domino.NotesDocumentCollection results =
notesDatabase.Search(this.SearchString, dateTime, 0);
It works with, for example:
searchString = "#Contains(ShortName;\"Bob\")";
How can I do the equivalent for conflict documents?
Try this:
searchString = "#IsAvailable($Conflict)";
There is a field on a document that flags any Notes document as a conflict called "$Conflict". If it's present on the document, then you know it's a conflict, (like Carlos is eluding to).
You can create a view in the database that has the formula.
Select #isAvailable("$Conflict")
and then loop through all documents in the view. It looks like you're doing it in Java so I think it would look like this
import lotus.domino.*;
import java.util.*;
//.....
//.....
Session s = NotesFactory.createSession();
Database db = s.getDatabase("server", "filename");
View vw = db.getView("viewname");
Document doc = null;
doc = vw.getFirstDocument();
while (doc != null) {
// do what you want in here.
doc = vw.getNextDocument(doc);
}
You'll need to make sure you have added the Domino jars to your project. This is a good reference for setting up the eclipse IDE for Domino java development.
PS. You can also modify the design of the database to minimise replication conflicts. But I won't bore you here with the details. Post a comment if you would like to know and ill provide instructions on this thread.