Example #1
0
 /**
  * Return all custom's fields from this user
  *
  * @param SingleRow $userRow
  */
 protected function setCustomFieldsInUser($userRow)
 {
     if ($this->getCustomTable()->table == "") {
         return;
     }
     $userId = $userRow->getField($this->getUserTable()->id);
     $sql = $this->_sqlHelper->createSafeSQL($this->sqlSetCustomFieldsInUser(), array("@@Table" => $this->getCustomTable()->table, "@@Id" => $this->getUserTable()->id));
     $param = array('id' => $userId);
     $it = $this->_db->getIterator($sql, $param);
     while ($it->hasNext()) {
         $sr = $it->moveNext();
         $userRow->addField($sr->getField($this->getCustomTable()->name), $sr->getField($this->getCustomTable()->value));
     }
 }
Example #2
0
 /**
  * @param bool $getAll
  * @return IteratorInterface
  */
 protected function GetIterator($getAll)
 {
     $fields = "";
     foreach ($this->_fields as $field) {
         if ($field->visibleInList || $field->key || !$getAll) {
             if ($fields != "") {
                 $fields .= ",";
             }
             $fields .= $this->getFieldDeliLeft() . $field->fieldName . $this->getFieldDeliRight();
         }
     }
     $sql = "select :fields from :table ";
     $param = array();
     if (!$getAll) {
         $sql .= "where :where ";
     }
     if ($this->_filter != "") {
         $sql .= ($getAll ? " where " : " and ") . " " . $this->getFilter();
     }
     if ($this->_sort != "" && $getAll) {
         $sql .= " order by :order ";
     }
     $sqlHelper = new SQLHelper($this->_dbData);
     $sql = $sqlHelper->createSafeSQL($sql, array(':fields' => $fields, ':table' => $this->_table, ':where' => $this->getWhereClause($param), ":order" => $this->getSort()));
     $this->DebugInfo($sql, $param);
     return $this->_dbData->getIterator($sql, $param);
 }
Example #3
0
 public function generateObject($current)
 {
     // Is there some error?
     if ($this->_error) {
         $nodeWorking = XmlUtil::CreateChild($current, "poll");
         XmlUtil::CreateChild($nodeWorking, "error", $this->_myWords->Value("ERROR_POLLNOTSETUP"));
     } else {
         // Get Data to SHOW the answers OR chart.
         $itf = new IteratorFilter();
         $itf->addRelation("name", Relation::EQUAL, $this->_poll);
         $itf->addRelation("lang", Relation::EQUAL, $this->_lang);
         if ($this->_isdb) {
             $dbdata = new DBDataset($this->_connection);
             $param = array();
             $sql = $itf->getSql($this->_tblpoll, $param);
             $itPoll = $dbdata->getIterator($sql, $param);
             $param = array();
             $sql = $itf->getSql($this->_tblanswer, $param);
             $itAnswer = $dbdata->getIterator($sql, $param);
         } else {
             $this->getAnyData();
             $itPoll = $this->_anyPoll->getIterator($itf);
             $itAnswer = $this->_anyAnswer->getIterator($itf);
         }
         // Show the answers if not was called the method processVote()
         if (!$this->_processed) {
             $nodeWorking = XmlUtil::CreateChild($current, "poll");
             XmlUtil::AddAttribute($nodeWorking, "url", $this->_url);
             XmlUtil::AddAttribute($nodeWorking, "name", $this->_poll);
             XmlUtil::AddAttribute($nodeWorking, "lang", $this->_lang);
             // Show Data Only if Poll is active
             if ($itPoll->hasNext()) {
                 $sr = $itPoll->moveNext();
                 XmlUtil::AddAttribute($nodeWorking, "multiple", $sr->getField("multiple") == "Y" ? "true" : "false");
                 if ($sr->getField("active") == "Y") {
                     XmlUtil::AddAttribute($nodeWorking, "active", "true");
                     XmlUtil::AddAttribute($nodeWorking, "sendbtn", $this->_myWords->Value("SENDBTN"));
                     XmlUtil::CreateChild($nodeWorking, "question", $sr->getField("question"));
                     while ($itAnswer->hasNext()) {
                         $sr = $itAnswer->moveNext();
                         $nodeanswer = XmlUtil::CreateChild($nodeWorking, "answer", $sr->getField("answer"));
                         XmlUtil::AddAttribute($nodeanswer, "code", $sr->getField("code"));
                     }
                 } else {
                     XmlUtil::AddAttribute($nodeWorking, "sendbtn", $this->_myWords->Value("VIEWRESULTSBTN"));
                     XmlUtil::CreateChild($nodeWorking, "question", $sr->getField("question") . " - " . $this->_myWords->Value("POLLENDED"));
                 }
             } else {
                 XmlUtil::CreateChild($nodeWorking, "error", $this->_myWords->Value("ERROR_POLLEMPTY"));
             }
         } else {
             $srPoll = $itPoll->moveNext();
             if ($srPoll->getField("showresults") == "Y") {
                 $colors = array('#FFF8A3', '#A9CC8F', '#B2C8D9', '#BEA37A', '#F3AA79', '#B5B5A9', '#E6A5A4', '#F8D753', '#5C9746', '#3E75A7', '#7A653E', '#E1662A', '#74796F', '#C4384F', '#F0B400', '#1E6C0B', '#00488C', '#332600', '#D84000', '#434C43', '#B30023', '#FAE16B', '#82B16A', '#779DBF', '#907A52', '#EB8953', '#8A8D82', '#D6707B', '#F3C01C', '#3D8128', '#205F9A', '#63522B', '#DC5313', '#5D645A', '#BC1C39');
                 //\Xmlnuke\Util\Debug::PrintValue($itAnswer);
                 $info = array();
                 $info[] = array("column" => "answer", "type" => ChartColumnType::String, "name" => "Legend");
                 $info[] = array("column" => "votes", "type" => ChartColumnType::Number, "name" => "Value");
                 $chart = new ChartObject("");
                 $chart->setChartType(ChartType::Pie);
                 $chart->setIs3d(true);
                 $chart->setWidth($this->_width);
                 $chart->setHeight($this->_height);
                 $chart->addSeriesIterator($itAnswer, $info);
                 $object = new ObjectHandler($current, $chart, "xmlnuke");
                 $object->CreateObjectFromModel();
             } else {
                 if ($srPoll->getField("active") == "Y") {
                     $txt = new XmlnukeText($this->_myWords->Value("VOTECOMPUTED"), true);
                 } else {
                     $txt = new XmlnukeText($this->_myWords->Value("CANNOTSHOWRESULTS"), true);
                 }
                 $txt->generateObject($current);
             }
         }
     }
 }