Created
August 5, 2013 19:18
-
-
Save greenstork/6158629 to your computer and use it in GitHub Desktop.
Power of Us Hub terms of use component and controller. It depends on Twitter Bootstrap, namespaced for use in a Visualforce page, and the plugin called Bootstrap Scroll Modal - https://github.com/aroc/Bootstrap-Scroll-Modal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:component allowDML="true" controller="PUB_TOUController"> | |
<apex:includeScript value="{!URLFOR($Resource.pubstyles, 'js/bootstrap-scroll-modal.js')}" /> | |
<apex:styleSheet value="{!URLFOR($Resource.pubstyles, 'css/bootstrap-scroll-modal.css')}" /> | |
<style> | |
.bootstrap .modal-backdrop, .bootstrap .modal-backdrop.fade.in { | |
opacity:1; | |
} | |
</style> | |
<apex:outputPanel rendered="{!updateTOU}"> | |
<script> | |
$(window).load(function(){ | |
$('#TOUmodal').modal({ | |
dynamic: true, | |
show: true, | |
backdrop: 'static', | |
keyboard: false | |
}); | |
}); | |
function closeModal() { | |
$('#TOUmodal').modal('hide'); | |
} | |
</script> | |
<div id="TOUmodal" class="modal fade hide" tabindex="-1" data-replace="true"> | |
<div class="modal-header"> | |
<h3>Salesforce.com Foundation <br /> | |
Power of Us Hub Terms of Use</h3> | |
</div> | |
<div class="modal-body"> | |
<div class="well well-small"> | |
<p><strong><em>Welcome to the Power of Us Hub - a central place for you to share, learn and collaborate.</em></strong></p> | |
<p><em>You must read and accept the remarkably funny and tender Terms of Use from our legal team below in order to gain access to the Power of Us Hub. Once you click "Accept" at the bottom of this page, you won’t see this document again (unless you want to).</em></p> | |
<p><em>Looking forward to seeing you in the Hub.</em></p> | |
<p><em>-Alicia Schmidt, Director, Customer Communities</em></p> | |
</div> | |
<p>By accessing or using any part of the site, You agree that You are subject to and will comply with these Terms of Use, as We may update them from time to time.</p> | |
<p>These Terms of Use were last updated on June 30, 2013.</p> | |
<h3>1. DEFINITIONS</h3> | |
<p>The <strong>"Power of Us Hub"</strong> means the web pages accessible via http://powerofus.salesforcefoundation.org, foundation.force.com, and powerofus.force.com.</p> | |
<p><strong>"We," "Our" or "Us"</strong> means The Salesforce.com Foundation and/or salesforce.org.</p> | |
<p><strong>"You" or "your"</strong> means you as an individual and any company or organization for whom you are using the Power of Us Hub.</p> | |
<h3>2. YOUR PROFILE AND ACCOUNT</h3> | |
<p>You agree that all information You submit to the Power of Us Hub pages, including to the profile pages, is accurate and that You will keep it current. If We have grounds to suspect that Your information is untrue, inaccurate or incomplete, We have the right to suspend or terminate Your use of the Power of Us Hub, including Your Power of Us Hub account. It is Your responsibility to maintain the confidentiality of any password created in association with Your use of the Power of Us Hub, and You are responsible for any activities in Your Power of Us Hub accounts. You agree that We may send You important information and notices regarding the Power of Us Hub and Your Power of Us Hub accounts by email, text messaging or other means based on the information You provide to Us.</p> | |
<h3>3. YOUR RESPONSIBILITIES</h3> | |
<p>You are responsible for all of Your activities in the Power of Us Hub. You shall treat other Power of Us Hub users with courtesy and respect. You shall not:</p> | |
<ul> | |
<li>Impersonate any other person;</li> | |
<li>Falsely say or imply that You are associated with another person or entity;</li> | |
<li>Submit content in exchange for payment or other consideration from another person or entity;</li> | |
<li>Collect information about other Power of Us Hub users without their consent; or</li> | |
<li>Submit or link to any content that:</li> | |
<ul> | |
<li>Infringes or violates the intellectual property or other rights of any person or entity;</li> | |
<li>Intentionally interferes with the operation of the Power of Us Hub;</li> | |
<li>Violates anyone’s privacy or publicity rights;</li> | |
<li>Breaches any duty of confidentiality that You owe to anyone;</li> | |
<li>Provides any non-public information about Us or any other company or person without authorization (including the names and contact information for Our employees or Power of Us Hub users);</li> | |
<li>Is, in Our judgment, harassing, defamatory, abusive, lewd, pornographic, obscene or otherwise objectionable;</li> | |
<li>Contains or installs any viruses, worms, bugs, Trojan horses, malware or other code, files or programs designed or having the capability to disrupt, damage or limit the functionality of any software or hardware; or</li> | |
<li>Contains false or deceptive language, unsubstantiated or comparative claims regarding Our or others’ products, advertising, commercial referrals, spam, chain letters, or any other solicitation, including solicitation of lawsuits.</li> | |
</ul> | |
</ul> | |
<p>Please remember that You may be providing content for an international audience. Things that do not seem abusive, obscene, or offensive to You might seem so to others.</p> | |
<p>We reserve the right, in Our sole discretion and without cause at any time, and without notice to You, to remove, or refuse to post any content submitted or posted by You to the Power of Us Hub.</p> | |
<h3>4. TRADEMARKS</h3> | |
<p>The Salesforce.com Foundation, salesforce.org, the "Power of Us" logo, and other marks of The Foundation used on the Power of Us Hub are owned by Us and may not be used in any manner without Our express prior written consent pursuant to The Salesforce.com Trademark and Copyright Usage Guidelines available at: http://www.sfdcstatic.com/assets/pdf/misc/salesforce_Trademark_Usage_Guidelines.pdf. A list of marks owned by Us is available at: http://www.sfdcstatic.com/assets/pdf/misc/salesforce_TM_list.pdf.</p> | |
<h3>5. NO WARRANTY</h3> | |
<p>THE POWER OF US HUB IS PROVIDED “AS-IS,” EXCLUSIVE OF ANY EXPRESS OR IMPLIED WARRANTIES WHATSOEVER. WE DISCLAIM ALL IMPLIED WARRANTIES, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.</p> | |
<p>CONTENT POSTED BY ANYONE OTHER THAN US ON THE POWER OF US HUB IS THE SOLE RESPONSIBILITY OF THE ORIGINATOR OF THAT CONTENT. WE ARE NOT RESPONSIBLE FOR ANY CONTENT POSTED BY YOU OR ANY THIRD PARTY, WHETHER OR NOT WE REVIEWED OR MODERATED SUCH CONTENT. CONTENT POSTED BY US ON THE POWER OF US HUB PAGES ARE NOT PART OF ANY USER GUIDE OR LEGAL AGREEMENT. ALL SUCH AFOREMENTIONED CONTENT IS PROVIDED “AS-IS”, AND WE DO NOT MAKE ANY REPRESENTATION AS TO ITS QUALITY OR ACCURACY, AND WE SPECIFICALLY DISCLAIM THE ACCURACY, COMPLETENESS, RELIABILITY, USEFULNESS, NON-INFRINGEMENT, QUALITY OR ORIGINALITY OF SUCH CONTENT. WE DISCLAIM ANY RESPONSIBILITY WHATSOEVER FOR ANY CONTENT OR MATERIAL ON THE POWER OF US HUB REGARDLESS OF WHO ORIGINATED THAT CONTENT (INCLUDING OUR EMPLOYEES, PARTNERS, AFFILIATES OR MODERATORS).</p> | |
<h3>6. NO DAMAGES</h3> | |
<p>YOU AGREE THAT YOU BEAR ALL RISKS ASSOCIATED WITH USING OR RELYING UPON CONTENT ON THE POWER OF US HUB, INCLUDING FEATURE REQUESTS AND CONTENT ON THE IDEAEXCHANGE. IN NO EVENT SHALL WE HAVE ANY LIABILITY HEREUNDER TO YOU FOR ANY LOSSES OR DAMAGES WHATSOEVER, INCLUDING BUT NOT LIMITED TO DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA OR USE, HOWEVER CAUSED AND, WHETHER IN CONTRACT, TORT OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p> | |
<h3>7. INDEMNITY</h3> | |
<p>You agree to indemnify and hold Us and Our subsidiaries, affiliates, officers, agents, and employees harmless from any claims, demands, liabilities, losses, damages, costs and expenses (including, without limitation, reasonable attorneys' fees) arising from: (i) Your breach of these Terms of Use or (ii) any claim made by any third party arising out of content You submit to or post on the Power of Us Hub, including, but not limited to, Your violation of these Terms of Use, Your violation of any rights of a third party.</p> | |
<h3>8. PROPRIETARY RIGHTS AND PRIVACY</h3> | |
<p>You grant to Us a perpetual, worldwide, fully paid up right and license to use, copy, modify, publish, republish, distribute and create derivative works based on, in any form, any content or material You contribute to the Power of Us Hub. Subject to the limited rights expressly granted hereunder, We reserve all rights, title and interest in and to all intellectual property rights subsisting in the Power of Us Hub, including but not limited to its user interface, branding, and underlying technology. No rights are granted to You hereunder other than as expressly set forth herein.</p> | |
<p>Subject to the above, we will treat information You submit to the Power of Us Hub pages in accordance with our Privacy Statement at http://www.salesforce.com/company/updated_privacy.jsp.</p> | |
<h3>9. REMOVAL OF MATERIAL UNDER U.S. DIGITAL MILLENNIUM COPYRIGHT ACT</h3> | |
<p>If We receive a notice alleging that material or content You posted on the Power of Us Hub infringes another party’s copyright, We may remove that material in accordance with Title II of the Digital Millennium Copyright Act of 1998 (Section 512 of the U.S. Copyright Act).</p> | |
<h3>10. ENFORCEMENT</h3> | |
<p>We generally do not pre-screen, verify, edit or moderate the content posted by users on the Power of Us Hub but may do so from time to time in its sole discretion. We and our agents reserve the right to investigate any violation of these Terms of Use and to take appropriate remedial action.</p> | |
<p>Any violation of these Terms of Use may result in the suspension or termination of Your ability to use or participate on the Power of Us Hub and its associated pages. We have absolute discretion to enforce these Terms of Use, including, but not limited to, warning users of violations, disabling or suspending privileges and/or access, deleting, screening or editing any content, or prohibiting any behavior that does not comply with these Terms of Use, or which is otherwise inappropriate, harmful, objectionable or inaccurate.</p> | |
<p>Deliberate attempts by You or someone on Your behalf to evade or circumvent the suspension or termination of Your rights to use or participate on the Power of Us Hub violates these Terms of Use, constitutes an unlawful trespass to Our equipment and systems, and may result in legal action.</p> | |
<p>We may release information concerning Your use of the Power of Us Hub (including posted content, registration information, and network records) when it believes release is appropriate to comply with the law (e.g., pursuant to a subpoena, warrant or court order); to enforce or apply these Terms of Use; to protect Our rights or property; to protect against fraudulent, abusive or unlawful use or participation on the Power of Us Hub; or if We reasonably believe that a situation involving imminent danger of death or serious bodily injury to any person requires disclosure.</p> | |
<p>To report violations of these Terms of Use, please email [email protected] with appropriate details, including Your contact information.</p> | |
<h3>11. MISCELLANEOUS</h3> | |
<p>These Terms of Use do not create a partnership, franchise, joint venture, agency, fiduciary or employment relationship between You and Us. You may not assign Your rights or obligations under these Terms of Use, whether by operation of law or otherwise, without Our prior written consent.</p> | |
<p>These Terms of Use shall be governed exclusively by the internal laws of the State of California, without regard to its conflicts of laws rules or the United Nations Convention on the International Sale of Goods. Each party hereby consents to the exclusive jurisdiction of the state and federal courts located in San Francisco County, California to adjudicate any dispute arising out of or relating to this Agreement. Except as expressly stated in these Terms of Use, these Terms of Use constitute the entire agreement between the parties, and supersede all prior and contemporaneous agreements, proposals or representations, written or oral, concerning their subject matter. No modification, amendment, or waiver of any provision of these Terms of Use shall be effective unless it is by an update to these Terms of Use that we make available on this website, or is in writing and signed by the party against whom the modification, amendment or waiver is to be asserted.</p> | |
</div> | |
<div class="modal-footer"> | |
<apex:form > | |
<apex:commandButton value="Logout" action="{!logout}" styleClass="btn" /> | |
<apex:commandButton value="Accept" action="{!acceptTOU}" styleClass="btn btn-primary" rerender="none" onClick="closeModal()" /> | |
</apex:form> | |
</div> | |
</div> | |
</apex:outputPanel> | |
</apex:component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public without sharing class PUB_TOUController { | |
public boolean updateTOU { get; private set; } | |
//constructor | |
public PUB_TOUController() { | |
// fetch the date the user last accepted the TOU, if ever | |
// and check the PUB settings to make sure it's later than the date listed | |
User[] u = [SELECT id, PUB_Terms_of_Use_Approval_Date__c FROM User WHERE id = :UserInfo.getUserId() | |
AND User.UserType != 'Standard' | |
]; | |
if (!u.isEmpty()) { | |
Power_of_Us_Hub_Settings__c settings = Power_of_Us_Hub_Settings__c.getOrgDefaults(); | |
// if the user has never accepted the TOU or the date of last approval is older | |
// than the date of requiring approval, the user needs to accept the TOU | |
if (u[0].PUB_Terms_of_Use_Approval_Date__c == null || u[0].PUB_Terms_of_Use_Approval_Date__c < settings.Required_Terms_of_Use_Approval_Date__c) { | |
updateTOU = true; | |
} else { | |
updateTOU = false; | |
} | |
} else { | |
//we have an internal user | |
updateTOU = false; | |
} | |
} | |
public pageReference acceptTOU() { | |
//set the date of acceptance on the user record and rerender the modal to hidden | |
User u = [SELECT id FROM User WHERE id = :UserInfo.getUserId()]; | |
u.PUB_Terms_of_Use_Approval_Date__c = system.today(); | |
update u; | |
updateTOU = false; | |
return null; | |
} | |
public pageReference logout() { | |
pageReference logoutPage = new pageReference('/PUBlogout'); | |
logoutPage.setRedirect(true); | |
return logoutPage; | |
} | |
/**************************************************** | |
* TESTS * | |
****************************************************/ | |
static testMethod void testInternalUser() { | |
//grab an internal user for testing | |
User u = [SELECT id FROM User WHERE User.UserType = 'Standard' AND IsActive = true LIMIT 1]; | |
// for this internal user, we shouldn't have to update the Terms of Use | |
// since this is a staff person and not a customer or partner | |
system.RunAs(u) { | |
PUB_TOUController controller = new PUB_TOUController(); | |
System.assertEquals(false, controller.updateTOU); | |
} | |
} | |
static testMethod void testExternalUserAccept() { | |
//grab a PUB user for testing | |
User u = [SELECT id FROM User WHERE User.UserType = 'PowerPartner' AND IsActive = true LIMIT 1]; | |
system.RunAs(u) { | |
PUB_TOUController controller = new PUB_TOUController(); | |
// for this external user, we should have to update the TOU | |
System.assertEquals(true, controller.updateTOU); | |
//now accept the TOU and check that the user record was updated with today's date | |
controller.acceptTOU(); | |
} | |
User updatedUser = [SELECT id, PUB_Terms_of_Use_Approval_Date__c FROM User WHERE id = :u.id]; | |
system.assertEquals(system.today(),updatedUser.PUB_Terms_of_Use_Approval_Date__c); | |
} | |
static testMethod void testExternalUserLogout() { | |
//grab a PUB user for testing | |
User u = [SELECT id FROM User WHERE User.UserType = 'PowerPartner' AND IsActive = true LIMIT 1]; | |
system.RunAs(u) { | |
PUB_TOUController controller = new PUB_TOUController(); | |
// for this external user, we should have to update the TOU | |
System.assertEquals(true, controller.updateTOU); | |
//now logout instead of accepting the TOU | |
controller.logout(); | |
} | |
User updatedUser = [SELECT id, PUB_Terms_of_Use_Approval_Date__c FROM User WHERE id = :u.id]; | |
system.assertEquals(null,updatedUser.PUB_Terms_of_Use_Approval_Date__c); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment