File size: 2.49Kb
<?php
/**
* @package XenCentral Feedback System
* @author DNF Technology
* @copyright Drnoyan & Nalyan LDA, Portugal, EU
* @license http://dnf.technology/terms/
* @link http://customers.dnf.technology
* @version 2.0.0 Beta 10
* @revision 12
*/
namespace XenCentral\Feedback\XF\Entity;
use XF\Mvc\Entity\Structure;
class User extends XFCP_User
{
public function canViewFeedback(&$error = null)
{
return $this->hasPermission('xcfs', 'xcfs_can_view');
}
public function getEffectivePermissionsFeedback()
{
return array (
'isAdmin' => $this->isAdministratorFeedback(),
'isUser' => $this->isUserFeedback(),
'isViewer' => $this->isAdministratorFeedback() || $this->isUserFeedback() || $this->isViewerFeedback(),
'canGive' => $this->canGive(),
'canReceive' => $this->canRecaive(),
'feedbackRestricted' => $this->feedbackRestricted()
);
}
public function canUseFeedback($user=false)
{
return $this->isUserFeedback($user=false);
}
public function canGiveFeedback()
{
return ($this->user_id && $this->hasPermission('xcfs', 'xcfs_can_give'));
}
public function isAdministratorFeedback($user=false)
{
return ($this->user_id && $this->hasPermission('xcfs', 'xcfs_can_admin'));
}
public function isViewerFeedback()
{
return ($this->user_id && $this->hasPermission('xcfs', 'xcfs_can_view'));
}
public function isUserFeedback()
{
return ($this->canGiveFeedback() || $this->canReceiveFeedback());
}
public function canBeInvisibleFeedback()
{
return ($this->user_id && $this->hasPermission('xcfs', 'xcfs_can_be_invisible'));
}
public function canSeeInvisibleFeedback()
{
return ($this->user_id && $this->hasPermission('xcfs', 'xcfs_can_see_invisible'));
}
public function canAdminFeedback()
{
return $this->isAdministratorFeedback();
}
public function canReceiveFeedback()
{
return ($this->user_id && $this->hasPermission('xcfs', 'xcfs_can_receive'));
}
public function feedbackRestricted ($user) {
if (\XF::options()->{'xcfs_'. 'can_give_feedback'} && $user['user_id'] !== 0 AND $this->hasPermission('xcfs','xcfs_can_give') AND \XF::repository('XenCentral\Feedback:User')->totalForUser( $user['user_id'] ) < 1 ) {
return false;
}
return true;
}
}