2sxc update an entity to set IsPulished to false - 2sxc

I need to be able to set the IsPublished value of an existing entity to false through the WebAPI. According to https://2sxc.org/en/docs/feature/feature/3360 :
Just so you don't get things wrong: an Update with "IsPublished"=false will not hide the existing entity, but will hide the change you just made.
Is there a way to do this through the WebAPI, or can this only be done through the 2sxc GUI panel?

In v13.02 you can include IsPublished true or false. The behavior will be
true will set everything to published
false will set it to draft, and if there was a published one before, it will remain published
In v13.03 you will be able to do true, false and "draft"
true will set everything to published
false will set everything to unpublished
"draft" will set the updated data to draft, and if there was a published one before, that will leave.

It will be available in 2sxc 13.02
old answer:
As of now it can only be done with very internal APIs.
But I believe it would be fairly easy to add it to the simple data-api - the App.Data.Update(...) - so if you think it's important, just add an issue.

Related

Check condition before changing post status in wordpress

I have a form in the front end which enables users to submit posts. These posts are by default saved as pending. It can only set to publish by the admin. Before publishing certain conditions are to be checked before its set as published.
If the condition is true set post status as publish. If not set it as pending. What is the appropriate action hook to achieve this?
look here, there is 6 hooks than you can use for that :
https://core.trac.wordpress.org/browser/tags/5.3/src/wp-includes/post.php#L4058
just take care that the values that you use in your condition can also be change on this hooks then you have to test where you have the values you need.

wp_delete_post() force deleting post, override ignored

I have set up a custom post type with a way to manage the posts on the front end of the site. On the front end users have the option to edit or delete posts.
When the user clicks delete, I run the wp_delete_post() function, to send the post to the trash. I don't want the post to bypass the trash, I would actually like the post to be sent to the trashcan.
The second parameter of the wp_delete_post is a boolean, true/false , which is supposed to dicate weather or not to bypass the trash.
The first is the ID of the post you'd like to delete.
http://codex.wordpress.org/Function_Reference/wp_delete_post
Here is my function:
wp_delete_post( $cpt_id, false );
As you can see, I've set the second parameter to false, but it still bypasses the trash and gets deleted from the server.
Is this a bug that I should report to core, or am I missing something simple?
Thanks!
Since you never want to delete and always want to trash, you could use wp_trash_post() instead. (http://codex.wordpress.org/Function_Reference/wp_trash_post)
However, that simply calls wp_delete_post() for you.
If none of your deletes are going to the trash, make sure that EMPTY_TRASH_DAYS is not set to 0 somewhere. (e.g. your wp-config.php) (http://codex.wordpress.org/Editing_wp-config.php)
HTH,
=C=

Keep a log of user actions in Symfony2

I'm working on a project where I'm using Symfony2 (latest) and SonataAdmin. I need to keep log of users actions by logging:
action/event date/time (when and at which time the user did something)
the user himself (the id of the user who did the action/event)
affected rows (which rows was affected by for example changing some data in a form)
I find in KnpBundles and over Google without success, can any give me some tips or ideas? Or if someone did this before give me some code as start point? Take in mind that I'm using SonataAdmin and this is a bit complicated.
The stofDoctrineExtensions (a Symfony wrapper for Gedmo's DoctrineExtensions) Loggable extension would do this for you.
This extensions can be set to log a username, changed (create, updated & remove) and the data changed (if specified) in a table that can then be used to log and/or revert changes.
StofDoctrineExtensions (Wrapper of below)
Gedmo\DoctrineExtensions (Loggable)

Sitecore context in HttpModule

I created simple HttpModule, all what I need is just get is valid Sitecore.Context inside but during processing I see that my Sitecore.Context is some kind of default.
I can get Sitecore user that log in to Sitecore, etc.
How to fix it ?
I assume you have a Sitecore Context, but it is null or set to the wrong site or language.
You can change the context like this:
// switch to the preferred site
Sitecore.Context.SetActiveSite("yourSiteName");
// set the preferred database
Sitecore.Context.Database = Sitecore.Configuration.Factory.GetDatabase("master");
// set the preferred language
Language language = Sitecore.Globalization.Language.Parse("en");
Sitecore.Context.SetLanguage = (language, false);
You probably also want to switch back to the original settings after your processing is done. So it is wise to "save" the original settings in a variable so you can change them back afterwards
Take a look at John West's posts on Sitecore pipelines for some background on how the context is being established.
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/All-About-Pipelines-in-the-Sitecore-ASPNET-CMS.aspx
and
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/Important-Pipelines-in-the-Sitecore-ASPNET-CMS.aspx
The following blog post on creating and running custom pipelines should give you an idea how to implement your own pipeline.
http://adeneys.wordpress.com/2008/08/27/creating-and-running-custom-pipelines-in-sitecore/

How to create a password field in xcode

I am trying to make an iPhone App in which i will make user to login into their account.
For this i want userID and Password from the user. My question is how i can make a password
field in which whatever I enter will be shown as "*".
Sounds like you are looking for "setSecureTextEntry" on a "UITextField" object.
Also known as the "secureTextEntry" property in the "UITextInputTraits" protocol.
You can call this programatically via calling ".secureTextEntry = YES" on the "UITextField" object you want to be set for passwords.
You can also set it in Interface Builder (look for "Secure" checkbox in your text field Attributes inspector). It looks like this:
And in newer version of Xcode:
Update for Xcode 12.2+
My opinion is programmatic declaration of properties are easier to toggle back and forth.
Programmatically in Swift 5:
myPasswordTextField.isSecureTextEntry = true

Resources