How to remove settings? or any direct access to Settings table? - aspnetboilerplate

How can we remove a tenant or user setting that has been saved to the database? so that the default Host setting is used again?
I don't see any direct access to the settings table via a repository? nor do I see an DeleteSetting options within the SettingManager.
Any help/ideas would be greatly appreciated.
take care,
jasen

Changing the setting to the default value removes it from the database.
var settingName = "mySettingName";
var userIdentifier = new UserIdentifier(1, 2);
var defaultValue = _settingDefinitionManager.GetSettingDefinition(settingName).DefaultValue;
_settingManager.ChangeSettingForUserAsync(userIdentifier, settingName, defaultValue);

Related

Creating Sugar configuration file (config.php) Creating Sugar application tables, audit tables and relationship metadata

I am getting timeout error and tried everything to change its value from 600 but now luck. Can any body help to do this for SugarCRM?
Instead of changing in SugarCRM configuration file config.php try to change in config_override.php. You can also add your custom configuration using module loader apply following code in manifest.php file.
$cfg = new Configurator();
// Your custom configuration code
$cfg->config['myaddon_setting'] = true; // This will make add-ons setting enable.
$cfg->handleOverride();
To Perform database queries use following code.
$mymodule = BeanFactory::newBean($module);
$db = DBManagerFactory::getInstance();
$query = "SELECT * FROM users WHERE 1";
$result = $db->query($query, true,"Error reading the database");
For logic hooks click on Logic Hooks. Write down in comment if you need anything else.

Parse JS SDK: How to set a default User ACL?

