ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjPoll Class Reference

Class ilObjPoll. More...

+ Inheritance diagram for ilObjPoll:
+ Collaboration diagram for ilObjPoll:

Public Member Functions

 __construct ($a_id=0, $a_reference=true)
 Constructor public.
 initType ()
 setOnline ($a_value)
 isOnline ()
 setAccessType ($a_value)
 getAccessType ()
 setAccessBegin ($a_value)
 getAccessBegin ()
 setAccessEnd ($a_value)
 getAccessEnd ()
 setAccessVisibility ($a_value)
 getAccessVisibility ()
 setQuestion ($a_value)
 getQuestion ()
 setImage ($a_value)
 getImage ()
 setViewResults ($a_value)
 getViewResults ()
 setVotingPeriod ($a_value)
 getVotingPeriod ()
 setVotingPeriodBegin ($a_value)
 getVotingPeriodBegin ()
 setVotingPeriodEnd ($a_value)
 getVotingPeriodEnd ()
 doCloneObject (ilObjPoll $new_obj, $a_target_id, $a_copy_id=0)
 Clone poll.
 getImageFullPath ($a_as_thumb=false)
 Get image incl.
 deleteImage ()
 remove existing file
 uploadImage (array $a_upload, $a_clone=false)
 Upload new image file.
 getAnswers ()
 getAnswer ($a_id)
 saveAnswer ($a_text, $a_pos=null)
 updateAnswer ($a_id, $a_text)
 rebuildAnswerPositions ()
 updateAnswerPositions (array $a_pos)
 deleteAnswer ($a_id)
 deleteAllVotes ()
 saveAnswers (array $a_answers)
 saveVote ($a_user_id, $a_answer_id)
 hasUserVoted ($a_user_id)
 countVotes ()
 getVotePercentages ()
- Public Member Functions inherited from ilObject2
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not)
 read ($a_force_db=false)
 Read data from db.
 getId ()
 get object id public
 setId ($a_id)
 set object id public
 setRefId ($a_id)
 set reference id public
 getRefId ()
 get reference id public
 getType ()
 get object type public
 setType ($a_type)
 set object type public
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions
 getTitle ()
 get object title public
 getUntranslatedTitle ()
 get untranslated object title public
 setTitle ($a_title)
 set object title
 getDescription ()
 get object description
 setDescription ($a_desc)
 set object description
 getLongDescription ()
 get object long description (stored in object_description)
 getImportId ()
 get import id
 setImportId ($a_import_id)
 set import id
 getOwner ()
 get object owner
 getOwnerName ()
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id
 setOwner ($a_owner)
 set object owner
 getCreateDate ()
 get create date public
 getLastUpdateDate ()
 get last update date public
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class)
 create ($a_clone_mode=false)
 update ()
 update object in db
 MDUpdateListener ($a_element)
 Meta data update listener.
 createMetaData ()
 create meta data entry
 updateMetaData ()
 update meta data entry
 deleteMetaData ()
 delete meta data entry
 updateOwner ()
 update owner of object in db
 _getIdForImportId ($a_import_id)
 get current object id for import id (static)
 _lookupOwner ($a_id)
 lookup object owner
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects.
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static)
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static)
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static)
 _isInTrash ($a_ref_id)
 checks wether object is in trash
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!?
 setPermissions ($a_parent_ref)
 set permissions of object
 createReference ()
 creates reference for object
 countReferences ()
 count references of object
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!!
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public
 createRoleFolder ()
 creates a local role folder
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts.
 setRegisterMode ($a_bool)
 isUserRegistered ($a_user_id=0)
 requireRegistration ()
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container.
 cloneMetaData ($target_obj)
 Copy meta data.
 cloneObject ($a_target_id, $a_copy_id=null, $a_omit_tree=false)
 Clone object permissions, put in tree ...
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies.
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor public.
 getDiskUsage ()
 Gets the disk usage of the object in bytes.
 create ()
 create
 applyDidacticTemplate ($a_tpl_id)
 Apply template.
 getXMLZip ()
 getHTMLDirectory ()
 _lookupCreationDate ($a_id)
 Lookup creation date.

Static Public Member Functions

static initStorage ($a_id, $a_subdir=null)
 Init file system storage.
static getImageSize ()
- Static Public Member Functions inherited from ilObject2
static _lookupObjIdByImportId ($a_import_id)
static _getAllReferences ($a_id)
 get all reference ids of object
static _lookupTitle ($a_id)
 lookup object title
static _getIdsForTitle ($title, $type= '', $partialmatch=false)
static _lookupDescription ($a_id)
 lookup object description
static _lookupObjId ($a_id)
static _lookupType ($a_id, $a_reference=false)
 lookup object type
static _lookupObjectId ($a_ref_id)
 lookup object id
static _exists ($a_id, $a_reference=false)
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type.
static _prepareCloneSelection ($a_ref_ids, $new_type)
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item.
- Static Public Member Functions inherited from ilObject
static setDeletedDates ($a_ref_ids)
 Set deleted date type $ilDB.
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection.
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies.
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies.
static getLongDescriptions (array $a_obj_ids)
 Get long description data.
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns.
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course.

Data Fields

const VIEW_RESULTS_ALWAYS = 1
const VIEW_RESULTS_NEVER = 2
const VIEW_RESULTS_AFTER_VOTE = 3
const VIEW_RESULTS_AFTER_PERIOD = 4

Protected Member Functions

 doRead ()
 propertiesToDB ()
 doCreate ()
 doUpdate ()
 doDelete ()
 deleteAllAnswers ()
- Protected Member Functions inherited from ilObject2
 beforeCreate ()
 beforeUpdate ()
 doMDUpdateListener ($a_element)
 beforeMDUpdateListener ($a_element)
 doCreateMetaData ()
 beforeCreateMetaData ()
 doUpdateMetaData ()
 beforeUpdateMetaData ()
 beforeDelete ()
 doCloneObject ($new_obj, $a_target_id, $a_copy_id=null)
 beforeCloneObject ()

Protected Attributes

 $online
 $access_type
 $access_begin
 $access_end
 $access_visibility
 $question
 $image
 $view_results
 $period
 $period_begin
 $period_end

Detailed Description

Class ilObjPoll.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id:
class.ilObjFolder.php 25528 2010-09-03 10:37:11Z smeyer

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

Constructor & Destructor Documentation

ilObjPoll::__construct (   $a_id = 0,
  $a_reference = true 
)

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Reimplemented from ilObject2.

Definition at line 35 of file class.ilObjPoll.php.

References setAccessType(), setOnline(), setViewResults(), setVotingPeriod(), and ilObjectActivation\TIMINGS_DEACTIVATED.

{
// default
$this->setOnline(false);
$this->setViewResults(self::VIEW_RESULTS_AFTER_VOTE);
$this->setVotingPeriod(false);
parent::__construct($a_id, $a_reference);
}

+ Here is the call graph for this function:

Member Function Documentation

ilObjPoll::countVotes ( )

Definition at line 660 of file class.ilObjPoll.php.

References $row, and ilObject2\getId().

{
global $ilDB;
$sql = "SELECT count(*) cnt".
" FROM il_poll_vote".
" WHERE poll_id = ".$ilDB->quote($this->getId(), "integer");
$set = $ilDB->query($sql);
$row = $ilDB->fetchAssoc($set);
return (int)$row["cnt"];
}

+ Here is the call graph for this function:

ilObjPoll::deleteAllAnswers ( )
protected

Definition at line 550 of file class.ilObjPoll.php.

References deleteAllVotes(), and ilObject2\getId().

Referenced by doDelete().

{
global $ilDB;
if($this->getId())
{
$this->deleteAllVotes();
$ilDB->manipulate("DELETE FROM il_poll_answer".
" WHERE poll_id = ".$ilDB->quote($this->getId(), "integer"));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjPoll::deleteAllVotes ( )

Definition at line 563 of file class.ilObjPoll.php.

References ilObject2\getId().

Referenced by deleteAllAnswers().

{
global $ilDB;
if($this->getId())
{
$ilDB->manipulate("DELETE FROM il_poll_vote".
" WHERE poll_id = ".$ilDB->quote($this->getId(), "integer"));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjPoll::deleteAnswer (   $a_id)

Definition at line 536 of file class.ilObjPoll.php.

Referenced by saveAnswers().

{
global $ilDB;
if($a_id)
{
$ilDB->manipulate("DELETE FROM il_poll_vote".
" WHERE answer_id = ".$ilDB->quote($this->getId(), "integer"));
$ilDB->manipulate("DELETE FROM il_poll_answer".
" WHERE id = ".$ilDB->quote($a_id, "integer"));
}
}

+ Here is the caller graph for this function:

ilObjPoll::deleteImage ( )

remove existing file

Definition at line 335 of file class.ilObjPoll.php.

References setImage().

Referenced by doDelete(), and uploadImage().

{
if($this->id)
{
include_once "Modules/Poll/classes/class.ilFSStoragePoll.php";
$storage = new ilFSStoragePoll($this->id);
$storage->delete();
$this->setImage(null);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjPoll::doCloneObject ( ilObjPoll  $new_obj,
  $a_target_id,
  $a_copy_id = 0 
)

Clone poll.

Parameters
ilObjPollnew object
inttarget ref_id
intcopy id
Returns
ilObjPoll

Definition at line 278 of file class.ilObjPoll.php.

References $image, getAnswers(), getImage(), getImageFullPath(), getQuestion(), getViewResults(), saveAnswer(), setQuestion(), setViewResults(), ilObject2\update(), and uploadImage().

{
// question/image
$new_obj->setQuestion($this->getQuestion());
if($image)
{
$image = array("tmp_name"=>$image,
"name"=>$this->getImage());
$new_obj->uploadImage($image, true);
}
$new_obj->setViewResults($this->getViewResults());
$new_obj->update();
// answers
$answers = $this->getAnswers();
if($answers)
{
foreach($answers as $item)
{
$new_obj->saveAnswer($item["answer"]);
}
}
return $new_obj;
}

+ Here is the call graph for this function:

ilObjPoll::doCreate ( )
protected

Reimplemented from ilObject2.

Definition at line 201 of file class.ilObjPoll.php.

References ilObject2\getId(), and propertiesToDB().

{
global $ilDB;
if($this->getId())
{
$fields = $this->propertiesToDB();
$fields["id"] = array("integer", $this->getId());
$ilDB->insert("il_poll", $fields);
// object activation default entry will be created on demand
// block handling
include_once "Modules/Poll/classes/class.ilPollBlock.php";
$block = new ilPollBlock();
$block->setType("poll");
$block->setContextObjId($this->getId());
$block->setContextObjType("poll");
$block->create();
}
}

+ Here is the call graph for this function:

ilObjPoll::doDelete ( )
protected

Reimplemented from ilObject2.

Definition at line 251 of file class.ilObjPoll.php.

References deleteAllAnswers(), ilObjectActivation\deleteAllEntries(), deleteImage(), and ilObject2\getId().

{
global $ilDB;
if($this->getId())
{
$this->deleteImage();
$this->deleteAllAnswers();
if($this->ref_id)
{
}
$ilDB->manipulate("DELETE FROM il_poll".
" WHERE id = ".$ilDB->quote($this->id, "integer"));
}
}

+ Here is the call graph for this function:

ilObjPoll::doRead ( )
protected

Reimplemented from ilObject2.

Definition at line 161 of file class.ilObjPoll.php.

References $row, ilObjectActivation\getItem(), setAccessBegin(), setAccessEnd(), setAccessType(), setAccessVisibility(), setImage(), setOnline(), setQuestion(), setViewResults(), setVotingPeriod(), setVotingPeriodBegin(), and setVotingPeriodEnd().

{
global $ilDB;
$set = $ilDB->query("SELECT * FROM il_poll".
" WHERE id = ".$ilDB->quote($this->getId(), "integer"));
$row = $ilDB->fetchAssoc($set);
$this->setQuestion($row["question"]);
$this->setImage($row["image"]);
$this->setOnline($row["online_status"]);
$this->setViewResults($row["view_results"]);
$this->setVotingPeriod($row["period"]);
$this->setVotingPeriodBegin($row["period_begin"]);
$this->setVotingPeriodEnd($row["period_end"]);
if($this->ref_id)
{
$activation = ilObjectActivation::getItem($this->ref_id);
$this->setAccessType($activation["timing_type"]);
$this->setAccessBegin($activation["timing_start"]);
$this->setAccessEnd($activation["timing_end"]);
$this->setAccessVisibility($activation["visible"]);
}
}

+ Here is the call graph for this function:

ilObjPoll::doUpdate ( )
protected

Reimplemented from ilObject2.

Definition at line 226 of file class.ilObjPoll.php.

References getAccessBegin(), getAccessEnd(), getAccessType(), getAccessVisibility(), ilObject2\getId(), and propertiesToDB().

{
global $ilDB;
if($this->getId())
{
$fields = $this->propertiesToDB();
$ilDB->update("il_poll", $fields,
array("id"=>array("integer", $this->getId())));
if($this->ref_id)
{
$activation = new ilObjectActivation();
$activation->setTimingType($this->getAccessType());
$activation->setTimingStart($this->getAccessBegin());
$activation->setTimingEnd($this->getAccessEnd());
$activation->toggleVisible($this->getAccessVisibility());
$activation->update($this->ref_id);
}
}
}

+ Here is the call graph for this function:

ilObjPoll::getAccessBegin ( )

Definition at line 76 of file class.ilObjPoll.php.

References $access_begin.

Referenced by doUpdate().

{
}

+ Here is the caller graph for this function:

ilObjPoll::getAccessEnd ( )

Definition at line 86 of file class.ilObjPoll.php.

References $access_end.

Referenced by doUpdate().

{
}

+ Here is the caller graph for this function:

ilObjPoll::getAccessType ( )

Definition at line 66 of file class.ilObjPoll.php.

References $access_type.

Referenced by doUpdate().

{
}

+ Here is the caller graph for this function:

ilObjPoll::getAccessVisibility ( )

Definition at line 96 of file class.ilObjPoll.php.

References $access_visibility.

Referenced by doUpdate().

+ Here is the caller graph for this function:

ilObjPoll::getAnswer (   $a_id)

Definition at line 454 of file class.ilObjPoll.php.

{
global $ilDB;
$sql = "SELECT * FROM il_poll_answer".
" WHERE id = ".$ilDB->quote($a_id, "integer");
$set = $ilDB->query($sql);
return (array)$ilDB->fetchAssoc($set);
}
ilObjPoll::getAnswers ( )

Definition at line 437 of file class.ilObjPoll.php.

References $res, $row, and ilObject2\getId().

Referenced by doCloneObject(), rebuildAnswerPositions(), and saveAnswers().

{
global $ilDB;
$res = array();
$sql = "SELECT * FROM il_poll_answer".
" WHERE poll_id = ".$ilDB->quote($this->getId(), "integer").
" ORDER BY pos ASC";
$set = $ilDB->query($sql);
while($row = $ilDB->fetchAssoc($set))
{
$res[] = $row;
}
return $res;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjPoll::getImage ( )

Definition at line 116 of file class.ilObjPoll.php.

References $image.

Referenced by doCloneObject(), getImageFullPath(), and propertiesToDB().

{
return $this->image;
}

+ Here is the caller graph for this function:

ilObjPoll::getImageFullPath (   $a_as_thumb = false)

Get image incl.

path

Parameters
bool$a_as_thumb

Definition at line 315 of file class.ilObjPoll.php.

References $img, $path, getImage(), and initStorage().

Referenced by doCloneObject().

{
$img = $this->getImage();
if($img)
{
$path = $this->initStorage($this->id);
if(!$a_as_thumb)
{
return $path.$img;
}
else
{
return $path."thb_".$img;
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilObjPoll::getImageSize ( )
static

Definition at line 426 of file class.ilObjPoll.php.

{
// :TODO:
return "300x300";
}
ilObjPoll::getQuestion ( )

Definition at line 106 of file class.ilObjPoll.php.

References $question.

Referenced by doCloneObject(), and propertiesToDB().

{
}

+ Here is the caller graph for this function:

ilObjPoll::getViewResults ( )

Definition at line 126 of file class.ilObjPoll.php.

References $view_results.

Referenced by doCloneObject(), and propertiesToDB().

{
}

+ Here is the caller graph for this function:

ilObjPoll::getVotePercentages ( )

Definition at line 672 of file class.ilObjPoll.php.

References ilObject\$id, $res, $row, and ilObject2\getId().

{
global $ilDB;
$res = array();
$cnt = 0;
$sql = "SELECT answer_id, count(*) cnt".
" FROM il_poll_vote".
" WHERE poll_id = ".$ilDB->quote($this->getId(), "integer").
" GROUP BY answer_id";
$set = $ilDB->query($sql);
while($row = $ilDB->fetchAssoc($set))
{
$cnt += $row["cnt"];
$res[$row["answer_id"]] = array("abs"=>$row["cnt"], "perc"=>0);
}
foreach($res as $id => $item)
{
$res[$id]["perc"] = $item["abs"]/$cnt*100;
}
return array("perc"=>$res, "total"=>$cnt);
}

+ Here is the call graph for this function:

ilObjPoll::getVotingPeriod ( )

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

References $period.

Referenced by propertiesToDB().

{
return $this->period;
}

+ Here is the caller graph for this function:

ilObjPoll::getVotingPeriodBegin ( )

Definition at line 146 of file class.ilObjPoll.php.

References $period_begin.

Referenced by propertiesToDB().

{
}

+ Here is the caller graph for this function:

ilObjPoll::getVotingPeriodEnd ( )

Definition at line 156 of file class.ilObjPoll.php.

References $period_end.

Referenced by propertiesToDB().

{
}

+ Here is the caller graph for this function:

ilObjPoll::hasUserVoted (   $a_user_id)

Definition at line 648 of file class.ilObjPoll.php.

References ilObject2\getId().

Referenced by saveVote().

{
global $ilDB;
$sql = "SELECT user_id".
" FROM il_poll_vote".
" WHERE poll_id = ".$ilDB->quote($this->getId(), "integer").
" AND user_id = ".$ilDB->quote($a_user_id, "integer");
$set = $ilDB->query($sql);
return (bool)$ilDB->numRows($set);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilObjPoll::initStorage (   $a_id,
  $a_subdir = null 
)
static

Init file system storage.

Parameters
type$a_id
type$a_subdir
Returns
string

Definition at line 354 of file class.ilObjPoll.php.

References $path.

Referenced by getImageFullPath(), ilPollDataSet\getXmlRecord(), ilPollDataSet\importRecord(), and uploadImage().

{
include_once "Modules/Poll/classes/class.ilFSStoragePoll.php";
$storage = new ilFSStoragePoll($a_id);
$storage->create();
$path = $storage->getAbsolutePath()."/";
if($a_subdir)
{
$path .= $a_subdir."/";
if(!is_dir($path))
{
mkdir($path);
}
}
return $path;
}

+ Here is the caller graph for this function:

ilObjPoll::initType ( )

Reimplemented from ilObject2.

Definition at line 46 of file class.ilObjPoll.php.

{
$this->type = "poll";
}
ilObjPoll::isOnline ( )

Definition at line 56 of file class.ilObjPoll.php.

References $online.

Referenced by propertiesToDB().

{
return $this->online;
}

+ Here is the caller graph for this function:

ilObjPoll::propertiesToDB ( )
protected

Definition at line 186 of file class.ilObjPoll.php.

References getImage(), getQuestion(), getViewResults(), getVotingPeriod(), getVotingPeriodBegin(), getVotingPeriodEnd(), and isOnline().

Referenced by doCreate(), and doUpdate().

{
$fields = array(
"question" => array("text", $this->getQuestion()),
"image" => array("text", $this->getImage()),
"online_status" => array("integer", $this->isOnline()),
"view_results" => array("integer", $this->getViewResults()),
"period" => array("integer", $this->getVotingPeriod()),
"period_begin" => array("integer", $this->getVotingPeriodBegin()),
"period_end" => array("integer", $this->getVotingPeriodEnd())
);
return $fields;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjPoll::rebuildAnswerPositions ( )

Definition at line 506 of file class.ilObjPoll.php.

References getAnswers(), and updateAnswerPositions().

{
$answers = $this->getAnswers();
$pos = array();
foreach($answers as $item)
{
$pos[$item["id"]] = $item["pos"];
}
$this->updateAnswerPositions($pos);
}

+ Here is the call graph for this function:

ilObjPoll::saveAnswer (   $a_text,
  $a_pos = null 
)

Definition at line 464 of file class.ilObjPoll.php.

References ilObject\$id, and ilObject2\getId().

Referenced by doCloneObject(), and saveAnswers().

{
global $ilDB;
if(!trim($a_text))
{
return;
}
$id = $ilDB->nextId("il_poll_answer");
if(!$a_pos)
{
// append
$sql = "SELECT max(pos) pos".
" FROM il_poll_answer".
" WHERE poll_id = ".$ilDB->quote($this->getId(), "integer");
$set = $ilDB->query($sql);
$a_pos = $ilDB->fetchAssoc($set);
$a_pos = (int)$a_pos["pos"]+10;
}
$fields = array(
"id" => array("integer", $id),
"poll_id" => array("integer", $this->getId()),
"answer" => array("text", trim($a_text)),
"pos" => array("integer", $a_pos)
);
$ilDB->insert("il_poll_answer", $fields);
return $id;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjPoll::saveAnswers ( array  $a_answers)

Definition at line 574 of file class.ilObjPoll.php.

References ilObject\$id, deleteAnswer(), getAnswers(), saveAnswer(), and updateAnswerPositions().

{
$existing = $this->getAnswers();
$ids = array();
$pos = 0;
foreach($a_answers as $answer)
{
if(trim($answer))
{
// existing answer?
$found = false;
foreach($existing as $idx => $item)
{
if(trim($answer) == $item["answer"])
{
$found = true;
unset($existing[$idx]);
$id = $item["id"];
}
}
// create new answer
if(!$found)
{
$id = $this->saveAnswer($answer);
}
// add existing answer id to order
if($id)
{
$ids[$id] = ++$pos;
}
}
}
// remove obsolete answers
if(sizeof($existing))
{
foreach($existing as $item)
{
$this->deleteAnswer($item["id"]);
}
}
// save current order
if(sizeof($ids))
{
$this->updateAnswerPositions($ids);
}
}

+ Here is the call graph for this function:

ilObjPoll::saveVote (   $a_user_id,
  $a_answer_id 
)

Definition at line 632 of file class.ilObjPoll.php.

References ilObject2\getId(), and hasUserVoted().

{
global $ilDB;
if($this->hasUserVoted($a_user_id))
{
return;
}
$fields = array("user_id" => array("integer", $a_user_id),
"poll_id" => array("integer", $this->getId()),
"answer_id" => array("integer", $a_answer_id));
$ilDB->insert("il_poll_vote", $fields);
}

+ Here is the call graph for this function:

ilObjPoll::setAccessBegin (   $a_value)

Definition at line 71 of file class.ilObjPoll.php.

Referenced by doRead().

{
$this->access_begin = (int)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::setAccessEnd (   $a_value)

Definition at line 81 of file class.ilObjPoll.php.

Referenced by doRead().

{
$this->access_end = (int)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::setAccessType (   $a_value)

Definition at line 61 of file class.ilObjPoll.php.

Referenced by __construct(), and doRead().

{
$this->access_type = (int)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::setAccessVisibility (   $a_value)

Definition at line 91 of file class.ilObjPoll.php.

Referenced by doRead().

{
$this->access_visibility = (bool)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::setImage (   $a_value)

Definition at line 111 of file class.ilObjPoll.php.

Referenced by deleteImage(), doRead(), and uploadImage().

{
$this->image = (string)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::setOnline (   $a_value)

Definition at line 51 of file class.ilObjPoll.php.

Referenced by __construct(), and doRead().

{
$this->online = (bool)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::setQuestion (   $a_value)

Definition at line 101 of file class.ilObjPoll.php.

Referenced by doCloneObject(), and doRead().

{
$this->question = (string)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::setViewResults (   $a_value)

Definition at line 121 of file class.ilObjPoll.php.

Referenced by __construct(), doCloneObject(), and doRead().

{
$this->view_results = (int)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::setVotingPeriod (   $a_value)

Definition at line 131 of file class.ilObjPoll.php.

Referenced by __construct(), and doRead().

{
$this->period = (bool)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::setVotingPeriodBegin (   $a_value)

Definition at line 141 of file class.ilObjPoll.php.

Referenced by doRead().

{
$this->period_begin = (int)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::setVotingPeriodEnd (   $a_value)

Definition at line 151 of file class.ilObjPoll.php.

Referenced by doRead().

{
$this->period_end = (int)$a_value;
}

+ Here is the caller graph for this function:

ilObjPoll::updateAnswer (   $a_id,
  $a_text 
)

Definition at line 497 of file class.ilObjPoll.php.

{
global $ilDB;
$ilDB->update("il_poll_answer",
array("answer" => array("text", $a_text)),
array("id" => array("integer", $a_id)));
}
ilObjPoll::updateAnswerPositions ( array  $a_pos)

Definition at line 519 of file class.ilObjPoll.php.

References ilObject\$id.

Referenced by rebuildAnswerPositions(), and saveAnswers().

{
global $ilDB;
asort($a_pos);
$pos = 0;
foreach(array_keys($a_pos) as $id)
{
$pos += 10;
$ilDB->update("il_poll_answer",
array("pos" => array("integer", $pos)),
array("id" => array("integer", $id)));
}
}

+ Here is the caller graph for this function:

ilObjPoll::uploadImage ( array  $a_upload,
  $a_clone = false 
)

Upload new image file.

Parameters
array$a_upload
Returns
bool

Definition at line 381 of file class.ilObjPoll.php.

References $path, $success, deleteImage(), ilUtil\escapeShellArg(), ilUtil\execConvert(), initStorage(), and setImage().

Referenced by doCloneObject().

{
if(!$this->id)
{
return false;
}
$this->deleteImage();
// #10074
$clean_name = preg_replace("/[^a-zA-Z0-9\_\.\-]/", "", $a_upload["name"]);
$path = $this->initStorage($this->id);
$original = "org_".$this->id."_".$clean_name;
$thumb = "thb_".$this->id."_".$clean_name;
$processed = $this->id."_".$clean_name;
$success = false;
if(!$a_clone)
{
$success = @move_uploaded_file($a_upload["tmp_name"], $path.$original);
}
else
{
$success = @copy($a_upload["tmp_name"], $path.$original);
}
{
chmod($path.$original, 0770);
// take quality 100 to avoid jpeg artefacts when uploading jpeg files
// taking only frame [0] to avoid problems with animated gifs
$original_file = ilUtil::escapeShellArg($path.$original);
$thumb_file = ilUtil::escapeShellArg($path.$thumb);
$processed_file = ilUtil::escapeShellArg($path.$processed);
ilUtil::execConvert($original_file."[0] -geometry \"100x100>\" -quality 100 PNG:".$thumb_file);
ilUtil::execConvert($original_file."[0] -geometry \"".self::getImageSize().">\" -quality 100 PNG:".$processed_file);
$this->setImage($processed);
return true;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilObjPoll::$access_begin
protected

Definition at line 20 of file class.ilObjPoll.php.

Referenced by getAccessBegin().

ilObjPoll::$access_end
protected

Definition at line 21 of file class.ilObjPoll.php.

Referenced by getAccessEnd().

ilObjPoll::$access_type
protected

Definition at line 19 of file class.ilObjPoll.php.

Referenced by getAccessType().

ilObjPoll::$access_visibility
protected

Definition at line 22 of file class.ilObjPoll.php.

Referenced by getAccessVisibility().

ilObjPoll::$image
protected

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

Referenced by doCloneObject(), and getImage().

ilObjPoll::$online
protected

Definition at line 18 of file class.ilObjPoll.php.

Referenced by isOnline().

ilObjPoll::$period
protected

Definition at line 26 of file class.ilObjPoll.php.

Referenced by getVotingPeriod().

ilObjPoll::$period_begin
protected

Definition at line 27 of file class.ilObjPoll.php.

Referenced by getVotingPeriodBegin().

ilObjPoll::$period_end
protected

Definition at line 28 of file class.ilObjPoll.php.

Referenced by getVotingPeriodEnd().

ilObjPoll::$question
protected

Definition at line 23 of file class.ilObjPoll.php.

Referenced by getQuestion().

ilObjPoll::$view_results
protected

Definition at line 25 of file class.ilObjPoll.php.

Referenced by getViewResults().

const ilObjPoll::VIEW_RESULTS_AFTER_PERIOD = 4
const ilObjPoll::VIEW_RESULTS_AFTER_VOTE = 3
const ilObjPoll::VIEW_RESULTS_ALWAYS = 1
const ilObjPoll::VIEW_RESULTS_NEVER = 2

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