Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dicarve/slims8_akasia
Browse files Browse the repository at this point in the history
  • Loading branch information
mucill committed Jun 5, 2015
2 parents c5360c5 + 8abd4ff commit bd89c93
Show file tree
Hide file tree
Showing 11 changed files with 370 additions and 618 deletions.
151 changes: 151 additions & 0 deletions admin/modules/bibliography/iframe_biblio_rel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php
/**
* Copyright (C) 2007,2008 Arie Nugraha ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

/* Authority List */

// key to authenticate
define('INDEX_AUTH', '1');
// key to get full database access
define('DB_ACCESS', 'fa');

// main system configuration
require '../../../sysconfig.inc.php';
// IP based access limitation
require LIB.'ip_based_access.inc.php';
do_checkIP('smc');
do_checkIP('smc-bibliography');
// start the session
require SB.'admin/default/session.inc.php';
require SIMBIO.'simbio_GUI/table/simbio_table.inc.php';
require SIMBIO.'simbio_DB/simbio_dbop.inc.php';

// page title
$page_title = 'Biblio Relation';
// get id from url
$biblioID = 0;
if (isset($_GET['biblioID']) AND !empty($_GET['biblioID'])) {
$biblioID = (integer)$_GET['biblioID'];
}

// start the output buffer
ob_start();
?>
<script type="text/javascript">
function confirmProcess(int_biblio_id, int_item_id)
{
var confirmBox = confirm('Are you sure to remove selected title?' + "\n" + 'Once deleted, it can\'t be restored!');
if (confirmBox) {
// set hidden element value
document.hiddenActionForm.bid.value = int_biblio_id;
document.hiddenActionForm.remove.value = int_item_id;
// submit form
document.hiddenActionForm.submit();
}
}
</script>
<?php
/* main content */
// author of removal
if (isset($_GET['removesess'])) {
$idx = $_GET['removesess'];
unset($_SESSION['biblioToBiblio'][$idx]);
echo '<script type="text/javascript">';
echo 'alert(\''.__('Biblio relation succesfully removed!').'\');';
echo 'location.href = \'iframe_biblio_rel.php\';';
echo '</script>';
}

if (isset($_POST['remove'])) {
$id = (integer)$_POST['remove'];
$bid = (integer)$_POST['bid'];
$sql_op = new simbio_dbop($dbs);
$sql_op->delete('biblio_relation', 'biblio_id='.$bid.' AND rel_biblio_id='.$id);
echo '<script type="text/javascript">';
echo 'alert(\''.__('Biblio relation removed!').'\');';
echo 'location.href = \'iframe_biblio_rel.php?biblioID='.$bid.'\';';
echo '</script>';
}

// if biblio ID is set
if ($biblioID) {
$table = new simbio_table();
$table->table_attr = 'align="center" style="width: 100%;" cellpadding="2" cellspacing="0"';

// database list
$biblio_relation_q = $dbs->query("SELECT b2.title, b2.edition, b2.publish_year, ba.rel_biblio_id FROM biblio_relation AS ba
LEFT JOIN biblio AS b2 ON ba.rel_biblio_id=b2.biblio_id
WHERE ba.biblio_id=$biblioID ORDER BY rel_type ASC");
$row = 1;
while ($biblio_relation_d = $biblio_relation_q->fetch_assoc()) {
// alternate the row color
$row_class = ($row%2 == 0)?'alterCell':'alterCell2';

// remove link
$remove_link = '<a href="#" class="notAJAX btn button btn-danger btn-delete" onclick="confirmProcess('.$biblioID.', '.$biblio_relation_d['rel_biblio_id'].')">Delete</a>';
$title = $biblio_relation_d['title'];
$publish_year = $biblio_relation_d['publish_year'];
$edition = $biblio_relation_d['edition'];

$table->appendTableRow(array($remove_link, $title, $publish_year, $edition));
$table->setCellAttr($row, 0, 'valign="top" class="'.$row_class.'" style="font-weight: bold; width: 10%;"');
$table->setCellAttr($row, 1, 'valign="top" class="'.$row_class.'" style="width: 50%;"');
$table->setCellAttr($row, 2, 'valign="top" class="'.$row_class.'" style="width: 20%;"');
$table->setCellAttr($row, 3, 'valign="top" class="'.$row_class.'" style="width: 20%;"');
$row++;
}

echo $table->printTable();
// hidden form
echo '<form name="hiddenActionForm" method="post" action="'.$_SERVER['PHP_SELF'].'"><input type="hidden" name="bid" value="0" /><input type="hidden" name="remove" value="0" /></form>';
} else {
if ($_SESSION['biblioToBiblio']) {
$table = new simbio_table();
$table->table_attr = 'align="center" style="width: 100%;" cellpadding="2" cellspacing="0"';

$row = 1;
$row_class = 'alterCell2';
foreach ($_SESSION['biblioToBiblio'] as $biblio_session) {
// remove link
$remove_link = '<a class="notAJAX btn button btn-danger btn-delete" href="iframe_biblio_rel.php?removesess='.$biblio_session[0].'">Remove</a>';

if ($biblio_session) {
$title_q = $dbs->query("SELECT title, publish_year, edition FROM biblio
WHERE biblio_id=".$biblio_session[0]);
$title_d = $title_q->fetch_row();
$title = $title_d[0];
$publish_year = $title_d[1];
$edition = $title_d[2];
}

$table->appendTableRow(array($remove_link, $title, $publish_year, $edition));
$table->setCellAttr($row, 0, 'valign="top" class="'.$row_class.'" style="font-weight: bold; background-color: #ffc466; width: 10%;"');
$table->setCellAttr($row, 1, 'valign="top" class="'.$row_class.'" style="background-color: #ffc466; width: 50%;"');
$table->setCellAttr($row, 2, 'valign="top" class="'.$row_class.'" style="background-color: #ffc466; width: 20%;"');
$table->setCellAttr($row, 3, 'valign="top" class="'.$row_class.'" style="background-color: #ffc466; width: 20%;"');
$row++;
}

echo $table->printTable();
}
}
/* main content end */
$content = ob_get_clean();
// include the page template
require SB.'/admin/'.$sysconf['admin_template']['dir'].'/notemplate_page_tpl.php';
15 changes: 15 additions & 0 deletions admin/modules/bibliography/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@
$sql_op->insert('biblio_attachment', array('biblio_id' => $last_biblio_id, 'file_id' => $attachment['file_id'], 'access_type' => $attachment['access_type']));
}
}
// biblio to biblio
if ($_SESSION['biblioToBiblio']) {
foreach ($_SESSION['biblioToBiblio'] as $rel_biblio_id) {
$sql_op->insert('biblio_relation', array('biblio_id' => $last_biblio_id, 'rel_biblio_id' => $rel_biblio_id[0]));
}
}
// insert custom data
if ($custom_data) {
$custom_data['biblio_id'] = $last_biblio_id;
Expand All @@ -291,6 +297,7 @@
$_SESSION['biblioAuthor'] = array();
$_SESSION['biblioTopic'] = array();
$_SESSION['biblioAttach'] = array();
$_SESSION['biblioToBiblio'] = array();
// update index
$indexer->makeIndex($last_biblio_id);
// auto insert catalog to UCS if enabled
Expand Down Expand Up @@ -359,6 +366,7 @@
$sql_op->delete('biblio_topic', "biblio_id=$itemID");
$sql_op->delete('biblio_author', "biblio_id=$itemID");
$sql_op->delete('biblio_attachment', "biblio_id=$itemID");
$sql_op->delete('biblio_relation', "biblio_id=$itemID");
$sql_op->delete('search_biblio', "biblio_id=$itemID");
// add to http query for UCS delete
$http_query .= "itemID[]=$itemID&";
Expand Down Expand Up @@ -473,6 +481,8 @@
$_sql_rec_cust_q = sprintf('SELECT * FROM biblio_custom WHERE biblio_id=%d', $itemID);
$rec_cust_q = $dbs->query($_sql_rec_cust_q);
$rec_cust_d = $rec_cust_q->fetch_assoc();
} else {
$_SESSION['biblioToBiblio'] = array();
}

