ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 @access public. More...
 
 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 ()
 
 setMaxNumberOfAnswers ($a_value)
 
 getMaxNumberOfAnswers ()
 
 setSortResultByVotes ($a_value)
 
 getSortResultByVotes ()
 
 setNonAnonymous ($a_value)
 
 getNonAnonymous ()
 
 setShowComments ($a_value)
 
 getShowComments ()
 
 setShowResultsAs ($a_value)
 
 getShowResultsAs ()
 
 doCloneObject (ilObjPoll $new_obj, $a_target_id, $a_copy_id=0)
 Clone poll. More...
 
 getImageFullPath ($a_as_thumb=false)
 Get image incl. More...
 
 deleteImage ()
 remove existing file More...
 
 uploadImage (array $a_upload, $a_clone=false)
 Upload new image file. More...
 
 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_answers)
 
 hasUserVoted ($a_user_id)
 
 countVotes ()
 
 getVotePercentages ()
 
 getVotesByUsers ()
 
- Public Member Functions inherited from ilObject2
 __construct ($a_id=0, $a_reference=true)
 Constructor @access public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ($a_force_db=false)
 Read data from db. More...
 
 getId ()
 get object id @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) More...
 
 create ($a_clone_mode=false)
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _lookupOwner ($a_id)
 lookup object owner More...
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
 _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 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!! More...
 
 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) @access public More...
 
 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. More...
 
 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. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 cloneObject ($a_target_id, $a_copy_id=null, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor @access public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ($a_force_db=false)
 read object data from db into object More...
 
 getId ()
 get object id @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _lookupOwner ($a_id)
 lookup object owner More...
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
 _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 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!! More...
 
 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) @access public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 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. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

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

Data Fields

const VIEW_RESULTS_ALWAYS = 1
 
const VIEW_RESULTS_NEVER = 2
 
const VIEW_RESULTS_AFTER_VOTE = 3
 
const VIEW_RESULTS_AFTER_PERIOD = 4
 
const SHOW_RESULTS_AS_BARCHART = 1
 
const SHOW_RESULTS_AS_PIECHART = 2
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $ilias
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 
 $obj_data_record
 object_data record More...
 

Protected Member Functions

 doRead ()
 
 propertiesToDB ()
 
 doCreate ()
 
 doUpdate ()
 
 doDelete ()
 
 deleteAllAnswers ()
 
