X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=0.2.1%2Finc%2Fmodules%2Fmember%2Fwhat-categories.php;h=e57da751c67143c4b917e6bd905a2aa9d6faa255;hb=4ac856c74ab07fc19ab64039904f2075c8f35b40;hp=616c0f31606d077ff3bda1d4edf9bd70384f5c7c;hpb=4696b799ced069ba2a264fa3b38fc033e3dc31dc;p=mailer.git diff --git a/0.2.1/inc/modules/member/what-categories.php b/0.2.1/inc/modules/member/what-categories.php index 616c0f3160..e57da751c6 100644 --- a/0.2.1/inc/modules/member/what-categories.php +++ b/0.2.1/inc/modules/member/what-categories.php @@ -1,173 +1,173 @@ - 0) -{ - $LEAST = false; - if (isset($_POST['ok'])) - { - $cnt = 0; - foreach ($_POST['cat'] as $cat=>$joined) - { - if ($joined == "N") $cnt++; - } - if (($cats - $cnt) < $CONFIG['least_cats']) - { - unset($_POST['ok']); - $LEAST = true; - } - } - if (isset($_POST['ok'])) - { - foreach ($_POST['cat'] as $cat=>$joined) - { - switch ($joined) - { - case "Y": - $sql = ""; - $result_user = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_cats WHERE userid=%d AND cat_id=%d LIMIT 1", - array($UID, bigintval($cat)), __FILE__, __LINE__); - - if (SQL_NUMROWS($result_user) == 0) - { - $sql = "INSERT INTO "._MYSQL_PREFIX."_user_cats (userid, cat_id) VALUES ('%s', '%s')"; - } - else - { - // Free memory - SQL_FREERESULT($result_user); - } - break; - - case "N": - $sql = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_cats WHERE userid=%d AND cat_id=%d LIMIT 1"; - break; - } - if (!empty($sql)) - { - // Run SQL command - $result = SQL_QUERY_ESC(trim($sql), array($UID, bigintval($cat)), __FILE__, __LINE__); - } - } - // Categories saved... - LOAD_TEMPLATE("admin_settings_saved", true, MEMBER_CATS_SAVED); - } - else - { - if ($LEAST) - { - // Also here we have to secure it... :( - LOAD_TEMPLATE("admin_settings_saved", true, CATS_LEAST.": ".$CONFIG['least_cats']); - } - // Put some data into constants for the template - define('__ROWS', ($cats*2+4)); - - // Load header template - LOAD_TEMPLATE("member_cats_header"); - - // Start switching colors and load all visible categories - $SW = 2; - while (list($id, $cat) = SQL_FETCHROW($result)) - { - // Default he has not joined - $JOINED_N = " checked"; $JOINED_Y = ""; - - // Check category selection - $result_user = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_cats WHERE userid=%d AND cat_id=%d LIMIT 1", - array($UID, bigintval($id)), __FILE__, __LINE__); - - // When we found an entry don't read it, just change the JOINED_x variables - if (isset($_POST['cat'])) - { - if ($_POST['cat'][$id] =="Y") { $JOINED_Y = " checked"; $JOINED_N = ""; } - } - else - { - if (SQL_NUMROWS($result_user) == 1) - { - $JOINED_Y = " checked"; $JOINED_N = ""; - } - - // Free memory - SQL_FREERESULT($result_user); - } - - // Prepare data for the template - $content = array( - 'sw' => $SW, - 'id' => $id, - 'cat' => $cat, - 'jy' => $JOINED_Y, - 'jn' => $JOINED_N, - ); - - // Load row template and switch colors - LOAD_TEMPLATE("member_cat_row", false, $content); - $SW = 3 - $SW; - } - - // Load footer template - LOAD_TEMPLATE("member_cats_footer"); - } -} - else -{ - // No cateogries are defined yet - LOAD_TEMPLATE("admin_settings_saved", true, MEMBER_NO_CATS); -} - -SQL_FREERESULT($result); - -// -?> + 0) +{ + $LEAST = false; + if (isset($_POST['ok'])) + { + $cnt = 0; + foreach ($_POST['cat'] as $cat=>$joined) + { + if ($joined == "N") $cnt++; + } + if (($cats - $cnt) < $CONFIG['least_cats']) + { + unset($_POST['ok']); + $LEAST = true; + } + } + if (isset($_POST['ok'])) + { + foreach ($_POST['cat'] as $cat=>$joined) + { + switch ($joined) + { + case "Y": + $sql = ""; + $result_user = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_cats WHERE userid=%d AND cat_id=%d LIMIT 1", + array($UID, bigintval($cat)), __FILE__, __LINE__); + + if (SQL_NUMROWS($result_user) == 0) + { + $sql = "INSERT INTO "._MYSQL_PREFIX."_user_cats (userid, cat_id) VALUES ('%s', '%s')"; + } + else + { + // Free memory + SQL_FREERESULT($result_user); + } + break; + + case "N": + $sql = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_cats WHERE userid=%d AND cat_id=%d LIMIT 1"; + break; + } + if (!empty($sql)) + { + // Run SQL command + $result = SQL_QUERY_ESC(trim($sql), array($UID, bigintval($cat)), __FILE__, __LINE__); + } + } + // Categories saved... + LOAD_TEMPLATE("admin_settings_saved", true, MEMBER_CATS_SAVED); + } + else + { + if ($LEAST) + { + // Also here we have to secure it... :( + LOAD_TEMPLATE("admin_settings_saved", true, CATS_LEAST.": ".$CONFIG['least_cats']); + } + // Put some data into constants for the template + define('__ROWS', ($cats*2+4)); + + // Load header template + LOAD_TEMPLATE("member_cats_header"); + + // Start switching colors and load all visible categories + $SW = 2; + while (list($id, $cat) = SQL_FETCHROW($result)) + { + // Default he has not joined + $JOINED_N = " checked"; $JOINED_Y = ""; + + // Check category selection + $result_user = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_cats WHERE userid=%d AND cat_id=%d LIMIT 1", + array($UID, bigintval($id)), __FILE__, __LINE__); + + // When we found an entry don't read it, just change the JOINED_x variables + if (isset($_POST['cat'])) + { + if ($_POST['cat'][$id] =="Y") { $JOINED_Y = " checked"; $JOINED_N = ""; } + } + else + { + if (SQL_NUMROWS($result_user) == 1) + { + $JOINED_Y = " checked"; $JOINED_N = ""; + } + + // Free memory + SQL_FREERESULT($result_user); + } + + // Prepare data for the template + $content = array( + 'sw' => $SW, + 'id' => $id, + 'cat' => $cat, + 'jy' => $JOINED_Y, + 'jn' => $JOINED_N, + ); + + // Load row template and switch colors + LOAD_TEMPLATE("member_cat_row", false, $content); + $SW = 3 - $SW; + } + + // Load footer template + LOAD_TEMPLATE("member_cats_footer"); + } +} + else +{ + // No cateogries are defined yet + LOAD_TEMPLATE("admin_settings_saved", true, MEMBER_NO_CATS); +} + +SQL_FREERESULT($result); + +// +?>