Source Code Documentation


s2member\includes\classes\user-notes.inc.php


  1. <?php
  2. /**
  3. * Administrative notes.
  4. *
  5. * Copyright: © 2009-2011
  6. * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
  7. * (coded in the USA)
  8. *
  9. * Released under the terms of the GNU General Public License.
  10. * You should have received a copy of the GNU General Public License,
  11. * along with this software. In the main directory, see: /licensing/
  12. * If not, see: {@link http://www.gnu.org/licenses/}.
  13. *
  14. * @package s2Member\Admin_Notes
  15. * @since 3.5
  16. */
  17. if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
  18. exit ("Do not access this file directly.");
  19.  
  20. if (!class_exists ("c_ws_plugin__s2member_user_notes"))
  21. {
  22. /**
  23. * Administrative notes.
  24. *
  25. * @package s2Member\Admin_Notes
  26. * @since 3.5
  27. */
  28. class c_ws_plugin__s2member_user_notes
  29. {
  30. /**
  31. * Appends a note onto a specific User/Member's account.
  32. *
  33. * @package s2Member\Admin_Notes
  34. * @since 3.5
  35. *
  36. * @param int|str $user_id A numeric WordPress® User ID.
  37. * @param str $notes The string of notes to append. One note, or many.
  38. * @return str The full set of notes, including appendage.
  39. */
  40. public static function append_user_notes ($user_id = FALSE, $notes = FALSE)
  41. {
  42. foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
  43. do_action ("ws_plugin__s2member_before_append_user_notes", get_defined_vars ());
  44. unset /* Unset defined __refs, __v. */ ($__refs, $__v);
  45.  
  46. if ($user_id && $notes && is_string ($notes)) // Must have these.
  47. {
  48. foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
  49. do_action ("ws_plugin__s2member_during_append_user_notes", get_defined_vars ());
  50. unset /* Unset defined __refs, __v. */ ($__refs, $__v);
  51.  
  52. $notes = trim (get_user_option ("s2member_notes", $user_id) . "\n" . $notes);
  53.  
  54. update_user_option ($user_id, "s2member_notes", $notes);
  55. }
  56.  
  57. return apply_filters ("ws_plugin__s2member_append_user_notes", ((!empty ($notes)) ? $notes : ""), get_defined_vars ());
  58. }
  59. /**
  60. * Clear specific notes from a User/Member's account; based on line-by-line regex.
  61. *
  62. * @package s2Member\Admin_Notes
  63. * @since 3.5
  64. *
  65. * @param int|str $user_id A numeric WordPress® User ID.
  66. * @param str $regex A regular expression to match against each line.
  67. * @return str The full set of notes, after clearing.
  68. */
  69. public static function clear_user_note_lines ($user_id = FALSE, $regex = FALSE)
  70. {
  71. foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
  72. do_action ("ws_plugin__s2member_before_clear_user_note_lines", get_defined_vars ());
  73. unset /* Unset defined __refs, __v. */ ($__refs, $__v);
  74.  
  75. if ($user_id && $regex && is_string ($regex) && ($lines = array ()))
  76. {
  77. // Careful here to preserve empty lines.
  78. $notes = trim (get_user_option ("s2member_notes", $user_id));
  79. foreach (preg_split ("/\n/", $notes) as $line)
  80. if (!preg_match ($regex, $line))
  81. $lines[] = $line;
  82.  
  83. $notes = trim (implode ("\n", $lines));
  84.  
  85. foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
  86. do_action ("ws_plugin__s2member_during_clear_user_note_lines", get_defined_vars ());
  87. unset /* Unset defined __refs, __v. */ ($__refs, $__v);
  88.  
  89. update_user_option ($user_id, "s2member_notes", $notes);
  90. }
  91.  
  92. return apply_filters ("ws_plugin__s2member_clear_user_note_lines", ((!empty ($notes)) ? $notes : ""), get_defined_vars ());
  93. }
  94. }
  95. }
  96. ?>

s2member\includes\classes\user-notes.inc.php

Source Code Documentation