예제 #1
0
	function display($tmpl = null)
	{
		$mainframe = JFactory::getApplication();
		$commentsModel = Komento::getModel( 'comments' );

		$cid = JRequest::getVar( 'cid', 'all' );

		$filter['component']	= $mainframe->getUserStateFromRequest( 'com_komento.pending.filter_component', 'filter-component', 'all', 'string' );
		$filter['sort']			= $mainframe->getUserStateFromRequest( 'com_komento.pending.filter_sort', 'filter-sort', 'latest', 'string' );
		$filter['search']		= trim( JString::strtolower( $mainframe->getUserStateFromRequest( 'com_komento.pending.filter_search', 'filter-search', '', 'string' ) ) );

		$options = array(
			'limit'		=> 0,
			'sort'		=> $filter['sort'],
			'search'	=> $filter['search'],
			'published'	=> 2,
			'threaded'	=> 0
		);

		$comments = $commentsModel->getComments( $filter['component'], $cid, $options );
		$pagination = $commentsModel->getPagination();
		$components = $commentsModel->getUniqueComponents();

		$theme = Komento::getTheme();
		$theme->set( 'components', $components );
		$theme->set( 'pagination', $pagination );
		$theme->set( 'comments', $comments );
		$theme->set( 'filter', $filter );

		echo $theme->fetch('dashboard/pending.php');
	}
예제 #2
0
 public function getResource()
 {
     $resources = JRequest::getVar('resource');
     $component = JRequest::getCmd('kmtcomponent');
     Komento::setCurrentComponent($component);
     if (!is_array($resources)) {
         header('Content-type: text/x-json; UTF-8');
         echo '[]';
         exit;
     }
     foreach ($resources as &$resource) {
         $resource = (object) $resource;
         switch ($resource->type) {
             case 'language':
                 $resource->content = JText::_(strtoupper($resource->name));
                 break;
             case 'view':
                 $template = Komento::getTheme();
                 $out = $template->fetch($resource->name . '.ejs');
                 if ($out !== false) {
                     $resource->content = $out;
                 }
                 break;
         }
     }
     Komento::getClass('json', 'KomentoJson');
     header('Content-type: text/x-json; UTF-8');
     $json = new KomentoJson();
     echo $json->encode($resources);
     exit;
 }
예제 #3
0
 public function purge()
 {
     $db = Komento::getDBO();
     $query = 'DELETE FROM ' . $db->nameQuote('#__komento_mailq');
     $db->setQuery($query);
     $db->Query();
 }
예제 #4
0
	public function getRule()
	{
		$component	= Komento::getCurrentComponent();
		$ip			= KomentoIpHelper::getIP();

		$rules		= Komento::getModel( 'ipfilter' )->getRule( $component, $ip );
	}
예제 #5
0
 function getColumnsState()
 {
     $columns = array('comment', 'published', 'link', 'edit', 'component', 'article', 'date', 'author', 'email', 'homepage', 'ip', 'latitude', 'longitude', 'address', 'id');
     $columnsConfig = Komento::getConfig('com_komento_pending_columns', false);
     $html = $this->renderColumnsConfiguration($columns, $columnsConfig);
     return $html;
 }
예제 #6
0
	public function toFormat( $format='%Y-%m-%d %H:%M:%S' )
	{
		if( Komento::joomlaVersion() >= '3.0' )
		{
			if( JString::stristr( $format, '%' ) !== false )
			{
				Komento::import( 'helper', 'date' );
				$format = KomentoDateHelper::strftimeToDate( $format );
			}

			return $this->date->format( $format, true );
		}
		else
		{
			// There is no way to have cross version working, except for detecting % in the format
			if( JString::stristr( $format , '%' ) === false )
			{
				if( Komento::isJoomla15() )
				{
					// forced fallback for Joomla 15 if format doesn't have %
					$format = '%c';
				}
				else
				{
					return $this->date->format( $format , true );
				}

			}

			return $this->date->toFormat( $format, true );
		}
	}
예제 #7
0
 public function getAjaxTemplate()
 {
     $files = JRequest::getVar('names', '');
     if (empty($files)) {
         return false;
     }
     // Ensure the integrity of each items submitted to be an array.
     if (!is_array($files)) {
         $files = array($files);
     }
     $result = array();
     foreach ($files as $file) {
         $template = Komento::getTheme();
         $out = $template->fetch($file . '.ejs');
         $obj = new stdClass();
         $obj->name = $file;
         $obj->content = $out;
         $result[] = $obj;
     }
     Komento::getClass('json', 'KomentoJson');
     header('Content-type: text/x-json; UTF-8');
     $json = new KomentoJson();
     echo $json->encode($result);
     exit;
 }
