5require_once 
"Services/Object/classes/class.ilObject2.php";
 
    6require_once 
"Services/Object/classes/class.ilObjectActivation.php";
 
   49        $this->db = 
$DIC->database();
 
   66        $this->online = (bool) $a_value;
 
   76        $this->access_type = (int) $a_value;
 
   86        $this->access_begin = (int) $a_value;
 
   96        $this->access_end = (int) $a_value;
 
  106        $this->access_visibility = (bool) $a_value;
 
  116        $this->question = (string) $a_value;
 
  126        $this->image = (string) $a_value;
 
  136        $this->view_results = (int) $a_value;
 
  146        $this->period = (bool) $a_value;
 
  156        $this->period_begin = (int) $a_value;
 
  166        $this->period_end = (int) $a_value;
 
  176        $this->max_number_answers = (int) $a_value;
 
  186        $this->result_sort_by_votes = (bool) $a_value;
 
  196        $this->mode_non_anonymous = (bool) $a_value;
 
  206        $this->show_comments = (bool) $a_value;
 
  216        $this->show_results_as = (int) $a_value;
 
  228        $set = 
$ilDB->query(
"SELECT * FROM il_poll" .
 
  229                " WHERE id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
  230        $row = 
$ilDB->fetchAssoc($set);
 
  244        include_once(
"./Services/Notes/classes/class.ilNote.php");
 
  263            "image" => array(
"text", $this->
getImage()),
 
  264            "online_status" => array(
"integer", $this->
isOnline()),
 
  282        if ($this->
getId()) {
 
  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");
 
  306        if ($this->
getId()) {
 
  312                array(
"id" => array(
"integer", $this->
getId()))
 
  316            include_once(
"./Services/Notes/classes/class.ilNote.php");
 
  325                $activation->update($this->ref_id);
 
  334        if ($this->
getId()) {
 
  342            $ilDB->manipulate(
"DELETE FROM il_poll" .
 
  343                " WHERE id = " . 
$ilDB->quote($this->id, 
"integer"));
 
  365            $new_obj->uploadImage(
$image, 
true);
 
  371        if (!$cp_options->isRootNode($this->getRefId())) {
 
  372            $new_obj->setOnline($this->
isOnline());
 
  383            foreach ($answers as $item) {
 
  384                $new_obj->saveAnswer($item[
"answer"]);
 
  409                return $path . 
"thb_" . 
$img;
 
  420            include_once 
"Modules/Poll/classes/class.ilFSStoragePoll.php";
 
  437        include_once 
"Modules/Poll/classes/class.ilFSStoragePoll.php";
 
  441        $path = $storage->getAbsolutePath() . 
"/";
 
  444            $path .= $a_subdir . 
"/";
 
  446            if (!is_dir($path)) {
 
  469        $clean_name = preg_replace(
"/[^a-zA-Z0-9\_\.\-]/", 
"", $a_upload[
"name"]);
 
  472        $original = 
"org_" . $this->
id . 
"_" . $clean_name;
 
  473        $thumb = 
"thb_" . $this->
id . 
"_" . $clean_name;
 
  474        $processed = $this->
id . 
"_" . $clean_name;
 
  480            $success = copy($a_upload[
"tmp_name"], $path . $original);
 
  483            chmod($path . $original, 0770);
 
  493            $convert_100 = $original_file . 
"[0] -geometry \"100x100>\" -quality 100 PNG:" . $thumb_file;
 
  495            $escaped_convert_100 = str_replace(
'-geometry "100x100>', 
'-geometry "100x100>', $escaped_convert_100);
 
  498            $convert_300 = $original_file . 
"[0] -geometry \"" . 
self::getImageSize() . 
">\" -quality 100 PNG:" . $processed_file;
 
  500            $escaped_convert_300 = str_replace(
'-geometry "' . self::getImageSize() . 
'>"', 
'-geometry "' . self::getImageSize() .
'>"', $escaped_convert_300);
 
  526        $sql = 
"SELECT * FROM il_poll_answer" .
 
  527            " WHERE poll_id = " . 
$ilDB->quote($this->
getId(), 
"integer") .
 
  529        $set = 
$ilDB->query($sql);
 
  530        while ($row = 
$ilDB->fetchAssoc($set)) {
 
  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);
 
  550        if (!trim($a_text)) {
 
  554        $id = 
$ilDB->nextId(
"il_poll_answer");
 
  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;
 
  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)
 
  572        $ilDB->insert(
"il_poll_answer", $fields);
 
  583            array(
"answer" => array(
"text", $a_text)),
 
  584            array(
"id" => array(
"integer", $a_id))
 
  593        foreach ($answers as $item) {
 
  594            $pos[$item[
"id"]] = $item[
"pos"];
 
  607        foreach (array_keys($a_pos) as 
$id) {
 
  612                array(
"pos" => array(
"integer", $pos)),
 
  613                array(
"id" => array(
"integer", 
$id))
 
  623            $ilDB->manipulate(
"DELETE FROM il_poll_vote" .
 
  624                " WHERE answer_id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
  626            $ilDB->manipulate(
"DELETE FROM il_poll_answer" .
 
  627                " WHERE id = " . 
$ilDB->quote($a_id, 
"integer"));
 
  635        if ($this->
getId()) {
 
  638            $ilDB->manipulate(
"DELETE FROM il_poll_answer" .
 
  639                " WHERE poll_id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
  647        if ($this->
getId()) {
 
  648            $ilDB->manipulate(
"DELETE FROM il_poll_vote" .
 
  649                " WHERE poll_id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
  659        foreach ($a_answers as $answer) {
 
  663                foreach ($existing as $idx => $item) {
 
  664                    if (trim($answer) == $item[
"answer"]) {
 
  666                        unset($existing[$idx]);
 
  685        if (
sizeof($existing)) {
 
  686            foreach ($existing as $item) {
 
  712        if (!is_array($a_answers)) {
 
  713            $a_answers = array($a_answers);
 
  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);
 
  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");
 
  733        $set = 
$ilDB->query($sql);
 
  734        return (
bool) 
$ilDB->numRows($set);
 
  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"];
 
  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)) {
 
  763            $res[$row[
"answer_id"]] = array(
"abs" => $row[
"cnt"], 
"perc" => 0);
 
  766        foreach (
$res as 
$id => $item) {
 
  767            $res[
$id][
"perc"] = $item[
"abs"] / $cnt * 100;
 
  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;
 
  788            $res[$row[
"user_id"]][
"answers"][] = $row[
"answer_id"];
 
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, $a_news_id=0)
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
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.
getId()
get object id @access public
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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
foreach($_POST as $key=> $value) $res