PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/paproject/web/BlockModules/EditProfileModule/export.php

https://github.com/ted27/people-aggregator
PHP | 192 lines | 133 code | 18 blank | 41 comment | 11 complexity | 3cd62d8b2be439bb1ca3a19228063f85 MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. /** !
  3. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4. * [filename] is a part of PeopleAggregator.
  5. * [description including history]
  6. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7. * @author [creator, or "Original Author"]
  8. * @license http://bit.ly/aVWqRV PayAsYouGo License
  9. * @copyright Copyright (c) 2010 Broadband Mechanics
  10. * @package PeopleAggregator
  11. */
  12. ?>
  13. <?php
  14. error_reporting(E_ALL); // for testing only!
  15. ?>
  16. <?php
  17. //----------------------- profile and company types: added by Zoran Hron ---------------------
  18. $companyType = '-1';
  19. if(isset($_POST['ptype'])) {
  20. $profileType = $_POST['ptype']; /* 0=Personal; 1=Professional */
  21. if($profileType == '0') { // Personal profile!
  22. unset($_POST['exposeCompany']); // we don't need the company info here!
  23. unset($_POST['exposeSummary']); // exposeSummary was used for summary company description
  24. $companyType = '-1'; // No company info!
  25. } else {
  26. unset($_POST['exposePersonal']); // we don't need the Personal interests in Professional profile
  27. $companyType = (isset($_POST['exposeCompany']))
  28. ? $_POST['exposeCompany']
  29. : '0'; /* '0'=Current; '1'=Prior; '-1'=No company info */
  30. }
  31. } else {
  32. $profileType = '0'; // default: 0-Personal!
  33. }
  34. //--------------------------------------------------------------------------------------------
  35. $merger = new ProfileMerger(PA::$login_user, NULL);
  36. $sections = array_merge( array('core'), array_keys($merger->userSections) );
  37. $normalizer = new Normalizer('pa2hcard');
  38. // setting parameters for the XSLT to include/exclude sections etc
  39. $normalizer->setParameter('','paUid',PA::$login_user->user_id);
  40. $normalizer->setParameter('','paUrl',PA::$url);
  41. //---- profile and compyny types: added by Zoran Hron -----
  42. $normalizer->setParameter('','paType',$profileType);
  43. $normalizer->setParameter('','paCompanyType',$companyType);
  44. //---------------------------------------------------------
  45. /* ------------------------ old code ------------------------
  46. $allExposes = array(
  47. 'exposeCore', 'exposeAddress',
  48. 'exposeSummary', 'exposePersonal',
  49. 'exposeEducation', 'exposeCompany', 'exposePriorCompany',
  50. 'exposeEducation',
  51. 'exposeFlickrFriends', 'exposeFacebookFriends'
  52. );
  53. ------------------------------------------------------------ */
  54. /* --- changed by Zoran Hron -------------------------------- */
  55. $allExposes = array(
  56. 'exposeCore', 'exposeAddress',
  57. 'exposeSummary', 'exposePersonal',
  58. 'exposeEducation',
  59. 'exposeFlickrFriends', 'exposeFacebookFriends', 'exposeInternalFriends',
  60. 'exposeOtherFriends'
  61. );
  62. /*------------------------------------------------------------ */
  63. $user_image = uihelper_resize_img(PA::$login_user->picture, 35, 35, DEFAULT_USER_PHOTO_REL, 'alt="User image."');
  64. $user_photo = $user_image['url'];
  65. $normalizer->setParameter('', 'userPic', $user_photo);
  66. // show the form with previews
  67. // filter the permissions
  68. /*
  69. values currently used in PA
  70. Nobody="0"
  71. Everybody="1"
  72. Immediate Relations="2"
  73. so to show all info a friend would see
  74. we need to allow perms 1 AND 2
  75. while friends only would be 2
  76. */
  77. $perms = (isset($_POST['perms'])) ? ($_POST['perms']) : "1,2";
  78. $filter = new Normalizer('filterPerms');
  79. foreach(preg_split('/,\s*/', $perms) as $p) {
  80. $parr[] = "perm".$p;
  81. }
  82. $filter->setParams(
  83. $parr,
  84. TRUE );
  85. $filteredDOM = $filter->transformToDoc( $merger->currentProfileDOM );
  86. $exps = Array();
  87. foreach($_POST as $k=>$v) {
  88. if (preg_match('/^expose/', $k)) {
  89. $exps[] = $k;
  90. }
  91. }
  92. if(! count($exps)) {
  93. $exps = $allExposes;
  94. foreach ($exps as $e) $_POST[$e] = 1;
  95. }
  96. // generate the hCard
  97. displayNone($normalizer, $allExposes);
  98. $normalizer->setParams( $exps, TRUE );
  99. $hCardXHTML = $normalizer->transformToDoc( $filteredDOM )->saveXML();
  100. // $filteredDOM->save('/opt/lampp/htdocs/pa/web/BetaBlockModules/EditProfileModule/UserProfile.xml');
  101. // echo htmlspecialchars($hCardXHTML);
  102. ?>
  103. <div id="user_info">
  104. <b><?= __("Personal and professional info") ?></b>
  105. <ul style="list-style:none;">
  106. <!-- BEGIN: added by Zoran Hron: select profile type -->
  107. <li>
  108. <select name="ptype" id="ptype" onchange="document.getElementById('export_profile').submit();">
  109. <option <?php if ($profileType=='0') echo 'selected="selected"' ?> value="0"> <?= __("Personal") ?> </option>
  110. <option <?php if ($profileType=='1') echo 'selected="selected"' ?> value="1"> <?= __("Professional") ?> </option>
  111. </select><b>Profile type</b>:
  112. </li><br />
  113. <!-- END -->
  114. <li><input type="checkbox" <? if ($_POST['exposeCore']) echo 'checked="checked"' ?> name="exposeCore" value="1" /> Basic info</li>
  115. <li><input type="checkbox" <? if (isset($_POST['exposeEmail'])) echo 'checked="checked"' ?> name="exposeEmail" value="1" />Email address</li>
  116. <!-- BEGIN: changed by Zoran Hron:
  117. profile and company types, at this time we don't have company addres details in our database
  118. and we must use Postal adress! Once time when we will have the company address we must uncomment PHP code below
  119. -->
  120. <?php // if ($profileType=='0') : ?>
  121. <li><input type="checkbox" <? if (isset($_POST['exposeAddress'])) echo 'checked="checked"' ?> name="exposeAddress" value="1" /> Postal address</li>
  122. <?php // endif; ?>
  123. <?php if ($profileType=='1') : ?> <!-- profile type = Professional -->
  124. <!--
  125. <li><input type="checkbox" <? // if (isset($_POST['exposeAddress'])) echo 'checked="checked"' ?> name="exposeAddress" value="1" /> Company address</li>
  126. -->
  127. <li><input type="radio" <?php if ($companyType=='0') echo 'checked="checked"' ?> name="exposeCompany" value="0" > Current company info</li>
  128. <li><input type="radio" <?php if ($companyType=='1') echo 'checked="checked"' ?> name="exposeCompany" value="1" > Prior company info</li>
  129. <li><input type="checkbox" <? if (isset($_POST['exposeSummary'])) echo 'checked="checked"' ?> name="exposeSummary" value="1" /> Professional summary</li>
  130. <?php endif; ?>
  131. <!-- END -->
  132. <li><input type="checkbox" <? if (isset($_POST['exposeEducation'])) echo 'checked="checked"' ?> name="exposeEducation" value="1" />Education and awards</li>
  133. <!-- BEGIN changed by Zoran Hron:
  134. 1. show personal interests only if profile type is personal
  135. 2. added checkbox for "exposeInternalFriends" option
  136. -->
  137. <?php if ($profileType=='0') : ?>
  138. <li><input type="checkbox" <? if (isset($_POST['exposePersonal'])) echo 'checked="checked"' ?> name="exposePersonal" value="1" /> Personal interests and beliefs</li>
  139. <?php endif; ?>
  140. <li><input type="checkbox" <? if (isset($_POST['exposeInternalFriends'])) echo 'checked="checked"' ?> name="exposeInternalFriends" value="1" />Friends on this network</li>
  141. <!-- END -->
  142. <li><input type="checkbox" <? if (isset($_POST['exposeFlickrFriends'])) echo 'checked="checked"' ?> name="exposeFlickrFriends" value="1" />Contacts from Flickr.com</li>
  143. <li> <input type="checkbox" <? if (isset($_POST['exposeFacebookFriends'])) echo 'checked="checked"' ?> name="exposeFacebookFriends" value="1" />Facebook.com friends</li>
  144. <li> <input type="checkbox" <? if (isset($_POST['exposeOtherFriends'])) echo 'checked="checked"' ?> name="exposeOtherFriends" value="1" />Friends from other networks</li>
  145. <li><p>Filter your data by the visibility you set on each field</p>
  146. <p>
  147. <select name="perms">
  148. <option <? if ($perms=='0,1,2') echo 'selected="selected"' ?> value="0,1,2"> <?= __("show everything") ?></option>
  149. <option <? if ($perms=='1,2') echo 'selected="selected"' ?> value="1,2"> <?= __("show what your friends see") ?></option>
  150. <option <? if ($perms=='1') echo 'selected="selected"' ?> value="1"> <?= __("show only public info") ?></option>
  151. </select>
  152. </p></li><br />
  153. <li><p>
  154. <input type="submit" value="<?= __("Preview") ?>" />
  155. </p>
  156. </li>
  157. <li><p>
  158. <textarea class="copyme" rows="60" cols="40"><? echo htmlspecialchars($hCardXHTML); ?></textarea>
  159. </p>
  160. </li>
  161. </ul>
  162. </div>
  163. <div id="user_detail">
  164. <b><?= __("Sidebar preview of your hCard/XFN profile") ?></b>
  165. <?php echo $hCardXHTML; ?>
  166. </div>
  167. <?php
  168. function displayNone($normalizer, $allExposes) {
  169. $normalizer->setParams(
  170. $allExposes, FALSE);
  171. }
  172. ?>