public function __construct($strTable, $arrModule = array())
 {
     parent::__construct();
     // Check the request token (see #4007)
     if (isset($_GET['act'])) {
         if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) {
             $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request'));
             $this->redirect('contao/confirm.php');
         }
     }
     $this->intId = \Input::get('id');
     // Check whether the table is defined
     if (!$strTable || !isset($GLOBALS['TL_DCA'][$strTable])) {
         $this->log('Could not load the data container configuration for "' . $strTable . '"', 'DC_Table __construct()', TL_ERROR);
         trigger_error('Could not load the data container configuration', E_USER_ERROR);
     }
     $this->strTable = $strTable;
     $this->arrModule = $arrModule;
     // Call onload_callback (e.g. to check permissions)
     if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) {
         foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $this->{$callback[0]}->{$callback[1]}($this);
             }
         }
     }
 }
Esempio n. 2
0
	/**
	 * Initialize the object
	 * @param string
	 */
	public function __construct($strTable)
	{
		parent::__construct();
		$this->intId = $this->Input->get('id');

		// Check whether the table is defined
		if ($strTable == '' || !isset($GLOBALS['TL_DCA'][$strTable])) 
		{
			$this->log('Could not load data container configuration for "' . $strTable . '"', 'DC_File __construct()', TL_ERROR);
			trigger_error('Could not load data container configuration', E_USER_ERROR);
		}

		// Build object from global configuration array
		$this->strTable = $strTable;

		// Call onload_callback (e.g. to check permissions)
		if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback']))
		{
			foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback)
			{
				if (is_array($callback))
				{
					$this->import($callback[0]);
					$this->$callback[0]->$callback[1]($this);
				}
			}
		}
	}
