Exemple #1
0
 public function loadByKey($key)
 {
     $sql = Komento::getSql();
     $sql->select('#__komento_hashkeys')->where('key', $key);
     $data = $sql->loadObject();
     return parent::bind($data);
 }
Exemple #2
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);
 }
Exemple #3
0
	public function send( $max = 5 )
	{
		$konfig		= Komento::getKonfig();

		if( $konfig->get( 'disable_mailq' ) )
		{
			return false;
		}

		$db			= Komento::getDBO();
		$config		= Komento::getConfig();

		$sql = Komento::getSql();

		$sql->select( '#__komento_mailq' )
			->column( 'id' )
			->where( 'status', 0 )
			->order( 'created' )
			->limit( $max );

		$result = $sql->loadObjectList();

		if(! empty($result))
		{
			foreach($result as $mail)
			{
				$mailq	= Komento::getTable('mailq');
				$mailq->load($mail->id);

				$sendHTML = $mailq->type == 'html' ? 1 : 0;

				$state = 0;

				if( empty( $mailq->recipient ) )
				{
					$state = 1;
				}

				//send emails.
				if( Komento::isJoomla15() )
				{
					$state = JUtility::sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
				}
				else
				{
					$mail = JFactory::getMailer();
					$state = $mail->sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
				}

				if( $state )
				{
					// update the status to 1 == proccessed
					$mailq->status  = 1;
					$mailq->store();
				}
			}
		}
	}
Exemple #4
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;
 }
Exemple #5
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();
	}
Exemple #6
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);
 }
Exemple #7
0
 public function compositeLoad($cid, $type, $component, $reset = true)
 {
     if ($reset) {
         $this->reset();
     }
     $sql = Komento::getSql();
     $sql->select('#__komento_acl')->where('component', $component)->where('type', $type)->where('cid', $cid);
     $result = $sql->loadObject();
     if (empty($result)) {
         $this->cid = $cid;
         $this->type = $type;
         $this->component = $component;
     } else {
         $this->bind($result);
     }
     return $this;
 }
Exemple #8
0
	public function getRule( $component, $ip )
	{
		$sql = Komento::getSql();

		$sql->select( '#__komento_ipfilter' )
			->column( 'rules' )
			->where( 'component', $component )
			->where( 'ip', $ip );

		$result = $sql->loadResult();

		if( !$result )
		{
			return false;
		}

		$result = json_decode( $result );

		return $result;
	}
 public function load($cid)
 {
     static $instances = array();
     if (empty($cid)) {
         return NULL;
     }
     if (!isset($instances[$cid])) {
         // Check if this record exist or not
         $sql = Komento::getSql();
         $sql->select('#__js_res_record')->column('id', 'id', 'count')->where('id', $cid);
         $result = $sql->loadResult();
         if ($result < 1) {
             return $this->onLoadArticleError($cid);
         }
         $item = ItemsStore::getRecord($cid);
         $item->url = $this->prepareLink(Url::record($item));
         $instances[$cid] = $item;
     }
     $this->_item = $instances[$cid];
     return $this;
 }
Exemple #10
0
	public function getAttachments( $uid )
	{
		$sql = Komento::getSql();

		$sql->select( '#__komento_uploads' )
			->where( 'uid', $uid )
			->order( 'created' );

		$result = $sql->loadObjectList();

		$attachments = array();

		foreach( $result as $row )
		{
			$table = Komento::getTable( 'uploads' );
			$table->bind( $row );

			$attachments[] = $table;
		}

		return $attachments;
	}
Exemple #11
0
 public function getData($component = 'com_component', $type = 'usergroup', $cid = 0)
 {
     $sql = Komento::getSql();
     $sql->select('#__komento_acl')->column('rules')->where('component', $component)->where('type', $type)->where('cid', $cid)->order('type');
     $rulesets = $sql->loadResult();
     if (empty($rulesets)) {
         $rulesets = new stdClass();
     } else {
         $json = Komento::getJSON();
         $rulesets = $json->decode($rulesets);
     }
     Komento::import('helper', 'acl');
     $defaultset = KomentoACLHelper::getEmptySet();
     foreach ($defaultset as $section => &$rules) {
         foreach ($rules as $key => &$value) {
             if (isset($rulesets->{$key})) {
                 $value = $rulesets->{$key};
             }
         }
     }
     return $defaultset;
 }
