Exemplo n.º 1
0
 /**
  * Generates an array from the database information
  * @global integer $client
  * @return void
  */
 private function _generateTree()
 {
     // globals
     global $client;
     $sql = "SELECT \r\n\t\t\t\t\tidbackendmenu, parent, sortindex, entry_langstring, entry_url, url_target, entry_validate\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . $this->cfg->db('backendmenu') . "\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tidclient IN(0, {$client})\r\n\t\t\t\t\tAND entry_langstring NOT IN('empty_dummy')\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tparent, sortindex";
     $rs = $this->db->Execute($sql);
     if ($rs === false || $rs->EOF) {
         return false;
     }
     while (!$rs->EOF) {
         $parent_old = $parent_new;
         $parent_new = $rs->fields['parent'];
         if ($parent_new != $parent_old) {
             $k = 0;
         }
         $unsort_array[$parent_new][$k]['id'] = $rs->fields['idbackendmenu'];
         $unsort_array[$parent_new][$k]['parent'] = $rs->fields['parent'];
         $unsort_array[$parent_new][$k]['sort'] = $rs->fields['sortindex'];
         $unsort_array[$parent_new][$k]['langstring'] = $rs->fields['entry_langstring'];
         $unsort_array[$parent_new][$k]['url'] = $rs->fields['entry_url'];
         $unsort_array[$parent_new][$k]['url_target'] = $rs->fields['url_target'];
         $unsort_array[$parent_new][$k]['validate'] = $rs->fields['entry_validate'];
         $k++;
         $rs->MoveNext();
     }
     // rekursives Auslesen vom $unsort_array
     // die Daten werden danach mit richtiger Reihenfolge in ein Array eingeordnet
     $this->count = 0;
     $this->maxlevel = 0;
     $this->unsort_array = $unsort_array;
     $this->_menuLevelOrder(0);
 }
Exemplo n.º 2
0
    /**
     * Delete files if client setting remove_files_404 is TRUE.
     * Otherwise only update the status and delete nothing.
     * @return boolean Returns TRUE on success. Otherwise returns FALSE.
     */
    protected function _deleteFilesNotFound()
    {
        // check for files not updated to remove them if config-value is set to do so
        if ($this->config_area['remove_files_404'] == TRUE) {
            $sql = 'DELETE u, ul
				FROM
					' . $this->cfg->db('upl') . ' AS u
				LEFT JOIN
					' . $this->cfg->db('upl_lang') . ' AS ul
					ON u.idupl = ul.idupl
				WHERE
					(u.status & 0x14) = 0x10
					AND u.idclient = ' . $this->config_area['idclient'] . '
					AND u.area = "' . $this->config_area['parent_area_name'] . '"';
        } else {
            $sql = 'UPDATE
					' . $this->cfg->db('upl') . '
				SET
					status = (status & 0xEF),
					lastmodified = lastmodified
				WHERE
					idclient = ' . $this->config_area['idclient'] . '
					AND u.area = ' . $this->config_area['parent_area_name'];
        }
        $sql .= ';';
        //echo $sql."<br />";
        $rs = $this->db->Execute($sql);
        if ($rs === FALSE || $rs->EOF) {
            return FALSE;
        }
        return TRUE;
    }
Exemplo n.º 3
0
 /**
  * Removes the current item from the DB.
  * The variable $what defines which field to use
  * @param string $what
  * @param string $tablename
  * @return Returns TRUE on success or FALSE on failure.
  */
 protected function _delete($tablename, $what)
 {
     if ($tablename == '' || !array_key_exists($tablename, $this->tables)) {
         return FALSE;
     }
     switch ($what) {
         case 'id':
             $sql = $this->_getDeleteSql($tablename, array('id' => $this->tables[$tablename]['fields']['id']));
             break;
         default:
             return FALSE;
     }
     if ($sql === FALSE) {
         return FALSE;
     }
     $rs = $this->db->Execute($sql);
     if ($rs === FALSE) {
         return FALSE;
     }
     $rs->Close();
     return TRUE;
 }