Esempio n. 3
0
 /**
  * Initialize the object
  * @param string
  */
 public function __construct($strTable)
 {
     parent::__construct();
     $this->import('String');
     $this->intId = $this->Input->get('id', true);
     // Clear the clipboard
     if (isset($_GET['clipboard'])) {
         $this->Session->set('CLIPBOARD', array());
         $this->redirect($this->getReferer());
     }
     // Check whether the table is defined
     if (!strlen($strTable) || !count($GLOBALS['TL_DCA'][$strTable])) {
         $this->log('Could not load data container configuration for "' . $strTable . '"', 'DC_Folder __construct()', TL_ERROR);
         trigger_error('Could not load data container configuration', E_USER_ERROR);
     }
     // Check permission to create new folders
     if ($this->Input->get('act') == 'paste' && $this->Input->get('mode') == 'create' && isset($GLOBALS['TL_DCA'][$strTable]['list']['new'])) {
         $this->log('Attempt to create a new folder although the method has been overwritten in the data container', 'DC_Folder __construct()', TL_ERROR);
         $this->redirect('contao/main.php?act=error');
     }
     // Set IDs and redirect
     if ($this->Input->post('FORM_SUBMIT') == 'tl_select') {
         $ids = deserialize($this->Input->post('IDS'));
         if (!is_array($ids) || count($ids) < 1) {
             $this->reload();
         }
         $session = $this->Session->getData();
         $session['CURRENT']['IDS'] = $ids;
         $this->Session->setData($session);
         if (isset($_POST['edit'])) {
             $this->redirect(str_replace('act=select', 'act=editAll', $this->Environment->request));
         } elseif (isset($_POST['delete'])) {
             $this->redirect(str_replace('act=select', 'act=deleteAll', $this->Environment->request));
         } elseif (isset($_POST['cut']) || isset($_POST['copy'])) {
             $arrClipboard = $this->Session->get('CLIPBOARD');
             $arrClipboard[$strTable] = array('id' => $ids, 'mode' => isset($_POST['cut']) ? 'cutAll' : 'copyAll');
             $this->Session->set('CLIPBOARD', $arrClipboard);
             $this->redirect($this->getReferer());
         }
     }
     $this->strTable = $strTable;
     // Check for valid file types
     if ($GLOBALS['TL_DCA'][$this->strTable]['config']['validFileTypes']) {
         $this->arrValidFileTypes = trimsplit(',', $GLOBALS['TL_DCA'][$this->strTable]['config']['validFileTypes']);
     }
     // Call onload_callback (e.g. to check permissions)
     if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) {
         foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $this->{$callback}[0]->{$callback}[1]($this);
             }
         }
     }
     // Get all filemounts (root folders)
     if (is_array($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root'])) {
         $this->arrFilemounts = $this->eliminateNestedPaths($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root']);
     }
 }
Esempio n. 4
0
 /**
  * Initialize the object
  *
  * @param string $strTable
  * @param array  $arrModule
  */
 public function __construct($strTable, $arrModule = array())
 {
     parent::__construct();
     // Check the request token (see #4007)
     if (isset($_GET['act'])) {
         if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) {
             $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request'));
             $this->redirect('contao/confirm.php');
         }
     }
     $this->intId = \Input::get('id');
     // Clear the clipboard
     if (isset($_GET['clipboard'])) {
         $this->Session->set('CLIPBOARD', array());
         $this->redirect($this->getReferer());
     }
     // Check whether the table is defined
     if ($strTable == '' || !isset($GLOBALS['TL_DCA'][$strTable])) {
         $this->log('Could not load the data container configuration for "' . $strTable . '"', __METHOD__, TL_ERROR);
         trigger_error('Could not load the data container configuration', E_USER_ERROR);
     }
     // Set IDs and redirect
     if (\Input::post('FORM_SUBMIT') == 'tl_select') {
         $ids = \Input::post('IDS');
         if (empty($ids) || !is_array($ids)) {
             $this->reload();
         }
         $session = $this->Session->getData();
         $session['CURRENT']['IDS'] = $ids;
         $this->Session->setData($session);
         if (isset($_POST['edit'])) {
             $this->redirect(str_replace('act=select', 'act=editAll', \Environment::get('request')));
         } elseif (isset($_POST['delete'])) {
             $this->redirect(str_replace('act=select', 'act=deleteAll', \Environment::get('request')));
         } elseif (isset($_POST['override'])) {
             $this->redirect(str_replace('act=select', 'act=overrideAll', \Environment::get('request')));
         } elseif (isset($_POST['cut']) || isset($_POST['copy'])) {
             $arrClipboard = $this->Session->get('CLIPBOARD');
             $arrClipboard[$strTable] = array('id' => $ids, 'mode' => isset($_POST['cut']) ? 'cutAll' : 'copyAll');
             $this->Session->set('CLIPBOARD', $arrClipboard);
             // Support copyAll in the list view (see #7499)
             if (isset($_POST['copy']) && $GLOBALS['TL_DCA'][$strTable]['list']['sorting']['mode'] < 4) {
                 $this->redirect(str_replace('act=select', 'act=copyAll', \Environment::get('request')));
             }
             $this->redirect($this->getReferer());
         }
     }
     $this->strTable = $strTable;
     $this->ptable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ptable'];
     $this->ctable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ctable'];
     $this->treeView = in_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'], array(5, 6));
     $this->root = null;
     $this->arrModule = $arrModule;
     // Call onload_callback (e.g. to check permissions)
     if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) {
         foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $this->{$callback[0]}->{$callback[1]}($this);
             } elseif (is_callable($callback)) {
                 $callback($this);
             }
         }
     }
     // Get the IDs of all root records (tree view)
     if ($this->treeView) {
         $table = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 6 ? $this->ptable : $this->strTable;
         // Unless there are any root records specified, use all records with parent ID 0
         if (!isset($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']) || $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] === false) {
             $objIds = $this->Database->prepare("SELECT id FROM " . $table . " WHERE pid=?" . ($this->Database->fieldExists('sorting', $table) ? ' ORDER BY sorting' : ''))->execute(0);
             if ($objIds->numRows > 0) {
                 $this->root = $objIds->fetchEach('id');
             }
         } elseif (is_array($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'])) {
             $this->root = $this->eliminateNestedPages($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'], $table, $this->Database->fieldExists('sorting', $table));
         }
     } elseif (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['root'])) {
         $this->root = array_unique($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['root']);
     }
     // Store the current referer
     if (!empty($this->ctable) && !\Input::get('act') && !\Input::get('key') && !\Input::get('token') && TL_SCRIPT == 'contao/main.php' && !\Environment::get('isAjaxRequest')) {
         $session = $this->Session->get('referer');
         $session[TL_REFERER_ID][$this->strTable] = substr(\Environment::get('requestUri'), strlen(TL_PATH) + 1);
         $this->Session->set('referer', $session);
     }
 }
Esempio n. 5
0
 /**
  * Initialize the object
  *
  * @param string $strTable
  */
 public function __construct($strTable)
 {
     parent::__construct();
     // Check the request token (see #4007)
     if (isset($_GET['act'])) {
         if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) {
             $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request'));
             $this->redirect('contao/confirm.php');
         }
     }
     $this->intId = \Input::get('id', true);
     // Clear the clipboard
     if (isset($_GET['clipboard'])) {
         $this->Session->set('CLIPBOARD', array());
         $this->redirect($this->getReferer());
     }
     // Check whether the table is defined
     if ($strTable == '' || !isset($GLOBALS['TL_DCA'][$strTable])) {
         $this->log('Could not load data container configuration for "' . $strTable . '"', __METHOD__, TL_ERROR);
         trigger_error('Could not load data container configuration', E_USER_ERROR);
     }
     // Check permission to create new folders
     if (\Input::get('act') == 'paste' && \Input::get('mode') == 'create' && isset($GLOBALS['TL_DCA'][$strTable]['list']['new'])) {
         $this->log('Attempt to create a new folder although the method has been overwritten in the data container', __METHOD__, TL_ERROR);
         $this->redirect('contao/main.php?act=error');
     }
     // Set IDs and redirect
     if (\Input::post('FORM_SUBMIT') == 'tl_select') {
         $ids = \Input::post('IDS');
         if (empty($ids) || !is_array($ids)) {
             $this->reload();
         }
         // Decode the values (see #5764)
         $ids = array_map('rawurldecode', $ids);
         $session = $this->Session->getData();
         $session['CURRENT']['IDS'] = $ids;
         $this->Session->setData($session);
         if (isset($_POST['edit'])) {
             $this->redirect(str_replace('act=select', 'act=editAll', \Environment::get('request')));
         } elseif (isset($_POST['delete'])) {
             $this->redirect(str_replace('act=select', 'act=deleteAll', \Environment::get('request')));
         } elseif (isset($_POST['cut']) || isset($_POST['copy'])) {
             $arrClipboard = $this->Session->get('CLIPBOARD');
             $arrClipboard[$strTable] = array('id' => $ids, 'mode' => isset($_POST['cut']) ? 'cutAll' : 'copyAll');
             $this->Session->set('CLIPBOARD', $arrClipboard);
             $this->redirect($this->getReferer());
         }
     }
     $this->strTable = $strTable;
     $this->blnIsDbAssisted = $GLOBALS['TL_DCA'][$strTable]['config']['databaseAssisted'];
     // Check for valid file types
     if ($GLOBALS['TL_DCA'][$this->strTable]['config']['validFileTypes']) {
         $this->arrValidFileTypes = trimsplit(',', strtolower($GLOBALS['TL_DCA'][$this->strTable]['config']['validFileTypes']));
     }
     // Call onload_callback (e.g. to check permissions)
     if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) {
         foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $this->{$callback[0]}->{$callback[1]}($this);
             } elseif (is_callable($callback)) {
                 $callback($this);
             }
         }
     }
     // Get all filemounts (root folders)
     if (is_array($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root'])) {
         $this->arrFilemounts = $this->eliminateNestedPaths($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root']);
     }
 }
Esempio n. 6
0
 /**
  * Initialize the object
  * @param string
  */
 public function __construct($strTable)
 {
     parent::__construct();
     $this->intId = $this->Input->get('id');
     // Clear the clipboard
     if (isset($_GET['clipboard'])) {
         $this->Session->set('CLIPBOARD', array());
         $this->redirect($this->getReferer());
     }
     $this->import('String');
     $this->loadDataContainer('tl_form_field');
     $this->import('FormData');
     // in Backend: Check BE User, Admin...
     if (TL_MODE == 'BE' || BE_USER_LOGGED_IN) {
         $this->import('BackendUser', 'User');
     }
     // in Frontend:
     if (TL_MODE == 'FE') {
         $this->import('FrontendUser', 'Member');
     }
     if ($this->Input->get('key') == 'export') {
         $this->strMode = 'export';
     }
     if ($this->Input->get('key') == 'exportxls') {
         $this->strMode = 'exportxls';
     }
     $this->blnExportUTF8Decode = true;
     if (isset($GLOBALS['EFG']['exportUTF8Decode']) && $GLOBALS['EFG']['exportUTF8Decode'] == false) {
         $this->blnExportUTF8Decode = false;
     }
     if (isset($GLOBALS['EFG']['exportIgnoreFields'])) {
         if (is_string($GLOBALS['EFG']['exportIgnoreFields']) && strlen($GLOBALS['EFG']['exportIgnoreFields'])) {
             $this->arrExportIgnoreFields = trimsplit(',', $GLOBALS['EFG']['exportIgnoreFields']);
         }
     }
     // get all forms marked to store data
     $objForms = $this->Database->prepare("SELECT id,title,formID,useFormValues,useFieldNames,efgAliasField FROM tl_form WHERE storeFormdata=?")->execute("1");
     if (!$this->arrStoreForms) {
         while ($objForms->next()) {
             if (strlen($objForms->formID)) {
                 $varKey = $objForms->formID;
             } else {
                 $varKey = str_replace('-', '_', standardize($objForms->title));
             }
             $this->arrStoreForms[$varKey] = $objForms->row();
             $this->arrFormsDcaKey[$varKey] = $objForms->title;
         }
     }
     // all field names of table tl_formdata
     foreach ($this->Database->listFields('tl_formdata') as $arrField) {
         if ($arrField['type'] != 'index') {
             $this->arrBaseFields[] = $arrField['name'];
         }
     }
     $this->arrBaseFields = array_unique($this->arrBaseFields);
     $this->arrOwnerFields = array('fd_member', 'fd_user', 'fd_member_group', 'fd_user_group');
     $this->getMembers();
     $this->getUsers();
     $this->getMemberGroups();
     $this->getUserGroups();
     // Check whether the table is defined
     if ($strTable == '' || !isset($GLOBALS['TL_DCA'][$strTable])) {
         $this->log('Could not load the data container configuration for "' . $strTable . '"', 'DC_Formdata __construct()', TL_ERROR);
         trigger_error('Could not load the data container configuration', E_USER_ERROR);
     }
     // Set IDs and redirect
     if ($this->Input->post('FORM_SUBMIT') == 'tl_select') {
         $ids = deserialize($this->Input->post('IDS'));
         if (!is_array($ids) || empty($ids)) {
             $this->reload();
         }
         $session = $this->Session->getData();
         $session['CURRENT']['IDS'] = deserialize($this->Input->post('IDS'));
         $this->Session->setData($session);
         if (isset($_POST['edit'])) {
             $this->redirect(str_replace('act=select', 'act=editAll', $this->Environment->request));
         } elseif (isset($_POST['delete'])) {
             $this->redirect(str_replace('act=select', 'act=deleteAll', $this->Environment->request));
         } elseif (isset($_POST['override'])) {
             $this->redirect(str_replace('act=select', 'act=overrideAll', $this->Environment->request));
         } elseif (isset($_POST['cut']) || isset($_POST['copy'])) {
             $arrClipboard = $this->Session->get('CLIPBOARD');
             $arrClipboard[$strTable] = array('id' => $ids, 'mode' => isset($_POST['cut']) ? 'cutAll' : 'copyAll');
             $this->Session->set('CLIPBOARD', $arrClipboard);
             $this->redirect($this->getReferer());
         }
     }
     $this->strTable = $strTable;
     $this->ptable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ptable'];
     $this->ctable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ctable'];
     $this->treeView = false;
     $this->root = null;
     // Key of a form or '' for no specific form
     $this->strFormKey = '';
     $this->strFormFilterKey = '';
     $this->strFormFilterValue = '';
     if ($this->Input->get('do')) {
         if ($this->Input->get('do') != 'feedback') {
             if (array_key_exists($this->Input->get('do'), $GLOBALS['BE_MOD']['formdata'])) {
                 $this->strFormKey = $this->Input->get('do');
                 $this->strFormFilterKey = 'form';
                 $this->strFormFilterValue = $this->arrStoreForms[str_replace('fd_', '', $this->strFormKey)]['title'];
                 $this->sqlFormFilter = ' AND ' . $this->strFormFilterKey . '=\'' . $this->strFormFilterValue . '\' ';
                 // add sql where condition 'form'=TILTE_OF_FORM
                 if ($this->strTable == 'tl_formdata') {
                     $this->procedure[] = $this->strFormFilterKey . '=?';
                     $this->values[] = $this->strFormFilterValue;
                 }
             }
         }
     }
     // Call onload_callback (e.g. to check permissions)
     if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) {
         foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $this->{$callback}[0]->{$callback}[1]($this);
             }
         }
     }
     // check names of detail fields
     // .. after call to onload_callback we have the form specific dca in $GLOBALS['TL_DCA'][$this->strTable]
     if (strlen($this->strFormKey)) {
         $arrFFNames = array_keys($GLOBALS['TL_DCA'][$this->strTable]['fields']);
     } else {
         $objFFNames = $this->Database->prepare("SELECT DISTINCT ff.name FROM tl_form_field ff, tl_form f WHERE (ff.pid=f.id) AND ff.name != '' AND f.storeFormdata=?")->execute("1");
         if ($objFFNames->numRows) {
             $arrFFNames = $objFFNames->fetchEach('name');
         }
     }
     if (!empty($arrFFNames)) {
         $this->arrDetailFields = array_diff($arrFFNames, $this->arrBaseFields, array('import_source'));
     }
     // store array of sql-stmts for detail fields
     if (!empty($this->arrDetailFields)) {
         $this->arrSqlDetails = array();
         foreach ($this->arrDetailFields as $strFName) {
             $this->arrSqlDetails[$strFName] = '(SELECT value FROM tl_formdata_details WHERE ff_name=\'' . $strFName . '\' AND pid=f.id) AS `' . $strFName . '`';
         }
     }
     // Store the current referer
     if (!empty($this->ctable) && !$this->Input->get('act') && !$this->Input->get('key') && !$this->Input->get('token')) {
         $session = $this->Session->get('referer');
         $session[$this->strTable] = $this->Environment->requestUri;
         $this->Session->set('referer', $session);
     }
 }
