*/ if (isset($_POST["member_notify"])) { $PROCESSED["notify"] = $_POST["member_notify"]; } else { $PROCESSED["notify"] = 0; } if (!$ERROR) { $PROCESSED["updated_date"] = time(); $PROCESSED["updated_by"] = $ENTRADA_USER->getID(); if ($db->AutoExecute("community_share_comments", $PROCESSED, "UPDATE", "`cscomment_id` = " . $db->qstr($RECORD_ID) . " AND `csfile_id` = " . $db->qstr($comment_record["csfile_id"]) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID))) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=view-file&id=" . $comment_record["csfile_id"] . "#comment-" . $RECORD_ID; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully edited your file comment.<br /><br />You will now be redirected back to this file; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":shares", "comment_edit", "cscomment_id", $RECORD_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $RECORD_ID, "community_history_edit_file_comment", 0, $comment_record["csfile_id"]); } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem editing this file comment. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error editing a file comment. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: $PROCESSED = $comment_record; break;
if ($notification) { $notification["release_time"] = $PROCESSED["release_date"]; $db->AutoExecute("community_notifications", $notification, "UPDATE", "`cnotification_id` = " . $db->qstr($notification["cnotification_id"])); } } $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $SUCCESS++; if (!$COMMUNITY_ADMIN && $PAGE_OPTIONS["moderate_posts"] == 1) { $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 15000)"; $SUCCESSSTR[] = "You have successfully updated this announcement, however because you are not an administrator your changes must be reviewed before the announcement will appear on the page again.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 15 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } else { $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESSSTR[] = "You have successfully updated this announcement.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } add_statistic("community:" . $COMMUNITY_ID . ":announcements", "edit", "cannouncement_id", $RECORD_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $RECORD_ID, "community_history_edit_announcement", 1); } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem updating this announcement in the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error updating an announcement. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: if (!$COMMUNITY_ADMIN && $PAGE_OPTIONS["moderate_posts"] == 1) { $NOTICE++;
$notification["release_time"] = $PROCESSED["release_date"]; $db->AutoExecute("community_notifications", $notification, "UPDATE", "`cnotification_id` = " . $db->qstr($notification["cnotification_id"])); } } if (isset($notifications) && $notify_record_exists && COMMUNITY_NOTIFICATIONS_ACTIVE && $_SESSION["details"]["notifications"] && COMMUNITY_NOTIFICATIONS_ACTIVE) { $db->Execute("UPDATE `community_notify_members` SET `notify_active` = '" . ($notifications ? "1" : "0") . "' WHERE `proxy_id` = " . $db->qstr($ENTRADA_USER->getID()) . " AND `record_id` = " . $db->qstr($topic_record["cdtopic_parent"]) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `notify_type` = 'reply'"); } elseif (isset($notifications) && !$notify_record_exists && COMMUNITY_NOTIFICATIONS_ACTIVE && $_SESSION["details"]["notifications"]) { $db->Execute("INSERT INTO `community_notify_members` (`proxy_id`, `record_id`, `community_id`, `notify_type`, `notify_active`) VALUES (" . $db->qstr($ENTRADA_USER->getID()) . ", " . $db->qstr($topic_record["cdtopic_parent"]) . ", " . $db->qstr($COMMUNITY_ID) . ", 'reply', '" . ($notifications ? "1" : "0") . "')"); } } $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=view-post&id=" . $topic_record["cdtopic_parent"] . "#post-" . $RECORD_ID; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully updated your discussion post reply.<br /><br />You will now be redirected to this thread; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":discussions", "post_edit", "cdtopic_id", $RECORD_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $RECORD_ID, "community_history_edit_reply", 0, $topic_record["cdtopic_parent"]); } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem updating this discussion post reply, perhaps there were no changes?. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error updating a discussion post reply. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: $PROCESSED = $topic_record; break;
if ((int) $photo_record["photo_active"]) { if (galleries_photo_module_access($RECORD_ID, "move-photo")) { if ($db->AutoExecute("community_gallery_photos", array("cgallery_id" => $gallery_id, "updated_date" => time(), "updated_by" => $ENTRADA_USER->getID()), "UPDATE", "`cgphoto_id` = " . $db->qstr($RECORD_ID) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID))) { if ($photo_record["gallery_cgphoto_id"] == $RECORD_ID) { if (!$db->AutoExecute("community_galleries", array("gallery_cgphoto_id" => 0), "UPDATE", "`cgallery_id` = " . $db->qstr($photo_record["cgallery_id"]) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `cpage_id` = " . $db->qstr($PAGE_ID) . " AND `gallery_cgphoto_id` = " . $db->qstr($RECORD_ID))) { application_log("error", "Failed to remove the gallery hilite image [" . $RECORD_ID . "] photo from community [" . $COMMUNITY_ID . "]. Database said: " . $db->ErrorMsg()); } } if (!(int) $gallery_record["gallery_cgphoto_id"]) { if (!$db->AutoExecute("community_galleries", array("gallery_cgphoto_id" => $RECORD_ID), "UPDATE", "`cgallery_id` = " . $db->qstr($gallery_id) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID))) { application_log("error", "Failed to add the gallery hilite image [" . $RECORD_ID . "] photo to community [" . $COMMUNITY_ID . "]. Database said: " . $db->ErrorMsg()); } } @$db->AutoExecute("community_gallery_comments", array("cgallery_id" => $gallery_id, "updated_date" => time(), "updated_by" => $ENTRADA_USER->getID()), "UPDATE", "`cgphoto_id` = " . $db->qstr($RECORD_ID) . " AND `cgallery_id` = " . $db->qstr($photo_record["cgallery_id"]) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID)); add_statistic("community:" . $COMMUNITY_ID . ":galleries", "photo_move", "cgphoto_id", $RECORD_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $RECORD_ID, "community_history_move_photo", true, $gallery_id); } else { application_log("error", "Failed to deactivate [" . $RECORD_ID . "] photo from community. Database said: " . $db->ErrorMsg()); } } } else { application_log("error", "The provided photo id [" . $RECORD_ID . "] is already deactivated."); } header("Location: " . COMMUNITY_URL . $COMMUNITY_URL . ":" . $gallery_record["page_url"] . "?section=view-gallery&id=" . $gallery_id); exit; } } else { application_log("error", "The provided photo id [" . $RECORD_ID . "] was invalid."); } } else { application_log("error", "No gallery id was provided for moving the photo.");
} } if (!has_error() && @array_intersect($_POST["update_recurring_fields"], array("event_description", "event_message", "event_objectives"))) { if (!$db->AutoExecute("`events`", $PROCESSED_RECURRING_EVENT, "UPDATE", "`event_id` = " . $db->qstr($recurring_event["event_id"]))) { add_error("There was an error while trying to save changes to the selected <strong>Recurring Event</strong>.<br /><br />The system administrator was informed of this error; please try again later."); application_log("error", "Unable to update an event record while editing a recurring event. Database said: " . $db->ErrorMsg()); } } } if (!has_error()) { $query = "\tSELECT b.*\n FROM `community_courses` AS a\n LEFT JOIN `community_pages` AS b\n ON a.`community_id` = b.`community_id`\n LEFT JOIN `community_page_options` AS c\n ON b.`community_id` = c.`community_id`\n WHERE c.`option_title` = 'show_history'\n AND c.`option_value` = 1\n AND b.`page_url` = 'course_calendar'\n AND b.`page_active` = 1\n AND a.`course_id` = " . $db->qstr($event_info["course_id"]); $result = $db->GetRow($query); if ($result) { $COMMUNITY_ID = $result["community_id"]; $PAGE_ID = $result["cpage_id"]; communities_log_history($COMMUNITY_ID, $PAGE_ID, $event_info["recurring_id"], "community_history_edit_recurring_events", 1); } $SUCCESS++; $SUCCESSSTR[] = "You have successfully edited the recurring events associated with <strong>" . html_encode($event_info["event_title"]) . "</strong> in the system."; application_log("success", "Recurring Events [" . $event_info["recurring_id"] . "] have been modified."); } } } } break; case "files": $FILE_IDS = array(); if (!isset($_POST["delete"]) || !is_array($_POST["delete"]) || !count($_POST["delete"])) { $ERROR++; $ERRORSTR[] = "You must select at least 1 file to delete by checking the checkbox to the left the file title."; application_log("notice", "User pressed the Delete Selected button without selecting any files to delete.");
$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 { $ERROR++; $ERRORSTR[] = "The community identifier that was provided does not exist in our database or has already been deactivated.";
$PROCESSED["cpage_id"] = $PAGE_ID; if (!$COMMUNITY_ADMIN) { $PROCESSED["pending_moderation"] = 1; } if ($db->AutoExecute("community_announcements", $PROCESSED, "INSERT")) { if ($ANNOUNCEMENT_ID = $db->Insert_Id()) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $SUCCESS++; if (!$COMMUNITY_ADMIN && $PAGE_OPTIONS["moderate_posts"] == 1) { $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 15000)"; $SUCCESSSTR[] = "You have successfully created a new announcement for this page, however because you are not an administrator your post must be reviewed before appearing to all users.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 15 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } else { $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESSSTR[] = "You have successfully added a new announcement to the community.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } communities_log_history($COMMUNITY_ID, $PAGE_ID, $ANNOUNCEMENT_ID, "community_history_add_announcement", $PROCESSED["pending_moderation"] == 1 ? 0 : 1); add_statistic("community:" . $COMMUNITY_ID . ":announcements", "add", "cannouncement_id", $ANNOUNCEMENT_ID); } } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem inserting this announcement into the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error inserting an announcement. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default:
communities_log_history($COMMUNITY_ID, $PAGE_ID, $event_info["recurring_id"], "community_history_edit_recurring_events", 1); } $SUCCESS++; $SUCCESSSTR[] = "You have successfully edited the recurring events associated with <strong>" . html_encode($event_info["event_title"]) . "</strong> in the system."; communities_log_history($COMMUNITY_ID, $PAGE_ID, $recurring_event["event_id"], "community_history_edit_learning_event", 1); application_log("success", "Recurring Events [" . $event_info["recurring_id"] . "] have been modified."); } } } if (!$ERROR) { $query = "\tSELECT b.*\n\t\t\t\t\t\t\t\t\t\t\t\tFROM `community_courses` AS a\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `community_pages` AS b\n\t\t\t\t\t\t\t\t\t\t\t\tON a.`community_id` = b.`community_id`\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `community_page_options` AS c\n\t\t\t\t\t\t\t\t\t\t\t\tON b.`community_id` = c.`community_id`\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE c.`option_title` = 'show_history'\n\t\t\t\t\t\t\t\t\t\t\t\tAND c.`option_value` = 1\n\t\t\t\t\t\t\t\t\t\t\t\tAND b.`page_url` = 'course_calendar'\n\t\t\t\t\t\t\t\t\t\t\t\tAND b.`page_active` = 1\n\t\t\t\t\t\t\t\t\t\t\t\tAND a.`course_id` = " . $db->qstr($PROCESSED["course_id"]); $result = $db->GetRow($query); if ($result) { $COMMUNITY_ID = $result["community_id"]; $PAGE_ID = $result["cpage_id"]; communities_log_history($COMMUNITY_ID, $PAGE_ID, $EVENT_ID, "community_history_edit_learning_event", 1); } $SUCCESS++; $SUCCESSSTR[] = "You have successfully edited <strong>" . html_encode($PROCESSED["event_title"]) . "</strong> in the system.<br /><br />" . $msg; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; application_log("success", "Event [" . $EVENT_ID . "] has been modified."); } if (!empty($stats)) { $stats_string = implode(", ", $stats); history_log($EVENT_ID, 'edited this learning event in sections: ' . $stats_string, $PROXY_ID); } } else { add_error("There was a problem updating this event in the system. The system administrator was informed of this error; please try again later." . $db->ErrorMsg()); application_log("error", "There was an error updating event_id [" . $EVENT_ID . "]. Database said: " . $db->ErrorMsg()); } }
$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: continue; break; } // Display Content switch ($STEP) { case 2:
$url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=edit-poll&id=" . $RECORD_ID; $SUCCESSSTR[] = "You have successfully added a new question to the " . $terminology . ".<br /><br />You will now be redirected back to edit this " . $terminology . "; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } elseif ($_POST["poll_action"] == "add-question") { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=add-question&id=" . $PROCESSED["cpolls_id"]; $SUCCESSSTR[] = "You have successfully added a new question to the " . $terminology . ".<br /><br />You will now be redirected to add another question to this " . $terminology . "; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } else { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $SUCCESSSTR[] = "You have successfully added a new question to the " . $terminology . ".<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } } else { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $SUCCESSSTR[] = "You have successfully added a new question to the " . $terminology . ".<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; add_statistic("community_polling", "question_add", "cpquestion_id", $QUESTION_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $PROCESSED["cpolls_id"], "community_history_edit_poll", 0); } } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem inserting this question into the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error inserting a poll. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: continue;
} elseif ($folder_record["allow_member_upload"] == 1) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; } } else { if ($folder_record["allow_troll_read"] == 1) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=view-folder&id=" . $RECORD_ID; } elseif ($folder_record["allow_troll_upload"] == 1) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; } } } $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully uploaded " . html_encode($PROCESSED["file_filename"]) . " (version 1).<br /><br />You will now be redirected to this files page; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":shares", "file_add", "csfile_id", $VERSION_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $FILE_ID, "community_history_add_file", 1, $RECORD_ID); } } } } } if (!$SUCCESS) { /** * Because there was no success, check if the file_id was set... if it * was we need to delete the database record :( In the future this will * be handled with transactions like it's supposed to be. */ if ($FILE_ID) { $query = "DELETE FROM `community_share_files` WHERE `csfile_id` = " . $db->qstr($FILE_ID) . " AND `cshare_id` = " . $db->qstr($RECORD_ID) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID) . " LIMIT 1"; @$db->Execute($query); /**
$url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=add-question&id=" . $POLL_ID; $SUCCESSSTR[] = "You have successfully added a new " . $terminology . " to the community.<br /><br />You will now be redirected to add another question to this poll; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } elseif ($_POST["poll_action"] == "edit-poll") { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=edit-poll&id=" . $POLL_ID; $SUCCESSSTR[] = "You have successfully added a new " . $terminology . " to the community.<br /><br />You will now be redirected to edit this poll; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } else { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $SUCCESSSTR[] = "You have successfully added a new " . $terminology . " to the community.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } } else { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $SUCCESSSTR[] = "You have successfully added a new " . $terminology . " to the community.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; add_statistic("community_polling", "poll_add", "cpolls_id", $POLL_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $POLL_ID, "community_history_add_poll", 1); } } } } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem inserting this " . $terminology . " into the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error inserting a poll. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1:
$PROCESSED["cpage_id"] = $PAGE_ID; if (!$COMMUNITY_ADMIN) { $PROCESSED["pending_moderation"] = 1; } if ($db->AutoExecute("community_events", $PROCESSED, "INSERT")) { if ($EVENT_ID = $db->Insert_Id()) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $SUCCESS++; if (!$COMMUNITY_ADMIN && $PAGE_OPTIONS["moderate_posts"] == 1) { $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 15000)"; $SUCCESSSTR[] = "You have successfully created a new event for this page, however because you are not an administrator your event must be reviewed before appearing to all users.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 15 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } else { $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESSSTR[] = "You have successfully added a new event to the community.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; } communities_log_history($COMMUNITY_ID, $PAGE_ID, $EVENT_ID, "community_history_add_event", $PROCESSED["pending_moderation"] == 1 ? 0 : 1); add_statistic("community:" . $COMMUNITY_ID . ":events", "add", "cevent_id", $EVENT_ID); } } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem inserting this event into the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error inserting an event. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default:
$mail_list->add_member($proxy_id); } $member_add_success++; } else { $member_add_failure++; application_error("error", "Unable to insert a new community member. Database said: " . $db->ErrorMsg()); } } } } } } if ($member_add_success) { $SUCCESS++; $SUCCESSSTR[] = "You have successfully added " . $member_add_success . " new member" . ($member_add_success != 1 ? "s" : "") . " to this community.<br /><br />You will now be redirected back to the Manage Members page; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . ENTRADA_URL . "/" . $MODULE . "?section=members&community=" . $COMMUNITY_ID . "\" style=\"font-weight: bold\">click here</a> to continue."; communities_log_history($COMMUNITY_ID, 0, $member_add_success, "community_history_add_members", 1); } if ($member_add_failure) { $NOTICE++; $NOTICESTR[] = "Failed to add or update" . $member_add_failure . " member" . ($member_add_failure != 1 ? "s" : "") . " during this process. The MEdTech Unit has been informed of this error, please try again later.<br /><br />You will now be redirected back to the Manage Members page; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . ENTRADA_URL . "/" . $MODULE . "?section=members&community=" . $COMMUNITY_ID . "\" style=\"font-weight: bold\">click here</a> to continue."; } break; case "admins": if (isset($_POST["admin_action"]) && @in_array(strtolower($_POST["admin_action"]), array("delete", "deactivate", "demote"))) { if (isset($_POST["admin_proxy_ids"]) && is_array($_POST["admin_proxy_ids"]) && count($_POST["admin_proxy_ids"])) { foreach ($_POST["admin_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\t\tSELECT a.*\n\t\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\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\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\t\tAND b.`app_id` IN (" . AUTH_APP_IDS_STRING . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE a.`id` = " . $db->qstr($proxy_id); $result = $db->GetRow($query); if ($result) { $PROXY_IDS[] = $proxy_id;
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(); } $ONLOAD[] = "setTimeout('window.location=\\'" . $community_url . "\\'', 5000)"; break; case 2: ?> <div class="display-notice" style="line-height: 175%"> <strong>Please review</strong> the following changes that will be made to your community once you press the "Save Changes" button at the bottom of the screen. If you have made a mistake, please press the "Cancel" button, <strong>not</strong> your browsers back button.
exit; } if ($RECORD_ID) { if (isset($_GET["share_id"]) && ($share_id = (int) $_GET["share_id"])) { $query = "\tSELECT a.*\n\t\t\t\t\t\t\tFROM `community_share_files` AS a\n\t\t\t\t\t\t\tLEFT JOIN `community_shares` AS b\n\t\t\t\t\t\t\tON a.`cshare_id` = b.`cshare_id`\n\t\t\t\t\t\t\tWHERE a.`csfile_id` = " . $db->qstr($RECORD_ID) . "\n\t\t\t\t\t\t\tAND a.`community_id` = " . $db->qstr($COMMUNITY_ID) . "\n\t\t\t\t\t\t\tAND a.`cshare_id` != " . $db->qstr($share_id) . "\n\t\t\t\t\t\t\tAND b.`cpage_id` = " . $db->qstr($PAGE_ID) . "\n\t\t\t\t\t\t\tAND b.`folder_active` = '1'"; $file_record = $db->GetRow($query); if ($file_record) { $query = "\tSELECT b.`page_url`\n\t\t\t\t\t\t\t\tFROM `community_shares` AS a\n\t\t\t\t\t\t\t\tLEFT JOIN `community_pages` AS b\n\t\t\t\t\t\t\t\tON b.`cpage_id` = a.`cpage_id`\n\t\t\t\t\t\t\t\tWHERE a.`cshare_id` = " . $db->qstr($share_id) . "\n\t\t\t\t\t\t\t\tAND a.`community_id` = " . $db->qstr($COMMUNITY_ID) . "\n\t\t\t\t\t\t\t\tAND a.`folder_active` = '1'"; $share_record = $db->GetRow($query); if ($share_record) { if ((int) $file_record["file_active"]) { if (shares_file_module_access($RECORD_ID, "move-file")) { if ($db->AutoExecute("community_share_files", array("cshare_id" => $share_id, "updated_date" => time(), "updated_by" => $ENTRADA_USER->getID()), "UPDATE", "`csfile_id` = " . $db->qstr($RECORD_ID) . " AND `cshare_id` = " . $db->qstr($file_record["cshare_id"]) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID))) { @$db->AutoExecute("community_share_file_versions", array("cshare_id" => $share_id, "updated_date" => time(), "updated_by" => $ENTRADA_USER->getID()), "UPDATE", "`csfile_id` = " . $db->qstr($RECORD_ID) . " AND `cshare_id` = " . $db->qstr($file_record["cshare_id"]) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID)); @$db->AutoExecute("community_share_comments", array("cshare_id" => $share_id, "updated_date" => time(), "updated_by" => $ENTRADA_USER->getID()), "UPDATE", "`csfile_id` = " . $db->qstr($RECORD_ID) . " AND `cshare_id` = " . $db->qstr($file_record["cshare_id"]) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID)); communities_log_history($COMMUNITY_ID, $PAGE_ID, $RECORD_ID, "community_history_move_file", true, $share_id); add_statistic("community:" . $COMMUNITY_ID . ":shares", "file_move", "csfile_id", $RECORD_ID); $db->AutoExecute("community_history", array("history_display" => 0), "UPDATE", "`community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `module_id` = " . $db->qstr($MODULE_ID) . " AND `record_id` = " . $db->qstr($RECORD_ID)); } else { application_log("error", "Failed to move [" . $RECORD_ID . "] file to folder. Database said: " . $db->ErrorMsg()); } } } else { application_log("error", "The provided file id [" . $RECORD_ID . "] is deactivated."); } header("Location: " . COMMUNITY_URL . $COMMUNITY_URL . ":" . $share_record["page_url"] . "?section=view-folder&id=" . $share_id); exit; } } else { application_log("error", "The provided file id [" . $RECORD_ID . "] was invalid."); }
} if (!$ERROR) { $PROCESSED["community_id"] = $COMMUNITY_ID; $PROCESSED["proxy_id"] = $ENTRADA_USER->getActiveId(); $PROCESSED["forum_active"] = 1; $PROCESSED["updated_date"] = time(); $PROCESSED["updated_by"] = $ENTRADA_USER->getID(); $PROCESSED["cpage_id"] = $PAGE_ID; if ($db->AutoExecute("community_discussions", $PROCESSED, "INSERT")) { if ($FORUM_ID = $db->Insert_Id()) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully added a new discussion forum to the community.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":discussions", "forum_add", "cdiscussion_id", $FORUM_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $FORUM_ID, "community_history_add_forum", 1); } } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem inserting this forum into the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error inserting a discussion forum. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: continue;
if ($db->AutoExecute("community_polls_access", $MEMBERS, "INSERT")) { $SUCCESS = TRUE; } } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem inserting the specific member permissions for this " . $terminology . " into the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error inserting the specific member permissions to a poll (ID: " . $RECORD_ID . "). Database said: " . $db->ErrorMsg()); } } $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully updated a " . $terminology . " to the community.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community_polling", "poll_edit", "cpolls_id", $RECORD_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $RECORD_ID, "community_history_edit_poll", 0); } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem editing this " . $terminology . " in the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error editing a poll. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: $PROCESSED = $poll_record; break;
$SUCCESSSTR[] = "You have successfully created your new community; however, it must be approved by an administrator before you can actually access the site.<br /><br />An e-mail has been sent to us and we will review and approve your Commmunity shortly. You will receive an e-mail notification once the Community has been activated."; communities_log_history($community_id, 0, $community_id, "community_history_create_moderated_community", 1); } else { $ERROR++; $ERRORSTR[] = "Your new community has been successfully created; however, this community requires an administrator's approval before it is activated and there was an error when trying to send an administrator this notification.<br /><br />The MEdTech Unit has been informed of this error and will contact you shortly."; application_log("error", "Community ID " . $community_id . " was successfully created, but an admin approval notification could not be sent."); } } else { if ($MAILING_LISTS["active"]) { $mail_list = new MailingList($community_id, $PROCESSED["community_list_mode"]); } $community_url = ENTRADA_URL . "/community" . $PROCESSED["community_url"]; $ONLOAD[] = "setTimeout('window.location=\\'" . $community_url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "<strong>You have successfully created your new 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, $community_id, "community_history_create_active_community", 1); } } else { $ERROR++; $ERRORSTR[] = "Your community was successfully created; however, administrative permissions for your account could not be set to the new community.<br /><br />The system administrator has been informed of this problem, and they will resolve it shortly."; application_log("error", "Community was created, but admin permissions for proxy id " . $ENTRADA_USER->getActiveId() . " could not be set. Database said: " . $db->ErrorMsg()); } } else { $ERROR++; $ERRORSTR[] = "We encountered a problem while creating your new community.<br /><br />The system administrator has been informed of this problem, please try again later."; application_log("error", "Failed to create new community. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 2; } else {
} elseif ($file_record["allow_member_upload"] == 1) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; } } else { if ($file_record["allow_troll_read"] == 1) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=view-file&id=" . $RECORD_ID; } elseif ($file_record["allow_member_upload"] == 1) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; } } } $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully added a new revision to " . html_encode($file_record["file_title"]) . " (version " . $PROCESSED["file_version"] . ").<br /><br />You will now be redirected to this files page; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":shares", "revision_add", "csfversion_id", $VERSION_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $VERSION_ID, "community_history_add_file_revision", 1, $RECORD_ID); } } } if (!$SUCCESS) { /** * Because there was no success, check if the file_id was set... if it * was we need to delete the database record :( In the future this will * be handled with transactions like it's supposed to be. */ if ($VERSION_ID) { $query = "DELETE FROM `community_share_file_versions` WHERE `csfversion_id` = " . $db->qstr($VERSION_ID) . " AND `csfile_id` = " . $db->qstr($RECORD_ID) . " AND `cshare_id` = " . $db->qstr($file_record["cshare_id"]) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID) . " LIMIT 1"; @$db->Execute($query); } $ERROR++; $ERRORSTR[] = "Unable to store the revised file on the server; the MEdTech Unit has been informed of this error, please try again later.";
} if (!$ERROR) { $PROCESSED["community_id"] = $COMMUNITY_ID; $PROCESSED["proxy_id"] = $ENTRADA_USER->getActiveId(); $PROCESSED["folder_active"] = 1; $PROCESSED["updated_date"] = time(); $PROCESSED["updated_by"] = $ENTRADA_USER->getID(); $PROCESSED["cpage_id"] = $PAGE_ID; if ($db->AutoExecute("community_shares", $PROCESSED, "INSERT")) { if ($FOLDER_ID = $db->Insert_Id()) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully added a new shared folder to the community.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":shares", "folder_add", "cshare_id", $FOLDER_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $FOLDER_ID, "community_history_add_share", 1); } } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem inserting this folder into the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error inserting a shared folder. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: continue;
$PROCESSED["community_id"] = $COMMUNITY_ID; $PROCESSED["proxy_id"] = $ENTRADA_USER->getActiveId(); $PROCESSED["topic_active"] = 1; $PROCESSED["updated_date"] = time(); $PROCESSED["updated_by"] = $ENTRADA_USER->getID(); if ($db->AutoExecute("community_discussion_topics", $PROCESSED, "INSERT")) { if ($TOPIC_ID = $db->Insert_Id()) { if (isset($notifications) && COMMUNITY_NOTIFICATIONS_ACTIVE && $_SESSION["details"]["notifications"]) { $db->Execute("INSERT INTO `community_notify_members` (`proxy_id`, `record_id`, `community_id`, `notify_type`, `notify_active`) VALUES (" . $db->qstr($PROCESSED["proxy_id"]) . ", " . $db->qstr($TOPIC_ID) . ", " . $db->qstr($COMMUNITY_ID) . ", 'reply', '" . ($notifications ? "1" : "0") . "')"); } $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=view-post&id=" . $TOPIC_ID; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully created a new discussion post.<br /><br />You will now be redirected to this thread; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":discussions", "post_add", "cdtopic_id", $TOPIC_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $TOPIC_ID, "community_history_add_post", 1, $RECORD_ID); } } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem inserting this discussion post into the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error inserting a discussion forum post. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: continue;
} else { $ERROR++; $ERRORSTR[] = "There was a problem updating the 'allow non-member posts' option for the home page of the community. Please contact the application administrator and inform them of this error."; application_log("error", "There was an error updating this page option. Database said: " . $db->ErrorMsg()); } } else { if (!$ERROR) { $url = ENTRADA_URL . "/community" . $community_details["community_url"] . ":pages"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully updated the home page of the community.<br /><br />You will now be redirected to the page management index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; $HEAD[] = "<script type=\"text/javascript\"> setTimeout('window.location=\\'" . $url . "\\'', 5000); </script>"; application_log("success", "Home Page [" . $PAGE_ID . "] updated in the system."); } } } else { communities_log_history($COMMUNITY_ID, $PAGE_ID, 0, "community_history_edit_page", 1); if ($PROCESSED["menu_title"] != $page_details["menu_title"]) { communities_set_children_urls($PAGE_ID, $PROCESSED["page_url"]); } if (isset($PROCESSED["page_order"]) && $PROCESSED["page_order"] != $page_details["page_order"]) { /** * Go through this process the second time to ensure each page is in the correct order. */ $query = "SELECT `cpage_id`, `page_order` FROM `community_pages` WHERE `community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `parent_id` = " . $db->qstr($PROCESSED["parent_id"]) . " AND `page_url` != '' ORDER BY `page_order` ASC"; $results = $db->GetAll($query); if ($results) { foreach ($results as $key => $result) { $order = $key; if ((int) $order != (int) $result["page_order"]) { $query = "UPDATE `community_pages` SET `page_order` = " . $db->qstr($order) . " WHERE `cpage_id` = " . $db->qstr($result["cpage_id"]); if (!$db->Execute($query)) {
if ($db->AutoExecute("community_share_files", $PROCESSED, "UPDATE", "`community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `csfile_id` = " . $db->qstr($RECORD_ID))) { if (COMMUNITY_NOTIFICATIONS_ACTIVE) { if ($PROCESSED["release_date"] != $file_record["release_date"]) { $notification = $db->GetRow("SELECT * FROM `community_notifications` WHERE `record_id` = " . $db->qstr($RECORD_ID) . " AND `type` = 'file'"); if ($notification) { $notification["release_time"] = $PROCESSED["release_date"]; $db->AutoExecute("community_notifications", $notification, "UPDATE", "`cnotification_id` = " . $db->qstr($notification["cnotification_id"])); } } } $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=view-file&id=" . $RECORD_ID; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully updated this file.<br /><br />You will now be redirected to this file page; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":shares", "file_edit", "csfile_id", $RECORD_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $RECORD_ID, "community_history_edit_file", 1, $file_record["cshare_id"]); } } if ($ERROR) { $STEP = 1; } break; case 1: default: $PROCESSED = $file_record; break; } // Page Display switch ($STEP) { case 2: if ($NOTICE) {
} if (!$ERROR) { $PROCESSED["community_id"] = $COMMUNITY_ID; $PROCESSED["proxy_id"] = $ENTRADA_USER->getActiveId(); $PROCESSED["gallery_active"] = 1; $PROCESSED["updated_date"] = time(); $PROCESSED["updated_by"] = $ENTRADA_USER->getID(); $PROCESSED["cpage_id"] = $PAGE_ID; if ($db->AutoExecute("community_galleries", $PROCESSED, "INSERT")) { if ($GALLERY_ID = $db->Insert_Id()) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully added a new photo gallery to the community.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":galleries", "gallery_add", "cgallery_id", $GALLERY_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $GALLERY_ID, "community_history_add_gallery", 1); } } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem inserting this gallery into the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error inserting a photo gallery. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: continue;
} if (isset($release_dates["finish"]) && (int) $release_dates["finish"]) { $PROCESSED["release_until"] = (int) $release_dates["finish"]; } else { $PROCESSED["release_until"] = 0; } if (!$ERROR) { $PROCESSED["updated_date"] = time(); $PROCESSED["updated_by"] = $ENTRADA_USER->getID(); if ($db->AutoExecute("community_shares", $PROCESSED, "UPDATE", "`community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `cpage_id` = " . $db->qstr($PAGE_ID) . " AND `cshare_id` = " . $db->qstr($RECORD_ID))) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully updated the <strong>" . html_encode($PROCESSED["folder_title"]) . "</strong> shared folder.<br /><br />You will now be redirected to the index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":shares", "folder_edit", "cshare_id", $RECORD_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $RECORD_ID, "community_history_edit_share", 1); } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem updating this shared folder in the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error updating a shared folder. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: $PROCESSED = $folder_record; break;
$db->Execute("INSERT INTO `community_notify_members` (`proxy_id`, `record_id`, `community_id`, `notify_type`, `notify_active`) VALUES (" . $db->qstr($ENTRADA_USER->getID()) . ", " . $db->qstr($photo_id) . ", " . $db->qstr($COMMUNITY_ID) . ", 'photo-comment', '" . (isset($notifications) && $notifications ? "1" : "0") . "')"); } if ($photo_id) { if (communities_galleries_process_photo($_FILES["photo_files"]["tmp_name"][$tmp_photo_id], $photo_id)) { if (!(int) $gallery_record["gallery_cgphoto_id"]) { if (!$db->AutoExecute("community_galleries", array("gallery_cgphoto_id" => $photo_id), "UPDATE", "`cgallery_id` = " . $db->qstr($RECORD_ID) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID))) { application_log("error", "Unable to set the gallery_cgphoto_id to this photo_id when adding the first picture. Database said: " . $db->ErrorMsg()); } } if (COMMUNITY_NOTIFICATIONS_ACTIVE) { community_notify($COMMUNITY_ID, $photo_id, "photo", COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=view-photo&id=" . $photo_id, $RECORD_ID, $PROCESSED["release_date"]); } $SUCCESS++; $SUCCESSSTR[] = "Photo " . $photo_number . " has been successfully uploaded [" . $PROCESSED["photo_title"] . "]."; add_statistic("community:" . $COMMUNITY_ID . ":galleries", "photo_add", "cgphoto_id", $photo_id); communities_log_history($COMMUNITY_ID, $PAGE_ID, $photo_id, "community_history_add_photo", 1, $RECORD_ID); } else { $query = "DELETE FROM `community_gallery_photos` WHERE `cgphoto_id` = " . $db->qstr($photo_id) . " AND `cgallery_id` = " . $db->qstr($RECORD_ID) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID) . " LIMIT 1"; if (!$db->Execute($query)) { application_log("error", "Failed to remove a newly uploaded photo [" . $photo_id . "] from the community_gallery_photos table in community [" . $COMMUNITY_ID . "]. Database said: " . $db->ErrorMsg()); } $error_current++; $ERROR++; $ERRORSTR[] = "Photo " . $photo_number . ": Unable to store the new photo file on the server; the system administrator has been informed of this error, please try again later."; application_log("error", "Failed to move the uploaded Community photo to the storage directory [" . COMMUNITY_STORAGE_GALLERIES . "/" . $photo_id . "]."); } } } } } $photo_uploads[$tmp_photo_id] = array("success" => $error_current ? false : true, "photo_id" => $photo_id ? $photo_id : 0, "title" => $PROCESSED["photo_title"], "description" => $PROCESSED["photo_description"]);
application_log("error", "Failed to set this photo as the gallery thumbnail. Database said: " . $db->ErrorMsg()); } } elseif ((int) $photo_record["gallery_cgphoto_id"] == (int) $RECORD_ID && (!isset($_POST["gallery_cgphoto_id"]) || (int) trim($_POST["gallery_cgphoto_id"]) != 1)) { if (!$db->AutoExecute("community_galleries", array("gallery_cgphoto_id" => 0), "UPDATE", "`community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `cpage_id` = " . $db->qstr($PAGE_ID) . " AND `cgallery_id` = " . $db->qstr($photo_record["cgallery_id"]))) { $NOTICE++; $NOTICESTR[] = "Unable to unset this photo as the gallery thumbnail; the MEdTech Unit has been informed of this error, please try again later."; application_log("error", "Failed to unset this photo as the gallery thumbnail. Database said: " . $db->ErrorMsg()); } } } $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=view-photo&id=" . $RECORD_ID; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully updated this photo.<br /><br />You will now be redirected to this image; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":galleries", "photo_edit", "cgphoto_id", $RECORD_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $RECORD_ID, "community_history_edit_photo", 1, $photo_record["cgallery_id"]); } else { $ERROR++; $ERRORSTR[] = "Unable to update this photo at this time; the MEdTech Unit has been informed of this error, please try again later."; application_log("error", "Failed to update a photo. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: $PROCESSED = $photo_record; break; }
$PROCESSED["csfile_id"] = $RECORD_ID; $PROCESSED["cshare_id"] = $file_record["cshare_id"]; $PROCESSED["community_id"] = $COMMUNITY_ID; $PROCESSED["proxy_id"] = $ENTRADA_USER->getActiveId(); $PROCESSED["comment_active"] = 1; $PROCESSED["release_date"] = time(); $PROCESSED["updated_date"] = time(); $PROCESSED["updated_by"] = $ENTRADA_USER->getID(); if ($db->AutoExecute("community_share_comments", $PROCESSED, "INSERT")) { if ($COMMENT_ID = $db->Insert_Id()) { $url = COMMUNITY_URL . $COMMUNITY_URL . ":" . $PAGE_URL . "?section=view-file&id=" . $RECORD_ID . "#comment-" . $COMMENT_ID; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $SUCCESS++; $SUCCESSSTR[] = "You have successfully added a new file comment.<br /><br />You will now be redirected back to this file; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; add_statistic("community:" . $COMMUNITY_ID . ":shares", "comment_add", "cscomment_id", $COMMENT_ID); communities_log_history($COMMUNITY_ID, $PAGE_ID, $COMMENT_ID, "community_history_add_file_comment", 1, $RECORD_ID); } } if (!$SUCCESS) { $ERROR++; $ERRORSTR[] = "There was a problem adding this file comment into the system. The MEdTech Unit was informed of this error; please try again later."; application_log("error", "There was an error inserting a file comment. Database said: " . $db->ErrorMsg()); } } if ($ERROR) { $STEP = 1; } break; case 1: default: continue;