Location: PHPKode > projects > oc4ware > oc4ware-0.4.2/oc4ware/forums/member/journal.php
<?php 
 
    /* 
	oc4ware - Software 4 Open Communities
	Copyright (c) 2001-2002 oc4 e.V. (http://www.oc4home.org)
	
	Software 4 Open Communities (oc4ware) provides Web community portal
	software in the scope of the Semantic Web initiative for distributed
	content, knowledge management, online publishing in self-organised
	online journals.
	---------------------------------------------------------------------- 
    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 2 
    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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
	---------------------------------------------------------------------- 
    Authors: Christian Zonsius <hide@address.com>; | 
    Your Name <hide@address.com>; | 
    ---------------------------------------------------------------------- 
    $Id: journal.php,v 1.3 2002/11/13 11:27:22 ordnas Exp $ 
    */ 
    /************************************************* 
    * INCLUDES 
    **************************************************/ 

	require_once 'Widget/1/OC4_WIDGET.php';
	
	// GLOBALs 
	$number = $_REQUEST['number']; 

	$retrieval = OC4_FRAMEWORK::connect('forums/connector/retrieval');
	$forum =  $retrieval->call('getForum', array($_REQUEST['number']));
	
	// check whether the user has access
	$acl = OC4_FRAMEWORK::connect('forums/connector/acl');
	if(!$acl->call('isAuthorized', array($_SESSION[userInfo]->listIdentities(), OC4_FRAMEWORK::uriPrefix('forums').$_REQUEST['number'].$forum["language"]))){

		OC4_AUTHENTICATION::redirectToLogin();
	}
 
	/*************************************************************************** 
    * PAGE CONTENT                                                             * 
    ***************************************************************************/ 

    // instantiate DB-API class  
	$widget = new OC4_WIDGET(); 
    $widget->loadWidgetSet( 'Widget/1/widgets/xml/' ); 
	// load default filter set 
	$widget->loadFilterSets( 'Widget/1/filters/'); 
	// load specific filter sets 
	$widget->loadFilterSets( 'Widget/1/filters/xml/' ); 

	if($_REQUEST[remove]) {
		if($forum["is_pending"]==1) {
			header("Location: ".OC4_FRAMEWORK::conf('forums/paths/member/pending').$_REQUEST["number"]);
			exit;
		}
		$acl->call( 'deleteAuthorization',
								array(urldecode($_REQUEST['remove']), $forum["URI"])
								);
		$_REQUEST[_oc4][note] = 'Item removed successfully.';
	}


	if($_REQUEST[assign]) {
		if($forum["is_pending"]==1) {
			header("Location: ".OC4_FRAMEWORK::conf('forums/paths/member/pending').$_REQUEST["number"]);
			exit;
		}
		// add role
		$acl->call( 'addAuthorization',
								array(
									urldecode($_REQUEST['assign']),
									$forum["URI"],
									OC4_FRAMEWORK::uriPrefix('roles').'pbl',
									array( 'type' => 'journal')
									)
								);
		$_REQUEST[_oc4][note] = 'Item added successfully.';
	}


	//$authors = $retrieval->call('listOwners', array($number, 'author' ));

	require_once 'header.php'; 

	// note on current process, e.g. errors, modifications, etc.
	if($_REQUEST[_oc4][note]){
		echo '<div class="note">'.$_REQUEST[_oc4][note].'</div>';
	}
?>
<form method="POST" action="<?php echo $_SERVER[PHP_SELF]; ?>">
<h4>assigned journals</h4>
<table border="0" width="<?php echo OC4_FRAMEWORK::conf('themes/params/width'); ?>">
<tr>
	<th align="left">name</th>
	<th></th>