Esempio n. 7
0
 /**
  * Import the back end user object
  */
 public function __construct()
 {
     parent::__construct();
     $this->import('BackendUser', 'User');
 }
Esempio n. 8
0
 public function __construct($strTable, array &$arrDCA = null, $blnOnloadCallback = true)
 {
     // Set start timer
     $this->intTimerStart = microtime(true);
     $this->intQueryCount = count($GLOBALS['TL_DEBUG']);
     // Call parent
     parent::__construct();
     // Callback
     $strTable = $this->getTablenameCallback($strTable);
     // Basic vars Init
     $this->strTable = $strTable;
     // in contao 3 the second constructor parameter is the backend module array.
     // Therefore we have to check if the passed argument is indeed a valid DCA.
     if ($arrDCA != null && $arrDCA['config']) {
         $this->arrDCA = $arrDCA;
     } else {
         $this->arrDCA =& $GLOBALS['TL_DCA'][$this->strTable];
     }
     // Check whether the table is defined
     if (!strlen($this->strTable) || !count($this->arrDCA)) {
         $this->log('Could not load data container configuration for "' . $strTable . '"', 'DC_Table __construct()', TL_ERROR);
         trigger_error('Could not load data container configuration', E_USER_ERROR);
     }
     // Import
     $this->import('Encryption');
     // Switch user for FE / BE support
     switch (TL_MODE) {
         case 'FE':
             $this->import('FrontendUser', 'User');
             break;
         default:
         case 'BE':
             $this->import('BackendUser', 'User');
             break;
     }
     // Load
     $this->checkPostGet();
     $this->loadProviderAndHandler();
     // Check for forcemode
     if ($this->arrDCA['config']['forceEdit']) {
         $this->blnForceEdit = true;
         $this->intId = 1;
     }
     // SH: We need the buttons here, because the onloadCallback is (the only) one
     // to remove buttons.
     $this->loadDefaultButtons();
     // Callback
     if ($blnOnloadCallback == true) {
         $this->objCallbackClass->onloadCallback($strTable);
     }
     // execute AJAX request, called from Backend::getBackendModule
     // we have to do this here, as otherwise the script will exit as it only checks for DC_Table and DC_File decendant classes. :/
     if ($_POST && $this->Environment->isAjaxRequest) {
         $this->getControllerHandler()->executePostActions();
     }
 }