Exemplo n.º 4
0
 /**
  * Generates the collection to the set criteria.
  * First build the SQL statement and select only the ids.
  * Then load the models (items) by id and push them to stack.
  * Note: The id field is taken from the first table of the model.
  * @see API/INTERFACES/SF_INTERFACE_Collection#generate()
  * @return boolean Returns TRUE on success or FALSE on failure.
  */
 public function generate()
 {
     $fields = $this->_getSqlFields($this->treecfg['fields']);
     $clientlang = $this->_getSqlClientLang($this->treecfg['idclient'], $this->treecfg['idlang'], array('client' => 'idclient', 'lang', 'idlang'));
     // default order
     if (count($this->treecfg['order']) <= 0) {
         $this->treecfg['order'][$this->treecfg['fields']['parent']] = 'ASC';
         if ($this->treecfg['fields']['sortindex'] != '') {
             $this->treecfg['order'][$this->treecfg['fields']['sortindex']] = 'ASC';
         }
     }
     $order = $this->_getSqlOrder($this->treecfg['order']);
     $sql = $this->_getGenerateSql($fields, $this->treecfg['tablename'], $clientlang, $order);
     //echo $sql."<br />";
     if ($sql === FALSE) {
         return FALSE;
     }
     $rs = $this->db->Execute($sql);
     if ($rs === FALSE || $rs->EOF) {
         return FALSE;
     }
     $sortindex = 0;
     while (!$rs->EOF) {
         if ($this->treecfg['fields']['sortindex'] == '') {
             $sortindex = count($this->data['rawdata'][$rs->fields['parent']]);
         } else {
             $sortindex = is_numeric($rs->fields['sortindex']) ? (int) $rs->fields['sortindex'] : $rs->fields['sortindex'];
         }
         $this->data['rawdata'][$rs->fields['parent']][$sortindex] = is_numeric($rs->fields['id']) ? (int) $rs->fields['id'] : $rs->fields['id'];
         $this->data['parents'][$rs->fields['id']] = is_numeric($rs->fields['parent']) ? (int) $rs->fields['parent'] : $rs->fields['parent'];
         $rs->MoveNext();
     }
     $rs->Close();
     $this->_treeOrder(0);
     return TRUE;
 }
Exemplo n.º 5
0
 /**
  * Generate a SQL statement to set the perm limits
  * @return string Returns the piece of the SQL statement.
  * If an error occurs it returns an empty string.
  */
 protected function _getSqlPerms()
 {
     static $sql_perms = '';
     //perms are allready generated, return the string
     if ($sql_perms != '') {
         return $sql_perms;
     }
     //init perms with nothing
     $sql_perms = ' ';
     //Check if permcheck is enabled
     if (!$this->colcfg['perm_check_active']) {
         return $sql_perms;
     }
     //TODO make it for other clients/langs work
     if (TRUE) {
         $perm = $this->cfg->perm();
     } else {
         //TODO $client, $lang
         $perm = new cms_perms($client, $lang, TRUE, $this->cfg->perm()->get_group());
     }
     //admin has all perms, no more actions are needed
     if ($perm->is_admin()) {
         return $sql_perms;
     }
     $fielditem = $this->colcfg['perm_dbfield_id'];
     $fieldparent = $this->colcfg['perm_dbfield_parent'] != '' ? $this->colcfg['perm_dbfield_parent'] : NULL;
     $tablename = $this->tables[0];
     $clientlang = $this->_getSqlClientLang($this->colcfg['client'], $this->colcfg['lang'], array('client' => 'idclient', 'lang' => 'idlang'));
     $timestamp = $this->_getSqlTimestamp('created', $this->colcfg['timestamp_from'], $this->colcfg['timestamp_to']);
     $freefilter = $this->_getSqlFreefilter($this->colcfg['freefilter']);
     $search = $this->_getSqlSearch($this->colcfg['searchterm'], $this->colcfg['fulltextsearchfileds']);
     $item = sf_api($this->colcfg['model_path'], $this->colcfg['model']);
     $idfield = $item->mapFieldToRow('id', $this->tables[0]);
     $sql = $this->_getPermcheckSql($fielditem, $fieldparent, $tablename, $clientlang, $timestamp, $freefilter, $search);
     if ($sql === FALSE) {
         return $sql_perms;
     }
     $rs = $this->db->Execute($sql);
     if ($rs === FALSE || $rs->EOF) {
         return $sql_perms;
     }
     $positives = array();
     $negatives = array();
     //perms with dependancy
     if ($this->colcfg['perm_dbfield_parent'] != NULL) {
         while (!$rs->EOF) {
             if ($perm->have_perm($this->colcfg['perm_nr'], $this->colcfg['perm_type'], $rs->fields['iditem'], $rs->fields['idparent'])) {
                 array_push($positives, $rs->fields['iditem']);
             } else {
                 array_push($negatives, $rs->fields['iditem']);
             }
             $rs->MoveNext();
         }
     } else {
         while (!$rs->EOF) {
             if ($perm->have_perm($this->colcfg['perm_nr'], $this->colcfg['perm_type'], $rs->fields['iditem'])) {
                 array_push($positives, $rs->fields['iditem']);
             } else {
                 array_push($negatives, $rs->fields['iditem']);
             }
             $rs->MoveNext();
         }
     }
     $rs->Close();
     $count_pos = count($positives);
     $count_neg = count($negatives);
     if ($count_pos == 0 && $count_neg == 0) {
         return $sql_perms;
     } else {
         if ($count_pos < $count_neg && $count_pos > 0) {
             $sql_perms = 'AND ' . $this->colcfg['perm_dbfield_id'] . ' IN (' . implode(',', $positives) . ') ';
         } else {
             if ($count_neg > 0) {
                 $sql_perms = 'AND ' . $this->colcfg['perm_dbfield_id'] . ' NOT IN (' . implode(',', $negatives) . ') ';
             }
         }
     }
     return $sql_perms;
 }