ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilPollBlock Class Reference

Custom block for polls. More...

+ Inheritance diagram for ilPollBlock:
+ Collaboration diagram for ilPollBlock:

Public Member Functions

 setRefId ($a_id)
 Set ref id (needed for poll access) More...
 
 getPoll ()
 Get poll object. More...
 
 hasAnyContent ($a_user_id, $a_ref_id)
 Check if user will see any content (vote/result) More...
 
 mayVote ($a_user_id)
 
 mayNotResultsYet ()
 
 maySeeResults ($a_user_id)
 
 getMessage ($a_user_id)
 
 showResultsAs ()
 Show Results as (Barchart or Piechart) More...
 
 showComments ()
 Are Comments enabled or disabled. More...
 
- Public Member Functions inherited from ilCustomBlock
 __construct ($a_id=0)
 Constructor. More...
 
 setId ($a_id)
 Set Id. More...
 
 getId ()
 Get Id. More...
 
 setContextObjId ($a_context_obj_id)
 Set ContextObjId. More...
 
 getContextObjId ()
 Get ContextObjId. More...
 
 setContextObjType ($a_context_obj_type)
 Set ContextObjType. More...
 
 getContextObjType ()
 Get ContextObjType. More...
 
 setContextSubObjId ($a_context_sub_obj_id)
 Set ContextSubObjId. More...
 
 getContextSubObjId ()
 Get ContextSubObjId. More...
 
 setContextSubObjType ($a_context_sub_obj_type)
 Set ContextSubObjType. More...
 
 getContextSubObjType ()
 Get ContextSubObjType. More...
 
 setType ($a_type)
 Set Type. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 create ()
 Create new item. More...
 
 read ()
 Read item from database. More...
 
 update ()
 Update item in database. More...
 
 delete ()
 Delete item from database. More...
 
 querygetBlocksForContext ()
 Query getBlocksForContext. More...
 
 queryBlocksForContext ($a_include_sub_obj=true)
 Query BlocksForContext. More...
 
 queryTitleForId ()
 Query TitleForId. More...
 
 queryCntBlockForContext ()
 Query CntBlockForContext. More...
 

Protected Attributes

 $poll
 
 $answers
 
 $visible
 
 $active
 
- Protected Attributes inherited from ilCustomBlock
 $id
 
 $context_obj_id
 
 $context_obj_type
 
 $context_sub_obj_id
 
 $context_sub_obj_type
 
 $type
 
 $title
 

Additional Inherited Members

- Static Public Member Functions inherited from ilCustomBlock
static multiBlockQuery ($a_context_obj_type, array $a_context_obj_ids)
 

Detailed Description

Custom block for polls.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 12 of file class.ilPollBlock.php.

Member Function Documentation

◆ getMessage()

ilPollBlock::getMessage (   $a_user_id)

Definition at line 136 of file class.ilPollBlock.php.

