PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/profile/views/profile/myprofile.php

https://github.com/yii-simon/yii-user-management
PHP | 142 lines | 137 code | 5 blank | 0 comment | 13 complexity | 3bf6297df4286cd3e1435710f2da5635 MD5 | raw file
  1. <div id="profile">
  2. <?
  3. $this->pageTitle= Yum::t('Profile');
  4. $this->breadcrumbs=array(Yum::t('Profile'));
  5. $this->title = Yum::t('Your profile');
  6. if(Yum::hasModule('messages'))
  7. $this->renderPartial('/messages/new_messages');?>
  8. <div class="avatar">
  9. <? echo $model->renderAvatar(); ?>
  10. </div>
  11. <table class="dataGrid">
  12. <? if(!Yum::module()->loginType & UserModule::LOGIN_BY_EMAIL) {?>
  13. <tr>
  14. <th class="label"><? echo CHtml::encode($model->getAttributeLabel('username')); ?>
  15. </th>
  16. <td><? echo CHtml::encode($model->username); ?>
  17. </td>
  18. </tr>
  19. <?
  20. }
  21. $profileFields = YumProfileField::model()->forOwner()->sort()->with('group')->together()->findAll();
  22. if ($profileFields && Yum::hasModule('profile')) {
  23. foreach($profileFields as $field) {
  24. if($field->field_type == 'DROPDOWNLIST') {
  25. ?>
  26. <tr>
  27. <th class="label"><? echo CHtml::encode(Yum::t($field->title)); ?>
  28. </th>
  29. <td><?
  30. if(is_object($model->profile->{ucfirst($field->varname)}))
  31. echo CHtml::encode($model->profile->{ucfirst($field->varname)}->{$field->related_field_name}); ?>
  32. </td>
  33. </tr>
  34. <?
  35. } else {
  36. ?>
  37. <tr>
  38. <th class="label"><? echo CHtml::encode(Yum::t($field->title)); ?>
  39. </th>
  40. <td><? echo CHtml::encode($model->profile->getAttribute($field->varname)); ?>
  41. </td>
  42. </tr>
  43. <?
  44. }
  45. }
  46. }
  47. ?>
  48. <tr>
  49. <th class="label"><? echo CHtml::encode($model->getAttributeLabel('password')); ?>
  50. </th>
  51. <td><? echo CHtml::link(Yum::t('Change password'),array(
  52. '//user/user/changepassword')); ?>
  53. </td>
  54. </tr>
  55. <tr>
  56. <th class="label"><? echo CHtml::encode($model->getAttributeLabel('createtime')); ?>
  57. </th>
  58. <td><? echo date(UserModule::$dateFormat,$model->createtime); ?>
  59. </td>
  60. </tr>
  61. <tr>
  62. <th class="label"><? echo CHtml::encode($model->getAttributeLabel('lastvisit')); ?>
  63. </th>
  64. <td><? echo date(UserModule::$dateFormat,$model->lastvisit); ?>
  65. </td>
  66. </tr>
  67. <tr>
  68. <th class="label"><? echo CHtml::encode($model->getAttributeLabel('status')); ?>
  69. </th>
  70. <td><? echo CHtml::encode(YumUser::itemAlias("UserStatus",$model->status));
  71. ?>
  72. </td>
  73. </tr>
  74. </table>
  75. <div id="friends">
  76. <h2> <? echo Yum::t('My friends'); ?> </h2>
  77. <?
  78. if(Yum::hasModule('friendship') && $model->friends)
  79. {
  80. foreach($friends as $friend) {
  81. ?>
  82. <div id="friend">
  83. <div id="avatar">
  84. <?
  85. $model->renderAvatar($friend);
  86. ?>
  87. <div id='user'>
  88. <?
  89. echo CHtml::link(ucwords($friend->username),
  90. Yii::app()->createUrl('profile/profile/view',array(
  91. 'id'=>$friend->id)));
  92. ?>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <?
  98. }
  99. }else {
  100. echo Yum::t('You have no friends yet');
  101. }
  102. ?>
  103. </div>
  104. <div id="visits">
  105. <h2> <? echo Yum::t('These users have visited my profile'); ?> </h2>
  106. <?
  107. if($model->visits) {
  108. $format = Yum::module()->dateTimeFormat;
  109. echo '<table>';
  110. printf('<th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th>',
  111. Yum::t('Visitor'),
  112. Yum::t('Time of first Visit'),
  113. Yum::t('Time of last Visit'),
  114. Yum::t('Num of Visits'),
  115. Yum::t('Message')
  116. );
  117. foreach($model->visits as $visit) {
  118. if(isset($visit->visitor)) //we need this in case a user quits
  119. {
  120. printf('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
  121. CHtml::link($visit->visitor->username, array(
  122. '//profile/profile/view', 'id' => $visit->visitor_id)),
  123. date($format, $visit->timestamp_first_visit),
  124. date($format, $visit->timestamp_last_visit),
  125. $visit->num_of_visits,
  126. CHtml::link(Yum::t('Write a message'), array(
  127. '//message/message/compose',
  128. 'to_user_id' => $visit->visitor_id))
  129. );
  130. }
  131. }
  132. echo '</table>';
  133. } else {
  134. echo Yum::t('Nobody has visited your profile yet');
  135. }
  136. ?>
  137. </div>