12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- if (!defined('SMF'))
- die('No direct access...');
- function getNotifyPrefs($members, $prefs = '', $process_default = false)
- {
- global $smcFunc;
-
- $members = is_array($members) ? $members : (array) $members;
- if (!empty($prefs))
- $prefs = is_array($prefs) ? $prefs : (array) $prefs;
- $result = array();
-
- $members[] = 0;
- $request = $smcFunc['db_query']('', '
- SELECT id_member, alert_pref, alert_value
- FROM {db_prefix}user_alerts_prefs
- WHERE id_member IN ({array_int:members})' . (!empty($prefs) ? '
- AND alert_pref IN ({array_string:prefs})' : ''),
- array(
- 'members' => $members,
- 'prefs' => $prefs,
- )
- );
- while ($row = $smcFunc['db_fetch_assoc']($request))
- {
- $result[$row['id_member']][$row['alert_pref']] = $row['alert_value'];
- }
-
- if ($process_default && isset($result[0]))
- {
- foreach ($members as $member)
- if (!isset($result[$member]))
- $result[$member] = $result[0];
- unset ($result[0]);
- }
- return $result;
- }
- function setNotifyPrefs($memID, $prefs = array())
- {
- global $smcFunc;
- if (empty($prefs) || empty($memID))
- return;
- $update_rows = array();
- foreach ($prefs as $k => $v)
- $update_rows[] = array($memID, $k, $v);
- $smcFunc['db_insert']('replace',
- '{db_prefix}user_alerts_prefs',
- array('id_member' => 'int', 'alert_pref' => 'string', 'alert_value' => 'int'),
- $update_rows,
- array('id_member', 'alert_pref')
- );
- }
- ?>
|