Guest User

Untitled

a guest
Jun 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. /**
  3. * Reorder Social Accounts
  4. */
  5. private function up1024_reorderSocialAccountOptions($accounts) {
  6. $socialAccounts = civicrm_api3('OptionValue', 'get', [
  7. 'option_group_id' => 'website_type',
  8. 'name' => ['IN' => $accounts],
  9. ]);
  10.  
  11. $socialAccounts = $socialAccounts['values'];
  12. foreach ($socialAccounts as $optionValueId => $optionValue) {
  13. switch ($optionValue['name']) {
  14. case 'LinkedIn':
  15. $newWeight = 1;
  16. $isDefault = 1;
  17. break;
  18.  
  19. case 'Twitter':
  20. $newWeight = 2;
  21. $isDefault = 0;
  22. break;
  23.  
  24. case 'Facebook':
  25. $newWeight = 3;
  26. $isDefault = 0;
  27. break;
  28. }
  29. civicrm_api3('OptionValue', 'create', [
  30. 'id' => $optionValueId,
  31. 'weight' => $newWeight,
  32. 'is_default' => $isDefault,
  33. ]);
  34. }
  35. }
Add Comment
Please, Sign In to add comment