ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ($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 ()
 Read data from db. 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 ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public 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...
 
 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 ()
 
 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...
 
 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)
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
- Public Member Functions inherited from ilObject
 __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 ()
 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...
 
 setOfflineStatus ($a_status)
 Set offline status. More...
 
 getOfflineStatus ()
 Get offline status. More...
 
 supportsOfflineHandling ()
 Check whether object supports offline handling. More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. 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...
 
 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...
 
 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...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 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...
 
 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 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id, $a_deleted_by)
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type 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, $a_show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static lookupOfflineStatus ($a_obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id, $a_deleted_by)
 
static setDeletedDates ($a_ref_ids, $a_user_id)
 Set deleted date. More...
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type 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 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 _lookupCreationDate ($a_id)
 Lookup creation date. 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
 
 $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
 

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
 
- Protected Attributes inherited from ilObject
 $objDefinition
 
 $db
 
 $log
 
 $error
 
 $tree
 
 $app_event_handler
 
 $rbacadmin
 
 $rbacreview
 

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 global $DIC;
48
49 $this->db = $DIC->database();
50 // default
51 $this->setOnline(false);
52 $this->setViewResults(self::VIEW_RESULTS_AFTER_VOTE);
54 $this->setVotingPeriod(false);
55
56 parent::__construct($a_id, $a_reference);
57 }
setVotingPeriod($a_value)
setAccessType($a_value)
setOnline($a_value)
setViewResults($a_value)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), 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 737 of file class.ilObjPoll.php.

738 {
740
741 $sql = "SELECT COUNT(DISTINCT(user_id)) cnt" .
742 " FROM il_poll_vote" .
743 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer");
744 $set = $ilDB->query($sql);
745 $row = $ilDB->fetchAssoc($set);
746 return (int) $row["cnt"];
747 }
getId()
get object id @access public
global $ilDB

References ilObject\$db, $ilDB, and ilObject\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 631 of file class.ilObjPoll.php.

632 {
634
635 if ($this->getId()) {
636 $this->deleteAllVotes();
637
638 $ilDB->manipulate("DELETE FROM il_poll_answer" .
639 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer"));
640 }
641 }

References ilObject\$db, $ilDB, deleteAllVotes(), and ilObject\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 643 of file class.ilObjPoll.php.

644 {
646
647 if ($this->getId()) {
648 $ilDB->manipulate("DELETE FROM il_poll_vote" .
649 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer"));
650 }
651 }

References ilObject\$db, $ilDB, and ilObject\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 618 of file class.ilObjPoll.php.

619 {
621
622 if ($a_id) {
623 $ilDB->manipulate("DELETE FROM il_poll_vote" .
624 " WHERE answer_id = " . $ilDB->quote($this->getId(), "integer"));
625
626 $ilDB->manipulate("DELETE FROM il_poll_answer" .
627 " WHERE id = " . $ilDB->quote($a_id, "integer"));
628 }
629 }

References ilObject\$db, and $ilDB.

Referenced by saveAnswers().

+ Here is the caller graph for this function:

◆ deleteImage()

ilObjPoll::deleteImage ( )

remove existing file

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

418 {
419 if ($this->id) {
420 include_once "Modules/Poll/classes/class.ilFSStoragePoll.php";
421 $storage = new ilFSStoragePoll($this->id);
422 $storage->delete();
423
424 $this->setImage(null);
425 }
426 }
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 (   $new_obj,
  $a_target_id,
  $a_copy_id = 0 
)

Clone poll.

Parameters
ilObjPollnew object
inttarget ref_id
intcopy id
Returns
ilObjPoll

Reimplemented from ilObject2.

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

356 {
357 assert($new_obj instanceof ilObjPoll);
358
359 // question/image
360 $new_obj->setQuestion($this->getQuestion());
361 $image = $this->getImageFullPath();
362 if ($image) {
363 $image = array("tmp_name" => $image,
364 "name" => $this->getImage());
365 $new_obj->uploadImage($image, true);
366 }
367
368 //copy online status if object is not the root copy object
369 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
370
371 if (!$cp_options->isRootNode($this->getRefId())) {
372 $new_obj->setOnline($this->isOnline());
373 }
374
375 $new_obj->setViewResults($this->getViewResults());
376 $new_obj->setShowComments($this->getShowComments());
377 $new_obj->setShowResultsAs($this->getShowResultsAs());
378 $new_obj->update();
379
380 // answers
381 $answers = $this->getAnswers();
382 if ($answers) {
383 foreach ($answers as $item) {
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.
Class ilObjPoll.
getImageFullPath($a_as_thumb=false)
Get image incl.

References $image, ilCopyWizardOptions\_getInstance(), getAnswers(), getImage(), getImageFullPath(), getQuestion(), getShowComments(), getShowResultsAs(), getViewResults(), and isOnline().

+ Here is the call graph for this function:

◆ doCreate()

ilObjPoll::doCreate ( )
protected

Reimplemented from ilObject2.

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

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

References ilObject\$db, $ilDB, ilObject\getId(), and propertiesToDB().

+ Here is the call graph for this function:

◆ doDelete()

ilObjPoll::doDelete ( )
protected

Reimplemented from ilObject2.

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

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

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

+ Here is the call graph for this function:

◆ doRead()

ilObjPoll::doRead ( )
protected

Reimplemented from ilObject2.

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

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

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

+ Here is the call graph for this function:

◆ doUpdate()

ilObjPoll::doUpdate ( )
protected

Reimplemented from ilObject2.

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

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

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

+ Here is the call graph for this function:

◆ getAccessBegin()

ilObjPoll::getAccessBegin ( )

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

90 {
92 }

References $access_begin.

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getAccessEnd()

ilObjPoll::getAccessEnd ( )

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

100 {
101 return $this->access_end;
102 }

References $access_end.

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getAccessType()

ilObjPoll::getAccessType ( )

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

80 {
81 return $this->access_type;
82 }

References $access_type.

Referenced by doRead(), and doUpdate().

+ Here is the caller graph for this function:

◆ getAccessVisibility()

ilObjPoll::getAccessVisibility ( )

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

110 {
112 }

References $access_visibility.

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getAnswer()

ilObjPoll::getAnswer (   $a_id)

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

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

References ilObject\$db, and $ilDB.

◆ getAnswers()

ilObjPoll::getAnswers ( )

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

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

References ilObject\$db, $ilDB, $res, and ilObject\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 129 of file class.ilObjPoll.php.

130 {
131 return $this->image;
132 }

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 $path = $this->initStorage($this->id);
406 if (!$a_as_thumb) {
407 return $path . $img;
408 } else {
409 return $path . "thb_" . $img;
410 }
411 }
412 }
static initStorage($a_id, $a_subdir=null)
Init file system storage.

References $img, 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 509 of file class.ilObjPoll.php.

510 {
511 // :TODO:
512 return "300x300";
513 }

Referenced by ilObjPollGUI\initQuestionForm(), and uploadImage().

+ Here is the caller graph for this function:

◆ getMaxNumberOfAnswers()

ilObjPoll::getMaxNumberOfAnswers ( )

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

180 {
182 }

References $max_number_answers.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getNonAnonymous()

ilObjPoll::getNonAnonymous ( )

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

200 {
202 }

References $mode_non_anonymous.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getQuestion()

ilObjPoll::getQuestion ( )

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

120 {
121 return $this->question;
122 }

References $question.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getShowComments()

ilObjPoll::getShowComments ( )

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

210 {
212 }

References $show_comments.

Referenced by doCloneObject(), and doUpdate().

+ Here is the caller graph for this function:

◆ getShowResultsAs()

ilObjPoll::getShowResultsAs ( )

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

220 {
222 }

References $show_results_as.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getSortResultByVotes()

ilObjPoll::getSortResultByVotes ( )

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

190 {
192 }

References $result_sort_by_votes.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getViewResults()

ilObjPoll::getViewResults ( )

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

140 {
141 return $this->view_results;
142 }

References $view_results.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getVotePercentages()

ilObjPoll::getVotePercentages ( )

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

750 {
752
753 $res = array();
754 $cnt = 0;
755
756 $sql = "SELECT answer_id, count(*) cnt" .
757 " FROM il_poll_vote" .
758 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer") .
759 " GROUP BY answer_id";
760 $set = $ilDB->query($sql);
761 while ($row = $ilDB->fetchAssoc($set)) {
762 $cnt += $row["cnt"];
763 $res[$row["answer_id"]] = array("abs" => $row["cnt"], "perc" => 0);
764 }
765
766 foreach ($res as $id => $item) {
767 $res[$id]["perc"] = $item["abs"] / $cnt * 100;
768 }
769
770 return array("perc" => $res, "total" => $this->countVotes());
771 }

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

+ Here is the call graph for this function:

◆ getVotesByUsers()

ilObjPoll::getVotesByUsers ( )

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

774 {
776
777 $res = array();
778
779 $sql = "SELECT answer_id, user_id, firstname, lastname, login" .
780 " FROM il_poll_vote" .
781 " JOIN usr_data ON (usr_data.usr_id = il_poll_vote.user_id)" .
782 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer");
783 $set = $ilDB->query($sql);
784 while ($row = $ilDB->fetchAssoc($set)) {
785 if (!isset($res[$row["user_id"]])) {
786 $res[$row["user_id"]] = $row;
787 }
788 $res[$row["user_id"]]["answers"][] = $row["answer_id"];
789 }
790
791 return $res;
792 }

References ilObject\$db, $ilDB, $res, and ilObject\getId().

+ Here is the call graph for this function:

◆ getVotingPeriod()

ilObjPoll::getVotingPeriod ( )

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

150 {
151 return $this->period;
152 }

References $period.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getVotingPeriodBegin()

ilObjPoll::getVotingPeriodBegin ( )

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

160 {
161 return $this->period_begin;
162 }

References $period_begin.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getVotingPeriodEnd()

ilObjPoll::getVotingPeriodEnd ( )

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

170 {
171 return $this->period_end;
172 }

References $period_end.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ hasUserVoted()

ilObjPoll::hasUserVoted (   $a_user_id)

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

725 {
727
728 $sql = "SELECT user_id" .
729 " FROM il_poll_vote" .
730 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer") .
731 " AND user_id = " . $ilDB->quote($a_user_id, "integer");
732 $ilDB->setLimit(1);
733 $set = $ilDB->query($sql);
734 return (bool) $ilDB->numRows($set);
735 }

References ilObject\$db, $ilDB, and ilObject\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 435 of file class.ilObjPoll.php.

436 {
437 include_once "Modules/Poll/classes/class.ilFSStoragePoll.php";
438 $storage = new ilFSStoragePoll($a_id);
439 $storage->create();
440
441 $path = $storage->getAbsolutePath() . "/";
442
443 if ($a_subdir) {
444 $path .= $a_subdir . "/";
445
446 if (!is_dir($path)) {
447 mkdir($path);
448 }
449 }
450
451 return $path;
452 }

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

60 {
61 $this->type = "poll";
62 }

◆ isOnline()

ilObjPoll::isOnline ( )

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

70 {
71 return $this->online;
72 }

References $online.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ propertiesToDB()

ilObjPoll::propertiesToDB ( )
protected

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

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

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

589 {
590 $answers = $this->getAnswers();
591
592 $pos = array();
593 foreach ($answers as $item) {
594 $pos[$item["id"]] = $item["pos"];
595 }
596
597 $this->updateAnswerPositions($pos);
598 }
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 546 of file class.ilObjPoll.php.

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

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

Referenced by 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 653 of file class.ilObjPoll.php.

654 {
655 $existing = $this->getAnswers();
656
657 $ids = array();
658 $pos = 0;
659 foreach ($a_answers as $answer) {
660 if (trim($answer)) {
661 // existing answer?
662 $found = false;
663 foreach ($existing as $idx => $item) {
664 if (trim($answer) == $item["answer"]) {
665 $found = true;
666 unset($existing[$idx]);
667
668 $id = $item["id"];
669 }
670 }
671
672 // create new answer
673 if (!$found) {
674 $id = $this->saveAnswer($answer);
675 }
676
677 // add existing answer id to order
678 if ($id) {
679 $ids[$id] = ++$pos;
680 }
681 }
682 }
683
684 // remove obsolete answers
685 if (sizeof($existing)) {
686 foreach ($existing as $item) {
687 $this->deleteAnswer($item["id"]);
688 }
689 }
690
691 // save current order
692 if (sizeof($ids)) {
693 $this->updateAnswerPositions($ids);
694 }
695
696 return sizeof($ids);
697 }
saveAnswer($a_text, $a_pos=null)
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 704 of file class.ilObjPoll.php.

705 {
707
708 if ($this->hasUserVoted($a_user_id)) {
709 return;
710 }
711
712 if (!is_array($a_answers)) {
713 $a_answers = array($a_answers);
714 }
715
716 foreach ($a_answers as $answer_id) {
717 $fields = array("user_id" => array("integer", $a_user_id),
718 "poll_id" => array("integer", $this->getId()),
719 "answer_id" => array("integer", $answer_id));
720 $ilDB->insert("il_poll_vote", $fields);
721 }
722 }
hasUserVoted($a_user_id)

References ilObject\$db, $ilDB, ilObject\getId(), and hasUserVoted().

+ Here is the call graph for this function:

◆ setAccessBegin()

ilObjPoll::setAccessBegin (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setAccessEnd()

ilObjPoll::setAccessEnd (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setAccessType()

ilObjPoll::setAccessType (   $a_value)

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

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

Referenced by __construct(), and doRead().

+ Here is the caller graph for this function:

◆ setAccessVisibility()

ilObjPoll::setAccessVisibility (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setImage()

ilObjPoll::setImage (   $a_value)

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

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

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

+ Here is the caller graph for this function:

◆ setMaxNumberOfAnswers()

ilObjPoll::setMaxNumberOfAnswers (   $a_value)

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

175 {
176 $this->max_number_answers = (int) $a_value;
177 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setNonAnonymous()

ilObjPoll::setNonAnonymous (   $a_value)

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

195 {
196 $this->mode_non_anonymous = (bool) $a_value;
197 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setOnline()

ilObjPoll::setOnline (   $a_value)

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

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

Referenced by __construct(), and doRead().

+ Here is the caller graph for this function:

◆ setQuestion()

ilObjPoll::setQuestion (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setShowComments()

ilObjPoll::setShowComments (   $a_value)

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

205 {
206 $this->show_comments = (bool) $a_value;
207 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setShowResultsAs()

ilObjPoll::setShowResultsAs (   $a_value)

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

215 {
216 $this->show_results_as = (int) $a_value;
217 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setSortResultByVotes()

ilObjPoll::setSortResultByVotes (   $a_value)

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

185 {
186 $this->result_sort_by_votes = (bool) $a_value;
187 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setViewResults()

ilObjPoll::setViewResults (   $a_value)

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

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

Referenced by __construct(), and doRead().

+ Here is the caller graph for this function:

◆ setVotingPeriod()

ilObjPoll::setVotingPeriod (   $a_value)

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

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

Referenced by __construct(), and doRead().

+ Here is the caller graph for this function:

◆ setVotingPeriodBegin()

ilObjPoll::setVotingPeriodBegin (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setVotingPeriodEnd()

ilObjPoll::setVotingPeriodEnd (   $a_value)

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

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

Referenced by doRead().

+ Here is the caller graph for this function:

◆ updateAnswer()

ilObjPoll::updateAnswer (   $a_id,
  $a_text 
)

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

578 {
580
581 $ilDB->update(
582 "il_poll_answer",
583 array("answer" => array("text", $a_text)),
584 array("id" => array("integer", $a_id))
585 );
586 }

References ilObject\$db, and $ilDB.

◆ updateAnswerPositions()

ilObjPoll::updateAnswerPositions ( array  $a_pos)

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

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

References ilObject\$db, 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 460 of file class.ilObjPoll.php.

461 {
462 if (!$this->id) {
463 return false;
464 }
465
466 $this->deleteImage();
467
468 // #10074
469 $clean_name = preg_replace("/[^a-zA-Z0-9\_\.\-]/", "", $a_upload["name"]);
470
471 $path = $this->initStorage($this->id);
472 $original = "org_" . $this->id . "_" . $clean_name;
473 $thumb = "thb_" . $this->id . "_" . $clean_name;
474 $processed = $this->id . "_" . $clean_name;
475
476 $success = false;
477 if (!$a_clone) {
478 $success = ilUtil::moveUploadedFile($a_upload["tmp_name"], $original, $path . $original);
479 } else {
480 $success = copy($a_upload["tmp_name"], $path . $original);
481 }
482 if ($success) {
483 chmod($path . $original, 0770);
484
485 // take quality 100 to avoid jpeg artefacts when uploading jpeg files
486 // taking only frame [0] to avoid problems with animated gifs
487 $original_file = ilUtil::escapeShellArg($path . $original);
488 $thumb_file = ilUtil::escapeShellArg($path . $thumb);
489 $processed_file = ilUtil::escapeShellArg($path . $processed);
490
491 // -geometry "100x100>" is escaped by -geometry "100x100>"
492 // re-replace ">" with ">"
493 $convert_100 = $original_file . "[0] -geometry \"100x100>\" -quality 100 PNG:" . $thumb_file;
494 $escaped_convert_100 = ilUtil::escapeShellCmd($convert_100);
495 $escaped_convert_100 = str_replace('-geometry "100x100>', '-geometry "100x100>', $escaped_convert_100);
496 ilUtil::execQuoted(PATH_TO_CONVERT, $escaped_convert_100);
497
498 $convert_300 = $original_file . "[0] -geometry \"" . self::getImageSize() . ">\" -quality 100 PNG:" . $processed_file;
499 $escaped_convert_300 = ilUtil::escapeShellCmd($convert_300);
500 $escaped_convert_300 = str_replace('-geometry "' . self::getImageSize() . '>"', '-geometry "' . self::getImageSize() .'>"', $escaped_convert_300);
501 ilUtil::execQuoted(PATH_TO_CONVERT, $escaped_convert_300);
502
503 $this->setImage($processed);
504 return true;
505 }
506 return false;
507 }
$success
Definition: Utf8Test.php:86
static getImageSize()
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static execQuoted($cmd, $args=null)
exec command and fix spaces on windows
static escapeShellArg($a_arg)
static escapeShellCmd($a_arg)
escape shell cmd

References $success, deleteImage(), ilUtil\escapeShellArg(), ilUtil\escapeShellCmd(), ilUtil\execQuoted(), getImageSize(), initStorage(), ilUtil\moveUploadedFile(), and setImage().

+ Here is the call 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: