public static function generateFeedEmail($filters, $userId, $range, $limit, $eventId, $deleteKey) { $image = Yii::app()->getAbsoluteBaseUrl(true) . '/images/x2engine.png'; $msg = "<div id='wrap' style='width:6.5in;height:9in;margin-top:auto;margin-left:auto;margin-bottom:auto;margin-right:auto;'><html><body><center>"; $msg .= '<table border="0" cellpadding="0" cellspacing="0" height="100%" id="top-activity" style="background: white; font-family: \'Helvetica Neue\', \'Helvetica\', Helvetica, Arial, sans-serif; font-weight: normal; font-style: normal; font-size: 14px; line-height: 1; color: #222222; position: relative; -webkit-font-smoothing: antialiased;background-color:#FAFAFA;height:25% !important; margin:0; padding:0; width:100% !important;" width="100%">' . "<tbody><tr><td align=\"center\" style=\"padding-top:20px;\" valign=\"top\">" . '<table border="0" cellpadding="0" cellspacing="0" id="templateContainer" style="border: 1px solid #DDDDDD;background-color:#FFFFFF;" width="600"><tbody>'; $msg .= '<tr> <td align="center" valign="top"><!-- // Begin Template Header \\ --> <table border="0" cellpadding="0" cellspacing="0" id="templateHeader" width="600"> <tbody> <tr> <td class="headerContent" style="color:#202020;font-weight:bold;line-height:100%;padding:0;text-align:center;vertical-align:middle;font-family: inherit;font-weight: normal;font-size: 14px;margin-bottom: 17px"><img id="headerImage campaign-icon" src="' . $image . '" style="border:0; height:auto; line-height:100%; outline:none; text-decoration:none;max-width:600px;" /></td> </tr> <tr> <td style="color:#202020;font-weight:bold;padding:5px;text-align:center;vertical-align:middle;font-family: inherit;font-weight: normal;font-size: 14px;"><h2>' . Yii::t('profile', 'Activity Feed Report') . '</h2></td> </tr> </tbody> </table> <hr width="60%"></td><!-- // End Template Header \\ --> </tr>'; $msg .= '<tr><td align="center" valign="top"><!-- // Begin Template Body \\ -->' . '<table border="0" cellpadding="0" cellspacing="0" id="templateBody" width="600"><tbody><tr>' . '<td valign="top"><!-- // Begin Module: Standard Content \\ -->' . '<table border="0" cellpadding="20" cellspacing="0" width="100%"><tbody>'; $params = array(); $userRecord = X2Model::model('Profile')->findByPk($userId); $params[':username'] = $userRecord->username; $parsedFilters = Events::parseFilters($filters, $params); $visibilityCondition = $parsedFilters['conditions']['visibility']; $accessCriteria = Events::model()->getAccessCriteria(); $userCondition = $parsedFilters['conditions']['users']; $typeCondition = $parsedFilters['conditions']['types']; $subtypeCondition = $parsedFilters['conditions']['subtypes']; $condition = "type!='comment' AND (type!='action_reminder' " . "OR user=:username) AND " . "(type!='notif' OR user=:username)" . $visibilityCondition . $userCondition . $typeCondition . $subtypeCondition . ' AND (' . $accessCriteria->condition . ')'; switch ($range) { case 'daily': $timeRange = 24 * 60 * 60; break; case 'weekly': $timeRange = 7 * 24 * 60 * 60; break; case 'monthly': $timeRange = 30 * 24 * 60 * 60; break; default: $timeRange = 24 * 60 * 60; break; } $condition .= " AND timestamp BETWEEN " . (time() - $timeRange) . " AND " . time(); $topTypes = Yii::app()->db->createCommand()->select('type, COUNT(type)')->from('x2_events')->where($condition, array_merge($params, $accessCriteria->params))->group('type')->order('COUNT(type) DESC')->limit(5)->queryAll(); $topUsers = Yii::app()->db->createCommand()->select('user, COUNT(user)')->from('x2_events')->where($condition, array_merge($params, $accessCriteria->params))->group('user')->order('COUNT(user) DESC')->limit(5)->queryAll(); $msg .= "<tr><td style='text-align:center;'>"; $msg .= "<div>" . Yii::t('profile', "Here's your {range} update on what's been going on in X2Engine!", array('{range}' => Yii::t('profile', $range))) . "</div><br>" . "<div>Time Range: <em>" . Formatter::formatDateTime(time() - $timeRange) . "</em> to <em>" . Formatter::formatDateTime(time()) . "</em></div>"; $msg .= "</tr></td>"; $msg .= "<tr><td><table width='100%'><tbody>"; $msg .= "<tr><th>" . Yii::t('profile', "Top Activity") . "</th><th>" . Yii::t('profile', "Top Users") . "</th></tr>"; for ($i = 0; $i < 5; $i++) { $msg .= "<tr><td style='text-align:center;'>"; if (isset($topTypes[$i])) { $type = Events::parseType($topTypes[$i]['type']); $count = $topTypes[$i]['COUNT(type)']; $msg .= $count . " " . $type; } $msg .= "</td><td style='text-align:center;'>"; if (isset($topUsers[$i]) && $topUsers[$i]['COUNT(user)'] > 0) { $username = User::getUserLinks($topUsers[$i]['user'], false, true); $count = $topUsers[$i]['COUNT(user)']; $msg .= $count . " " . Yii::t('profile', "events from") . " " . $username . "."; } $msg .= "</td></tr>"; } $msg .= "</tbody></table></td></tr>"; $msg .= "<tr><td style='text-align:center'><hr width='60%'>"; $msg .= "<tr><td style='text-align:center;'>" . Yii::t('profile', "Here's the {limit} most recent items on the Activity Feed.", array('{limit}' => $limit)) . "</td></tr>"; $msg .= "</td></tr>"; $msg .= "<tr><td style='text-align:center'><hr width='60%'><table><tbody>"; $events = new CActiveDataProvider('Events', array('criteria' => array('condition' => $condition, 'order' => 'timestamp DESC', 'params' => array_merge($params, $accessCriteria->params)), 'pagination' => array('pageSize' => $limit))); foreach ($events->getData() as $event) { $msg .= "<tr>"; $avatar = Yii::app()->db->createCommand()->select('avatar')->from('x2_profile')->where('username=:user', array(':user' => $event->user))->queryScalar(); if (!empty($avatar) && file_exists($avatar)) { $avatar = Yii::app()->getAbsoluteBaseUrl() . '/' . $avatar; } else { $avatar = Yii::app()->getAbsoluteBaseUrl(true) . '/uploads/default.png'; } $typeFile = $event->type; if (in_array($event->type, array('email_sent', 'email_opened'))) { if (in_array($event->subtype, array('quote', 'invoice'))) { $typeFile .= "_{$event->subtype}"; } } if ($event->type == 'record_create') { switch ($event->subtype) { case 'call': $typeFile = 'voip_call'; break; case 'time': $typeFile = 'log_time'; break; } } $imgFile = $avatar; if (file_exists(Yii::app()->theme->getBasePath() . '/images/eventIcons/' . $typeFile . '.png')) { $imgFile = Yii::app()->getAbsoluteBaseUrl() . '/themes/' . Yii::app()->theme->getName() . '/images/eventIcons/' . $typeFile . '.png'; } $img = CHtml::image($imgFile, '', array('style' => 'width:45px;height:45px;float:left;margin-right:5px;')); $msg .= "<td>" . $img . "</td>"; $msg .= "<td style='text-align:left'><span class='event-text'>" . $event->getText(array('requireAbsoluteUrl' => true), array('style' => 'text-decoration:none;')) . "</span></td>"; $msg .= "</tr>"; } $msg .= "</tbody></table></td></tr>"; $msg .= "<tr><td style='text-align:center'><hr width='60%'><table><tbody>"; $msg .= Yii::t('profile', "To stop receiving this report, ") . CHtml::link(Yii::t('profile', 'click here'), Yii::app()->getAbsoluteBaseUrl() . '/index.php/profile/deleteActivityReport?id=' . $eventId . '&deleteKey=' . $deleteKey); $msg .= "</tbody></table></td></tr>"; $msg .= '</tbody></table></td></tr></tbody></table></td></tr>'; $msg .= "<tbody></table></td></tr></tbody></table></center></body></html></div>"; return $msg; }
* "Powered by X2Engine". *****************************************************************************************/ Yii::app()->clientScript->registerCss('filterControlsCss', "\n\n#filter-controls > .portlet-content {\n padding: 5px 0px !important;\n}\n\n#filter-controls > .portlet-content > .x2-button-group {\n text-align: center;\n margin-bottom: 5px;\n}\n\n#sidebar-full-controls-button-container {\n text-align:center;\n}\n#sidebar-full-controls-button-container > .toggle-filters-link {\n margin-bottom: 4px;\n}\n\n"); if (isset($_SESSION['filters'])) { $filters = $_SESSION['filters']; } else { $filters = array('visibility' => array(), 'users' => array(), 'types' => array(), 'subtypes' => array()); } $visibility = array('1' => 'Public', '0' => 'Private'); $socialSubtypes = Dropdowns::getSocialSubtypes(); $users = User::getNames(); $eventTypeList = Yii::app()->db->createCommand()->select('type')->from('x2_events')->group('type')->queryAll(); $eventTypes = array(); foreach ($eventTypeList as $key => $value) { if ($value['type'] != 'comment') { $eventTypes[$value['type']] = Events::parseType($value['type']); } } $profile = Yii::app()->params->profile; $this->beginWidget('LeftWidget', array('widgetLabel' => Yii::t('app', 'Filter Controls'), 'widgetName' => 'FilterControls', 'id' => 'filter-controls')); echo '<div class="x2-button-group">'; echo '<a href="#" class="simple-filters x2-button' . ($profile->fullFeedControls ? "" : " disabled-link") . '" style="width:42px">' . Yii::t('app', 'Simple') . '</a>'; echo '<a href="#" class="full-filters x2-button x2-last-child' . ($profile->fullFeedControls ? " disabled-link" : "") . '" style="width:42px">' . Yii::t('app', 'Full') . '</a>'; echo "</div>\n"; $filterList = json_decode($profile->feedFilters, true); echo "<div id='sidebar-full-controls'" . ($profile->fullFeedControls ? "" : "style='display:none;'") . ">"; $visFilters = $filters['visibility']; $this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('app', 'Visibility') . CHtml::link(CHtml::image(Yii::app()->theme->getBaseUrl() . "/images/icons/" . (!isset($filterList['visibility']) || $filterList['visibility'] ? "Collapse" : "Expand") . "_Widget.png"), "#", array('title' => 'visibility', 'class' => 'activity-control-link', 'style' => 'float:right;padding-right:5px;')), 'id' => 'visibility-filter', 'htmlOptions' => array('class' => !isset($filterList['visibility']) || $filterList['visibility'] ? "" : "hidden-filter"))); echo '<ul style="font-size: 0.8em; font-weight: bold; color: black;">'; foreach ($visibility as $value => $label) { echo "<li>\n";