예제 #8
0
	/**
	 * This renders the necessary bootstrap data into the html headers.
	 */
	public function bootstrap()
	{
		static $isRendered	= false;

		$doc 				= JFactory::getDocument();

		if( !$isRendered && $doc->getType() == 'html' )
		{
			// @task: Include dependencies from foundry.
			require_once( JPATH_ROOT . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'foundry' . DIRECTORY_SEPARATOR . '3.1' . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'configuration.php' );

			$config = Komento::getConfig();

			$environment = JRequest::getVar( 'komento_environment' , $config->get( 'komento_environment' ) );

			$folder	= 'scripts';

			// @task: Let's see if we should load the dev scripts.
			if( $environment == 'development' )
			{
				$folder		= 'scripts_';
			}

			$doc->addScript( rtrim( JURI::root() , '/' ) . '/media/com_komento/' . $folder . '/abstract.js' );

			$isRendered		= true;
		}

		return $isRendered;
	}
예제 #9
0
 private function doSave()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $mainframe = JFactory::getApplication();
     if (!JRequest::getMethod() == 'POST') {
         $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_INVALID_REQUEST', 'error'));
         return false;
     }
     // Unset unecessary post data.
     $post = JRequest::get('POST');
     unset($post['task']);
     unset($post['option']);
     unset($post['c']);
     $token = Komento::_('getToken');
     unset($post[$token]);
     // check the target component
     if (!$post['target_component']) {
         $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_MISSING_TARGET_COMPONENT'));
         return false;
     }
     // rememeber user's choice
     // $mainframe->setUserState('com_komento.acl.component', $post['target_component']);
     // Save post data
     $model = Komento::getModel('Acl', true);
     if (!$model->save($post)) {
         $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_ERROR', 'error'));
         return false;
     }
     $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_SUCCESS', 'message'));
     // Clear the component's cache
     $cache = JFactory::getCache('com_komento');
     $cache->clean();
     return true;
 }
예제 #10
0
	public static function loadForm( $id, $component, $options = array() )
	{
		$theme	= Komento::getTheme();
		$html	= $theme->fetch( 'comment/form.php' );

		echo $html;
	}
예제 #11
0
 public function loadComposite($component, $ip)
 {
     $sql = Komento::getSql();
     $sql->select('#__komento_ipfilter')->where('component', $component)->where('ip', $ip);
     $data = $sql->loadObject();
     return parent::bind($data);
 }
예제 #12
0
 public function purge()
 {
     JRequest::checkToken() or jexit('Invalid Token');
     $app = JFactory::getApplication();
     $model = Komento::getModel('Mailq', $backend = true);
     $model->purge();
     $app->redirect('index.php?option=com_komento&view=mailq', JText::_('COM_KOMENTO_EMAILS_PURGED'), 'success');
 }
예제 #13
0
 /**
  * Delete the outdated entries.
  */
 public function clear()
 {
     $db = Komento::getDBO();
     $date = Komento::getDate();
     $query = 'DELETE FROM ' . $db->nameQuote('#__komento_captcha') . ' WHERE ' . $db->nameQuote('created') . ' <= DATE_SUB( ' . $db->Quote($date->toMySQL()) . ', INTERVAL 12 HOUR )';
     $db->setQuery($query);
     $db->query();
     return true;
 }