// include custom fields file
Expand Down Expand Up @@ -640,6 +650,11 @@
$str_input .= '<iframe name="attachIframe" id="attachIframe" class="borderAll" style="width: 100%; height: 70px;" src="'.MWB.'bibliography/iframe_attach.php?biblioID='.$rec_d['biblio_id'].'&block=1"></iframe>';
$form->addAnything(__('File Attachment'), $str_input);

// biblio relation
$str_input = '<div class="'.$visibility.'"><a class="notAJAX button btn btn-info openPopUp" href="'.MWB.'bibliography/pop_biblio_rel.php?biblioID='.$rec_d['biblio_id'].'" title="'.__('Biblio Relation').'">'.__('Add Relation').'</a></div>';
$str_input .= '<iframe name="biblioIframe" id="biblioIframe" class="borderAll" style="width: 100%; height: 100px;" src="'.MWB.'bibliography/iframe_biblio_rel.php?biblioID='.$rec_d['biblio_id'].'&block=1"></iframe>';
$form->addAnything(__('Related Biblio Data'), $str_input);

/**
* Custom fields
*/
Expand Down
105 changes: 105 additions & 0 deletions admin/modules/bibliography/pop_biblio_rel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
/**
* Copyright (C) 2007,2008 Arie Nugraha ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/


/* Biblio Author Adding Pop Windows */

// key to authenticate
define('INDEX_AUTH', '1');

// main system configuration
require '../../../sysconfig.inc.php';
// IP based access limitation
require LIB.'ip_based_access.inc.php';
do_checkIP('smc');
do_checkIP('smc-bibliography');
// start the session
require SB.'admin/default/session.inc.php';
require SB.'admin/default/session_check.inc.php';
require SIMBIO.'simbio_GUI/table/simbio_table.inc.php';
require SIMBIO.'simbio_GUI/form_maker/simbio_form_table.inc.php';
require SIMBIO.'simbio_DB/simbio_dbop.inc.php';

// page title
$page_title = 'Biblio Relation';
// check for biblioID in url
$biblioID = 0;
if (isset($_GET['biblioID']) AND $_GET['biblioID']) {
$biblioID = (integer)$_GET['biblioID'];
}

// start the output buffer
ob_start();
/* main content */
// biblio author save proccess
if (isset($_POST['save']) AND (isset($_POST['biblioID']) OR trim($_POST['search_str']))) {
$author_name = trim($dbs->escape_string(strip_tags($_POST['search_str'])));
// create new sql op object
$sql_op = new simbio_dbop($dbs);
// check if biblioID POST var exists
if (isset($_POST['biblioID']) AND !empty($_POST['biblioID'])) {
$data['rel_biblio_id'] = intval($_POST['relBiblioID']);
$data['biblio_id'] = intval($_POST['biblioID']);

if ($sql_op->insert('biblio_relation', $data)) {
echo '<script type="text/javascript">';
echo 'alert(\''.__('Biblio relation succesfully updated!').'\');';
echo 'parent.setIframeContent(\'biblioIframe\', \''.MWB.'bibliography/iframe_biblio_rel.php?biblioID='.$data['biblio_id'].'\');';
echo '</script>';
} else {
utility::jsAlert(__('Biblio relation FAILED to Add. Please Contact System Administrator')."\n".$sql_op->error);
}
} else {
if (isset($_POST['relBiblioID']) AND !empty($_POST['relBiblioID'])) {
// add to current session
$_SESSION['biblioToBiblio'][$_POST['relBiblioID']] = array($_POST['relBiblioID']);
echo '<script type="text/javascript">';
echo 'alert(\''.__('Biblio relation added!').'\');';
echo 'parent.setIframeContent(\'biblioIframe\', \''.MWB.'bibliography/iframe_biblio_rel.php\');';
echo '</script>';
}
}
}

?>

