Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane Luis Daniel Lucio Quiroz */ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('conference_room_add') || permission_exists('conference_room_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $conference_room_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http post variables and set them to php variables if (count($_POST) > 0) { $conference_center_uuid = check_str($_POST["conference_center_uuid"]); $meeting_uuid = check_str($_POST["meeting_uuid"]); $conference_room_name = check_str($_POST['conference_room_name']); $moderator_pin = check_str($_POST["moderator_pin"]); $participant_pin = check_str($_POST["participant_pin"]); $profile = check_str($_POST["profile"]); $record = check_str($_POST["record"]); $user_uuid = check_str($_POST["user_uuid"]); $max_members = check_str($_POST["max_members"]); $start_datetime = check_str($_POST["start_datetime"]); $stop_datetime = check_str($_POST["stop_datetime"]); $wait_mod = check_str($_POST["wait_mod"]); $announce = check_str($_POST["announce"]); $sounds = check_str($_POST["sounds"]); $mute = check_str($_POST["mute"]); $created = check_str($_POST["created"]); $created_by = check_str($_POST["created_by"]); $enabled = check_str($_POST["enabled"]); $description = check_str($_POST["description"]); //remove any pin number formatting $moderator_pin = preg_replace('{\D}', '', $moderator_pin); $participant_pin = preg_replace('{\D}', '', $participant_pin); } //get the conference centers array and set a default conference center $sql = "select * from v_conference_centers "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "order by conference_center_name asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $conference_centers = $prep_statement->fetchAll(PDO::FETCH_ASSOC); if (strlen($conference_center_uuid) == 0) { $conference_center_uuid = $conference_centers[0]["conference_center_uuid"]; } //define fucntion get_meeting_pin - used to find a unique pin number function get_meeting_pin($length, $meeting_uuid) { global $db; $pin = generate_password($length,1); $sql = "select count(*) as num_rows from v_meetings "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; //$sql .= "and meeting_uuid <> '".$meeting_uuid."' "; $sql .= "and (moderator_pin = '".$pin."' or participant_pin = '".$pin."') "; $prep_statement = $db->prepare(check_sql($sql)); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); if ($row['num_rows'] == 0) { return $pin; } else { get_meeting_pin($length, $uuid); } } } //record announcment if ($record == "true") { //prepare the values $default_language = 'en'; $default_dialect = 'us'; $default_voice = 'callie'; $switch_cmd = "conference ".$meeting_uuid."-".$_SESSION['domain_name']." play ".$_SESSION['switch']['sounds']['dir']."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav"; //connect to event socket $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } } //generate the pins $sql = "select conference_center_pin_length from v_conference_centers "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; if (strlen($conference_center_uuid) > 0) { $sql .= "and conference_center_uuid = '".$conference_center_uuid."' "; } $prep_statement = $db->prepare(check_sql($sql)); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); $pin_length = $row['conference_center_pin_length']; } if (strlen($moderator_pin) == 0) { $moderator_pin = get_meeting_pin($pin_length, $meeting_uuid); } if (strlen($participant_pin) == 0) { $participant_pin = get_meeting_pin($pin_length, $meeting_uuid); } //delete the user if ($_GET["a"] == "delete" && permission_exists('conference_room_delete')) { if (strlen($_REQUEST["meeting_user_uuid"]) > 0) { //set the variables $meeting_user_uuid = check_str($_REQUEST["meeting_user_uuid"]); $conference_room_uuid = check_str($_REQUEST["conference_room_uuid"]); //delete the extension from the ring_group $sql = "delete from v_meeting_users "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and meeting_user_uuid = '$meeting_user_uuid' "; $db->exec(check_sql($sql)); unset($sql); } $_SESSION["message"] = $text['message-delete']; header("Location: conference_room_edit.php?id=".$conference_room_uuid); return; } if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $conference_room_uuid = check_str($_POST["conference_room_uuid"]); } //check for a unique pin number and length if (strlen($moderator_pin) > 0 || strlen($participant_pin) > 0) { //make sure the moderator pin number is unique $sql = "select count(*) as num_rows from v_meetings "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; if (strlen($meeting_uuid) > 0) { $sql .= "and meeting_uuid <> '".$meeting_uuid."' "; } $sql .= "and (moderator_pin = '".$moderator_pin."' or participant_pin = '".$moderator_pin."') "; $prep_statement = $db->prepare(check_sql($sql)); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); if ($row['num_rows'] > 0) { $msg .= $text['message-unique_moderator_pin']."
\n"; } } //make sure the participant pin number is unique $sql = "select count(*) as num_rows from v_meetings "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; if (strlen($meeting_uuid) > 0) { $sql .= "and meeting_uuid <> '".$meeting_uuid."' "; } $sql .= "and (moderator_pin = '".$participant_pin."' or participant_pin = '".$participant_pin."') "; $prep_statement = $db->prepare(check_sql($sql)); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); if ($row['num_rows'] > 0) { $msg .= $text['message-unique_participant_pin']."
\n"; } } //additional checks if ($moderator_pin == $participant_pin) { $msg .= $text['message-non_unique_pin']."
\n"; } if (strlen($moderator_pin) < $pin_length || strlen($participant_pin) < $pin_length) { $msg .= $text['message-minimum_pin_length']." ".$pin_length."
\n"; } } //check for all required data //if (strlen($conference_center_uuid) == 0) { $msg .= "Please provide: Conference UUID
\n"; } //if (strlen($max_members) == 0) { $msg .= "Please provide: Max Members
\n"; } //if (strlen($start_datetime) == 0) { $msg .= "Please provide: Start Date/Time
\n"; } //if (strlen($stop_datetime) == 0) { $msg .= "Please provide: Stop Date/Time
\n"; } //if (strlen($wait_mod) == 0) { $msg .= "Please provide: Wait for the Moderator
\n"; } //if (strlen($profile) == 0) { $msg .= "Please provide: Conference Profile
\n"; } //if (strlen($announce) == 0) { $msg .= "Please provide: Announce
\n"; } //if (strlen($enter_sound) == 0) { $msg .= "Please provide: Enter Sound
\n"; } //if (strlen($mute) == 0) { $msg .= "Please provide: Mute
\n"; } //if (strlen($sounds) == 0) { $msg .= "Please provide: Sounds
\n"; } //if (strlen($created) == 0) { $msg .= "Please provide: Created
\n"; } //if (strlen($created_by) == 0) { $msg .= "Please provide: Created By
\n"; } //if (strlen($enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } //if (strlen($description) == 0) { $msg .= "Please provide: Description
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; exit; } //add or update the database if ($_POST["persistformvar"] != "true") { if ($action == "add" && permission_exists('conference_room_add')) { //set default values if (strlen($profile) == 0) { $profile = 'default'; } if (strlen($record) == 0) { $record = 'false'; } if (strlen($max_members) == 0) { $max_members = 0; } if (strlen($wait_mod) == 0) { $wait_mod = 'true'; } if (strlen($announce) == 0) { $announce = 'true'; } if (strlen($mute) == 0) { $mute = 'false'; } if (strlen($enabled) == 0) { $enabled = 'true'; } if (strlen($sounds) == 0) { $sounds = 'false'; } //add a meeting $meeting_uuid = uuid(); $sql = "insert into v_meetings "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "meeting_uuid, "; $sql .= "moderator_pin, "; $sql .= "participant_pin, "; $sql .= "enabled, "; $sql .= "description "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$meeting_uuid', "; $sql .= "'$moderator_pin', "; $sql .= "'$participant_pin', "; $sql .= "'$enabled', "; $sql .= "'$description' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); //add a conference room $conference_room_uuid = uuid(); $sql = "insert into v_conference_rooms "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "conference_room_uuid, "; $sql .= "conference_center_uuid, "; $sql .= "meeting_uuid, "; $sql .= "conference_room_name, "; $sql .= "profile, "; $sql .= "record, "; $sql .= "max_members, "; $sql .= "start_datetime, "; $sql .= "stop_datetime, "; $sql .= "wait_mod, "; $sql .= "announce, "; $sql .= "sounds, "; $sql .= "mute, "; $sql .= "created, "; $sql .= "created_by, "; $sql .= "enabled, "; $sql .= "description "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$conference_room_uuid', "; $sql .= "'$conference_center_uuid', "; $sql .= "'$meeting_uuid', "; $sql .= "'$conference_room_name', "; $sql .= "'$profile', "; $sql .= "'$record', "; $sql .= "'$max_members', "; $sql .= "'$start_datetime', "; $sql .= "'$stop_datetime', "; $sql .= "'$wait_mod', "; $sql .= "'$announce', "; $sql .= "'$sounds', "; $sql .= "'$mute', "; $sql .= "now(), "; $sql .= "'".$_SESSION['user_uuid']."', "; $sql .= "'$enabled', "; $sql .= "'$description' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); //assign the logged in user to the meeting if (strlen($_SESSION["user_uuid"]) > 0) { $meeting_user_uuid = uuid(); $sql = "insert into v_meeting_users "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "meeting_user_uuid, "; $sql .= "meeting_uuid, "; $sql .= "user_uuid "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$meeting_user_uuid', "; $sql .= "'$meeting_uuid', "; $sql .= "'".$_SESSION["user_uuid"]."' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } $_SESSION["message"] = $text['message-add']; } //if ($action == "add") if ($action == "update" && permission_exists('conference_room_edit')) { //get the meeting_uuid if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { $conference_room_uuid = check_str($_GET["id"]); $sql = "select * from v_conference_rooms "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and conference_room_uuid = '$conference_room_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(); foreach ($result as &$row) { $meeting_uuid = $row["meeting_uuid"]; } unset ($prep_statement); } //update conference meetings $sql = "update v_meetings set "; $sql .= "moderator_pin = '$moderator_pin', "; $sql .= "participant_pin = '$participant_pin', "; $sql .= "enabled = '$enabled', "; $sql .= "description = '$description' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and meeting_uuid = '$meeting_uuid' "; $db->exec(check_sql($sql)); unset($sql); //update the conference room $sql = "update v_conference_rooms set "; $sql .= "conference_center_uuid = '$conference_center_uuid', "; //$sql .= "meeting_uuid = '$meeting_uuid', "; $sql .= "conference_room_name = '$conference_room_name', "; if (strlen($profile) > 0) { $sql .= "profile = '$profile', "; } if (strlen($record) > 0) { $sql .= "record = '$record', "; } if (strlen($max_members) > 0) { $sql .= "max_members = '$max_members', "; } $sql .= "start_datetime = '".$start_datetime."', "; $sql .= "stop_datetime = '".$stop_datetime."', "; if (strlen($wait_mod) > 0) { $sql .= "wait_mod = '$wait_mod', "; } if (strlen($announce) > 0) { $sql .= "announce = '$announce', "; } //$sql .= "enter_sound = '$enter_sound', "; if (strlen($mute) > 0) { $sql .= "mute = '$mute', "; } $sql .= "sounds = '$sounds', "; if (strlen($enabled) > 0) { $sql .= "enabled = '$enabled', "; } $sql .= "description = '$description' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and conference_room_uuid = '$conference_room_uuid' "; $db->exec(check_sql($sql)); unset($sql); $_SESSION["message"] = $text['message-update']; } //if ($action == "update") //assign the user to the meeting if (strlen($user_uuid) > 0 && $_SESSION["user_uuid"] != $user_uuid) { $meeting_user_uuid = uuid(); $sql = "insert into v_meeting_users "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "meeting_user_uuid, "; $sql .= "meeting_uuid, "; $sql .= "user_uuid "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$meeting_user_uuid', "; $sql .= "'$meeting_uuid', "; $sql .= "'$user_uuid' "; $sql .= ")"; //echo $sql; //exit; $db->exec(check_sql($sql)); unset($sql); $_SESSION["message"] = $text['message-add']; } header("Location: conference_room_edit.php?id=".$conference_room_uuid); return; } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { //get the conference room details $conference_room_uuid = check_str($_REQUEST["id"]); $sql = "select * from v_conference_rooms as r, v_meetings as m "; $sql .= "where r.domain_uuid = '$domain_uuid' "; $sql .= "and r.meeting_uuid = m.meeting_uuid "; $sql .= "and r.conference_room_uuid = '$conference_room_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(); foreach ($result as &$row) { $conference_center_uuid = $row["conference_center_uuid"]; $meeting_uuid = $row["meeting_uuid"]; $moderator_pin = $row["moderator_pin"]; $participant_pin = $row["participant_pin"]; $conference_room_name = $row["conference_room_name"]; $profile = $row["profile"]; $record = $row["record"]; $max_members = $row["max_members"]; $start_datetime = $row["start_datetime"]; $stop_datetime = $row["stop_datetime"]; $wait_mod = $row["wait_mod"]; $announce = $row["announce"]; $sounds = $row["sounds"]; $mute = $row["mute"]; $created = $row["created"]; $created_by = $row["created_by"]; $enabled = $row["enabled"]; $description = $row["description"]; } unset ($prep_statement, $sql); } //get the users array $sql = "SELECT * FROM v_users "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "order by username asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $users = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset($prep_statement, $sql); //get the users assigned to this meeting $sql = "SELECT * FROM v_users as u, v_meeting_users as m "; $sql .= "where u.user_uuid = m.user_uuid "; $sql .= "and m.domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and m.meeting_uuid = '$meeting_uuid' "; $sql .= "order by u.username asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $meeting_users = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset($prep_statement, $sql); //set default profile if (strlen($profile) == 0) { $profile = 'default'; } //get default pins if (strlen($moderator_pin) == 0) { $moderator_pin = get_meeting_pin($pin_length, $meeting_uuid); } if (strlen($participant_pin) == 0) { $participant_pin = get_meeting_pin($pin_length, $meeting_uuid); } //format the pins if (strlen($moderator_pin) == 9) { $moderator_pin = substr($moderator_pin, 0, 3) ."-". substr($moderator_pin, 3, 3) ."-". substr($moderator_pin, -3)."\n"; } if (strlen($participant_pin) == 9) { $participant_pin = substr($participant_pin, 0, 3) ."-". substr($participant_pin, 3, 3) ."-". substr($participant_pin, -3)."\n"; } //set default values if (strlen($record) == 0) { $record = 'false'; } if (strlen($max_members) == 0) { $max_members = 0; } if (strlen($wait_mod) == 0) { $wait_mod = 'true'; } if (strlen($announce) == 0) { $announce = 'true'; } if (strlen($mute) == 0) { $mute = 'false'; } if (strlen($sounds) == 0) { $sounds = 'false'; } if (strlen($enabled) == 0) { $enabled = 'true'; } //show the header require_once "resources/header.php"; //show the content echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; if (if_group("superadmin") || if_group("admin")) { echo " "; echo " "; echo " "; echo " "; } if (permission_exists('conference_room_profile')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('conference_room_record')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('conference_room_max_members')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('conference_room_wait_mod')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('conference_room_announce')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } //echo "\n"; //echo "\n"; //echo "\n"; //echo "\n"; if (permission_exists('conference_room_mute')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('conference_room_profile')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('conference_room_sounds')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo ""; echo "
".$text['title-conference_rooms']."\n"; echo " \n"; if (strlen($meeting_uuid) > 0) { echo " \n"; echo " \n"; } echo " \n"; echo "
\n"; echo "
\n"; echo "
".$text['label-conference_name']."\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
".$text['label-room-name'].""; echo " \n"; echo "
\n"; echo " ".$text['description-room-name']."\n"; echo "
".$text['label-moderator-pin'].""; echo " \n"; echo "
\n"; echo " ".$text['description-moderator_pin']."\n"; echo "
".$text['label-participant-pin'].""; echo " \n"; echo "
\n"; echo " ".$text['description-participant-pin']."\n"; echo "
".$text['label-users'].""; if ($action == "update") { echo " \n"; foreach($meeting_users as $field) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; } echo "
".$field['username']."\n"; if (permission_exists('conference_room_delete')) { echo " $v_link_label_delete\n"; } echo "
\n"; } echo "
\n"; if (permission_exists('conference_room_add')) { echo " "; if ($action == "update") { echo " \n"; } unset($users); echo "
\n"; } echo " ".$text['description-users']."\n"; echo "
".$text['label-profile']."\n"; echo " \n"; echo "
\n"; echo " ".$text['description-profile']."\n"; echo "
".$text['label-record']."\n"; echo " \n"; echo "
\n"; echo "
".$text['label-max-members']."\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
".$text['label-schedule']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; echo "
\n"; echo "
".$text['description-schedule']; echo "
".$text['label-wait_for_moderator']."\n"; echo " \n"; echo "
\n"; echo "
".$text['label-announce']."\n"; echo " \n"; echo "
\n"; echo "
\n"; //echo " ".$text['label-enter-sound']."\n"; //echo "\n"; //echo " \n"; //echo "
\n"; //echo "\n"; //echo "
".$text['label-mute']."\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
".$text['label-enabled']."\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
".$text['label-sounds']."\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
".$text['label-description']."\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo "
"; if ($action == "update") { echo " \n"; echo " \n"; echo " \n"; } echo " \n"; echo "
"; echo "
"; echo "
"; //include the footer require_once "resources/footer.php"; ?>