Exemple #12
0
	public function getAclObject( $cid = 0, $type = 'usergroup', $component = 'com_content' )
	{
		$sql = Komento::getSql();

		$sql->select( '#__komento_acl' )
			->column( 'rules' )
			->where( 'cid', $cid )
			->where( 'type', $type )
			->where( 'component', $component )
			->order( 'id' );

		$result = $sql->loadResult();

		if( empty( $result ) )
		{
			return false;
		}

		$json = Komento::getJSON();

		$result = $json->decode( $result );

		return $result;
	}
Exemple #13
0
	private function buildQuery( $id, $options )
	{
		$sql = Komento::getSql();


		$sql->select( '#__komento_activities', 'a' )
			->column( 'a.*' )
			->column( 'b.component' )
			->column( 'b.cid' )
			->column( 'b.comment' )
			->column( 'b.name' )
			->column( 'b.created_by' )
			->column( 'b.parent_id' )
			->leftjoin( '#__komento_comments', 'b' )
			->on( 'a.comment_id', 'b.id' );

		if( $id !== 'all' )
		{
			$sql->where( 'a.uid', $id );
		}

		$sql->where( 'a.published', $options['published'] );
		$sql->where( 'b.published', 1 );

		if( $options['component'] !== 'all' )
		{
			$sql->where( 'b.component', $options['component'] );
		}

		if( $options['cid'] !== 'all' )
		{
			if( !is_array( $options['cid'] ) )
			{
				$options['cid'] = explode( ',', $options['cid'] );
			}

			if( count( $options['cid'] ) > 1 )
			{
				$sql->where( 'b.cid', $options['cid'], 'in' );
			}
			else
			{
				$sql->where( 'b.cid', $options['cid'][0] );
			}
		}

		if( $options['type'] !== 'all' )
		{
			if( !is_array( $options['type'] ) )
			{
				$options['type'] = explode( ',', $options['type'] );
			}

			if( count( $options['type'] ) > 1 )
			{
				$sql->where( 'a.type', $options['type'], 'in' );
			}
			else
			{
				$sql->where( 'a.type', $options['type'][0] );
			}
		}

		if( isset( $options['sort'] ) )
		{
			switch( $options['sort'] )
			{
				case 'oldest':
					$sql->order( 'a.created' );
					break;
				case 'latest':
				default:
					$sql->order( 'a.created', 'desc' );
					break;
			}
		}

		if( isset( $options['start'] ) && isset( $options['limit'] ) )
		{
			$sql->limit( $options['start'], $options['limit'] );
		}

		return $sql;
	}
	public function buildQuery()
	{
		$mainframe	= JFactory::getApplication();

		$filter_component	= $mainframe->getUserStateFromRequest( 'com_komento.subscribers.filter_component', 'filter_component', '*', 'string' );
		$filter_type		= $mainframe->getUserStateFromRequest( 'com_komento.subscribers.filter_type', 'filter_type', '*', 'string' );
		$filter_order		= $mainframe->getUserStateFromRequest( 'com_komento.subscribers.filter_order', 'filter_order', 'created', 'cmd' );
		$filter_order_Dir	= $mainframe->getUserStateFromRequest( 'com_komento.subscribers.filter_order_Dir',	'filter_order_Dir',	'DESC', 'word' );

		$sql = Komento::getSql();

		$sql->select( '#__komento_subscription' );

		if( $filter_component != '*' )
		{
			$sql->where( 'component', $filter_component );
		}

		if( $filter_type != '*' )
		{
			$sql->where( 'type', $filter_type );
		}

		$sql->order( $filter_order, $filter_order_Dir );

		return $sql;
	}
 public function getItemId($categoryId = null)
 {
     static $itemids = array();
     if (is_null($categoryId)) {
         $categoryId = $this->getCategoryId();
     }
     if (empty($itemids[$categoryId])) {
         $sql = Komento::getSql();
         $sql->select('#__menu')->column('id')->column('link')->where('link', 'index.php?option=com_jdownloads&view=category&catid%', 'LIKE')->where('published', 1);
         $itemid = 0;
         $result = $sql->loadObjectList();
         if (!empty($result)) {
             foreach ($result as $row) {
                 $catid = substr(strrchr($row->link, '='), 1);
                 if ($catid == $categoryId) {
                     $itemid = $row->id;
                     break;
                 }
             }
         }
         if (empty($itemid)) {
             $sql->clear();
             $sql->select('#__menu')->column('id')->where('link', 'index.php?option=com_jdownloads')->where('published', 1);
             $itemid = $sql->loadResult();
         }
         if (empty($itemid)) {
             $sql->clear();
             $sql->select('#__menu')->column('id')->where('link', 'index.php?option=com_jdownloads&view=category')->where('published', 1);
             $itemid = $sql->loadResult();
         }
         $itemids[$categoryId] = $itemid;
     }
     return $itemids[$categoryId];
 }
Exemple #16
0
 public static function getUsersByGroup($gid)
 {
     $userArr = array();
     if (Komento::joomlaVersion() >= '1.6') {
         $userArr = JAccess::getUsersByGroup($gid);
     } else {
         $sql = Komento::getSql();
         $sql->select('#__users')->column('id')->where('gid', $gid);
         $userArr = $sql->loadResultArray();
     }
     return $userArr;
 }
Exemple #17
0
	/**
	 * @access	public
	 * @param	string	$optionName	The component element
	 * @return	boolean	True if the component is installed and enabled
	 */
	public static function isEnabled( $componentName )
	{
		self::_clean( $componentName );

		$sql = Komento::getSql();

		$sql->select( '#__extensions' )
			->column( 'enabled' )
			->where( 'type', 'component' )
			->where( 'element', $componentName );

		return $sql->loadResult();
	}
	public function getAdmins()
	{
		$config		= Komento::getConfig();
		if( !$config->get( 'notification_to_admins' ) )
		{
			return array();
		}

		$saUsersIds	= Komento::getSAUsersIds();

		$sql = Komento::getSql();

		$sql->select( '#__users' )
			->column( 'id' )
			->column( 'name', 'fullname' )
			->column( 'email' );

		if( $saUsersIds )
		{
			$sql->where( 'id', $saUsersIds, 'in' );
		}

		$sql->where( 'sendEmail', '1' );

		$admins	= $sql->loadObjectList();

		if( !$admins )
		{
			return array();
		}
		else
		{
			$result = array();

			foreach( $admins as $admin )
			{
				$result[$admin->email] = $admin;
			}

			return $result;
		}
	}
 private function pushBoundaries($item, $count)
 {
     $diff = $count * 2;
     $sql = Komento::getSql();
     $query = "UPDATE `#__komento_comments` SET `lft` = `lft` + {$diff} WHERE `component` = '{$item->component}' AND `cid` = '{$item->cid}' AND `lft` > {$item->lft}";
     $sql->raw($query);
     $sql->query();
     $query = "UPDATE `#__komento_comments` SET `rgt` = `rgt` + {$diff} WHERE `component` = '{$item->component}' AND `cid` = '{$item->cid}' AND `rgt` > {$item->lft}";
     $sql->raw($query);
     $sql->query();
 }
Exemple #20
0
 public function getUsers($options = array())
 {
     $sql = Komento::getSql();
     $sql->select('#__komento_comments')->column('created_by', 'user', 'distinct');
     if (!empty($options['noguest'])) {
         $sql->where('created_by', 0, '>');
     }
     if (!empty($options['component'])) {
         $sql->where('component', $options['component']);
     }
     if (!empty($options['cid'])) {
         $sql->where('cid', $options['cid']);
     }
     if (isset($options['state'])) {
         $sql->where('published', $options['state']);
     }
     $result = $sql->loadColumn();
     return $result;
 }
 public function getAvatar()
 {
     $sql = Komento::getSql();
     $sql->select('#__hwdms_users')->where('id', $this->profile->id);
     $result = $sql->loadObject();
     if (isset($result->key)) {
         hwdMediaShareFactory::load('files');
         hwdMediaShareFiles::getLocalStoragePath();
         $folders = hwdMediaShareFiles::getFolders($result->key);
         $filename = hwdMediaShareFiles::getFilename($result->key, 10);
         $ext = hwdMediaShareFiles::getExtension($result, 10);
         $path = hwdMediaShareFiles::getPath($folders, $filename, $ext);
         if (file_exists($path)) {
             return hwdMediaShareFiles::getUrl($folders, $filename, $ext);
         }
     }
     return JURI::root(true) . '/media/com_hwdmediashare/assets/images/default-avatar.png';
 }
Exemple #22
0
 public function getComponentSelection()
 {
     $query = "SELECT DISTINCT `component` FROM `#__komento_comments`";
     $sql = Komento::getSql();
     $sql->raw($query);
     $result = $sql->loadColumn();
     $options = array($this->renderOption('all', '*'));
     foreach ($result as $row) {
         $options[] = $this->renderOption($row, Komento::loadApplication($row)->getComponentName());
     }
     $html = JHtml::_('select.genericlist', $options, 'componentSelection', 'size="1" class="inputbox componentSelection"', 'value', 'text');
     return $html;
 }