Esempio n. 9
0
	/**
	 * Initialize the object
	 * @param string
	 */
	public function __construct($strTable)
	{
		parent::__construct();
		$this->intId = $this->Input->get('id');

		// Clear the clipboard
		if (isset($_GET['clipboard']))
		{
			$this->Session->set('CLIPBOARD', array());
			$this->redirect($this->getReferer());
		}

		// Check whether the table is defined
		if ($strTable == '' || !isset($GLOBALS['TL_DCA'][$strTable]))
		{
			$this->log('Could not load the data container configuration for "' . $strTable . '"', 'DC_Table __construct()', TL_ERROR);
			trigger_error('Could not load the data container configuration', E_USER_ERROR);
		}

		// Set IDs and redirect
		if ($this->Input->post('FORM_SUBMIT') == 'tl_select')
		{
			$ids = deserialize($this->Input->post('IDS'));

			if (!is_array($ids) || empty($ids))
			{
				$this->reload();
			}

			$session = $this->Session->getData();
			$session['CURRENT']['IDS'] = deserialize($this->Input->post('IDS'));
			$this->Session->setData($session);

			if (isset($_POST['edit']))
			{
				$this->redirect(str_replace('act=select', 'act=editAll', $this->Environment->request));
			}
			elseif (isset($_POST['delete']))
			{
				$this->redirect(str_replace('act=select', 'act=deleteAll', $this->Environment->request));
			}
			elseif (isset($_POST['override']))
			{
				$this->redirect(str_replace('act=select', 'act=overrideAll', $this->Environment->request));
			}
			elseif (isset($_POST['cut']) || isset($_POST['copy']))
			{
				$arrClipboard = $this->Session->get('CLIPBOARD');

				$arrClipboard[$strTable] = array
				(
					'id' => $ids,
					'mode' => (isset($_POST['cut']) ? 'cutAll' : 'copyAll')
				);

				$this->Session->set('CLIPBOARD', $arrClipboard);
				$this->redirect($this->getReferer());
			}
		}

		$this->strTable = $strTable;
		$this->ptable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ptable'];
		$this->ctable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ctable'];
		$this->treeView = in_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'], array(5, 6));
		$this->root = null;

		// Call onload_callback (e.g. to check permissions)
		if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback']))
		{
			foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback)
			{
				if (is_array($callback))
				{
					$this->import($callback[0]);
					$this->$callback[0]->$callback[1]($this);
				}
			}
		}

		// Get the IDs of all root records (tree view)
		if ($this->treeView)
		{
			$table = ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 6) ? $this->ptable : $this->strTable;

			 // Unless there are any root records specified, use all records with parent ID 0
			if (!isset($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']) || $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] === false)
			{
				$objIds = $this->Database->prepare("SELECT id FROM " . $table . " WHERE pid=?" . ($this->Database->fieldExists('sorting', $table) ? ' ORDER BY sorting' : ''))
										 ->execute(0);

				if ($objIds->numRows > 0)
				{
					$this->root = $objIds->fetchEach('id');
				}
			}

			// Get root records from global configuration file
			elseif (is_array($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']))
			{
				$this->root = $this->eliminateNestedPages($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'], $table, $this->Database->fieldExists('sorting', $table));
			}
		}

		// Get the IDs of all root records (list view or parent view)
		elseif (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['root']))
		{
			$this->root = array_unique($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['root']);
		}

		// Store the current referer
		if (!empty($this->ctable) && !$this->Input->get('act') && !$this->Input->get('key') && !$this->Input->get('token'))
		{
			$session = $this->Session->get('referer');
			$session[$this->strTable] = $this->Environment->requestUri;
			$this->Session->set('referer', $session);
		}
	}
Esempio n. 10
0
 public function __construct($smarty, $interface, $languageManager)
 {
     parent::__construct($smarty, $interface);
     $this->_languageManager = $languageManager;
 }
Esempio n. 11
0
 /**
  * Initialize the object
  * @param string
  * @param array
  */
 public function __construct($strTable, $arrModule = array())
 {
     parent::__construct();
     // Check the request token (see #4007)
     if (isset($_GET['act'])) {
         if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) {
             $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request'));
             \Controller::redirect('contao/confirm.php');
         }
     }
     $this->intId = \Input::get('id');
     // Clear the clipboard
     if (isset($_GET['clipboard'])) {
         $this->Session->set('CLIPBOARD', array());
         \Controller::redirect($this->getReferer());
     }
     $this->loadDataContainer('tl_form_field');
     $this->import('Formdata');
     // in Backend: Check BE User, Admin...
     if (TL_MODE == 'BE' || BE_USER_LOGGED_IN) {
         $this->import('BackendUser', 'User');
     }
     // in Frontend:
     if (TL_MODE == 'FE') {
         $this->import('FrontendUser', 'Member');
     }
     if (\Input::get('key') == 'export') {
         $this->strMode = 'export';
     } elseif (\Input::get('key') == 'exportxls') {
         $this->strMode = 'exportxls';
     }
     $this->blnExportUTF8Decode = true;
     $this->strExportConvertToCharset = 'CP1252';
     if (isset($GLOBALS['EFG']['exportUTF8Decode']) && $GLOBALS['EFG']['exportUTF8Decode'] == false) {
         $this->blnExportUTF8Decode = false;
     }
     if (isset($GLOBALS['EFG']['exportConvertToCharset'])) {
         $this->strExportConvertToCharset = $GLOBALS['EFG']['exportConvertToCharset'];
     }
     if (isset($GLOBALS['EFG']['exportIgnoreFields'])) {
         if (is_string($GLOBALS['EFG']['exportIgnoreFields']) && strlen($GLOBALS['EFG']['exportIgnoreFields'])) {
             $this->arrExportIgnoreFields = trimsplit(',', $GLOBALS['EFG']['exportIgnoreFields']);
         }
     }
     // all field names of table tl_formdata
     foreach (\Database::getInstance()->listFields('tl_formdata') as $arrField) {
         if ($arrField['type'] != 'index') {
             $this->arrBaseFields[] = $arrField['name'];
         }
     }
     $this->arrBaseFields = array_unique($this->arrBaseFields);
     $this->arrOwnerFields = array('fd_member', 'fd_user', 'fd_member_group', 'fd_user_group');
     $this->arrMembers = $this->Formdata->arrMembers;
     $this->arrMemberGroups = $this->Formdata->arrMemberGroups;
     $this->arrUsers = $this->Formdata->arrUsers;
     $this->arrUserGroups = $this->Formdata->arrUserGroups;
     // Check whether the table is defined
     if ($strTable == '' || !isset($GLOBALS['TL_DCA'][$strTable])) {
         $this->log('Could not load the data container configuration for "' . $strTable . '"', __METHOD__, TL_ERROR);
         trigger_error('Could not load the data container configuration', E_USER_ERROR);
     }
     // Set IDs and redirect
     if (\Input::post('FORM_SUBMIT') == 'tl_select') {
         $ids = \Input::post('IDS');
         if (!is_array($ids) || empty($ids)) {
             \Controller::reload();
         }
         $session = $this->Session->getData();
         $session['CURRENT']['IDS'] = \Input::post('IDS');
         $this->Session->setData($session);
         if (isset($_POST['edit'])) {
             \Controller::redirect(str_replace('act=select', 'act=editAll', \Environment::get('request')));
         } elseif (isset($_POST['delete'])) {
             \Controller::redirect(str_replace('act=select', 'act=deleteAll', \Environment::get('request')));
         } elseif (isset($_POST['override'])) {
             \Controller::redirect(str_replace('act=select', 'act=overrideAll', \Environment::get('request')));
         } elseif (isset($_POST['cut']) || isset($_POST['copy'])) {
             $arrClipboard = $this->Session->get('CLIPBOARD');
             $arrClipboard[$strTable] = array('id' => $ids, 'mode' => isset($_POST['cut']) ? 'cutAll' : 'copyAll');
             $this->Session->set('CLIPBOARD', $arrClipboard);
             \Controller::redirect($this->getReferer());
         }
     }
     $this->strTable = $strTable;
     $this->ptable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ptable'];
     $this->ctable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ctable'];
     $this->treeView = false;
     $this->root = null;
     $this->arrModule = $arrModule;
     // Key of a form or '' for no specific form
     $this->strFormKey = '';
     $this->strFormFilterKey = '';
     $this->strFormFilterValue = '';
     if (\Input::get('do')) {
         if (\Input::get('do') != 'feedback') {
             if (array_key_exists(\Input::get('do'), $GLOBALS['BE_MOD']['formdata'])) {
                 $this->strFormKey = \Input::get('do');
                 $this->strFormFilterKey = 'form';
                 $this->strFormFilterValue = $this->Formdata->arrStoringForms[substr($this->strFormKey, 3)]['title'];
                 $this->sqlFormFilter = ' AND ' . $this->strFormFilterKey . '=\'' . $this->strFormFilterValue . '\' ';
                 // add sql where condition 'form'=TITLE_OF_FORM
                 if ($this->strTable == 'tl_formdata') {
                     $this->procedure[] = $this->strFormFilterKey . '=?';
                     $this->values[] = $this->strFormFilterValue;
                 }
             }
         }
     }
     // Call onload_callback (e.g. to check permissions)
     if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) {
         foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $this->{$callback}[0]->{$callback}[1]($this);
             } elseif (is_callable($callback)) {
                 $callback($this);
             }
         }
     }
     // check names of detail fields
     // .. after call to onload_callback we have the form specific dca in $GLOBALS['TL_DCA'][$this->strTable]
     if (strlen($this->strFormKey)) {
         $arrFFNames = array_keys($GLOBALS['TL_DCA'][$this->strTable]['fields']);
     } else {
         $objFFNames = \Database::getInstance()->prepare("SELECT DISTINCT ff.name FROM tl_form_field ff, tl_form f WHERE (ff.pid=f.id) AND ff.name != '' AND f.storeFormdata=?")->execute("1");
         if ($objFFNames->numRows) {
             $arrFFNames = $objFFNames->fetchEach('name');
         }
     }
     if (!empty($arrFFNames)) {
         $this->arrDetailFields = array_diff($arrFFNames, $this->arrBaseFields, array('import_source'));
     }
     // store array of sql-stmts for detail fields
     if (!empty($this->arrDetailFields)) {
         $this->arrSqlDetails = array();
         foreach ($this->arrDetailFields as $strFName) {
             $this->arrSqlDetails[$strFName] = '(SELECT value FROM tl_formdata_details WHERE ff_name=\'' . $strFName . '\' AND pid=f.id) AS `' . $strFName . '`';
         }
     }
     // Store the current referer
     if (!empty($this->ctable) && !\Input::get('act') && !\Input::get('key') && !\Input::get('token') && \Environment::get('script') == 'contao/main.php' && !\Environment::get('isAjaxRequest')) {
         $session = $this->Session->get('referer');
         $session[TL_REFERER_ID][$this->strTable] = substr(\Environment::get('requestUri'), strlen(TL_PATH) + 1);
         $this->Session->set('referer', $session);
     }
 }