- Protected Member Functions inherited from ilObject2
 initType ()
 
 doRead ()
 
 doCreate ()
 
 beforeCreate ()
 
 doUpdate ()
 
 beforeUpdate ()
 
 doMDUpdateListener ($a_element)
 
 beforeMDUpdateListener ($a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDelete ()
 
 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
 
 $max_number_answers = 1
 
 $result_sort_by_votes = false
 
 $mode_non_anonymous = false
 
 $show_comments = false
 
 $show_results_as = 1
 

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

◆ __construct()

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

Constructor @access public.

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

Reimplemented from ilObject2.

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

46 {
47 // default
48 $this->setOnline(false);
49 $this->setViewResults(self::VIEW_RESULTS_AFTER_VOTE);
51 $this->setVotingPeriod(false);
52
53 parent::__construct($a_id, $a_reference);
54 }
setVotingPeriod($a_value)
setAccessType($a_value)
setOnline($a_value)
setViewResults($a_value)

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

+ Here is the call graph for this function:

Member Function Documentation

◆ countVotes()

ilObjPoll::countVotes ( )

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

757 {
758 global $ilDB;
759
760 $sql = "SELECT COUNT(DISTINCT(user_id)) cnt".
761 " FROM il_poll_vote".
762 " WHERE poll_id = ".$ilDB->quote($this->getId(), "integer");
763 $set = $ilDB->query($sql);
764 $row = $ilDB->fetchAssoc($set);
765 return (int)$row["cnt"];
766 }
getId()
get object id @access public
global $ilDB

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

Referenced by getVotePercentages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAllAnswers()

ilObjPoll::deleteAllAnswers ( )
protected

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

637 {
638 global $ilDB;
639
640 if($this->getId())
641 {
642 $this->deleteAllVotes();
643
644 $ilDB->manipulate("DELETE FROM il_poll_answer".
645 " WHERE poll_id = ".$ilDB->quote($this->getId(), "integer"));
646 }
647 }

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

Referenced by doDelete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAllVotes()

ilObjPoll::deleteAllVotes ( )

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

650 {
651 global $ilDB;
652
653 if($this->getId())
654 {
655 $ilDB->manipulate("DELETE FROM il_poll_vote".
656 " WHERE poll_id = ".$ilDB->quote($this->getId(), "integer"));
657 }
658 }

References $ilDB, and ilObject2\getId().

Referenced by deleteAllAnswers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAnswer()

ilObjPoll::deleteAnswer (   $a_id)

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

623 {
624 global $ilDB;
625
626 if($a_id)
627 {
628 $ilDB->manipulate("DELETE FROM il_poll_vote".
629 " WHERE answer_id = ".$ilDB->quote($this->getId(), "integer"));
630
631 $ilDB->manipulate("DELETE FROM il_poll_answer".
632 " WHERE id = ".$ilDB->quote($a_id, "integer"));
633 }
634 }

References $ilDB.

Referenced by saveAnswers().

+ Here is the caller graph for this function:

◆ deleteImage()

ilObjPoll::deleteImage ( )

remove existing file

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

422 {
423 if($this->id)
424 {
425 include_once "Modules/Poll/classes/class.ilFSStoragePoll.php";
426 $storage = new ilFSStoragePoll($this->id);
427 $storage->delete();
428
429 $this->setImage(null);
430 }
431 }
setImage($a_value)

References setImage().

Referenced by doDelete(), and uploadImage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doCloneObject()

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 353 of file class.ilObjPoll.php.

354 {
355 // question/image
356 $new_obj->setQuestion($this->getQuestion());
357 $image = $this->getImageFullPath();
358 if($image)
359 {
360 $image = array("tmp_name"=>$image,
361 "name"=>$this->getImage());
362 $new_obj->uploadImage($image, true);
363 }
364
365 //copy online status if object is not the root copy object
366 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
367
368 if(!$cp_options->isRootNode($this->getRefId()))
369 {
370 $new_obj->setOnline($this->isOnline());
371 }
372
373 $new_obj->setViewResults($this->getViewResults());
374 $new_obj->setShowComments($this->getShowComments());
375 $new_obj->setShowResultsAs($this->getShowResultsAs());
376 $new_obj->update();
377
378 // answers
379 $answers = $this->getAnswers();
380 if($answers)
381 {
382 foreach($answers as $item)
383 {
384 $new_obj->saveAnswer($item["answer"]);
385 }
386 }
387
388 return $new_obj;
389 }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
setShowResultsAs($a_value)
uploadImage(array $a_upload, $a_clone=false)
Upload new image file.
setQuestion($a_value)
saveAnswer($a_text, $a_pos=null)
setShowComments($a_value)
getImageFullPath($a_as_thumb=false)
Get image incl.
update()
update object in db

References $image, ilCopyWizardOptions\_getInstance(), getAnswers(), getImage(), getImageFullPath(), getQuestion(), getShowComments(), getShowResultsAs(), getViewResults(), isOnline(), saveAnswer(), setOnline(), setQuestion(), setShowComments(), setShowResultsAs(), setViewResults(), ilObject2\update(), and uploadImage().

+ Here is the call graph for this function:

◆ doCreate()

ilObjPoll::doCreate ( )
protected

Reimplemented from ilObject2.

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

274 {
275 global $ilDB;
276
277 if($this->getId())
278 {
279 $fields = $this->propertiesToDB();
280 $fields["id"] = array("integer", $this->getId());
281
282 $ilDB->insert("il_poll", $fields);
283
284
285 // object activation default entry will be created on demand
286
287
288 // block handling
289 include_once "Modules/Poll/classes/class.ilPollBlock.php";
290 $block = new ilPollBlock();
291 $block->setType("poll");
292 $block->setContextObjId($this->getId());
293 $block->setContextObjType("poll");
294 $block->create();
295 }
296 }
Custom block for polls.

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

+ Here is the call graph for this function:

◆ doDelete()

ilObjPoll::doDelete ( )
protected

Reimplemented from ilObject2.

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

327 {
328 global $ilDB;
329
330 if($this->getId())
331 {
332 $this->deleteImage();
333 $this->deleteAllAnswers();
334
335 if($this->ref_id)
336 {
338 }
339
340 $ilDB->manipulate("DELETE FROM il_poll".
341 " WHERE id = ".$ilDB->quote($this->id, "integer"));
342 }
343 }
deleteImage()
remove existing file
static deleteAllEntries($a_ref_id)
Delete all db entries for ref id.

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

+ Here is the call graph for this function:

◆ doRead()

ilObjPoll::doRead ( )
protected

Reimplemented from ilObject2.

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

222 {
223 global $ilDB;
224
225 $set = $ilDB->query("SELECT * FROM il_poll".
226 " WHERE id = ".$ilDB->quote($this->getId(), "integer"));
227 $row = $ilDB->fetchAssoc($set);
228 $this->setQuestion($row["question"]);
229 $this->setImage($row["image"]);
230 $this->setOnline($row["online_status"]);
231 $this->setViewResults($row["view_results"]);
232 $this->setVotingPeriod($row["period"]);
233 $this->setVotingPeriodBegin($row["period_begin"]);
234 $this->setVotingPeriodEnd($row["period_end"]);
235 $this->setMaxNumberOfAnswers($row["max_answers"]);
236 $this->setSortResultByVotes($row["result_sort"]);
237 $this->setNonAnonymous($row["non_anon"]);
238 $this->setShowResultsAs($row["show_results_as"]);
239
240 // #14661
241 include_once("./Services/Notes/classes/class.ilNote.php");
242 $this->setShowComments(ilNote::commentsActivated($this->getId(), 0, $this->getType()));
243
244 if($this->ref_id)
245 {
246 $activation = ilObjectActivation::getItem($this->ref_id);
247 $this->setAccessType($activation["timing_type"]);
248 $this->setAccessBegin($activation["timing_start"]);
249 $this->setAccessEnd($activation["timing_end"]);
250 $this->setAccessVisibility($activation["visible"]);
251 }
252 }
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
setNonAnonymous($a_value)
setVotingPeriodBegin($a_value)
setAccessBegin($a_value)
setMaxNumberOfAnswers($a_value)
setAccessEnd($a_value)
setSortResultByVotes($a_value)
setVotingPeriodEnd($a_value)
setAccessVisibility($a_value)
getType()
get object type @access public
static getItem($a_ref_id)
Get item data.

References $ilDB, $row, ilNote\commentsActivated(), ilObject2\getId(), ilObjectActivation\getItem(), ilObject2\getType(), setAccessBegin(), setAccessEnd(), setAccessType(), setAccessVisibility(), setImage(), setMaxNumberOfAnswers(), setNonAnonymous(), setOnline(), setQuestion(), setShowComments(), setShowResultsAs(), setSortResultByVotes(), setViewResults(), setVotingPeriod(), setVotingPeriodBegin(), and setVotingPeriodEnd().

+ Here is the call graph for this function:

◆ doUpdate()

ilObjPoll::doUpdate ( )
protected

Reimplemented from ilObject2.

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

299 {
300 global $ilDB;
301
302 if($this->getId())
303 {
304 $fields = $this->propertiesToDB();
305
306 $ilDB->update("il_poll", $fields,
307 array("id"=>array("integer", $this->getId())));
308
309 // #14661
310 include_once("./Services/Notes/classes/class.ilNote.php");
311 ilNote::activateComments($this->getId(), 0, $this->getType(), $this->getShowComments());
312
313 if($this->ref_id)
314 {
315 $activation = new ilObjectActivation();
316 $activation->setTimingType($this->getAccessType());
317 $activation->setTimingStart($this->getAccessBegin());
318 $activation->setTimingEnd($this->getAccessEnd());
319 $activation->toggleVisible($this->getAccessVisibility());
320 $activation->update($this->ref_id);
321 }
322
323 }
324 }
static activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
Activate notes feature.
Class ilObjectActivation.

References $ilDB, ilNote\activateComments(), getAccessBegin(), getAccessEnd(), getAccessType(), getAccessVisibility(), ilObject2\getId(), getShowComments(), ilObject2\getType(), and propertiesToDB().

+ Here is the call graph for this function:

◆ getAccessBegin()

ilObjPoll::getAccessBegin ( )

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

87 {
89 }

References $access_begin.

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getAccessEnd()

ilObjPoll::getAccessEnd ( )

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

97 {
98 return $this->access_end;
99 }

References $access_end.

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getAccessType()

ilObjPoll::getAccessType ( )

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

77 {
78 return $this->access_type;
79 }

References $access_type.

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getAccessVisibility()

ilObjPoll::getAccessVisibility ( )

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

107 {
109 }

References $access_visibility.

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getAnswer()

ilObjPoll::getAnswer (   $a_id)

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

541 {
542 global $ilDB;
543
544 $sql = "SELECT * FROM il_poll_answer".
545 " WHERE id = ".$ilDB->quote($a_id, "integer");
546 $set = $ilDB->query($sql);
547 return (array)$ilDB->fetchAssoc($set);
548 }

References $ilDB.

◆ getAnswers()

ilObjPoll::getAnswers ( )

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

524 {
525 global $ilDB;
526
527 $res = array();
528
529 $sql = "SELECT * FROM il_poll_answer".
530 " WHERE poll_id = ".$ilDB->quote($this->getId(), "integer").
531 " ORDER BY pos ASC";
532 $set = $ilDB->query($sql);
533 while($row = $ilDB->fetchAssoc($set))
534 {
535 $res[] = $row;
536 }
537 return $res;
538 }

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImage()

ilObjPoll::getImage ( )

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

127 {
128 return $this->image;
129 }

References $image.

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

+ Here is the caller graph for this function:

◆ getImageFullPath()

ilObjPoll::getImageFullPath (   $a_as_thumb = false)

Get image incl.

path

Parameters
bool$a_as_thumb

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

402 {
403 $img = $this->getImage();
404 if($img)
405 {
406 $path = $this->initStorage($this->id);
407 if(!$a_as_thumb)
408 {
409 return $path.$img;
410 }
411 else
412 {
413 return $path."thb_".$img;
414 }
415 }
416 }
static initStorage($a_id, $a_subdir=null)
Init file system storage.
$path
Definition: index.php:22

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

Referenced by doCloneObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImageSize()

static ilObjPoll::getImageSize ( )
static

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

513 {
514 // :TODO:
515 return "300x300";
516 }

◆ getMaxNumberOfAnswers()

ilObjPoll::getMaxNumberOfAnswers ( )

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

177 {
179 }

References $max_number_answers.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getNonAnonymous()

ilObjPoll::getNonAnonymous ( )

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

197 {
199 }

References $mode_non_anonymous.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getQuestion()

ilObjPoll::getQuestion ( )

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

117 {
118 return $this->question;
119 }

References $question.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getShowComments()

ilObjPoll::getShowComments ( )

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

207 {
209 }

References $show_comments.

Referenced by doCloneObject(), and doUpdate().

+ Here is the caller graph for this function:

◆ getShowResultsAs()

ilObjPoll::getShowResultsAs ( )

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

217 {
219 }

References $show_results_as.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getSortResultByVotes()

ilObjPoll::getSortResultByVotes ( )

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

187 {
189 }

References $result_sort_by_votes.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getViewResults()

ilObjPoll::getViewResults ( )

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

137 {
138 return $this->view_results;
139 }

References $view_results.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getVotePercentages()

ilObjPoll::getVotePercentages ( )

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

769 {
770 global $ilDB;
771
772 $res = array();
773 $cnt = 0;
774
775 $sql = "SELECT answer_id, count(*) cnt".
776 " FROM il_poll_vote".
777 " WHERE poll_id = ".$ilDB->quote($this->getId(), "integer").
778 " GROUP BY answer_id";
779 $set = $ilDB->query($sql);
780 while($row = $ilDB->fetchAssoc($set))
781 {
782 $cnt += $row["cnt"];
783 $res[$row["answer_id"]] = array("abs"=>$row["cnt"], "perc"=>0);
784 }
785
786 foreach($res as $id => $item)
787 {
788 $res[$id]["perc"] = $item["abs"]/$cnt*100;
789 }
790
791 return array("perc"=>$res, "total"=>$this->countVotes());
792 }

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

+ Here is the call graph for this function:

◆ getVotesByUsers()

ilObjPoll::getVotesByUsers ( )

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

795 {
796 global $ilDB;
797
798 $res = array();
799
800 $sql = "SELECT answer_id, user_id, firstname, lastname, login".
801 " FROM il_poll_vote".
802 " JOIN usr_data ON (usr_data.usr_id = il_poll_vote.user_id)".
803 " WHERE poll_id = ".$ilDB->quote($this->getId(), "integer");
804 $set = $ilDB->query($sql);
805 while($row = $ilDB->fetchAssoc($set))
806 {
807 if(!isset($res[$row["user_id"]]))
808 {
809 $res[$row["user_id"]] = $row;
810 }
811 $res[$row["user_id"]]["answers"][] = $row["answer_id"];
812 }
813
814 return $res;
815 }

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

+ Here is the call graph for this function:

◆ getVotingPeriod()

ilObjPoll::getVotingPeriod ( )

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

147 {
148 return $this->period;
149 }

References $period.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getVotingPeriodBegin()

ilObjPoll::getVotingPeriodBegin ( )

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

157 {
158 return $this->period_begin;
159 }

References $period_begin.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getVotingPeriodEnd()

ilObjPoll::getVotingPeriodEnd ( )

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

167 {
168 return $this->period_end;
169 }

References $period_end.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ hasUserVoted()

ilObjPoll::hasUserVoted (   $a_user_id)

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

744 {
745 global $ilDB;
746
747 $sql = "SELECT user_id".
748 " FROM il_poll_vote".
749 " WHERE poll_id = ".$ilDB->quote($this->getId(), "integer").
750 " AND user_id = ".$ilDB->quote($a_user_id, "integer");
751 $ilDB->setLimit(1);
752 $set = $ilDB->query($sql);
753 return (bool)$ilDB->numRows($set);
754 }

References $ilDB, and ilObject2\getId().

Referenced by saveVote().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initStorage()

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 440 of file class.ilObjPoll.php.

441 {
442 include_once "Modules/Poll/classes/class.ilFSStoragePoll.php";
443 $storage = new ilFSStoragePoll($a_id);
444 $storage->create();
445
446 $path = $storage->getAbsolutePath()."/";
447
448 if($a_subdir)
449 {
450 $path .= $a_subdir."/";
451
452 if(!is_dir($path))
453 {
454 mkdir($path);
455 }
456 }
457
458 return $path;
459 }

References $path.

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

+ Here is the caller graph for this function:

◆ initType()

ilObjPoll::initType ( )

Reimplemented from ilObject2.

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

57 {
58 $this->type = "poll";
59 }

◆ isOnline()

ilObjPoll::isOnline ( )

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

67 {
68 return $this->online;
69 }

References $online.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ propertiesToDB()

ilObjPoll::propertiesToDB ( )
protected

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

255 {
256 $fields = array(
257 "question" => array("text", $this->getQuestion()),
258 "image" => array("text", $this->getImage()),
259 "online_status" => array("integer", $this->isOnline()),
260 "view_results" => array("integer", $this->getViewResults()),
261 "period" => array("integer", $this->getVotingPeriod()),
262 "period_begin" => array("integer", $this->getVotingPeriodBegin()),
263 "period_end" => array("integer", $this->getVotingPeriodEnd()),
264 "max_answers" => array("integer", $this->getMaxNumberOfAnswers()),
265 "result_sort" => array("integer", $this->getSortResultByVotes()),
266 "non_anon" => array("integer", $this->getNonAnonymous()),
267 "show_results_as" => array("integer", $this->getShowResultsAs()),
268 );
269
270 return $fields;
271 }

References getImage(), getMaxNumberOfAnswers(), getNonAnonymous(), getQuestion(), getShowResultsAs(), getSortResultByVotes(), getViewResults(), getVotingPeriod(), getVotingPeriodBegin(), getVotingPeriodEnd(), and isOnline().

Referenced by doCreate(), and doUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rebuildAnswerPositions()

ilObjPoll::rebuildAnswerPositions ( )

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

593 {
594 $answers = $this->getAnswers();
595
596 $pos = array();
597 foreach($answers as $item)
598 {
599 $pos[$item["id"]] = $item["pos"];
600 }
601
602 $this->updateAnswerPositions($pos);
603 }
updateAnswerPositions(array $a_pos)

References getAnswers(), and updateAnswerPositions().

+ Here is the call graph for this function:

◆ saveAnswer()

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

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

551 {
552 global $ilDB;
553
554 if(!trim($a_text))
555 {
556 return;
557 }
558
559 $id = $ilDB->nextId("il_poll_answer");
560
561 if(!$a_pos)
562 {
563 // append
564 $sql = "SELECT max(pos) pos".
565 " FROM il_poll_answer".
566 " WHERE poll_id = ".$ilDB->quote($this->getId(), "integer");
567 $set = $ilDB->query($sql);
568 $a_pos = $ilDB->fetchAssoc($set);
569 $a_pos = (int)$a_pos["pos"]+10;
570 }
571
572 $fields = array(
573 "id" => array("integer", $id),
574 "poll_id" => array("integer", $this->getId()),
575 "answer" => array("text", trim($a_text)),
576 "pos" => array("integer", $a_pos)
577 );
578 $ilDB->insert("il_poll_answer", $fields);
579
580 return $id;
581 }

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

Referenced by doCloneObject(), and saveAnswers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswers()

ilObjPoll::saveAnswers ( array  $a_answers)

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

661 {
662 $existing = $this->getAnswers();
663
664 $ids = array();
665 $pos = 0;
666 foreach($a_answers as $answer)
667 {
668 if(trim($answer))
669 {
670 // existing answer?
671 $found = false;
672 foreach($existing as $idx => $item)
673 {
674 if(trim($answer) == $item["answer"])
675 {
676 $found = true;
677 unset($existing[$idx]);
678
679 $id = $item["id"];
680 }
681 }
682
683 // create new answer
684 if(!$found)
685 {
686 $id = $this->saveAnswer($answer);
687 }
688
689 // add existing answer id to order
690 if($id)
691 {
692 $ids[$id] = ++$pos;
693 }
694 }
695 }
696
697 // remove obsolete answers
698 if(sizeof($existing))
699 {
700 foreach($existing as $item)
701 {
702 $this->deleteAnswer($item["id"]);
703 }
704 }
705
706 // save current order
707 if(sizeof($ids))
708 {
709 $this->updateAnswerPositions($ids);
710 }
711
712 return sizeof($ids);
713 }
deleteAnswer($a_id)

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

+ Here is the call graph for this function:

◆ saveVote()

ilObjPoll::saveVote (   $a_user_id,
  $a_answers 
)

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

721 {
722 global $ilDB;
723
724 if($this->hasUserVoted($a_user_id))
725 {
726 return;
727 }
728
729 if(!is_array($a_answers))
730 {
731 $a_answers = array($a_answers);
732 }
733
734 foreach($a_answers as $answer_id)
735 {
736 $fields = array("user_id" => array("integer", $a_user_id),
737 "poll_id" => array("integer", $this->getId()),
738 "answer_id" => array("integer", $answer_id));
739 $ilDB->insert("il_poll_vote", $fields);
740 }
741 }
hasUserVoted($a_user_id)

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

+ Here is the call graph for this function:

◆ setAccessBegin()

ilObjPoll::setAccessBegin (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setAccessEnd()

ilObjPoll::setAccessEnd (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setAccessType()

ilObjPoll::setAccessType (   $a_value)

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

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

Referenced by __construct(), and doRead().

+ Here is the caller graph for this function:

◆ setAccessVisibility()

ilObjPoll::setAccessVisibility (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setImage()

ilObjPoll::setImage (   $a_value)

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

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

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

+ Here is the caller graph for this function:

◆ setMaxNumberOfAnswers()

ilObjPoll::setMaxNumberOfAnswers (   $a_value)

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

172 {
173 $this->max_number_answers = (int)$a_value;
174 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setNonAnonymous()

ilObjPoll::setNonAnonymous (   $a_value)

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

192 {
193 $this->mode_non_anonymous = (bool)$a_value;
194 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setOnline()

ilObjPoll::setOnline (   $a_value)

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

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

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

+ Here is the caller graph for this function:

◆ setQuestion()

ilObjPoll::setQuestion (   $a_value)

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

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

Referenced by doCloneObject(), and doRead().

+ Here is the caller graph for this function:

◆ setShowComments()

ilObjPoll::setShowComments (   $a_value)

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

202 {
203 $this->show_comments = (bool)$a_value;
204 }

Referenced by doCloneObject(), and doRead().

+ Here is the caller graph for this function:

◆ setShowResultsAs()

ilObjPoll::setShowResultsAs (   $a_value)

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

212 {
213 $this->show_results_as = (int)$a_value;
214 }

Referenced by doCloneObject(), and doRead().

+ Here is the caller graph for this function:

◆ setSortResultByVotes()

ilObjPoll::setSortResultByVotes (   $a_value)

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

182 {
183 $this->result_sort_by_votes = (bool)$a_value;
184 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setViewResults()

ilObjPoll::setViewResults (   $a_value)

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

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

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

+ Here is the caller graph for this function:

◆ setVotingPeriod()

ilObjPoll::setVotingPeriod (   $a_value)

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

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

Referenced by __construct(), and doRead().

+ Here is the caller graph for this function:

◆ setVotingPeriodBegin()

ilObjPoll::setVotingPeriodBegin (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setVotingPeriodEnd()

ilObjPoll::setVotingPeriodEnd (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ updateAnswer()

ilObjPoll::updateAnswer (   $a_id,
  $a_text 
)

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

584 {
585 global $ilDB;
586
587 $ilDB->update("il_poll_answer",
588 array("answer" => array("text", $a_text)),
589 array("id" => array("integer", $a_id)));
590 }

References $ilDB.

◆ updateAnswerPositions()

ilObjPoll::updateAnswerPositions ( array  $a_pos)

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

606 {
607 global $ilDB;
608
609 asort($a_pos);
610
611 $pos = 0;
612 foreach(array_keys($a_pos) as $id)
613 {
614 $pos += 10;
615
616 $ilDB->update("il_poll_answer",
617 array("pos" => array("integer", $pos)),
618 array("id" => array("integer", $id)));
619 }
620 }

References ilObject\$id, and $ilDB.

Referenced by rebuildAnswerPositions(), and saveAnswers().

+ Here is the caller graph for this function:

◆ uploadImage()

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

Upload new image file.

Parameters
array$a_upload
Returns
bool

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

468 {
469 if(!$this->id)
470 {
471 return false;
472 }
473
474 $this->deleteImage();
475
476 // #10074
477 $clean_name = preg_replace("/[^a-zA-Z0-9\_\.\-]/", "", $a_upload["name"]);
478
479 $path = $this->initStorage($this->id);
480 $original = "org_".$this->id."_".$clean_name;
481 $thumb = "thb_".$this->id."_".$clean_name;
482 $processed = $this->id."_".$clean_name;
483
484 $success = false;
485 if(!$a_clone)
486 {
487 $success = ilUtil::moveUploadedFile($a_upload["tmp_name"], $original, $path.$original);
488 }
489 else
490 {
491 $success = copy($a_upload["tmp_name"], $path.$original);
492 }
493
494 if($success)
495 {
496 chmod($path.$original, 0770);
497
498 // take quality 100 to avoid jpeg artefacts when uploading jpeg files
499 // taking only frame [0] to avoid problems with animated gifs
500 $original_file = ilUtil::escapeShellArg($path.$original);
501 $thumb_file = ilUtil::escapeShellArg($path.$thumb);
502 $processed_file = ilUtil::escapeShellArg($path.$processed);
503 ilUtil::execConvert($original_file."[0] -geometry \"100x100>\" -quality 100 PNG:".$thumb_file);
504 ilUtil::execConvert($original_file."[0] -geometry \"".self::getImageSize().">\" -quality 100 PNG:".$processed_file);
505
506 $this->setImage($processed);
507 return true;
508 }
509 return false;
510 }
$success
Definition: Utf8Test.php:87
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static escapeShellArg($a_arg)
static execConvert($args)
execute convert command

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

Referenced by doCloneObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access_begin

ilObjPoll::$access_begin
protected

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

Referenced by getAccessBegin().

◆ $access_end

ilObjPoll::$access_end
protected

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

Referenced by getAccessEnd().

◆ $access_type

ilObjPoll::$access_type
protected

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

Referenced by getAccessType().

◆ $access_visibility

ilObjPoll::$access_visibility
protected

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

Referenced by getAccessVisibility().

◆ $image

ilObjPoll::$image
protected

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

Referenced by doCloneObject(), and getImage().

◆ $max_number_answers

ilObjPoll::$max_number_answers = 1
protected

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

Referenced by getMaxNumberOfAnswers().

◆ $mode_non_anonymous

ilObjPoll::$mode_non_anonymous = false
protected

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

Referenced by getNonAnonymous().

◆ $online

ilObjPoll::$online
protected

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

Referenced by isOnline().

◆ $period

ilObjPoll::$period
protected

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

Referenced by getVotingPeriod().

◆ $period_begin

ilObjPoll::$period_begin
protected

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

Referenced by getVotingPeriodBegin().

◆ $period_end

ilObjPoll::$period_end
protected

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

Referenced by getVotingPeriodEnd().

◆ $question

ilObjPoll::$question
protected

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

Referenced by getQuestion().

◆ $result_sort_by_votes

ilObjPoll::$result_sort_by_votes = false
protected

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

Referenced by getSortResultByVotes().

◆ $show_comments

ilObjPoll::$show_comments = false
protected

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

Referenced by getShowComments().

◆ $show_results_as

ilObjPoll::$show_results_as = 1
protected

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

Referenced by getShowResultsAs().

◆ $view_results

ilObjPoll::$view_results
protected

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

Referenced by getViewResults().

◆ SHOW_RESULTS_AS_BARCHART

const ilObjPoll::SHOW_RESULTS_AS_BARCHART = 1

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

Referenced by ilObjPollGUI\initEditCustomForm().

◆ SHOW_RESULTS_AS_PIECHART

const ilObjPoll::SHOW_RESULTS_AS_PIECHART = 2

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

Referenced by ilPollBlockGUI\fillRow(), and ilObjPollGUI\initEditCustomForm().

◆ VIEW_RESULTS_AFTER_PERIOD

const ilObjPoll::VIEW_RESULTS_AFTER_PERIOD = 4

◆ VIEW_RESULTS_AFTER_VOTE

const ilObjPoll::VIEW_RESULTS_AFTER_VOTE = 3

◆ VIEW_RESULTS_ALWAYS

const ilObjPoll::VIEW_RESULTS_ALWAYS = 1

◆ VIEW_RESULTS_NEVER

const ilObjPoll::VIEW_RESULTS_NEVER = 2

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