137 {
138 global $lng;
139
140 if(!sizeof($this->answers))
141 {
142 return $lng->txt("poll_block_message_no_answers");
143 }
144
145 if(!$this->active)
146 {
147 if(!$this->poll->isOnline())
148 {
149 return $lng->txt("poll_block_message_offline");
150 }
151 if($this->poll->getAccessBegin() > time())
152 {
153 $date = ilDatePresentation::formatDate(new ilDateTime($this->poll->getAccessBegin(), IL_CAL_UNIX));
154 return sprintf($lng->txt("poll_block_message_inactive"), $date);
155 }
156 }
157 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
global $lng
Definition: privfeed.php:40

References $lng, ilDatePresentation\formatDate(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ getPoll()

ilPollBlock::getPoll ( )

Get poll object.

Returns
ilObjPoll

Definition at line 36 of file class.ilPollBlock.php.

37 {
38 return $this->poll;
39 }

References $poll.

◆ hasAnyContent()

ilPollBlock::hasAnyContent (   $a_user_id,
  $a_ref_id 
)

Check if user will see any content (vote/result)

Parameters
int$a_user_id
Returns
boolean

Definition at line 47 of file class.ilPollBlock.php.

48 {
49 if(!sizeof($this->answers))
50 {
51 return false;
52 }
53
54 include_once "Modules/Poll/classes/class.ilObjPollAccess.php";
55 $this->active = ilObjPollAccess::_isActivated($a_ref_id);
56 if(!$this->active)
57 {
58 return false;
59 }
60
61 if(!$this->mayVote($a_user_id) &&
62 !$this->maySeeResults($a_user_id))
63 {
64 return false;
65 }
66
67 return true;
68 }
static _isActivated($a_ref_id)
Is activated?
mayVote($a_user_id)
maySeeResults($a_user_id)

References ilObjPollAccess\_isActivated(), maySeeResults(), and mayVote().

+ Here is the call graph for this function:

◆ mayNotResultsYet()

ilPollBlock::mayNotResultsYet ( )

Definition at line 97 of file class.ilPollBlock.php.

98 {
99 if($this->poll->getViewResults() == ilObjPoll::VIEW_RESULTS_AFTER_PERIOD &&
100 $this->poll->getVotingPeriod() &&
101 $this->poll->getVotingPeriodEnd() > time())
102 {
103 return true;
104 }
105 return false;
106 }
const VIEW_RESULTS_AFTER_PERIOD

References ilObjPoll\VIEW_RESULTS_AFTER_PERIOD.

◆ maySeeResults()

ilPollBlock::maySeeResults (   $a_user_id)

Definition at line 108 of file class.ilPollBlock.php.

109 {
110 if(!$this->active)
111 {
112 return false;
113 }
114
115 switch($this->poll->getViewResults())
116 {
118 return false;
119
121 // fallthrough
122
123 // #12023 - see mayNotResultsYet()
125 return true;
126
128 if($this->poll->hasUserVoted($a_user_id))
129 {
130 return true;
131 }
132 return false;
133 }
134 }
const VIEW_RESULTS_ALWAYS
const VIEW_RESULTS_AFTER_VOTE
const VIEW_RESULTS_NEVER

References ilObjPoll\VIEW_RESULTS_AFTER_PERIOD, ilObjPoll\VIEW_RESULTS_AFTER_VOTE, ilObjPoll\VIEW_RESULTS_ALWAYS, and ilObjPoll\VIEW_RESULTS_NEVER.

Referenced by hasAnyContent().

+ Here is the caller graph for this function:

◆ mayVote()

ilPollBlock::mayVote (   $a_user_id)

Definition at line 70 of file class.ilPollBlock.php.

71 {
72 if(!$this->active)
73 {
74 return false;
75 }
76
77 if($a_user_id == ANONYMOUS_USER_ID)
78 {
79 return false;
80 }
81
82 if($this->poll->hasUserVoted($a_user_id))
83 {
84 return false;
85 }
86
87 if($this->poll->getVotingPeriod() &&
88 ($this->poll->getVotingPeriodBegin() > time() ||
89 $this->poll->getVotingPeriodEnd() < time()))
90 {
91 return false;
92 }
93
94 return true;
95 }

Referenced by hasAnyContent().

+ Here is the caller graph for this function:

◆ setRefId()

ilPollBlock::setRefId (   $a_id)

Set ref id (needed for poll access)

Parameters
int$a_id

Definition at line 24 of file class.ilPollBlock.php.

25 {
26 include_once "Modules/Poll/classes/class.ilObjPoll.php";
27 $this->poll = new ilObjPoll($a_id, true);
28 $this->answers = $this->poll->getAnswers();
29 }
Class ilObjPoll.

◆ showComments()

ilPollBlock::showComments ( )

Are Comments enabled or disabled.

Returns
bool

Definition at line 173 of file class.ilPollBlock.php.

174 {
175 return $this->poll->getShowComments();
176 }

◆ showResultsAs()

ilPollBlock::showResultsAs ( )

Show Results as (Barchart or Piechart)

Returns
int

Definition at line 164 of file class.ilPollBlock.php.

165 {
166 return $this->poll->getShowResultsAs();
167 }

Field Documentation

◆ $active

ilPollBlock::$active
protected

Definition at line 17 of file class.ilPollBlock.php.

◆ $answers

ilPollBlock::$answers
protected

Definition at line 15 of file class.ilPollBlock.php.

◆ $poll

ilPollBlock::$poll
protected

Definition at line 14 of file class.ilPollBlock.php.

Referenced by getPoll().

◆ $visible

ilPollBlock::$visible
protected

Definition at line 16 of file class.ilPollBlock.php.


The documentation for this class was generated from the following file: