5require_once
"Services/Object/classes/class.ilObject2.php";
6require_once
"Services/Object/classes/class.ilObjectActivation.php";
53 parent::__construct($a_id, $a_reference);
63 $this->online = (bool)$a_value;
73 $this->access_type = (int)$a_value;
83 $this->access_begin = (int)$a_value;
93 $this->access_end = (int)$a_value;
103 $this->access_visibility = (bool)$a_value;
113 $this->question = (string)$a_value;
123 $this->image = (string)$a_value;
133 $this->view_results = (int)$a_value;
143 $this->period = (bool)$a_value;
153 $this->period_begin = (int)$a_value;
163 $this->period_end = (int)$a_value;
173 $this->max_number_answers = (int)$a_value;
183 $this->result_sort_by_votes = (bool)$a_value;
193 $this->mode_non_anonymous = (bool)$a_value;
203 $this->show_comments = (bool)$a_value;
213 $this->show_results_as = (int)$a_value;
225 $set =
$ilDB->query(
"SELECT * FROM il_poll".
226 " WHERE id = ".
$ilDB->quote($this->getId(),
"integer"));
241 include_once(
"./Services/Notes/classes/class.ilNote.php");
262 "image" => array(
"text", $this->
getImage()),
263 "online_status" => array(
"integer", $this->
isOnline()),
284 $fields[
"id"] = array(
"integer", $this->
getId());
286 $ilDB->insert(
"il_poll", $fields);
293 include_once
"Modules/Poll/classes/class.ilPollBlock.php";
295 $block->setType(
"poll");
296 $block->setContextObjId($this->
getId());
297 $block->setContextObjType(
"poll");
310 $ilDB->update(
"il_poll", $fields,
311 array(
"id"=>array(
"integer", $this->
getId())));
314 include_once(
"./Services/Notes/classes/class.ilNote.php");
324 $activation->update($this->ref_id);
344 $ilDB->manipulate(
"DELETE FROM il_poll".
345 " WHERE id = ".
$ilDB->quote($this->id,
"integer"));
368 $new_obj->uploadImage(
$image,
true);
374 if(!$cp_options->isRootNode($this->getRefId()))
376 $new_obj->setOnline($this->
isOnline());
388 foreach($answers as $item)
390 $new_obj->saveAnswer($item[
"answer"]);
431 include_once
"Modules/Poll/classes/class.ilFSStoragePoll.php";
448 include_once
"Modules/Poll/classes/class.ilFSStoragePoll.php";
452 $path = $storage->getAbsolutePath().
"/";
456 $path .= $a_subdir.
"/";
483 $clean_name = preg_replace(
"/[^a-zA-Z0-9\_\.\-]/",
"", $a_upload[
"name"]);
486 $original =
"org_".$this->id.
"_".$clean_name;
487 $thumb =
"thb_".$this->id.
"_".$clean_name;
488 $processed = $this->
id.
"_".$clean_name;
502 chmod(
$path.$original, 0770);
509 ilUtil::execConvert($original_file.
"[0] -geometry \"100x100>\" -quality 100 PNG:".$thumb_file);
510 ilUtil::execConvert($original_file.
"[0] -geometry \"".self::getImageSize().
">\" -quality 100 PNG:".$processed_file);
535 $sql =
"SELECT * FROM il_poll_answer".
536 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer").
538 $set =
$ilDB->query($sql);
550 $sql =
"SELECT * FROM il_poll_answer".
551 " WHERE id = ".$ilDB->quote($a_id,
"integer");
552 $set =
$ilDB->query($sql);
553 return (array)
$ilDB->fetchAssoc($set);
565 $id =
$ilDB->nextId(
"il_poll_answer");
570 $sql =
"SELECT max(pos) pos".
571 " FROM il_poll_answer".
572 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer");
573 $set =
$ilDB->query($sql);
574 $a_pos =
$ilDB->fetchAssoc($set);
575 $a_pos = (int)$a_pos[
"pos"]+10;
579 "id" => array(
"integer",
$id),
580 "poll_id" => array(
"integer", $this->
getId()),
581 "answer" => array(
"text", trim($a_text)),
582 "pos" => array(
"integer", $a_pos)
584 $ilDB->insert(
"il_poll_answer", $fields);
593 $ilDB->update(
"il_poll_answer",
594 array(
"answer" => array(
"text", $a_text)),
595 array(
"id" => array(
"integer", $a_id)));
603 foreach($answers as $item)
605 $pos[$item[
"id"]] = $item[
"pos"];
618 foreach(array_keys($a_pos) as
$id)
622 $ilDB->update(
"il_poll_answer",
623 array(
"pos" => array(
"integer", $pos)),
624 array(
"id" => array(
"integer",
$id)));
634 $ilDB->manipulate(
"DELETE FROM il_poll_vote".
635 " WHERE answer_id = ".
$ilDB->quote($this->getId(),
"integer"));
637 $ilDB->manipulate(
"DELETE FROM il_poll_answer".
638 " WHERE id = ".
$ilDB->quote($a_id,
"integer"));
650 $ilDB->manipulate(
"DELETE FROM il_poll_answer".
651 " WHERE poll_id = ".
$ilDB->quote($this->getId(),
"integer"));
661 $ilDB->manipulate(
"DELETE FROM il_poll_vote".
662 " WHERE poll_id = ".
$ilDB->quote($this->getId(),
"integer"));
672 foreach($a_answers as $answer)
678 foreach($existing as $idx => $item)
680 if(trim($answer) == $item[
"answer"])
683 unset($existing[$idx]);
704 if(
sizeof($existing))
706 foreach($existing as $item)
735 if(!is_array($a_answers))
737 $a_answers = array($a_answers);
740 foreach($a_answers as $answer_id)
742 $fields = array(
"user_id" => array(
"integer", $a_user_id),
743 "poll_id" => array(
"integer", $this->
getId()),
744 "answer_id" => array(
"integer", $answer_id));
745 $ilDB->insert(
"il_poll_vote", $fields);
753 $sql =
"SELECT user_id".
754 " FROM il_poll_vote".
755 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer").
756 " AND user_id = ".$ilDB->quote($a_user_id,
"integer");
758 $set =
$ilDB->query($sql);
759 return (
bool)
$ilDB->numRows($set);
766 $sql =
"SELECT COUNT(DISTINCT(user_id)) cnt".
767 " FROM il_poll_vote".
768 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer");
769 $set =
$ilDB->query($sql);
771 return (
int)
$row[
"cnt"];
781 $sql =
"SELECT answer_id, count(*) cnt".
782 " FROM il_poll_vote".
783 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer").
784 " GROUP BY answer_id";
785 $set =
$ilDB->query($sql);
789 $res[
$row[
"answer_id"]] = array(
"abs"=>
$row[
"cnt"],
"perc"=>0);
794 $res[
$id][
"perc"] = $item[
"abs"]/$cnt*100;
806 $sql =
"SELECT answer_id, user_id, firstname, lastname, login".
807 " FROM il_poll_vote".
808 " JOIN usr_data ON (usr_data.usr_id = il_poll_vote.user_id)".
809 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer");
810 $set =
$ilDB->query($sql);
An exception for terminatinating execution or to throw for unit testing.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
static activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
Activate notes feature.
setShowResultsAs($a_value)
const VIEW_RESULTS_ALWAYS
uploadImage(array $a_upload, $a_clone=false)
Upload new image file.
__construct($a_id=0, $a_reference=true)
Constructor @access public.
setNonAnonymous($a_value)
static initStorage($a_id, $a_subdir=null)
Init file system storage.
setVotingPeriodBegin($a_value)
const SHOW_RESULTS_AS_PIECHART
saveAnswer($a_text, $a_pos=null)
const VIEW_RESULTS_AFTER_VOTE
setMaxNumberOfAnswers($a_value)
setVotingPeriod($a_value)
updateAnswerPositions(array $a_pos)
const SHOW_RESULTS_AS_BARCHART
saveAnswers(array $a_answers)
setSortResultByVotes($a_value)
const VIEW_RESULTS_AFTER_PERIOD
updateAnswer($a_id, $a_text)
doCloneObject($new_obj, $a_target_id, $a_copy_id=0)
Clone poll.
saveVote($a_user_id, $a_answers)
deleteImage()
remove existing file
setVotingPeriodEnd($a_value)
setAccessVisibility($a_value)
setShowComments($a_value)
getImageFullPath($a_as_thumb=false)
Get image incl.
Class ilObject2 This is an intermediate progress of ilObject class.
getType()
get object type @access public
getId()
get object id @access public
Class ilObjectActivation.
const TIMINGS_DEACTIVATED
static deleteAllEntries($a_ref_id)
Delete all db entries for ref id.
static getItem($a_ref_id)
Get item data.
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