ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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)
 getPoll ()
 Get poll object.
 hasAnyContent ($a_user_id, $a_ref_id)
 Check if user will see any content (vote/result)
 mayVote ($a_user_id)
 mayNotResultsYet ()
 maySeeResults ($a_user_id)
 getMessage ($a_user_id)
- Public Member Functions inherited from ilCustomBlock
 __construct ($a_id=0)
 Constructor.
 setId ($a_id)
 Set Id.
 getId ()
 Get Id.
 setContextObjId ($a_context_obj_id)
 Set ContextObjId.
 getContextObjId ()
 Get ContextObjId.
 setContextObjType ($a_context_obj_type)
 Set ContextObjType.
 getContextObjType ()
 Get ContextObjType.
 setContextSubObjId ($a_context_sub_obj_id)
 Set ContextSubObjId.
 getContextSubObjId ()
 Get ContextSubObjId.
 setContextSubObjType ($a_context_sub_obj_type)
 Set ContextSubObjType.
 getContextSubObjType ()
 Get ContextSubObjType.
 setType ($a_type)
 Set Type.
 getType ()
 Get Type.
 setTitle ($a_title)
 Set Title.
 getTitle ()
 Get Title.
 create ()
 Create new item.
 read ()
 Read item from database.
 update ()
 Update item in database.
 delete ()
 Delete item from database.
 querygetBlocksForContext ()
 Query getBlocksForContext.
 queryBlocksForContext ()
 Query BlocksForContext.
 queryTitleForId ()
 Query TitleForId.
 queryCntBlockForContext ()
 Query CntBlockForContext.

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

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

ilPollBlock::getMessage (   $a_user_id)

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

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

{
global $lng;
if(!sizeof($this->answers))
{
return $lng->txt("poll_block_message_no_answers");
}
if(!$this->active)
{
if(!$this->poll->isOnline())
{
return $lng->txt("poll_block_message_offline");
}
if($this->poll->getAccessBegin() > time())
{
$date = ilDatePresentation::formatDate(new ilDateTime($this->poll->getAccessBegin(), IL_CAL_UNIX));
return sprintf($lng->txt("poll_block_message_inactive"), $date);
}
}
}

+ Here is the call graph for this function:

ilPollBlock::getPoll ( )

Get poll object.

Returns
ilObjPoll

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

References $poll.

{
return $this->poll;
}
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.

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

{
if(!sizeof($this->answers))
{
return false;
}
include_once "Modules/Poll/classes/class.ilObjPollAccess.php";
$this->active = ilObjPollAccess::_isActivated($a_ref_id);
if(!$this->active)
{
return false;
}
if(!$this->mayVote($a_user_id) &&
!$this->maySeeResults($a_user_id))
{
return false;
}
return true;
}

+ Here is the call graph for this function:

ilPollBlock::mayNotResultsYet ( )

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

References ilObjPoll\VIEW_RESULTS_AFTER_PERIOD.

{
if($this->poll->getViewResults() == ilObjPoll::VIEW_RESULTS_AFTER_PERIOD &&
$this->poll->getVotingPeriod() &&
$this->poll->getVotingPeriodEnd() > time())
{
return true;
}
return false;
}
ilPollBlock::maySeeResults (   $a_user_id)

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

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

Referenced by hasAnyContent().

{
if(!$this->active)
{
return false;
}
switch($this->poll->getViewResults())
{
return false;
// fallthrough
// #12023 - see mayNotResultsYet()
return true;
if($this->poll->hasUserVoted($a_user_id))
{
return true;
}
return false;
}
}

+ Here is the caller graph for this function:

ilPollBlock::mayVote (   $a_user_id)

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

Referenced by hasAnyContent().

{
if(!$this->active)
{
return false;
}
if($a_user_id == ANONYMOUS_USER_ID)
{
return false;
}
if($this->poll->hasUserVoted($a_user_id))
{
return false;
}
if($this->poll->getVotingPeriod() &&
($this->poll->getVotingPeriodBegin() > time() ||
$this->poll->getVotingPeriodEnd() < time()))
{
return false;
}
return true;
}

+ Here is the caller graph for this function:

ilPollBlock::setRefId (   $a_id)

Set ref id (needed for poll access)

Parameters
int$a_id

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

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

Field Documentation

ilPollBlock::$active
protected

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

ilPollBlock::$answers
protected

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

ilPollBlock::$poll
protected

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

Referenced by getPoll().

ilPollBlock::$visible
protected

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


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