PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/x2engine/protected/views/profile/_activityFeed.php

https://gitlab.com/e0/X2CRM
PHP | 311 lines | 261 code | 14 blank | 36 comment | 3 complexity | 4e59e011f5bd2efd4cffab6ec1ec17ff MD5 | raw file
  1. <?php
  2. /***********************************************************************************
  3. * X2CRM is a customer relationship management program developed by
  4. * X2Engine, Inc. Copyright (C) 2011-2016 X2Engine Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it under
  7. * the terms of the GNU Affero General Public License version 3 as published by the
  8. * Free Software Foundation with the addition of the following permission added
  9. * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
  10. * IN WHICH THE COPYRIGHT IS OWNED BY X2ENGINE, X2ENGINE DISCLAIMS THE WARRANTY
  11. * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License along with
  19. * this program; if not, see http://www.gnu.org/licenses or write to the Free
  20. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  21. * 02110-1301 USA.
  22. *
  23. * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
  24. * California 95067, USA. on our website at www.x2crm.com, or at our
  25. * email address: contact@x2engine.com.
  26. *
  27. * The interactive user interfaces in modified source and object code versions
  28. * of this program must display Appropriate Legal Notices, as required under
  29. * Section 5 of the GNU Affero General Public License version 3.
  30. *
  31. * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
  32. * these Appropriate Legal Notices must retain the display of the "Powered by
  33. * X2Engine" logo. If the display of the logo is not reasonably feasible for
  34. * technical reasons, the Appropriate Legal Notices must display the words
  35. * "Powered by X2Engine".
  36. **********************************************************************************/
  37. Yii::app()->clientScript->registerScriptFile(
  38. Yii::app()->getBaseUrl().'/js/activityFeed.js', CClientScript::POS_END);
  39. Yii::app()->clientScript->registerScriptFile(
  40. Yii::app()->getBaseUrl().'/js/EnlargeableImage.js', CClientScript::POS_END);
  41. Yii::app()->clientScript->registerScriptFile(
  42. Yii::app()->getBaseUrl().'/js/jquery-expander/jquery.expander.js', CClientScript::POS_END);
  43. // used for rich editing in new post text field
  44. Yii::app()->clientScript->registerPackage ('emailEditor');
  45. Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl().'/js/multiselect/js/ui.multiselect.js');
  46. Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl().'/js/lib/moment-with-locales.min.js');
  47. $groups = Groups::getUserGroups(Yii::app()->user->getId());
  48. $tempUserList = array();
  49. foreach($groups as $groupId){
  50. $userLinks = GroupToUser::model()->findAllByAttributes(array('groupId'=>$groupId));
  51. foreach($userLinks as $link){
  52. $user = User::model()->findByPk($link->userId);
  53. if(isset($user)){
  54. $tempUserList[] = $user->username;
  55. }
  56. }
  57. }
  58. $userList = array_keys(User::getNames());
  59. $tempUserList = array_diff($userList,$tempUserList);
  60. $usersGroups = implode(",",$tempUserList);
  61. Yii::app()->clientScript->registerScript('setUpActivityFeedManager', "
  62. x2.activityFeed = new x2.ActivityFeed ({
  63. translations: ".CJSON::encode (array (
  64. 'Unselect All' => Yii::t('app','Unselect All'),
  65. 'Select All' => Yii::t('app','Select All'),
  66. 'Uncheck All' => Yii::t('app','Uncheck All'),
  67. 'Check All' => Yii::t('app','Check All'),
  68. 'Enter text here...' => Yii::t('app','Enter text here...'),
  69. 'Broadcast Event' => Yii::t('app','Broadcast Event'),
  70. 'Make Important' => Yii::t('app','Make Important'),
  71. 'Broadcast' => Yii::t('app','Broadcast'),
  72. 'broadcast error message 1' => Yii::t('app','Select at least one user to broadcast to'),
  73. 'broadcast error message 2' => Yii::t('app','Select at least one broadcast method'),
  74. 'Okay' => Yii::t('app','Okay'),
  75. 'Nevermind' => Yii::t('app','Cancel'),
  76. 'Create' => Yii::t('app','Create'),
  77. 'Cancel' => Yii::t('app','Cancel'),
  78. 'Read more' => Yii::t('app','Read') . '&nbsp;' . Yii::t('app', 'More'),
  79. 'Read less' => Yii::t('app','Read') . '&nbsp;' . Yii::t('app', 'Less'),
  80. )).",
  81. usersGroups: '".$usersGroups."',
  82. minimizeFeed: ".(Yii::app()->params->profile->minimizeFeed==1?'true':'false').",
  83. commentFlag: false,
  84. lastEventId: ".(!empty($lastEventId)?$lastEventId:0).",
  85. lastTimestamp: ".(!empty($lastTimestamp)?$lastTimestamp:0).",
  86. profileId: ".$profileId.",
  87. myProfileId: ".Yii::app()->params->profile->id.",
  88. deletePostUrl: '".$this->createUrl('/profile/deletePost')."'
  89. });
  90. ", CClientScript::POS_END);
  91. ?>
  92. <div id='activity-feed-container' class='x2-layout-island'>
  93. <div id='page-title-container'>
  94. <div class="page-title icon rounded-top activity-feed x2Activity">
  95. <h2><?php echo Yii::t('app','Activity Feed'); ?></h2>
  96. <span title='<?php echo Yii::t('app', 'Feed Settings'); ?>'>
  97. <?php
  98. echo X2Html::settingsButton (Yii::t('app', 'Feed Settings'),
  99. array ('id' => 'activity-feed-settings-button'));
  100. ?>
  101. </span>
  102. <a href='#' id='feed-filters-button'
  103. class='filter-button right'>
  104. <span class='fa fa-filter'></span>
  105. </a>
  106. <div id="menu-links" class="title-bar" style='display: none;'>
  107. <?php
  108. echo CHtml::link(
  109. Yii::t('app','Toggle Comments'),'#',
  110. array('id'=>'toggle-all-comments','class'=>'x2-button x2-minimal-button right'));
  111. echo CHtml::link(
  112. Yii::t('app','Restore Posts'),'#',
  113. array('id'=>'restore-posts','style'=>'display:none;',
  114. 'class'=>'x2-button x2-minimal-button right'));
  115. echo CHtml::link(
  116. Yii::t('app','Minimize Posts'),
  117. '#',array('id'=>'min-posts','class'=>'x2-button x2-minimal-button right'));
  118. ?>
  119. </div>
  120. </div>
  121. </div>
  122. <?php
  123. $this->renderPartial ('_feedFilters');
  124. ?>
  125. <div class="form" id="post-form" style="clear:both">
  126. <?php $feed=new Events; ?>
  127. <?php $form = $this->beginWidget('CActiveForm', array(
  128. 'id'=>'feed-form',
  129. 'enableAjaxValidation'=>false,
  130. 'method'=>'post',
  131. )); ?>
  132. <div class="float-row" style='overflow:visible;'>
  133. <?php
  134. echo $form->textArea($feed,'text',array('style'=>'width:99%;height:25px;color:#aaa;display:block;clear:both;'));
  135. echo "<div id='post-buttons' style='display:none;'>";
  136. echo $form->dropDownList($feed,'associationId',$users,
  137. array (
  138. 'style' => ($isMyProfile ? '' : 'display:none;'),
  139. 'class' => 'x2-select'
  140. )
  141. );
  142. $feed->visibility=1;
  143. echo $form->dropDownList($feed,'visibility',
  144. array(1=>Yii::t('actions','Public'), 0=>Yii::t('actions','Private')),
  145. array ('class' => 'x2-select')
  146. );
  147. function translateOptions($item){
  148. return Yii::t('app',$item);
  149. }
  150. echo $form->dropDownList($feed,'subtype',
  151. array_map(
  152. 'translateOptions',
  153. Dropdowns::getSocialSubtypes ()),
  154. array ('class' => 'x2-select'));
  155. ?>
  156. <div id='second-row-buttons-container'>
  157. <?php
  158. echo CHtml::submitButton(
  159. Yii::t('app','Post'),array('class'=>'x2-button','id'=>'save-button'));
  160. if ($isMyProfile) {
  161. echo CHtml::button(
  162. Yii::t('app','Attach A File/Photo'),
  163. array(
  164. 'class'=>'x2-button',
  165. 'onclick'=>"x2.FileUploader.toggle('activity')",
  166. 'id'=>"toggle-attachment-menu-button"));
  167. }
  168. ?>
  169. </div>
  170. </div>
  171. <?php
  172. ?>
  173. </div>
  174. <?php $this->endWidget(); ?>
  175. </div>
  176. <?php
  177. if ($isMyProfile) {
  178. $this->widget ('FileUploader',array(
  179. 'id' => 'activity',
  180. 'url' => '/site/upload',
  181. 'mediaParams' => array(
  182. 'profileId' => $profileId,
  183. 'associationType' => 'feed',
  184. 'associationId' => Yii::app()->user->getId(),
  185. ),
  186. 'viewParams' => array (
  187. 'showButton' => false
  188. )
  189. ));
  190. }
  191. $this->widget('zii.widgets.CListView', array(
  192. 'dataProvider'=>$stickyDataProvider,
  193. 'itemView'=>'_viewEvent',
  194. 'viewData' => array (
  195. 'profileId' => $profileId
  196. ),
  197. 'id'=>'sticky-feed',
  198. 'htmlOptions' => array (
  199. 'style' => $stickyDataProvider->itemCount === 0 ? 'display: none;' : '',
  200. ),
  201. 'pager' => array(
  202. 'class' => 'ext.infiniteScroll.IasPager',
  203. 'rowSelector'=>'.view.top-level',
  204. 'listViewId' => 'sticky-feed',
  205. 'header' => '',
  206. 'options'=>array(
  207. 'onRenderComplete'=>'js:function(){
  208. x2.activityFeed.makePostsExpandable ();
  209. if(x2.activityFeed.minimizeFeed){
  210. x2.activityFeed.minimizePosts();
  211. }
  212. if(x2.activityFeed.commentFlag){
  213. $(".comment-link").click();
  214. }
  215. }'
  216. ),
  217. ),
  218. 'baseScriptUrl'=>Yii::app()->request->baseUrl.'/themes/'.Yii::app()->theme->name.'/css/listview',
  219. 'template'=>'{pager} {items}'
  220. ));
  221. $this->widget('zii.widgets.CListView', array(
  222. 'dataProvider'=>$dataProvider,
  223. 'itemView'=>'_viewEvent',
  224. 'viewData' => array (
  225. 'profileId' => $profileId
  226. ),
  227. 'id'=>'activity-feed',
  228. 'pager' => array(
  229. 'class' => 'ext.infiniteScroll.IasPager',
  230. 'rowSelector'=>'.view.top-level',
  231. 'listViewId' => 'activity-feed',
  232. 'header' => '',
  233. 'options'=>array(
  234. 'onRenderComplete'=>'js:function(){
  235. x2.activityFeed.makePostsExpandable ();
  236. if(x2.activityFeed.minimizeFeed){
  237. x2.activityFeed.minimizePosts();
  238. }
  239. if(x2.activityFeed.commentFlag){
  240. $(".comment-link").click();
  241. }
  242. $.each($(".comment-count"),function(){
  243. if($(this).attr("val")>0){
  244. $(this).parent().click();
  245. }
  246. });
  247. }'
  248. ),
  249. ),
  250. 'baseScriptUrl'=>Yii::app()->request->baseUrl.'/themes/'.Yii::app()->theme->name.'/css/listview',
  251. 'template'=>'{pager} {items}',
  252. ));
  253. ?>
  254. <div id="make-important-dialog" style="display: none;">
  255. <div class='dialog-explanation'>
  256. <?php echo Yii::t('app','Leave colors blank for defaults.');?>
  257. </div>
  258. <div>
  259. <?php
  260. echo CHtml::label(Yii::t('app','What color should the event be?'),'broadcastColor');
  261. ?>
  262. <div class='row'>
  263. <?php echo CHtml::textField('broadcastColor',''); ?>
  264. </div>
  265. </div>
  266. <div>
  267. <?php echo CHtml::label(Yii::t('app','What color should the font be?'),'fontColor'); ?>
  268. <div class='row'>
  269. <?php echo CHtml::textField('fontColor',''); ?>
  270. </div>
  271. </div>
  272. <div>
  273. <?php echo CHtml::label(Yii::t('app','What color should the links be?'),'linkColor'); ?>
  274. <div class='row'>
  275. <?php echo CHtml::textField('linkColor',''); ?>
  276. </div>
  277. </div>
  278. </div>
  279. <div id="broadcast-dialog" style='display: none;'>
  280. <div class='dialog-explanation'>
  281. <?php echo Yii::t('app', 'Select a group of users to send this event to via email or notification.'); ?>
  282. </div>
  283. <select id='broadcast-dialog-user-select' class='multiselect' multiple='multiple' size='6'>
  284. <?php foreach ($userModels as $user) { ?>
  285. <option value="<?php echo $user->id; ?>"> <?php echo $user->firstName . ' ' . $user->lastName; ?> </option>
  286. <?php } ?>
  287. </select>
  288. <div>
  289. <?php echo CHtml::label(Yii::t('app','Do you want to email selected users?'),'email-users'); ?>
  290. <?php echo CHtml::checkBox('email-users'); ?>
  291. </div>
  292. <div id='notify-users-checkbox-container'>
  293. <?php echo CHtml::label(Yii::t('app','Do you want to notify selected users?'),'notify-users'); ?>
  294. <?php echo CHtml::checkBox('notify-users'); ?>
  295. </div>
  296. </div>
  297. </div>