Know Admin from HMUsers array - homekit

I have an issue that When I want to add the room to the Home incase if the user is Guest then I am getting HMErrorCodeInsufficientPrivileges error. I have a view which will display after click on the button named "Add Room", My intensin is I want to detect it when the user clicked on the Add Room button and wants to display the alert without redirecting the user to Add Room View. Thank you for the valuable time. Please let me know if I am not clear.

Finally in iOS 9 I found this solution.
HMUser *adminOrNot = [selectedHome currentUser];
HMHomeAccessControl *homeContr = [selectedHome homeAccessControlForUser:adminOrNot];
if(homeContr.administrator)
{
}

Related

PrestaShop: How to fix a social share toggle that open in automatic in all products

I entered a toggle for social sharing in the /miniatures/product.tpl but if I click it, it works only in the first product of the page, not in a random single one I want. I tried to fix it changing the .js but in the second way it opens in all products at the same time!
Is there a way to open it in every single product one by one?
I'm using this toggle
You should try thisĀ :
$(document).ready(function(){
$('#s-icons').click(function() {
$(this).children('.navbar-nav').toggleClass("show");
});
});

User validation in Google Sheets

I've been working on a project in Google Sheets for my team! The thing is: I've a sheet inside it and I want only me and 2 other people (they can edit the sheet) to see it, so that anyone entering with a "View-Only" permission would not see it!
EDIT: Let me explain a little better: I have a project which includes the specific sheet (let me call it Sheet_1) that I want to keep secret.
The project consists in a database for financial status of my team, so it is mandatory that ALL team members may see it. But there's the catch: I don't want EVERYONE in the team to see Sheet_1, I want only a specific group (call it Admins) to be able to see it. I cannot simply hide Sheet_1 because every time the Admins edit it in any way, it becomes visible for everyone again.
So let me be clear over who's involved in this
Admins: People (including me) who can see everything and change everything in the project
Non-Admins: People who must view the project in a "View-Only" Mode, and may not see Sheet_1
I've searched for a little bit and this is the code that I have:
function onOpen() {
var adminUsers = ['admin#email.com'];
if (adminUsers.indexOf(Session.getEffectiveUser().getEmail()) >= 0) {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('sheetname').showSheet()
}
else {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('sheetname').hideSheet()
}
}
But this code doesn't work! It doesn't hide the sheet when the non-Admins view my project, and it also asks for a Google login each time someone opens the project!
So, the code that I'm looking for is something like this:
function onOpen(){
var admin = [authorized emails that I inputted manually]
var email = getCurrentUserEmail()
if(email is in admin){
show specific sheet
}
else{
don't show specific sheet
}
EDIT: I see now that maybe what I'm asking is too complicated, so I'd be glad if anyone could give me suggestions!
Can anyone help me with this? I'll give more detalis if necessary!
Thanks!

UITabViewController hide / make appear a view in code

I am using Xcode 5.1.1.
I have a UITabViewController and used Storyboard to add 10 views to it.
It works great and I get the "more" and table view all for free.
I only want to show some of the tabs at the beginning.
Once the user logs in with their Google+ account (I actually got that working), then I want the rest of the tabs to appear, since they are content sensitive to the user logging in.
I have found:
[[[[self.tabBarController tabBar]items]objectAtIndex:3]setEnabled:FALSE];
But I do not want the items just greyed out, I want them removed completely until they log in.
Thanks
Get all the tabbarviewcontrollers and remove them specifying the index of your need as follows:
NSMutableArray *tabbarViewControllers = [NSMutableArray arrayWithArray:[self.tabBarController viewControllers]];
[tabbarViewControllers removeObjectAtIndex: 0 or 1 or 2];
[self.tabBarController setViewControllers: tabbarViewControllers ];

Order of links in Settings Charm

Does anyone know how I can position a link inside the settings charm to always appear at the bottom?
Our UI team would like the "Sign out" link to always be position last, unfortunately the "Permissions" link, which is automatically added, shows below it, even though I use the append call on the applicationCommands object.
var signOutCommand = new Windows.UI.ApplicationSettings.SettingsCommand(
"sign-out",
"Sign out",
signOutHandler,
);
e.detail.e.request.applicationCommands.append(signOutCommand);
I haven't found anything explicitly stating so, but I don't think it's possible to get in below the Permissions link.

Joomla 2.5 - Visible Menu Item - but need login to access

I followed this tutorial about ACL - http://community.joomla.org/blogs/community/1252-16-acl.html
To make everything clear: this is what I need:
having a menu item that is linking to an article
a user enters (not logged yet) the web site (it does not matter if the user is already registered or not)
this user should see the menu item
the user clicks on the menu item
if the user is NOT logged in - the user is asked to enter the username/pass
if the user is logged in -> goto 6
after login is ok, the user can see the content of the article where the menu item was linked.
My aim is to have a menu item that would be visible for all users: logged in and not logged in. But when clicked - only logged in users can view the content where the menu item is pointing. In case the user is not logged in -> log in form should be displayed.
After following the above tutorial I got a menu item that is completely invisible for users that are NOT logged in.
How can I make the menu item to be visible for all, but need login to see content?
Thank you.
EDIT 1:
I just found this solution http://docs.joomla.org/Auto_redirect_guests_to_login
Is it the only solution? I have a huge tree menu structure. That means I need to have a clone of my huge menu... And everytime I change a menu item name - I should do it twice (in visible menu and in invisible menu).
Are there any other solutions without having 2 menus?
EDIT 2:
Found another solution (hacking core files).
This is when menu item is set to "public" but the article ACL is set to "registered"
components/com_content/views/article/view.html.php
from
// Check the view access to the article (the model has already computed the values).
if ($item->params->get('access-view') != true && (($item->params->get('show_noauth') != true && $user->get('guest') ))) {
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
to
// Check the view access to the article (the model has already computed the values).
if ($item->params->get('access-view') != true && (($item->params->get('show_noauth') != true && $user->get('guest') ))) {
// Redirect to login
$uri = JFactory::getURI();
$app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('Members please login to view this page. If you are not a member please <a href="/component/users/?view=registration">register here<a>'));
return;
}
How can I override that code and avoid hacking core files?
Or maybe there is a more elegant solution?
Thanks.
What you can do is a template override and add the login form to the page that provides the message. A template override will allow you to add extras to pages without hacking the core files, therefore when updating Joomla, it will still be there.
For more information on how to override, please see the link below:
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
Hope this helps.

Resources