00001 <?php
00002 /*********************************************************************************00003 * Zurmo is a customer relationship management program developed by00004 * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.00005 *00006 * Zurmo is free software; you can redistribute it and/or modify it under00007 * the terms of the GNU Affero General Public License version 3 as published by the00008 * Free Software Foundation with the addition of the following permission added00009 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK00010 * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY00011 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.00012 *00013 * Zurmo is distributed in the hope that it will be useful, but WITHOUT00014 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS00015 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more00016 * details.00017 *00018 * You should have received a copy of the GNU Affero General Public License along with00019 * this program; if not, see http://www.gnu.org/licenses or write to the Free00020 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA00021 * 02110-1301 USA.00022 *00023 * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive00024 * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.00025 *00026 * The interactive user interfaces in original and modified versions00027 * of this program must display Appropriate Legal Notices, as required under00028 * Section 5 of the GNU Affero General Public License version 3.00029 *00030 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,00031 * these Appropriate Legal Notices must retain the display of the Zurmo00032 * logo and Zurmo copyright notice. If the display of the logo is not reasonably00033 * feasible for technical reasons, the Appropriate Legal Notices must display the words00034 * "Copyright Zurmo Inc. 2017. All rights reserved".00035 ********************************************************************************/00036
00040class GameNotificationToSocialItemContentAdapterextendsGameNotificationToContentAdapter00041 {
00045public function getMessageContent()
00046 {
00047 $data = $this->getAndValidateUnserializedData();
00048 if ($data['type'] == GameNotification::TYPE_LEVEL_CHANGE)
00049 {
00050 return Zurmo::t('GamificationModule', 'I reached level {nextLevel}', array('{nextLevel}' => $data['levelValue']));
00051 }
00052 elseif ($data['type'] == GameNotification::TYPE_NEW_BADGE)
00053 {
00054 $gameBadgeRulesClassName = $data['badgeType'] . 'GameBadgeRules';
00055 $value = $gameBadgeRulesClassName::getItemCountByGrade(1);
00056 $content = Zurmo::t('GamificationModule', 'Game on!') . ' ' .
00057 Zurmo::t('GamificationModule', 'I received a new badge: {badgeContent}',
00058 array('{badgeContent}' =>
00059 $gameBadgeRulesClassName::getPassiveDisplayLabel($value)));
00060 return $content;
00061 }
00062 elseif ($data['type'] == GameNotification::TYPE_BADGE_GRADE_CHANGE)
00063 {
00064 $gameBadgeRulesClassName = $data['badgeType'] . 'GameBadgeRules';
00065 $value = $gameBadgeRulesClassName::getItemCountByGrade((int)$data['grade']);
00066 $content = Zurmo::t('GamificationModule', 'Game on!') . ' ' .
00067 Zurmo::t('GamificationModule', 'I received a new badge: {badgeContent}',
00068 array('{badgeContent}' =>
00069 $gameBadgeRulesClassName::getPassiveDisplayLabel($value)));
00070 return $content;
00071 }
00072 else00073 {
00074 thrownewNotSupportedException();
00075 }
00076 }
00077 }
00078 ?>