function OutCommune($commune_id, $mode = false) { session_start(); if (!isset($_SESSION['uid'])) { return; } $cm = new commune(); $objResponse = new xajaxResponse(); commune::Join($commune_id, $_SESSION['uid'], true); $comm = $cm->getCommune($commune_id, $_SESSION['uid']); $is_restricted = bitStr2Int($comm['restrict_type']) & commune::RESTRICT_JOIN_MASK; /*$url = substr($comm['restrict_type'], 1, 1) == '1' ? '/commune/?id='.$commune_id : 'document.location.href'; $objResponse->script("$('ov-commune-confirm').setStyle('display','none');"); $objResponse->script('document.location.href = '.$url);*/ if ($mode == 1 || $mode == 2) { $objResponse->script('document.location.href = document.location.href'); return $objResponse; } $html = '<a href="javascript:void(0)" onclick="xajax_JoinCommune(' . $comm['id'] . ', ' . $is_restricted . '); return false;"><img src="/images/btn-сgoin.png" alt="Вступить в сообщество"/></a>'; $objResponse->assign('join_' . $commune_id, 'innerHTML', $html); return $objResponse; }
case 'Join': $user_login = __paramInit('string', NULL, 'login', 0); $fromPage = urldecode(__paramInit('string', 'fp', 'fp')); $out = __paramInit('int', NULL, 'out', 0); $curr_login = get_login($uid); if ($user_login != $curr_login) { header('Location: /404.php'); exit; } if (!$out) { if ($user_mod & commune::MOD_COMM_ACCEPTED) { header("Location: /commune/?id={$id}"); exit; } } $result = commune::Join($id, $uid, $out); // commune::JOIN_STATUS_ACCEPTED if ($result == commune::JOIN_STATUS_ASKED) { $sm = new smail(); $sm->CommuneJoinAction($uid, $comm); } // if(!$result) { if ($out) { header('Location: /' . ($fromPage ? $fromPage : 'commune/')); } else { header("Location: /commune/?id={$id}"); } // if(!$out) header("Location: /commune/?id={$id}"); // else header('Location: '.($fromPage ? $fromPage : '/commune/')); // exit; // }