예제 #14
0
 /**
  * Renders the comment count for Komento
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function getCount(EasyBlogPost $post)
 {
     if (!$this->exists()) {
         return;
     }
     $model = Komento::getModel('Comments');
     $count = $model->getCount('com_easyblog', $post->id);
     return $count;
 }
예제 #15
0
 function preview()
 {
     $id = JRequest::getInt('id');
     $table = Komento::getTable('mailq');
     $table->load($id);
     $ajax = Komento::getAjax();
     $ajax->success($table->body, $table->type);
     $ajax->send();
 }
예제 #16
0
 function getTotal()
 {
     // Lets load the content if it doesn't already exist
     if (empty($this->_total)) {
         $sql = Komento::getSql();
         $sql->select('#__komento_comments', 'a')->column('a.id', 'id', 'count distinct')->rightjoin('#__komento_actions', 'b')->on('a.id', 'b.comment_id')->where('b.type', 'report');
         $this->_total = $sql->loadResult();
     }
     return $this->_total;
 }
예제 #17
0
 function getComponentState($filter_component = '*')
 {
     $model = Komento::getModel('subscription');
     $components = $model->getUniqueComponents();
     $component_state[] = JHTML::_('select.option', '*', JText::_('COM_KOMENTO_ALL_COMPONENTS'));
     foreach ($components as $component) {
         $component_state[] = JHTML::_('select.option', $component, Komento::loadApplication($component)->getComponentName());
     }
     return JHTML::_('select.genericlist', $component_state, 'filter_component', 'class="inputbox" size="1" onchange="submitform();"', 'value', 'text', $filter_component);
 }
예제 #18
0
 public static function getNoun($var, $count, $includeCount = false)
 {
     static $zeroIsPlural;
     if (!isset($zeroIsPlural)) {
         $config = Komento::getConfig();
         $zeroIsPlural = $config->get('layout_zero_as_plural');
     }
     $count = (int) $count;
     $var = $count === 1 || $count === -1 || $count === 0 && !$zeroIsPlural ? $var . '_SINGULAR' : $var . '_PLURAL';
     return $includeCount ? JText::sprintf($var, $count) : JText::_($var);
 }
예제 #19
0
 public function getVersion()
 {
     $ajax = Komento::getAjax();
     $local = Komento::komentoVersion();
     $remote = Komento::getHelper('Version')->getVersion();
     $html = '<span class="version_outdated">' . JText::sprintf('COM_KOMENTO_VERSION_OUTDATED', $local) . '</span>';
     if ((string) $local >= (string) $remote) {
         $html = '<span class="version_latest">' . JText::sprintf('COM_KOMENTO_VERSION_LATEST', $local) . '</span>';
     }
     $ajax->success($html);
     $ajax->send();
 }
예제 #20
0
 function display($tpl = null)
 {
     $user = JFactory::getUser();
     $mainframe = JFactory::getApplication();
     if (Komento::joomlaVersion() >= '1.6') {
         if (!$user->authorise('komento.manage.migrators', 'com_komento')) {
             $mainframe->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
             $mainframe->close();
         }
     }
     parent::display($tpl);
 }
예제 #21
0
    public function addButton($link, $image, $text, $description = '', $newWindow = false, $acl = '', $notification = 0)
    {
        if (!empty($acl) && Komento::joomlaVersion() >= '1.6') {
            if (!JFactory::getUser()->authorise('komento.manage.' . $acl, 'com_komento')) {
                return '';
            }
        }
        $target = $newWindow ? ' target="_blank"' : '';
        $bubble = $notification > 0 ? '<b>' . $notification . '</b>' : '';
        ?>
	<li>
		<a href="<?php 
        echo $link;
        ?>
"<?php 
        echo $target;
        ?>
>
			<img src="<?php 
        echo JURI::root();
        ?>
administrator/components/com_komento/assets/images/cpanel/<?php 
        echo $image;
        ?>
" width="32" />
			<span class="item-title">
				<span><?php 
        echo $text;
        ?>
</span>
				<?php 
        if ($notification > 0) {
            ?>
					<b><?php 
            echo $notification;
            ?>
</b>
				<?php 
        }
        ?>
			</span>
		</a>
		<div class="item-description">
			<div class="tipsArrow"></div>
			<div class="tipsBody"><?php 
        echo $description;
        ?>
</div>
		</div>
	</li>
<?php 
    }
예제 #22
0
	public function shorten()
	{
		$link = JRequest::getVar( 'url', '' );

		if( $link != '' )
		{
			Komento::import( 'helper', 'social' );
			$shortenlink = KomentoSocialHelper::shortenUrl( $link );
			echo $shortenlink;
		}

		exit;
	}
예제 #23
0
	public function exists( $id )
	{
		$sql = Komento::getSql();

		$sql->select( '#__users' )
			->where( 'id', $id )
			->where( 'block', 0 );

		$query = $sql->getTotalSql();

		$sql->db->setQuery( $query );
		return $sql->db->loadResult();
	}
예제 #24
0
 public function getCategories()
 {
     $db = Komento::getDBO();
     $query = 'SELECT `id`, `title`, `level`, `parent_id` FROM `CATEGORY_TABLE`';
     $db->setQuery($query);
     $categories = $db->loadObjectList();
     // optional. populate tree listing
     foreach ($categories as &$row) {
         $repeat = $row->level - 1 >= 0 ? $row->level - 1 : 0;
         $row->treename = str_repeat('.&#160;&#160;&#160;', $repeat) . ($row->level - 1 > 0 ? '|_&#160;' : '') . $row->title;
     }
     return $categories;
 }
예제 #25
0
	/**
	 * Generates a random captcha image
	 *
	 **/
	function display($cachable = false, $urlparams = false)
	{
		$id			= JRequest::getInt( 'captcha-id' , '' );
		$captcha	= Komento::getTable( 'Captcha' , 'KomentoTable' );

		if( ob_get_length() !== false )
		{
			while (@ ob_end_clean());
			if( function_exists( 'ob_clean' ) )
			{
				@ob_clean();
			}
		}

		// clearing the oudated keys.
		$captcha->clear();

		// load the captcha records.
		$captcha->load( $id );

		if( !$captcha->id )
		{
			return false;
		}

		// @task: Generate a very random integer and take only 5 chars max.
		$hash	= JString::substr( md5( rand( 0, 9999 ) ) , 0 , 5 );
	    $captcha->response	= $hash;
		$captcha->store();

	    // Captcha width and height
	    $width	= 100;
	    $height = 20;

	    $image	= ImageCreate( $width , $height );
	    $white	= ImageColorAllocate($image, 255, 255, 255);
	    $black	= ImageColorAllocate($image, 0, 0, 0);
	    $gray	= ImageColorAllocate($image, 204, 204, 204);

	    ImageFill( $image , 0 , 0 , $white );
		ImageString( $image , 5 , 30 , 3 , $hash , $black );
		ImageRectangle( $image , 0 , 0 , $width - 1 , $height - 1 , $gray );
		imageline( $image , 0 , $height / 2 , $width , $height / 2 , $gray );
		imageline( $image , $width / 2 , 0 , $width / 2 , $height , $gray );

		header( 'Content-type: image/jpeg' );
	    ImageJpeg( $image );
	    ImageDestroy($image);
	    exit;
	}
