case "add": $member_add_success = 0; $member_add_failure = 0; if (isset($_POST["acc_community_members"]) && ($proxy_ids = explode(',', $_POST["acc_community_members"])) && count($proxy_ids)) { if ($MAILING_LISTS["active"]) { $mail_list = new MailingList($COMMUNITY_ID); } foreach ($proxy_ids as $proxy_id) { if ($proxy_id = (int) trim($proxy_id)) { $query = "\n\t\t\t\t\t\t\t\t\t\t\t\tSELECT a.`id` AS `proxy_id`, c.`cmember_id`, c.`member_acl`\n\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\t\t\t\t\t\t\tON b.`user_id` = " . $db->qstr($proxy_id) . "\n\t\t\t\t\t\t\t\t\t\t\t\tAND b.`app_id` IN (" . AUTH_APP_IDS_STRING . ")\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `community_members` AS c\n\t\t\t\t\t\t\t\t\t\t\t\tON c.`proxy_id` = " . $db->qstr($proxy_id) . "\n\t\t\t\t\t\t\t\t\t\t\t\tAND c.`community_id` = " . $db->qstr($COMMUNITY_ID) . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE a.`id` = " . $db->qstr($proxy_id); $result = $db->GetRow($query); if ($result) { if ((int) $result["cmember_id"]) { if (@$db->AutoExecute("community_members", array("member_active" => 1), "UPDATE", "`cmember_id` = " . $db->qstr((int) $result["cmember_id"]))) { if ($MAILING_LISTS["active"]) { $mail_list->add_member($proxy_id, (bool) $result["member_acl"]); } $member_add_success++; } else { $member_add_failure++; application_error("error", "Unable to activate a deactivated member. Database said: " . $db->ErrorMsg()); } } else { $PROCESSED = array(); $PROCESSED["community_id"] = $COMMUNITY_ID; $PROCESSED["proxy_id"] = (int) $result["proxy_id"]; $PROCESSED["member_active"] = 1; $PROCESSED["member_joined"] = time(); $PROCESSED["member_acl"] = 0; if (@$db->AutoExecute("community_members", $PROCESSED, "INSERT")) { if ($MAILING_LISTS["active"]) {
echo "</div>\n"; } } else { // Error Checking switch ($STEP) { case 2: $PROCESSED["community_id"] = $COMMUNITY_ID; $PROCESSED["proxy_id"] = $ENTRADA_USER->getActiveId(); $PROCESSED["member_active"] = 1; $PROCESSED["member_joined"] = time(); $PROCESSED["member_acl"] = 0; if ($db->AutoExecute("community_members", $PROCESSED, "INSERT")) { $member_id = $db->Insert_Id(); if ($MAILING_LISTS["active"]) { $mail_list = new MailingList($COMMUNITY_ID); $mail_list->add_member($PROCESSED["proxy_id"]); } $community_url = ENTRADA_URL . "/community" . $community_details["community_url"]; $ONLOAD[] = "setTimeout('window.location=\\'" . $community_url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "<strong>You have successfully joined " . html_encode($community_details["community_title"]) . "!</strong><br /><br />Please <a href=\"" . $community_url . "\">click here</a> to proceed to it or you will be automatically forwarded in 5 seconds."; communities_log_history($COMMUNITY_ID, 0, $member_id, "community_history_add_member", 1); } else { $community_url = ENTRADA_URL . "/communities"; $ONLOAD[] = "setTimeout('window.location=\\'" . $community_url . "\\'', 5000)"; $ERROR++; $ERRORSTR[] = "<strong>Failed to join " . html_encode($community_details["community_title"]) . ".</strong><br /><br />We were unable to register you in this community. The MEdTech Unit has been informed of this error, please try again later."; application_log("error", "Unable to register " . $ENTRADA_USER->getActiveId() . " in community id " . $COMMUNITY_ID . ". Database said: " . $db->ErrorMsg()); } break; default: