예제 #1
0
 private function getTableJoinExpression()
 {
     $tableJoin = "\n\t\t\tINNER JOIN\tqpl_qst_type\n\t\t\tON\t\t\tqpl_qst_type.question_type_id = qpl_questions.question_type_fi\n\t\t";
     if ($this->getAnswerStatusActiveId()) {
         $tableJoin .= "\n\t\t\t\tLEFT JOIN\ttst_test_result\n\t\t\t\tON\t\t\ttst_test_result.question_fi = qpl_questions.question_id\n\t\t\t\tAND\t\t\ttst_test_result.active_fi = {$this->db->quote($this->getAnswerStatusActiveId(), 'integer')}\n\t\t\t";
     }
     return $tableJoin;
 }
 private function getWhereConditions()
 {
     $conditions = array('obj_fi = ' . $this->db->quote($this->getParentObjId(), 'integer'));
     if ($this->getQuestionIdFilter()) {
         $conditions[] = 'question_fi = ' . $this->db->quote($this->getQuestionIdFilter(), 'integer');
     }
     return implode(' AND ', $conditions);
 }
 /**
  * Load the value
  */
 protected function loadValue()
 {
     if ($this->value === NULL) {
         $datatype = $this->field->getDatatype();
         $query = "SELECT * FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = " . $this->db->quote($this->id, "integer");
         $set = $this->db->query($query);
         $rec = $this->db->fetchAssoc($set);
         $this->value = $rec['value'];
     }
 }
 /**
  * Read object data from database
  *
  * @throws ilOrgUnitTypeException
  */
 protected function read()
 {
     $sql = 'SELECT * FROM ' . self::TABLE_NAME . ' WHERE orgu_type_id = ' . $this->db->quote($this->orgu_type_id, 'integer') . ' AND lang = ' . $this->db->quote($this->lang, 'text');
     $set = $this->db->query($sql);
     if (!$this->db->numRows($set)) {
         throw new ilOrgUnitTypeException("OrgUnit type translation for OrgUnit type {$this->orgu_type_id} and language {$this->lang} does not exist in database");
     }
     while ($rec = $this->db->fetchObject($set)) {
         $this->members[$rec->member] = (string) $rec->value;
     }
 }
 /**
  * Return dependencies form entities to other entities (in our case these are all the DB relations)
  *
  * @param $a_entity
  * @param $a_version
  * @param $a_rec
  * @param $a_ids
  *
  * @return array
  */
 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
 {
     if (!$a_rec && !$a_ids) {
         return false;
     }
     switch ($a_entity) {
         case 'dcl':
             $set = $this->db->query('SELECT * FROM il_dcl_table WHERE obj_id = ' . $this->db->quote($a_rec['id'], 'integer') . ' ORDER BY id');
             $ids = $this->buildCache('il_dcl_table', $set);
             return array('il_dcl_table' => array('ids' => $ids));
             break;
         case 'il_dcl_table':
             $set = $this->db->query('SELECT * FROM il_dcl_record WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
             $ids_records = $this->buildCache('il_dcl_record', $set);
             $set = $this->db->query('SELECT * FROM il_dcl_field WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
             $ids_fields = $this->buildCache('il_dcl_field', $set);
             $set = $this->db->query('SELECT * FROM il_dcl_view WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
             $ids_views = $this->buildCache('il_dcl_view', $set);
             return array('il_dcl_field' => array('ids' => $ids_fields), 'il_dcl_record' => array('ids' => $ids_records), 'il_dcl_view' => array('ids' => $ids_views));
         case 'il_dcl_field':
             $set = $this->db->query('SELECT * FROM il_dcl_field_prop WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
             $ids = $this->buildCache('il_dcl_field_prop', $set);
             return array('il_dcl_field_prop' => array('ids' => $ids));
         case 'il_dcl_record':
             $sql = 'SELECT rf.*, d.storage_location FROM il_dcl_record_field AS rf' . ' INNER JOIN il_dcl_field AS f ON (f.id = rf.field_id)' . ' INNER JOIN il_dcl_datatype AS d ON (f.datatype_id = d.id) ' . ' WHERE rf.record_id = ' . $this->db->quote($a_rec['id'], 'integer');
             $set = $this->db->query($sql);
             $ids = $this->buildCache('il_dcl_record_field', $set);
             $set = $this->db->query($sql);
             while ($rec = $this->db->fetchObject($set)) {
                 $this->record_field_ids_2_storage[$rec->id] = $rec->storage_location;
             }
             // Also build a cache of all values, no matter in which table they are (il_dcl_stloc(1|2|3)_value)
             $sql = 'SELECT rf.id AS record_field_id, st1.value AS value1, st2.value AS value2, st3.value AS value3 FROM il_dcl_record_field AS rf ' . 'LEFT JOIN il_dcl_stloc1_value AS st1 ON (st1.record_field_id = rf.id) ' . 'LEFT JOIN il_dcl_stloc2_value AS st2 ON (st2.record_field_id = rf.id) ' . 'LEFT JOIN il_dcl_stloc3_value AS st3 ON (st3.record_field_id = rf.id) ' . 'WHERE rf.record_id = ' . $this->db->quote($a_rec['id'], 'integer');
             $set = $this->db->query($sql);
             while ($rec = $this->db->fetchObject($set)) {
                 $stloc = $this->record_field_ids_2_storage[$rec->record_field_id];
                 $value = "value{$stloc}";
                 // Save reocrd field id. Internal ID is not used currently
                 $this->caches["il_dcl_stloc{$stloc}_value"][$rec->record_field_id] = array('record_field_id' => $rec->record_field_id, 'value' => $rec->{$value});
             }
             return array('il_dcl_record_field' => array('ids' => $ids));
         case 'il_dcl_view':
             $set = $this->db->query('SELECT * FROM il_dcl_viewdefinition WHERE view_id = ' . $this->db->quote($a_rec['id'], 'integer'));
             $ids = $this->buildCache('il_dcl_viewdefinition', $set);
             return array('il_dcl_viewdefinition' => array('ids' => $ids));
         case 'il_dcl_record_field':
             $record_field_id = $a_rec['id'];
             $storage_loc = $this->record_field_ids_2_storage[$record_field_id];
             return array("il_dcl_stloc{$storage_loc}_value" => array('ids' => array($record_field_id)));
     }
     return false;
 }
 /**
  * Load the value
  */
 protected function loadValue()
 {
     if ($this->value === NULL) {
         $datatype = $this->field->getDatatype();
         switch ($datatype->getId()) {
             case ilDataCollectionDatatype::INPUTFORMAT_RATING:
                 return true;
         }
         $query = "SELECT * FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = " . $this->db->quote($this->id, "integer");
         $set = $this->db->query($query);
         $rec = $this->db->fetchAssoc($set);
         $this->value = $rec['value'];
     }
 }
예제 #7
0
 /**
  * Read object data from database
  *
  * @throws ilOrgUnitTypeException
  */
 protected function read()
 {
     $sql = 'SELECT * FROM ' . self::TABLE_NAME . ' WHERE id = ' . $this->db->quote($this->id, 'integer');
     $set = $this->db->query($sql);
     if (!$this->db->numRows($set)) {
         throw new ilOrgUnitTypeException("OrgUnit type with id {$this->id} does not exist in database");
     }
     $rec = $this->db->fetchObject($set);
     $this->default_lang = $rec->default_lang;
     // Don't use Setter because of unnecessary plugin checks
     $this->setCreateDate($rec->create_date);
     $this->setLastUpdate($rec->last_update);
     $this->setOwner($rec->owner);
     $this->setIcon($rec->icon);
 }
 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
 {
     $page_object_ids = array();
     foreach ($a_ids as $dcl_obj_id) {
         // If a DCL table has a detail view, we need to export the associated page objects!
         $sql = "SELECT il_dcl_view.id AS page_obj_id FROM il_dcl_view " . "INNER JOIN il_dcl_table ON (il_dcl_table.id = il_dcl_view.table_id) " . "WHERE il_dcl_table.obj_id = " . $this->db->quote($dcl_obj_id, 'integer') . " " . "AND il_dcl_view.type=0 AND il_dcl_view.formtype=0";
         $set = $this->db->query($sql);
         while ($rec = $this->db->fetchObject($set)) {
             $page_object_ids[] = "dclf:" . $rec->page_obj_id;
         }
     }
     if (count($page_object_ids)) {
         return array(array('component' => 'Services/COPage', 'entity' => 'pg', 'ids' => $page_object_ids));
     }
     return array();
 }
 /**
  * @return bool
  */
 private function read()
 {
     if (!$this->getRuleId()) {
         return true;
     }
     $query = 'SELECT * FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote($this->getRuleId(), 'integer');
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $this->setRoleId($row->role_id);
         $this->setName($row->name);
         $this->setValue($row->value);
         $this->enablePlugin($row->plugin);
         $this->setPluginId($row->plugin_id);
         $this->enableAddOnUpdate($row->add_on_update);
         $this->enableRemoveOnUpdate($row->remove_on_update);
     }
 }
 private function getFieldFilterExpressions()
 {
     $expressions = array();
     foreach ($this->fieldFilters as $fieldName => $fieldValue) {
         switch ($fieldName) {
             case 'title':
             case 'description':
             case 'author':
                 $expressions[] = $this->db->like('qpl_questions.' . $fieldName, 'text', "%%{$fieldValue}%%");
                 break;
             case 'type':
                 $expressions[] = "qpl_qst_type.type_tag = {$this->db->quote($fieldValue, 'text')}";
                 break;
         }
     }
     return $expressions;
 }
예제 #11
0
 /**
  * getOrgUnitOfUser
  *
  * @param $user_id
  * @param int $ref_id if given, only OrgUnits under this ID are returned (including $ref_id)
  * @return int[]
  */
 public function getOrgUnitOfUser($user_id, $ref_id = 0)
 {
     $q = "SELECT orgu.obj_id, refr.ref_id FROM object_data orgu\n                INNER JOIN object_reference refr ON refr.obj_id = orgu.obj_id\n\t\t\t\tINNER JOIN object_data roles ON roles.title LIKE CONCAT('il_orgu_superior_',refr.ref_id) OR roles.title LIKE CONCAT('il_orgu_employee_',refr.ref_id)\n\t\t\t\tINNER JOIN rbac_ua rbac ON rbac.usr_id = " . $this->db->quote($user_id, "integer") . " AND roles.obj_id = rbac.rol_id\n\t\t\t\tWHERE orgu.type = 'orgu' AND refr.deleted IS NULL";
     $set = $this->db->query($q);
     $orgu_ref_ids = array();
     while ($res = $this->db->fetchAssoc($set)) {
         $orgu_ref_ids[] = $res['ref_id'];
     }
     $orgu_ref_ids = array_unique($orgu_ref_ids);
     if ($ref_id) {
         $childernOrgIds = $this->getAllChildren($ref_id);
         foreach ($orgu_ref_ids as $k => $refId) {
             if (!in_array($refId, $childernOrgIds)) {
                 unset($orgu_ref_ids[$k]);
             }
         }
     }
     return $orgu_ref_ids;
 }
 /**
  * @param ilTermsOfServiceAcceptanceEntity $entity
  */
 public function deleteAcceptanceHistoryByUser(ilTermsOfServiceAcceptanceEntity $entity)
 {
     $this->db->manipulate('DELETE FROM tos_acceptance_track WHERE usr_id = ' . $this->db->quote($entity->getUserId(), 'integer'));
 }