[geeklog-cvs] Geeklog-1.x/system lib-user.php,1.47,1.48
Dirk Haun
dhaun at qs1489.pair.com
Sun Aug 3 04:05:54 EDT 2008
- Previous message (by thread): [geeklog-cvs] Geeklog-1.x/public_html lib-common.php, 1.715, 1.716 usersettings.php, 1.173, 1.174
- Next message (by thread): [geeklog-cvs] Geeklog-1.x/language german.php, 1.198, 1.199 german_formal.php, 1.103, 1.104 german_formal_utf-8.php, 1.56, 1.57 german_utf-8.php, 1.87, 1.88
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/geeklog/Geeklog-1.x/system
In directory qs1489.pair.com:/tmp/cvs-serv53349/system
Modified Files:
lib-user.php
Log Message:
Some minor Daily Digest improvements and code for future use
Index: lib-user.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/system/lib-user.php,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** lib-user.php 1 Aug 2008 18:49:09 -0000 1.47
--- lib-user.php 3 Aug 2008 08:05:50 -0000 1.48
***************
*** 9,13 ****
// | User-related functions needed in more than one place. |
// +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2007 by the following authors: |
// | |
// | Authors: Tony Bibbs - tony AT tonybibbs DOT com |
--- 9,13 ----
// | User-related functions needed in more than one place. |
// +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2008 by the following authors: |
// | |
// | Authors: Tony Bibbs - tony AT tonybibbs DOT com |
***************
*** 675,677 ****
--- 675,830 ----
}
+ /**
+ * Subscribe user to a topic (for the Daily Digest)
+ *
+ * @param string $tid Topic ID
+ *
+ */
+ function USER_subscribeToTopic($tid)
+ {
+ global $_CONF, $_TABLES, $_USER;
+
+ if ($_CONF['emailstories'] == 0) {
+ return;
+ }
+
+ if (COM_isAnonUser()) {
+ return;
+ }
+
+ if (!SEC_hasTopicAccess($tid)) {
+ return;
+ }
+
+ $user_etids = DB_getItem($_TABLES['userindex'], 'etids',
+ "uid = {$_USER['uid']}");
+ if (empty($user_etids)) {
+ return; // already subscribed to all topics
+ }
+
+ if ($user_etids == '-') {
+ $user_etids = $tid; // first topic user subscribed to
+ } else {
+ $etids = explode(' ', $user_etids);
+ if (in_array($tid, $etids)) {
+ return; // already subscribed
+ }
+ $etids[] = $tid;
+ $user_etids = implode(' ', $etids);
+ }
+ $user_etids = addslashes($user_etids);
+
+ DB_query("UPDATE {$_TABLES['userindex']} SET etids = '$user_etids' WHERE uid = {$_USER['uid']}");
+ }
+
+ /**
+ * Unsubscribe user from a topic (for the Daily Digest)
+ *
+ * @param string $tid Topic ID
+ *
+ */
+ function USER_unsubscribeFromTopic($tid)
+ {
+ global $_CONF, $_TABLES, $_USER;
+
+ if ($_CONF['emailstories'] == 0) {
+ return;
+ }
+
+ if (COM_isAnonUser()) {
+ return;
+ }
+
+ // no check for SEC_hasTopicAccess here to unsubscribe user "just in case"
+
+ $user_etids = DB_getItem($_TABLES['userindex'], 'etids',
+ "uid = {$_USER['uid']}");
+ if ($user_etids == '-') {
+ return; // not subscribed to any topics
+ }
+
+ if (empty($user_etids)) {
+ // subscribed to all topics - get list
+ $etids = USER_getAllowedTopics();
+ } else {
+ $etids = explode(' ', $user_etids);
+ }
+
+ $key = array_search($tid, $etids);
+ if ($key === false) {
+ return; // not subscribed to this topic
+ }
+
+ unset($etids[$key]);
+
+ if (count($etids) == 0) {
+ $user_etids = '-';
+ } else {
+ $user_etids = implode(' ', $etids);
+ }
+ $user_etids = addslashes($user_etids);
+
+ DB_query("UPDATE {$_TABLES['userindex']} SET etids = '$user_etids' WHERE uid = {$_USER['uid']}");
+ }
+
+ /**
+ * Check if user is subscribed to a topic
+ *
+ * @param string $tid Topic ID
+ * @return boolean true: subscribed, false: not subscribed
+ *
+ */
+ function USER_isSubscribedToTopic($tid)
+ {
+ global $_CONF, $_TABLES, $_USER;
+
+ if ($_CONF['emailstories'] == 0) {
+ return false;
+ }
+
+ if (COM_isAnonUser()) {
+ return false;
+ }
+
+ if (!SEC_hasTopicAccess($tid)) {
+ return false;
+ }
+
+ $user_etids = DB_getItem($_TABLES['userindex'], 'etids',
+ "uid = {$_USER['uid']}");
+ if (empty($user_etids)) {
+ return true; // subscribed to all topics
+ } elseif ($user_etids == '-') {
+ return false; // not subscribed to any topics
+ }
+
+ $etids = explode(' ', $user_etids);
+
+ return in_array($tid, $etids);
+ }
+
+ /**
+ * Get topics the current user has access to
+ *
+ * @return array Array of topic IDs
+ *
+ */
+ function USER_getAllowedTopics()
+ {
+ global $_TABLES;
+
+ $topics = array();
+
+ $result = DB_query("SELECT tid FROM {$_TABLES['topics']}");
+ $numrows = DB_numRows($result);
+ for ($i = 0; $i < $numrows; $i++) {
+ $A = DB_fetchArray($result);
+ if (SEC_hasTopicAccess($A['tid'])) {
+ $topics[] = $A['tid'];
+ }
+ }
+
+ return $topics;
+ }
+
?>
- Previous message (by thread): [geeklog-cvs] Geeklog-1.x/public_html lib-common.php, 1.715, 1.716 usersettings.php, 1.173, 1.174
- Next message (by thread): [geeklog-cvs] Geeklog-1.x/language german.php, 1.198, 1.199 german_formal.php, 1.103, 1.104 german_formal_utf-8.php, 1.56, 1.57 german_utf-8.php, 1.87, 1.88
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the geeklog-cvs
mailing list