*/
if (isset($_POST["community_id"]) && (int) trim($_POST["community_id"])) {
    $COMMUNITY_ID = (int) trim($_POST["community_id"]);
}
/**
 * Ensure that the selected community is editable by you.
 */
if ($COMMUNITY_ID) {
    $query = "SELECT * FROM `communities` WHERE `community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `community_active` = '1'";
    $community_details = $db->GetRow($query);
    if ($community_details) {
        if ($ENTRADA_ACL->amIAllowed(new CommunityResource($COMMUNITY_ID), 'delete')) {
            if (@$db->AutoExecute("communities", array("community_active" => 0), "UPDATE", "`community_id` = " . $db->qstr($COMMUNITY_ID))) {
                if ($MAILING_LISTS["active"]) {
                    $list = new MailingList($COMMUNITY_ID);
                    $list->mode_change("inactive");
                }
                communities_log_history($COMMUNITY_ID, 0, $COMMUNITY_ID, "community_history_deactivate_page", 1);
                $SUCCESS++;
                $SUCCESSSTR[] = "<strong>You have just deactiviated " . html_encode($community_details["community_title"]) . ".</strong><br /><br />If there has been a mistake please contact the MEdTech unit directly for assistance.<br /><br />You will now be redirected back to the communities section; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue.";
                application_log("success", "Community ID [" . $COMMUNITY_ID . "] has been deactivated.");
            } else {
                $ERROR++;
                $ERRORSTR[] = "<strong>Unable to deactive " . html_encode($community_details["community_title"]) . ".</strong><br /><br />The MEdTech unit has been informed of this error, please try again later. You will now be redirected back to the communities section; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue.";
            }
        } else {
            $ERROR++;
            $ERRORSTR[] = "You are not listed as an active administrator of this community, or the community has already been deactivated. If you are having trouble, please contact a community administrator or the MEdTech Unit directly.";
            application_log("error", "The proxy_id [" . $ENTRADA_USER->getActiveId() . " / " . $ENTRADA_USER->getID() . "] is not an administrator of community_id [" . $COMMUNITY_ID . "] was not found or was already deactivated.");
        }
    } else {
Esempio n. 2
0
                         $query = "SELECT * FROM `courses` \n                                                            WHERE `course_id` = " . $db->qstr($course_id) . "\n                                                            AND `course_active` = 1\n                                                            AND `course_id` NOT IN (\n                                                                SELECT `course_id` FROM `community_courses` WHERE `course_id` = " . $db->qstr($course_id) . "\n                                                            )";
                         $course = $db->GetRow($query);
                         if ($course && $ENTRADA_ACL->amIAllowed(new CourseContentResource($course["course_id"], $course["organisation_id"]), "update")) {
                             if (!$db->AutoExecute("community_courses", array("community_id" => $COMMUNITY_ID, "course_id" => $course["course_id"]), "INSERT")) {
                                 $ERROR++;
                                 $ERRORSTR[] = "An issue was encountered while attempting to attach a course to this community.";
                                 application_log("error", "Could not connect a course [" . $course["course_id"] . "] to an existing community [" . $community_id . "]. Database said: " . $db->ErrorMsg());
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($MAILING_LISTS["active"] && array_key_exists("community_list_mode", $PROCESSED) && $PROCESSED["community_list_mode"] != $mailing_list->type) {
         $mailing_list->mode_change($PROCESSED["community_list_mode"]);
     }
     $SUCCESS++;
     $SUCCESSSTR[] = "<strong>You have successfully updated your community.</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, $ENTRADA_USER->getID(), "community_history_edit_community", 1);
     if ($community_details["community_title"] != $PROCESSED["community_title"]) {
         communities_log_history($COMMUNITY_ID, 0, 0, "community_history_rename_community", 1);
     }
 }
 application_log("success", "Community ID " . $community_id . " was successfully updated.");
 if ($NOTICE) {
     echo display_notice();
 }
 if ($SUCCESS) {
     echo display_success();
 }