Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 97 pm calendar missing projects #98

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 85 additions & 70 deletions src/classes/Milestone1_General_Utility.cls
Original file line number Diff line number Diff line change
@@ -1,71 +1,86 @@
/*
Copyright (c) 2011, salesforce.com, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the salesforce.com, Inc. nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.

*/
public with sharing class Milestone1_General_Utility
{
public static String processTaskName(String name)
{
String nameString = name;
if(nameString.length() >= 80)
{
nameString = nameString.subString(0,76);
Integer lastSpaceLocation = Milestone1_General_Utility.truncateStringAtSpace(nameString);
if(lastSpaceLocation > -1)
{
nameString = nameString.subString(0,lastSpaceLocation);
}
nameString = namesTring + '...';
}

return nameString;
}

/**
* Checks if the current User have Permissions like System Admin
* @return boolean
* @author Sebastian Muñoz
* @createDate January 19, 2011
*/
public static Boolean isSysAdmin() {
Profile pObj = [SELECT PermissionsModifyAllData, Id FROM Profile WHERE Id=:Userinfo.getProfileId() limit 1];
return pObj.PermissionsModifyAllData;
}

public static Integer truncateStringAtSpace(String inputString)
{
Integer location = inputString.lastIndexOf(' ');
return location;
}

static testMethod void testTruncateString()
{
String example = 'NEW DESCRIPTION 1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ THIS IS LONG DESCRIPTION GREATER THAN 80 CHARACTER LIMIT FOR NAME TEST TRUNCATING';
String nameString = Milestone1_General_Utility.processTaskName(example);
system.AssertEquals('NEW DESCRIPTION 1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ THIS IS LONG...',nameString);
}
/*
Copyright (c) 2011, salesforce.com, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the salesforce.com, Inc. nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.

*/
public with sharing class Milestone1_General_Utility
{
public static String processTaskName(String name)
{
String nameString = name;
if(nameString.length() >= 80)
{
nameString = nameString.subString(0,76);
Integer lastSpaceLocation = Milestone1_General_Utility.truncateStringAtSpace(nameString);
if(lastSpaceLocation > -1)
{
nameString = nameString.subString(0,lastSpaceLocation);
}
nameString = namesTring + '...';
}

return nameString;
}

/**
* Checks if the current User have Permissions like System Admin
* @return boolean
* @author Sebastian Muñoz
* @createDate January 19, 2011
*/
public static Boolean isSysAdmin() {
/****************************************************************************************************
/* Author: Passage Technology (www.passagetech.com) *
/* Issue: It is possible to have a user without a profile Id. *
/* http://www.salesforce.com/us/developer/docs/packagingGuide/Content/apex_post_install_script.htm *
/* Comment: This fix resolves an error on no rows to assign to SObject. *
/****************************************************************************************************/

Profile pObj;

for(Profile p : [SELECT PermissionsModifyAllData, Id FROM Profile WHERE Id=:Userinfo.getProfileId()]) {
pObj = p;
}
if(pObj == null) {
return true;
} else {
return pObj.PermissionsModifyAllData;
}
}

public static Integer truncateStringAtSpace(String inputString)
{
Integer location = inputString.lastIndexOf(' ');
return location;
}

static testMethod void testTruncateString()
{
String example = 'NEW DESCRIPTION 1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ THIS IS LONG DESCRIPTION GREATER THAN 80 CHARACTER LIMIT FOR NAME TEST TRUNCATING';
String nameString = Milestone1_General_Utility.processTaskName(example);
system.AssertEquals('NEW DESCRIPTION 1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ THIS IS LONG...',nameString);
}
}
2 changes: 1 addition & 1 deletion src/classes/Milestone1_General_Utility.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>20.0</apiVersion>
<apiVersion>27.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>20.0</apiVersion>
<apiVersion>27.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>20.0</apiVersion>
<apiVersion>27.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>20.0</apiVersion>
<apiVersion>27.0</apiVersion>
<status>Active</status>
</ApexClass>
Loading