function JoinCommune($commune_id, $mode = false)
{
    session_start();
    if (!isset($_SESSION['uid'])) {
        return;
    }
    $cm = new commune();
    $objResponse = new xajaxResponse();
    $result = commune::Join($commune_id, $_SESSION['uid'], false);
    $objResponse->script("\$('ov-commune-confirm').setStyle('display','none');");
    $comm = $cm->getCommune($commune_id, $_SESSION['uid']);
    /*
    !!! Посылаем уведомление 
    todo не плохо бы придумать антиспам, пользователь может бесконечно раз выходить и входить в такое сообщество 
    с каждым входом автору сообщества будет высылаться уведомление (skif)
    */
    if ($result == commune::JOIN_STATUS_ASKED) {
        $sm = new smail();
        $sm->CommuneJoinAction($_SESSION['uid'], $comm);
    }
    if ($mode == 1) {
        $href = "'/commune/?id={$commune_id}'";
        $objResponse->script('document.location.href = ' . $href);
        return $objResponse;
    }
    if ($mode == 2) {
        $objResponse->script('document.location.href = document.location.href');
        return $objResponse;
    }
    $html = "<a href=\"javascript:void(0)\" onclick=\"xajax_OutCommune({$commune_id}); return false;\"><img src=\"/images/btn-cgoout.png\" alt=\"Выйти из сообщество\"/></a>";
    $objResponse->assign('join_' . $commune_id, 'innerHTML', $html);
    /*$href = "document.location.href";
      if($mode == true) {
          $href = "'/commune/?id={$commune_id}'";
      }
      
      $objResponse->script('document.location.href = '.$href);*/
    //  	$html = __commPrntJoinButton($comm, $_SESSION['uid'], null, true);
    //        $html_s = __commPrntSubmitButton($comm, $_SESSION['uid'], NULL, $mode);
    //        $mAcceptedCnt = $comm['a_count'] - $comm['w_count'] + 1;
    //	$objResponse->assign('join_btn_'.$commune_id,"innerHTML", $html);
    //        $objResponse->assign('commSubscrButton_'.$commune_id,"innerHTML", $html_s ? $html_s : '');
    //        $objResponse->assign('accepted_'.$commune_id,"innerHTML", $mAcceptedCnt);
    //        $objResponse->assign('idCommRating_'.$commune_id,'innerHTML',__commPrntRating($comm, $_SESSION['uid']));
    return $objResponse;
}
Exemple #2
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;
     //      }
     $commune_output = 'join.php';
     break;
 case 'Delete':
     if (commune::Delete($id)) {