</tr>
<?php
$authors = $acl->call( 'listOwners', array( $forum["URI"], OC4_FRAMEWORK::uriPrefix('roles').'pbl' ));
if(count($authors) && is_array($authors)){
	foreach($authors as $author) {
	  	//echo $author;
	  	// retrieve the member data
		$journals_repository_retrieval = OC4_FRAMEWORK::connect('journals_repository/connector/retrieval');
		$data = $journals_repository_retrieval->call( 'getJournal', array($author, 'URI'));
		//print_r($data);
		echo '<tr><td><a href="'.OC4_FRAMEWORK::ddoUrl($data['URI']).'">'.$data[name].'</a></td>';
		echo '<td>';
		if($news["published"]=="") {
			echo '<a href="';
			if(in_array($data[number], $_SESSION[userInfo]->identities))
				echo OC4_FRAMEWORK::conf('framework/paths/url_rel').'message.php?buttons=yesno&msg='.urlencode('Really remove your journal?<br>(Be careful: afterwards you will NOT have any rights to access this item)').'&target_ok='.urlencode($_SERVER[PHP_SELF].'?number='.$_REQUEST[number].'&remove='.urlencode($data['URI'])).'&target_cancel='.urlencode($_SERVER[PHP_SELF].'?number='.$_REQUEST[number]);
			else
				echo OC4_FRAMEWORK::conf('framework/paths/url_rel').'message.php?buttons=yesno&msg='.urlencode('Really remove this journal?').'&target_ok='.urlencode($_SERVER[PHP_SELF].'?number='.$_REQUEST[number].'&remove='.urlencode($data['URI'])).'&target_cancel='.urlencode($_SERVER[PHP_SELF].'?number='.$_REQUEST[number]);
			echo '"><img src="'.OC4_FRAMEWORK::theme('path_icons').'16x16/delete.gif" border="0" width="16" alt="remove journal from news entry"></a>';
		}
		echo '</td>';
		echo '</tr>';
	}
}
?>
</table>
<p><br>
<h4>add journal</h4>
<?php
if($news["published"]!="") { ?>
<table border="0" width="<?php echo OC4_FRAMEWORK::conf('themes/params/width'); ?>" class="form">
	<tr>
		<td>
			You cannot change journals on a published news item.
		</td>
	</tr>
</table>
<?php } else { ?>
<table border="0" width="<?php echo OC4_FRAMEWORK::conf('themes/params/width'); ?>" class="form">
	<tr>
		<td width="200">enter journal name (part of it): </td>
		<td>
			<input type="text" name="keyword" value="<?php echo $_REQUEST[keyword]; ?>">
			<input type="image" src="<?php echo OC4_FRAMEWORK::theme('path_icons').'24x24/search.gif'; ?>" name="submit" border="0"> 
		</td>
	</tr>
</table>
<br>
<?php
if($_REQUEST[keyword]) {
  	$search_criteria = array(
								'_main' => array(
											'name' => $_REQUEST[keyword],
											)
							);
	$journals_repository_retrieval = OC4_FRAMEWORK::connect('journals_repository/connector/retrieval');
	$records = $journals_repository_retrieval->call('search', array($search_criteria));
	$count = 0;
	?>
	<table border="0" width="<?php echo OC4_FRAMEWORK::conf('themes/params/width'); ?>">
	<?php
	while(($row = $records[$count]) && ($count<15)) {
		if($count==0) {
			echo '<tr><th>number</th><th>name</th><th>full name</th><th></th></tr>';
		}
		echo '<tr align="center"><td><a href="'.OC4_FRAMEWORK::ddoUrl($row['URI']).'">'.$row[number].'</a></td><td>'.$row[name].'</td><td>'.$row[name_full].'</td>';
		echo '<td><a href="'.$_SERVER[PHP_SELF].'?number='.$number.'&assign='.urlencode($row['URI']).'"><img src="'.OC4_FRAMEWORK::theme('path_icons').'16x16/save.gif" width="16" border="0" alt="assign journal"></a></td></tr>';
		$count++;
	}
	if($count>=15) {
		echo '<tr align="center"><td colspan="4"><strong>more than 15 records found ..</strong></td></tr>';
	} elseif ($count<1) {
		echo '<tr align="center"><td colspan="4"><em>no records found</em></td></tr>';
	}
	echo '</table>';
}
?>
<input type="hidden" name="number" value="<?php echo $number; ?>">
<?php } ?>
</form>
<?php
	// footer 
	require_once 'footer.php'; 
?>
Return current item: oc4ware