<div class="popUpForm">
<form name="mainForm" action="pop_biblio_rel.php?biblioID=<?php echo $biblioID; ?>" method="post">
<div>
<strong><?php echo __('Add Biblio Relation'); ?> </strong>
<hr />
<form name="searchBiblio" method="post" style="display: inline;">
<?php
$ajax_exp = "ajaxFillSelect('../../AJAX_lookup_handler.php', 'biblio', 'biblio_id:title:edition:publish_year', 'relBiblioID', $('#search_str').val())";
echo __('Title'); ?> : <input type="text" name="search_str" id="search_str" style="width: 30%;" onkeyup="<?php echo $ajax_exp; ?>" onchange="<?php echo $ajax_exp; ?>" />
</div>
<div class="popUpSubForm">
<select name="relBiblioID" id="relBiblioID" size="5" style="width: 100%;"><option value="0"><?php echo __('Type to search for existing biblio data'); ?></option></select>
<?php if ($biblioID) { echo '<input type="hidden" name="biblioID" value="'.$biblioID.'" />'; } ?>
<input type="submit" name="save" value="<?php echo __('Insert To Bibliography'); ?>" class="popUpSubmit btn btn-primary" />
</div>
</form>
</div>

<?php
/* main content end */
$content = ob_get_clean();
// include the page template
require SB.'/admin/'.$sysconf['admin_template']['dir'].'/notemplate_page_tpl.php';
65 changes: 65 additions & 0 deletions chatserver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
// prevent the server from timing out
set_time_limit(0);

define('INDEX_AUTH', 1);

// include the web sockets server script (the server is started at the far bottom of this file)
require 'sysconfig.inc.php';
require LIB.'phpwebsocket.php';

// when a client sends data to the server
function wsOnMessage($clientID, $message, $messageLength, $binary) {
global $Server;
$ip = long2ip( $Server->wsClients[$clientID][6] );

// check if message length is 0
if ($messageLength == 0) {
$Server->wsClose($clientID);
return;
}

//The speaker is the only person in the room. Don't let them feel lonely.
if ( sizeof($Server->wsClients) == 1 )
$Server->wsSend($clientID, "There isn't anyone else in the room, but I'll still listen to you. --Your Trusty Server");
else
//Send the message to everyone but the person who said it
foreach ( $Server->wsClients as $id => $client )
if ( $id != $clientID )
$Server->wsSend($id, "Visitor $clientID ($ip) said \"$message\"");
}

// when a client connects
function wsOnOpen($clientID)
{
global $Server;
$ip = long2ip( $Server->wsClients[$clientID][6] );

$Server->log( "$ip ($clientID) has connected." );

//Send a join notice to everyone but the person who joined
foreach ( $Server->wsClients as $id => $client )
if ( $id != $clientID )
$Server->wsSend($id, "Visitor $clientID ($ip) has joined the room.");
}

// when a client closes or lost connection
function wsOnClose($clientID, $status) {
global $Server;
$ip = long2ip( $Server->wsClients[$clientID][6] );

$Server->log( "$ip ($clientID) has disconnected." );

//Send a user left notice to everyone in the room
foreach ( $Server->wsClients as $id => $client )
$Server->wsSend($id, "Visitor $clientID ($ip) has left the room.");
}

// start the server
$Server = new PHPWebSocket();
$Server->bind('message', 'wsOnMessage');
$Server->bind('open', 'wsOnOpen');
$Server->bind('close', 'wsOnClose');
// for other computers to connect, you will probably need to change this to your LAN IP or external IP,
// alternatively use: gethostbyaddr(gethostbyname($_SERVER['SERVER_NAME']))
$Server->wsStartServer($sysconf['chat_system']['server'], $sysconf['chat_system']['server_port']);
2 changes: 1 addition & 1 deletion lib/biblio_list_model.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public function XMLresult() {
$_image = '';
if (!empty($_biblio_d['image'])) {
$_image = urlencode($_biblio_d['image']);
$_buffer .= '<slims:image>'.$_image.'</slims:image>'."\n";
$_buffer .= '<slims:image>'.$_image.'</slims:image>'."\n";
}

$_buffer .= '</mods>'."\n";
Expand Down
Loading

0 comments on commit bd89c93

Please sign in to comment.