plugins:addopen:addopen_code

NP_AddOpen.phpのソースコード

<?php
// plugin needs to work on Nucleus versions <=2.0 as well
if (!function_exists('sql_table')){
	function sql_table($name) {
		return 'nucleus_' . $name;
	}
}
 
/*
	Version history:
	- 0.1 (2003-08-13): initial version
	- 0.2 (2004-10-26): first release
	- 0.3 (2006-03-23): available for Team member without blogadmin
*/
class NP_AddOpen extends NucleusPlugin {
 
	function getName() {	return 'AddOpen';	 }
	function getAuthor()  { return 'nakahara21';	 }
	function getURL() {		return 'http://nakahara21.com/'; }
	function getVersion() {	return '0.3'; }
	function getDescription() { return 'AddOpen';}
	function supportsFeature($what) {
		switch($what){
			case 'SqlTablePrefix':
				return 1;
			default:
				return 0;
		}
	}
	function install() {	}
	function unInstall() {	}
	function init() {	}
	function doSkinVar($skinType){ 
		global $CONF, $member;
 
		if(!$member->isLoggedIn()) return;
 
		$canblog = $this->getTeamBlogs();
		if(!$canblog) return;
 
		echo '<h2>* as '.$member->getDisplayName().'*</h2>';
		echo ' <ul class="nobullets">';
		for($i=0;$i<count($canblog);$i++){
			$blogname = shorten(getBlogNameFromID($canblog[$i]),15,"...");
			echo '<li>';
			echo "<a href=\"javascript:wingm=window.open('".$CONF['AdminURL']."bookmarklet.php?blogid=".$canblog[$i]."','nucleusbm','scrollbars=yes,width=600,height=500,left=10,top=10,status=yes,resizable=yes');wingm.focus();\">Add to ".$blogname;
			echo "</a>";
			echo '</li>';
		}
		echo ' </ul>';
	}
	/** 
	  * Returns an array of all blogids for which member has teamRights
	  */
	function getTeamBlogs() {
		global $member;
		$blogs = array();
 
		if ($member->isAdmin())
			$query = 'SELECT bnumber as blogid from '.sql_table('blog');
		else
			$query = 'SELECT tblog as blogid from '.sql_table('team').' where tmember=' . $member->getID();
 
		$res = sql_query($query);
		if (mysql_num_rows($res) > 0) {
			while ($obj = mysql_fetch_object($res)) {
				array_push($blogs, $obj->blogid);
			}
		}
 
		return $blogs;
	}
}
?>
 
plugins/addopen/addopen_code.txt · 最終更新: 2011/03/23 21:28 (外部編集)