Conveniently this is blank in the JS Docs
Does an ACL have to be explicitly applied when each User is created?
I had the same question. The following appears to work, applied right after new User is created (before calling the signUp method):
var user = new Parse.User();
user.set( userObj )
var acl = new Parse.ACL();
// apply desired ACL methods here..
// by default, public read/write will be restricted
user.setACL( acl );
user.signUp( null, ... )
Initially, I tried passing user into new Parse.ACL() per Parse's docs, but that was not working.
(I'm now reading up on the Cloud Code because perhaps such security logic be better done there?)

Windows Azure Stored Access Policy Remove

I want to download blobs using Shared access signatures, SAS.
I also want to be able to remove active SAS URI's and, if I understand it correctly, I must use Stored Access Policy for this.
What confuses me is how I can remove a policy. I also read you can only have 5 stored access policies active?
My goal here is to be able to remove an active SAS URI. The only way I can think of accomplishing this is to remove the policy that the SAS URI is linked with, right? If I have over hundreds of files in my blob storage, how in the world can I make this work? I can't have one policy for each blob right? 5 is the maximum policies?
This code demonstrates how I add a policy and how I create a SAS URI that uses this policy, which users can download from.
static void CreateSharedAccessPolicy(CloudBlobContainer container)
{
//Create a new stored access policy and define its constraints.
SharedAccessBlobPolicy sharedPolicy = new SharedAccessBlobPolicy()
{
SharedAccessExpiryTime = DateTime.UtcNow.AddHours(10),
Permissions = SharedAccessBlobPermissions.Read | SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.List
};
//Get the container's existing permissions.
BlobContainerPermissions permissions = new BlobContainerPermissions();
//Add the new policy to the container's permissions.
permissions.SharedAccessPolicies.Clear();
permissions.SharedAccessPolicies.Add("PolicyName", sharedPolicy);
container.SetPermissions(permissions);
}
static string GetBlobSasUriWithPolicy(CloudBlobContainer container, string policyName)
{
//Get a reference to a blob within the container.
CloudBlockBlob blob = container.GetBlockBlobReference("file_name");
//Generate the shared access signature on the blob.
string sasBlobToken = blob.GetSharedAccessSignature(null, "PolicyName");
//Return the URI string for the container, including the SAS token.
return blob.Uri + sasBlobToken;
}
One last question, how do I remove a policy? Is it as simple as:
permissions.SharedAccessPolicies.Remove("PolicyName");
My goal here is to be able to remove an active SAS URI. The only way I
can think of accomplishing this is to remove the policy that the SAS
URI is linked with, right?
Partly correct. Removing the access policy is one way to do it. Other would be to change the name of the policy (policy identifier). For example if the policy identifier is mypolicy then changing it to mypolicy1 would have the same effect as removing the policy.
If I have over hundreds of files in my blob storage, how in the world
can I make this work?
As you may already know, access policy is defined at the blob container level and not at the blob level. Removing/invalidating an access policy would make invalidate SAS URL for all blobs in that container.
I can't have one policy for each blob right? 5 is the maximum
policies?
That is correct.
One last question, how do I remove a policy? Is it as simple as:
permissions.SharedAccessPolicies.Remove("PolicyName");
That is correct. Make sure you save it back though. You can use something like:
var cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
var blobClient = cloudStorageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("container-name");
var containerPermissions = container.GetPermissions();
containerPermissions.SharedAccessPolicies.Remove("access-policy-id");
container.SetPermissions(containerPermissions);

CodeIgniter to run from a subdirectory of another codeigniter installation

I am trying to find a way to run codeigniter from a sub-directory of another codeigniter installation. The CI from the sub-directory would be for testing and the main one is the live site. Anyone could advice on this or any other better approach ?
I believe you can just place this in the root folder and set the base url in the config :
$config['base_url'] = 'http://www.example.com/testsite/';
then it works.
There can be issues with the first application serving the 404 pages when a route is not matched however
I am posting the answer here, because is too long to use it as a comment...
I made it thru another approach: setting different $active_group in the config/database.php file.
So, first I have checked for a parameter in $_GET, if that is set we use a group, otherwise the default group (the other group is used for testing - a separate database, exact structure but without touching the main db)
if(!isset($_SESSION)){session_start();}
if (isset($_GET["debugmode"])){
$active_group = 'demodb';
$active_record = TRUE;
$_SESSION['debugmode'] = true;
}elseif (isset($_SESSION["debugmode"])){
$active_group = 'demodb';
$active_record = TRUE;
}elseif(!isset($_GET["debugmode"]) && !isset($_SESSION["debugmode"])){
$active_group = 'default';
$active_record = TRUE;
}
To make sure this will work on all the controllers /views, because we wont have that $_GET parameter all over the application, we can set that session value once we have that $_GET parameter present. Also, we have to make sure we destroy that session when we log out or after an amount of time.
Reason of using a Session value: by default CI is using that table to store the sessions, without using our session value, it will force somehow to use the default DB, or at least I couldn't find it to trick this step.

Modifying native module to work with other tables

I want to modify a native joomla module that display articles of a category. I want it to display articles of an other prefix tables (both joomla website are on the same server).
Notice that I already looked at available extension but none of them would fit.
I tried to modify the helper.php of the native joomla module
tables, by changing the
$com_path =
but i am getting aFatal error.
Native code:
$com_path = JPATH_SITE.'/components/com_content/';
My try :
$com_path = '/homez.420/kmxsiksf/rsc/components/com_content/helpers/route.php
To use an external database (even if it's on your server) in Joomla extensions, the proper way would be to set some options before retrieving the JDatabase-object.
Create a helperclass to handle your external db, and in every method that uses the DB-object you simply set the options of your external db before retrieving the object:
$option = array();
$option['driver']   = 'mysql';
$option['host']     = 'localhost';    // In your case probably localhost
$option['user']     = 'dbusername';       // User for database authentication $option['password'] = 'badpass12345';   // Password for database authentication $option['database'] = 'bigdatabase';      // Database name
$option['prefix']   = 'abc_';             // Database prefix (may be empty)
$db = & JDatabase::getInstance( $option );
You are now able to use your external database the same way as you would with your regular db.

Resources