예제 #26
0
 public function store($updateNulls = false)
 {
     $sql = Komento::getSql();
     $sql->select('#__komento_configs')->column('1', '', 'count', true)->where('component', $this->component);
     $exists = $sql->loadResult() > 0 ? true : false;
     $data = new stdClass();
     $data->component = $this->component;
     $data->params = trim($this->params);
     $database = Komento::getDBO();
     if ($exists) {
         return $database->updateObject('#__komento_configs', $data, 'component');
     }
     return $database->insertObject('#__komento_configs', $data);
 }
예제 #27
0
	public function getEmbedHTML( $url )
	{
		$code	= $this->getCode( $url );

		$config	= Komento::getConfig();
		$width	= $config->get( 'bbcode_video_width' );
		$height	= $config->get( 'bbcode_video_height' );

		if( $code )
		{
			return '<iframe src="http://player.vimeo.com/video/' . $code . '" width="' . $width . '" height="' . $height . '" frameborder="0"></iframe>';
		}
		return false;
	}
예제 #28
0
 public function getView($name)
 {
     // Due to compatibility, we had to append komento/ infront of the views, but we do not want this when fetching template
     if (strpos('komento/', $name) >= 0) {
         $name = substr($name, 8);
     }
     $template = Komento::getTheme();
     $out = $template->fetch($name . '.ejs');
     $contents = '';
     if ($out !== false) {
         $contents = $out;
     }
     return $contents;
 }
예제 #29
0
	public function getEmbedHTML( $url )
	{
		$code	= $this->getCode( $url );

		$config	= Komento::getConfig();
		$width	= $config->get( 'bbcode_video_width' );
		$height	= $config->get( 'bbcode_video_height' );

		if( $code )
		{
			return '<embed flashVars="playerVars=showStats=yes|autoPlay=no" src="http://www.metacafe.com/fplayer/' . $code . '/easyblog.swf" width="' . $width . '" height="' . $height . '" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_' . $code . '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>';
		}
		return false;
	}
예제 #30
0
	public function getEmbedHTML( $url )
	{
		$code	= $this->getCode( $url );

		$config	= Komento::getConfig();
		$width	= $config->get( 'bbcode_video_width' );
		$height	= $config->get( 'bbcode_video_height' );

		if( $code )
		{
			return '<script src="http://flash.revver.com/player/1.0/player.js?mediaId:' . $code . ';width:' . $width . ';height:' . $height . ';" type="text/javascript"></script>';
		}
		return false;
	}