<?php 
/*#################################################################*\
|# Licence Number 0H6R-0808-0UVQ-0111
|# -------------------------------------------------------------   #|
|# Copyright (c)2012 PHP Link Directory.                           #|
|# http://www.phplinkdirectory.com                                 #|
\*#################################################################*/
	 
	
/**
 # ################################################################################
 # Project:   PHP Link Directory
 #
 # **********************************************************************
 # Copyright (C) 2004-2012 NetCreated, Inc. (http://www.netcreated.com/)
 #
 # This software is for use only to those who have purchased a license.
 # A license must be purchased for EACH installation of the software.
 #
 # By using the software you agree to the terms:
 #
 #    - You may not redistribute, sell or otherwise share this software
 #      in whole or in part without the consent of the the ownership
 #      of PHP Link Directory. Please contact david@david-duval.com
 #      if you need more information.
 #
 #    - You agree to retain a link back to http://www.phplinkdirectory.com/
 #      on all pages of your directory if you purchased any of our "link back" 
 #      versions of the software.
 #
 #
 # In some cases, license holders may be required to agree to changes
 # in the software license before receiving updates to the software.
 # **********************************************************************
 #
 # For questions, help, comments, discussion, etc., please join the
 # PHP Link Directory Forum http://www.phplinkdirectory.com/forum/
 #
 # @link           http://www.phplinkdirectory.com/
 # @copyright      2004-2012 NetCreated, Inc. (http://www.netcreated.com/)
 # @projectManager David DuVal <david@david-duval.com>
 # @package        PHPLinkDirectory
 # @version        4.2.1
 # ################################################################################
 */
 
class SiteSpotlight extends Widget {
	var $name;
	var $type;
	var $tpl;
	
	function SiteSpotlight($name='', $type='', $tpl='') {
		$this->name = $name;
		$this->type = $type;
		$this->tpl = get_widget_tpl($name);
		$this->tpl->assign('date_format', '%D %H:%M:%S');
	}
	
	function getContent() {
		global $db;
		global $tables;

		
	    
			if (isset($_SESSION['phpld']['user']['id'])) {
	        if (get_user_level($_SESSION['phpld']['user']['id']) == 1 || get_user_level($_SESSION['phpld']['user']['id']) == 3 ) {
	              $permission_cats = "1 ";
	              $permission_links_arts = "1 ";
	        } else {
	           $permissions = get_user_permissions($_SESSION['phpld']['user']['id']);
	           $permission_cats = "`ID` IN (";
	           $permission_links_arts = "`CATEGORY_ID` IN (";
	           if (count($permissions) >0) {
	               for ($i=0; $i<count($permissions); $i++) {
	                   if ($i<count($permissions)-1) {
	                        $permission_cats .= "'".$permissions[$i]['CATEGORY_ID']."', ";
	                        $permission_links_arts .= "'".$permissions[$i]['CATEGORY_ID']."', ";
	                   } else {
	                        $permission_cats .= "'".$permissions[$i]['CATEGORY_ID']."') ";
	                        $permission_links_arts .= "'".$permissions[$i]['CATEGORY_ID']."') ";
	                   }
	               }
	           } else {
	               $permission_cats = "0 ";
	               $permission_cats_parents = "0 ";
	               $permission_links_arts = "0 ";
	           }
	       }
	    } else {
	        $permission_cats = "0 ";
	        $permission_cats_parents = "0 ";
	        $permission_links_arts = "0 ";
	    }
	
		//end of article permission realted
	    
		
		$set = $this->getFrontSettings();
	    
		if (intval($set['SITE_ID']) > 0) 
			$sid = intval($set['SITE_ID']);
		if ($set['CACHE_RESULTS'] == "Yes") {
			$spotlight = $db->CacheRow("SELECT * FROM `{$tables['link']['name']}` WHERE `ID` = ".$db->qstr($sid));
		} else {
			$spotlight = $db->GetRow("SELECT * FROM `{$tables['link']['name']}`  WHERE `ID` = ".$db->qstr($sid));
		}
	 
        	$spotlight['SEO_URL'] = seo_url($spotlight['ID'], $spotlight['TITLE'], REWRITE_TYPE, REWRITE_EXT, 2);
	 	
		$this->tpl->assign('spotlight', $spotlight);	

		if ($set['DISPLAY_IN_BOX'] == "No") {
			$this->tpl->assign('show_title', 1);
		}
		$this->tpl->assign("TITLE", $set['TITLE']);
	
		return $this->tpl->fetch('content.tpl');
	}
}

?>