/** * Checks if a menu's action is permitted for the user * * @param SimpleXMLElement $menu * @return boolean */ protected function authorised($menu) { $childAction = $menu->attributes('action'); if (substr($childAction, 0, 10) == 'cb_action:') { $actionName = substr($childAction, 10); $action = $this->_actions->getChildByNameAttr('action', 'name', $actionName); if ($action) { if (!Access::authorised($action)) { return false; } } } return true; }
/** * @param string $cbUri The CB-URI (cbo;,,,) * @param SimpleXMLElement $sourceElem The XML element from which the URL is computed * @param TableInterface $data The data of the object for dynamic URL request values * @param int $id The id of the current row * @param bool $htmlspecialchars If htmlspecialchars should be made for this * @param bool $inPage URL target: true: html (full page), false: raw (only center component content) * @return string The URL */ function drawUrl($cbUri, SimpleXMLElement $sourceElem, $data, $id, $htmlspecialchars = true, $inPage = true) { global $_CB_framework; if (!Access::authorised($sourceElem)) { return null; } $ui = $_CB_framework->getUi(); $actionName = null; if (substr($cbUri, 0, 4) == 'cbo:') { $subTaskValue = substr($cbUri, 4); switch ($subTaskValue) { /** @noinspection PhpMissingBreakStatementInspection */ case 'newrow': // $id = 0; // fallthrough: no break on purpose. // $id = 0; // fallthrough: no break on purpose. case 'rowedit': //TBD this is duplicate of below $baseUrl = 'index.php'; if ($this->_options['view'] == 'editPlugin') { $task = $this->_options['view']; } else { $task = 'editrow'; } $baseUrl .= '?option=' . $this->_options['option'] . '&view=' . $task; if (isset($this->_options['pluginid'])) { $baseUrl .= '&cid=' . $this->_options['pluginid']; } $url = $baseUrl . '&table=' . $this->_tableBrowserModel->attributes('name') . '&action=editrow'; // below: . '&tid=' . $id; break; case 'saveorder': case 'editrows': case 'deleterows': case 'copyrows': case 'updaterows': case 'publish': case 'unpublish': case 'enable': case 'disable': default: $url = 'javascript:cbDoListTask(this, ' . "'" . addslashes($this->taskName(false)) . "','" . addslashes($this->subtaskName(false)) . "','" . addslashes($this->subtaskValue($subTaskValue, false)) . "','" . addslashes($this->fieldId('id', null, false)) . "'" . ");"; break; } } elseif (substr($cbUri, 0, 10) == 'cb_action:') { $actionName = substr($cbUri, 10); $action = $this->_actions->getChildByNameAttr('action', 'name', $actionName); if ($action) { if (!Access::authorised($action)) { return null; } $requestNames = explode(' ', $action->attributes('request')); $requestValues = explode(' ', $action->attributes('action')); $parametersValues = explode(' ', $action->attributes('parameters')); $baseUrl = 'index.php'; $baseUrl .= '?'; $baseRequests = array('option' => 'option', 'view' => 'view', 'cid' => 'pluginid'); $urlParams = array(); foreach ($baseRequests as $breq => $breqOptionsValue) { if (!(in_array($breq, $requestNames) || in_array($breq, $parametersValues)) && isset($this->_options[$breqOptionsValue])) { $urlParams[$breq] = $breq . '=' . $this->_options[$breqOptionsValue]; } } for ($i = 0, $n = count($requestNames); $i < $n; $i++) { $urlParams[$requestNames[$i]] = $requestNames[$i] . '=' . $requestValues[$i]; // other parameters = paramvalues added below } $url = $baseUrl . implode('&', $urlParams); } else { $url = "#action_not_defined:" . $actionName; } } else { $url = cbUnHtmlspecialchars($cbUri); } if (cbStartOfStringMatch($url, 'index.php')) { // get the parameters of action/link from XML : $parametersNames = explode(' ', $sourceElem->attributes('parameters')); $parametersValues = explode(' ', $sourceElem->attributes('paramvalues')); $parametersValuesTypes = explode(' ', $sourceElem->attributes('paramvaluestypes')); // generate current action (and parameters ?) as cbprevstate $cbprevstate = array(); foreach ($this->_options as $req => $act) { if ($req && $act && !in_array($req, array('cbprevstate'))) { $cbprevstate[] = $req . '=' . $act; } } $parametersNames[] = 'cbprevstate'; $parametersValues[] = "'" . base64_encode(implode('&', $cbprevstate)) . "'"; // finally generate URL: for ($i = 0, $n = count($parametersNames); $i < $n; $i++) { $nameOfVariable = $parametersValues[$i]; if ($nameOfVariable != '') { if (isset($parametersValuesTypes[$i]) && $parametersValuesTypes[$i]) { if ($parametersValuesTypes[$i] == 'sql:field') { if (is_callable(array($data, 'get'))) { $nameOfVariable = $data->get($nameOfVariable); } else { $nameOfVariable = $data->{$nameOfVariable}; } } else { // $nameOfVariable untouched } } elseif (substr($nameOfVariable, 0, 1) == "'" && substr($nameOfVariable, -1) == "'") { $nameOfVariable = substr($nameOfVariable, 1, -1); } else { if (is_callable(array($data, 'get'))) { $nameOfVariable = $data->get($nameOfVariable); } else { $nameOfVariable = $data->{$nameOfVariable}; } } $url .= '&' . $parametersNames[$i] . '=' . urlencode($nameOfVariable); } } if ($ui == 2) { $url = $_CB_framework->backendUrl($url, $htmlspecialchars, $inPage ? 'html' : 'component'); } else { $url = cbSef($url, $htmlspecialchars, $inPage ? 'html' : 'component'); } } elseif ($htmlspecialchars) { $url = htmlspecialchars($url); } return $url; }
/** * Checks if an index exists and has the type of the parameters below: * * @param string $tableName Name of table (for error strings) * @param SimpleXMLElement $row <row> to change * @param SimpleXMLElement $columns Corresponding <column> of table * @param array $allColumns From $this->getAllTableColumns( $table ) : columns which were existing before upgrading columns called before this function * @param string $colNamePrefix Prefix to add to all column names * @param boolean $change TRUE: changes row, FALSE: checks row * @param boolean $directlyInsert TRUE: does not test if row exists first, FALSE: checks first if row exists * @return boolean TRUE: identical, FALSE: errors are in $this->getErrors() */ protected function checkOrChangeRow($tableName, SimpleXMLElement $row, SimpleXMLElement $columns, $allColumns, $colNamePrefix, $change = true, $directlyInsert = false) { $indexName = $this->prefixedName($row, $colNamePrefix, 'index', 'indextype'); $indexValue = $row->attributes('value'); $indexValueType = $row->attributes('valuetype'); if ($change && $directlyInsert) { $rowsArray = array(); } else { $rowsArray = $this->loadRows($tableName, $indexName, $indexValue, $indexValueType); } $mismatchingFields = array(); $mismatchingFieldsOldValues = array(); if (is_array($rowsArray) && count($rowsArray) > 0) { foreach ($rowsArray as $rowData) { foreach ($row->children() as $field) { if ($field->getName() == 'field') { $strictField = $field->attributes('strict'); $fieldName = $this->prefixedName($field, $colNamePrefix); if ($strictField || !isset($allColumns[$fieldName])) { // if field is strict, or if column has just been created: compare value to the should be one: $fieldValue = $field->attributes('value'); $fieldValueType = $field->attributes('valuetype'); $column = $columns->getChildByNameAttr('column', 'name', $field->attributes('name')); $columnMustExist = $column && $column->attributes('mandatory') !== 'false'; if ($columnMustExist && !isset($allColumns[$fieldName]) || $columnMustExist && !array_key_exists($fieldName, $rowData) || $strictField === 'true' && $this->adjustToStrictType($rowData->{$fieldName}, $fieldValueType) !== $this->phpCleanQuote($fieldValue, $fieldValueType) || $strictField === 'notnull' && $this->adjustToStrictType($rowData->{$fieldName}, $fieldValueType) === null && $this->phpCleanQuote($fieldValue, $fieldValueType) !== null || $strictField === 'notzero' && (($this->adjustToStrictType($rowData->{$fieldName}, $fieldValueType) === null || $this->adjustToStrictType($rowData->{$fieldName}, $fieldValueType) == 0) && !($this->phpCleanQuote($fieldValue, $fieldValueType) === null || $this->phpCleanQuote($fieldValue, $fieldValueType) === 0)) || $strictField === 'notempty' && (($this->adjustToStrictType($rowData->{$fieldName}, $fieldValueType) === null || $this->adjustToStrictType($rowData->{$fieldName}, $fieldValueType) == '') && !($this->phpCleanQuote($fieldValue, $fieldValueType) === null || $this->phpCleanQuote($fieldValue, $fieldValueType) === ''))) { $mismatchingFields[$fieldName] = $this->sqlCleanQuote($fieldValue, $fieldValueType); $mismatchingFieldsOldValues[$fieldName] = array_key_exists($fieldName, $rowData) ? $rowData->{$fieldName} : '""'; } } } } foreach ($row->children() as $field) { if ($field->getName() == 'field') { $strictField = $field->attributes('strict'); if ($strictField == 'updatewithfield') { // if field should be updated same time than another field: check if the field is in the list to be upgraded: $strictSameAsField = $field->attributes('strictsameasfield'); if (isset($mismatchingFields[$strictSameAsField])) { $fieldName = $this->prefixedName($field, $colNamePrefix); $fieldValue = $field->attributes('value'); $fieldValueType = $field->attributes('valuetype'); if (!array_key_exists($fieldName, $rowData) || $this->adjustToStrictType($rowData->{$fieldName}, $fieldValueType) !== $this->phpCleanQuote($fieldValue, $fieldValueType)) { $mismatchingFields[$fieldName] = $this->sqlCleanQuote($fieldValue, $fieldValueType); } } } } } } if (count($mismatchingFields) > 0) { if ($change === true) { return $this->setFields($tableName, $row, $mismatchingFields, $colNamePrefix); } else { $texts = array(); foreach ($mismatchingFields as $name => $val) { $texts[] = sprintf('Field %s = %s instead of %s', $name, $mismatchingFieldsOldValues[$name], $val); } $this->setError(sprintf('Table %s Rows %s = %s : %s', $tableName, $indexName, $indexValue, implode(', ', $texts))); return false; } } else { if ($change === false) { $this->setLog(sprintf('Table %s Rows %s = %s are up-to-date.', $tableName, $indexName, $this->sqlCleanQuote($indexValue, $indexValueType)), null, 'ok'); } return true; } } else { if ($change === true) { return $this->insertRow($tableName, $row, $colNamePrefix); } else { $this->setError(sprintf('Table %s Rows %s = %s do not exist', $tableName, $indexName, $this->sqlCleanQuote($indexValue, $indexValueType)), null); } return false; } }
/** * Extends $param with option children, resolving xml:.... types. * * @param SimpleXMLElement $param Parameter to extend * @param bool $addErrorToXmlAsOption Should the error be added as an option instead of the options in case of error * @return null|string Error message */ function resolveXmlParamType( SimpleXMLElement $param, $addErrorToXmlAsOption = false ) { $errorMsg = null; $type = $param->attributes( 'type' ); if ( substr( $type, 0, 4 ) == 'xml:' ) { $xmlType = substr( $type, 4 ); if ( $this->_types ) { $typeModel = $this->_types->getChildByNameAttr( 'type', 'name' , $xmlType ); // find root type: if ( $typeModel ) { $root = $typeModel; $subbasetype = $root->attributes( 'base' ); for ( $i = 0; $i < 100; $i++ ) { if ( substr( $root->attributes( 'base' ), 0, 4 ) == 'xml:' ) { $subbasetype = $root->attributes( 'base' ); $root = $this->_types->getChildByNameAttr( 'type', 'name' , substr( $subbasetype, 4 ) ); if ( ! $root ) { $errorMsg = "Missing type definition of " . $subbasetype; break; } } else { // we found the root and type: $type = $root->attributes( 'base' ); break; } } if ( $i >= 99 ) { echo 'Error: recursion loop in XML type definition of ' . $typeModel->getName() . ' ' . $typeModel->attributes( 'name' ) . ' type: ' . $typeModel->attributes( 'type' ); exit; } $levelModel = $typeModel; $insertAfter = array(); for ( $i = 0; $i < 100; $i++ ) { switch ( $type ) { case 'list': case 'multilist': case 'radio': case 'checkbox': case 'checkmark': case 'published': case 'usergroup': case 'viewaccesslevel': case 'tag': $valueType = $root->attributes( 'valuetype' ); $subbasetype = $valueType ? $valueType : 'string'; /* if ( $view ) { $valueNode = $levelModel->getAnyChildByNameAttr( 'option', 'value', $value ); // recurse in children over optgroups if needed. if ( $valueNode ) { if ( $htmlFormatting == 'fieldsListArray' ) { $result[1] = $valueNode->data(); } else { $value = $valueNode->data(); } } } else { */ if ( $levelModel->attributes( 'insertbase' ) != 'before' ) { foreach ( $levelModel->children() as $option ) { /** @var SimpleXMLElement $option */ if ( $option->getName() == 'option' ) { $param->addChildWithAttr( 'option', $option->data(), null, $option->attributes() ); } elseif ( $option->getName() == 'optgroup' ) { $paramOptgroup = $param->addChildWithAttr( 'optgroup', $option->data(), null, $option->attributes() ); // in HTML 4, optgroups can not be nested (w3c) foreach ( $option->children() as $optChild ) { /** @var SimpleXMLElement $optChild */ if ( $optChild->getName() == 'option' ) { $paramOptgroup->addChildWithAttr( 'option', $optChild->data(), null, $optChild->attributes() ); } elseif ( $optChild->getName() == 'data' ) { $paramOptgroup->appendChild( $optChild ); } } } elseif ( $option->getName() == 'data' ) { $param->appendChild( $option ); } } } else { $insertAfter[] = $levelModel; } break; default: $errorMsg = "Unknown base type " . $type . " in XML"; break; } if ( ( $levelModel->attributes( 'name' ) == $typeModel->attributes( 'name' ) ) && ( substr( $levelModel->attributes( 'type' ), 0, 4 ) == 'xml:' ) ) { $levelModel = $this->_types->getChildByNameAttr( 'type', 'name' , substr( $levelModel->attributes( 'type' ), 4 ) ); } elseif ( substr( $levelModel->attributes( 'base' ), 0, 4 ) == 'xml:' ) { $levelModel = $this->_types->getChildByNameAttr( 'type', 'name' , substr( $levelModel->attributes( 'base' ), 4 ) ); } else { break; } } foreach ( $insertAfter as $levelModel ) { /** @var SimpleXMLElement $levelModel */ foreach ($levelModel->children() as $option ) { /** @var SimpleXMLElement $option */ if ( $option->getName() == 'option' ) { $param->addChildWithAttr( 'option', $option->data(), null, $option->attributes() ); } elseif ( $option->getName() == 'optgroup' ) { $paramOptgroup = $param->addChildWithAttr( 'optgroup', $option->data(), null, $option->attributes() ); foreach ( $option->children() as $optChild ) { if ( $optChild->getName() == 'option' ) { $paramOptgroup->addChildWithAttr( 'option', $optChild->data(), null, $optChild->attributes() ); } elseif ( $optChild->getName() == 'data' ) { $paramOptgroup->appendChild( $optChild ); } } } elseif ( $option->getName() == 'data' ) { $param->appendChild( $option ); } } } $param['type'] = $type; if ( $subbasetype ) { $param['base'] = $subbasetype; } } else { $errorMsg = "Missing type def. for param-type " . $param->attributes( 'type' ); } } else { $errorMsg = "No types defined in XML"; } if ( $errorMsg && $addErrorToXmlAsOption ) { $param->addChildWithAttr( 'option', $errorMsg, null, array( 'value' => '0') ); } } return $errorMsg; }
/** * Performs a table action on a click in table * * @return void * @throws \Exception */ protected function _performTableActions() { global $_CB_framework; if (!isset($_REQUEST[$this->name])) { return; } $subtask = cbGetParam($_REQUEST[$this->name], 'subtask', ''); if (!$subtask) { return; } $task_parsed = explode('/', $subtask); $cid = cbGetParam($_REQUEST[$this->name], 'idcid', array()); if (!is_array($cid)) { $ocid = $cid; $cid = array(); $cid[] = $ocid; } switch ($task_parsed[0]) { case 'orderup': case 'orderdown': case 'saveorder': if ($this->listFieldsRows) { if (isset($task_parsed[1])) { $field = $task_parsed[1]; $fieldNode = $this->listFieldsRows->getChildByNameAttr('field', 'name', $field); if (!$fieldNode) { $fieldNode = $this->listFieldsRows->getChildByNameAttr('param', 'name', $field); } } else { $field = null; $fieldNode = false; } if (!$fieldNode || $fieldNode->attributes('type') !== 'ordering' || !Access::authorised($fieldNode)) { $_CB_framework->enqueueMessage(CBTxt::T('This field can not ordered'), 'error'); return; } $dataModelClass = $this->class; if ($task_parsed[0] != 'saveorder') { $dataModelValue = $cid[0]; } else { $dataModelValue = null; } $row = $this->createLoadClass($dataModelClass, $dataModelValue); if (!$row) { $_CB_framework->enqueueMessage(CBTxt::T('No row data found'), 'error'); return; } if ($task_parsed[0] == 'saveorder') { $order = cbGetParam($_REQUEST[$this->name], $field, array(0)); } $where = ''; $orderinggroups = $fieldNode->getElementByPath('orderinggroups'); /** @var $orderinggroups SimpleXMLElement|null */ if ($orderinggroups) { foreach ($orderinggroups->children() as $group) { /** @var $group SimpleXMLElement */ $orderingFieldName = $group->attributes('name'); if ($group->getName() == 'ordering' && $orderingFieldName && array_key_exists($orderingFieldName, get_object_vars($row))) { if ($task_parsed[0] != 'saveorder') { $where .= $this->_db->NameQuote($orderingFieldName) . ' = ' . XmlTypeCleanQuote::sqlCleanQuote($row->{$orderingFieldName}, $group->attributes('type'), $this->_pluginParams, $this->_db) . ' AND '; } else { $where .= $orderingFieldName . "='\$row->" . $orderingFieldName . "' AND "; } } } } if ($task_parsed[0] != 'saveorder') { $inc = $task_parsed[0] == 'orderup' ? -1 : 1; /** @var OrderedTable $row */ $row->move($inc, $where . $field . " > -10000 AND " . $field . " < 10000 ", $field); } else { $this->saveOrder($cid, $row, $order, "\$condition = \"" . $where . $field . " > -10000 AND " . $field . " < 10000 \";", $field); } $_CB_framework->enqueueMessage(CBTxt::T('ROW_COUNT_ORDER_SUCCESS', 'Row ordered successfully!|%%COUNT%% rows ordered successfully!', array('%%COUNT%%' => count($cid)))); } break; case 'publish': case 'unpublish': case 'enable': case 'disable': case 'setfield': case 'doaction': if ($this->listFieldsRows) { $field = null; switch ($task_parsed[0]) { case 'publish': case 'unpublish': $value = $task_parsed[0] == 'publish' ? 1 : 0; $field = 'published'; break; case 'enable': case 'disable': $value = $task_parsed[0] == 'enable' ? 1 : 0; $field = 'enabled'; break; case 'setfield': $value = $task_parsed[2]; break; case 'doaction': $value = null; break; default: throw new \Exception(__FUNCTION__ . ': Impossible value'); } if (isset($task_parsed[1])) { $field = $task_parsed[1]; } /** @var SimpleXMLElement $fieldNode */ $fieldNode = $this->listFieldsRows->xpath('(//field[@name="' . $field . '"][@onclick="toggle"])[last()]'); if (!$fieldNode) { $fieldNode = $this->listFieldsRows->xpath('(//param[@name="' . $field . '"][@onclick="toggle"])[last()]'); } if (!$fieldNode) { // We're not a field toggle so lets check if we're a menu item for permission/usage checks: $fieldNode = $this->toolbarmenu->xpath('(//menu[@name="' . $field . '"])[last()]'); } if (!$fieldNode || !Access::authorised($fieldNode[0])) { $_CB_framework->enqueueMessage(CBTxt::T('THIS_FIELD_CAN_NOT_TOGGLE_TASK', 'This field can not toggle: [task]', array('[task]' => $task_parsed[0])), 'error'); return; } $fieldNode = $fieldNode[0]; $taskName = CBTxt::T($fieldNode->attributes('label')); if ($task_parsed[0] == 'setfield') { // Check field value if allowed: $this->registryEditVew->resolveXmlParamType($fieldNode); if ($fieldNode->getChildByNameAttributes('option')) { $valueNode = $fieldNode->getAnyChildByNameAttr('option', 'index', $value); if (!$valueNode) { $valueNode = $fieldNode->getAnyChildByNameAttr('option', 'value', $value); } if ($valueNode) { $valueLabel = CBTxt::T($valueNode->data()); if ($valueLabel) { $taskName = $valueLabel; } } else { $_CB_framework->enqueueMessage(CBTxt::T('This field can not be set to that value'), 'error'); return; } } } if (!$taskName) { $taskName = $task_parsed[0]; } if (count($cid) < 1) { $_CB_framework->enqueueMessage(CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => strtolower($taskName))), 'error'); return; } $dataModelClass = $this->class; foreach ($cid as $c) { $dataModelValue = $c; $row = $this->createLoadClass($dataModelClass, $dataModelValue); if (!$row) { $_CB_framework->enqueueMessage(CBTxt::T('No row data found'), 'error'); return; } if ($task_parsed[0] == 'doaction') { $this->registryEditVew->pushModelOfData($row); $toggle = $this->registryEditVew->_form_private($field, $value, $fieldNode, null); $this->registryEditVew->popModelOfData(); if (!$toggle) { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_TASK_ROW_ID_ID_BECAUSE_ERROR', 'Cannot [task] row id [id] because: [error]', array('[id]' => $dataModelValue, '[task]' => strtolower($taskName), '[error]' => $row->getError())), 'error'); return; } } elseif ($row->{$field} != $value) { if (is_callable(array($row, 'historySetMessage'))) { $row->historySetMessage(ucfirst($task_parsed[0]) . ' ' . $field . ' from administration backend'); } if ($fieldNode->attributes('class') && $fieldNode->attributes('method')) { $this->registryEditVew->pushModelOfData($row); $toggle = $this->registryEditVew->_form_private($field, $value, $fieldNode, null); $this->registryEditVew->popModelOfData(); if (!$toggle) { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_TASK_ROW_ID_ID_BECAUSE_ERROR', 'Cannot [task] row id [id] because: [error]', array('[id]' => $dataModelValue, '[task]' => strtolower($taskName), '[error]' => $row->getError())), 'error'); return; } } elseif ($row->hasFeature('checkout')) { /** @var CheckedOrderedTable $row */ if (!$row->isCheckedOut($_CB_framework->myId())) { $row->{$field} = $value; if ($row->check()) { if (!$row->store()) { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_TASK_ROW_ID_ID_BECAUSE_ERROR', 'Cannot [task] row id [id] because: [error]', array('[id]' => $dataModelValue, '[task]' => strtolower($taskName), '[error]' => $row->getError())), 'error'); return; } } else { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_TASK_ROW_ID_ID_BECAUSE_ERROR', 'Cannot [task] row id [id] because: [error]', array('[id]' => $dataModelValue, '[task]' => strtolower($taskName), '[error]' => $row->getError())), 'error'); return; } $row->checkin(); } } else { $row->{$field} = $value; if ($row->check()) { if (!$row->store()) { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_TASK_ROW_ID_ID_BECAUSE_ERROR', 'Cannot [task] row id [id] because: [error]', array('[id]' => $dataModelValue, '[task]' => strtolower($taskName), '[error]' => $row->getError())), 'error'); return; } } else { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_TASK_ROW_ID_ID_BECAUSE_ERROR', 'Cannot [task] row id [id] because: [error]', array('[id]' => $dataModelValue, '[task]' => strtolower($taskName), '[error]' => $row->getError())), 'error'); return; } } } } $_CB_framework->enqueueMessage(CBTxt::T('ROW_COUNT_TASK_SUCCESS', '{1} Row [task] successfully!|%%COUNT%% rows [task] successfully!', array('%%COUNT%%' => count($cid), '[task]' => strtolower($taskName)))); } break; case 'editrows': if ($this->listFieldsRows) { if (count($cid) != 1) { $_CB_framework->enqueueMessage(CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => 'edit')), 'error'); return; } if (isset($task_parsed[1])) { $field = $task_parsed[1]; } else { $field = 'tid'; } if ($this->_options['view'] == 'editPlugin') { $task = $this->_options['view']; } else { $task = 'editrow'; } $baseUrl = 'index.php?option=' . $this->_options['option'] . '&view=' . $task; if (isset($this->_options['pluginid'])) { $baseUrl .= '&cid=' . $this->_options['pluginid']; } $url = $baseUrl . '&table=' . $this->_tableBrowserModel->attributes('name') . '&action=editrow&' . urlencode($field) . '=' . urlencode($cid[0]); cbRedirect($url); } break; case 'deleterows': if ($this->listFieldsRows) { if (count($cid) < 1) { $_CB_framework->enqueueMessage(CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => 'delete')), 'error'); return; } $dataModelClass = $this->class; foreach ($cid as $id) { $dataModelValue = $id; $row = $this->createLoadClass($dataModelClass, $dataModelValue); if (!$row) { $_CB_framework->enqueueMessage(CBTxt::T('No row data found'), 'error'); return; } if ($row->canDelete($dataModelValue)) { if (!$row->delete($dataModelValue)) { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_DELETE_ROW_ID_BECAUSE_ERROR', 'Cannot delete row id [id] because: [error]', array('[id]' => $dataModelValue, '[error]' => $row->getError())), 'error'); return; } } else { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_DELETE_ROW_ID_BECAUSE_ERROR', 'Cannot delete row id [id] because: [error]', array('[id]' => $dataModelValue, '[error]' => $row->getError())), 'error'); return; } } $_CB_framework->enqueueMessage(CBTxt::T('ROW_COUNT_DELETED_SUCCESS', 'Row deleted successfully!|%%COUNT%% rows deleted successfully!', array('%%COUNT%%' => count($cid)))); } break; case 'batchrows': if ($this->listFieldsRows) { if (count($cid) < 1) { $_CB_framework->enqueueMessage(CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => 'batch')), 'error'); return; } $postData = array(); foreach ($this->_batchPossibilitesArray as $key => $value) { // <batchprocess><batch> if (!$this->isValueEmpty($value['internalvalue'])) { $field = $value['valuefield']; $postData[$field] = $value['internalvalue']; } // Reset back to null as we don't want the values reselected on display: $this->_batchPossibilitesArray[$key]['value'] = null; $this->_batchPossibilitesArray[$key]['internalvalue'] = $value['value']; } if (count($postData) < 1) { $_CB_framework->enqueueMessage(CBTxt::T('Nothing to process'), 'error'); return; } $dataModelClass = $this->class; foreach ($cid as $id) { $dataModelValue = $id; /** @var $row TableInterface */ $row = $this->createLoadClass($dataModelClass, $dataModelValue); if (!$row) { $_CB_framework->enqueueMessage(CBTxt::T('No row data found'), 'error'); return; } $rowPost = array(); foreach ($postData as $key => $value) { if (property_exists($row, $key)) { $rowPost[$key] = is_array($value) ? json_encode($value) : $value; } } if (count($rowPost) < 1) { $_CB_framework->enqueueMessage(CBTxt::T('Nothing to process'), 'error'); return; } if (!$row->bind($rowPost)) { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_BATCH_PROCESS_ROW_ID_ID_BECAUSE_ERROR', 'Cannot batch process row id [id] because: [error]', array('[id]' => $dataModelValue, '[error]' => $row->getError())), 'error'); return; } if (!$row->check()) { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_BATCH_PROCESS_ROW_ID_ID_BECAUSE_ERROR', 'Cannot batch process row id [id] because: [error]', array('[id]' => $dataModelValue, '[error]' => $row->getError())), 'error'); return; } if (!$row->store()) { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_BATCH_PROCESS_ROW_ID_ID_BECAUSE_ERROR', 'Cannot batch process row id [id] because: [error]', array('[id]' => $dataModelValue, '[error]' => $row->getError())), 'error'); return; } } $_CB_framework->enqueueMessage(CBTxt::T('ROW_COUNT_SAVED_SUCCESS', 'Row saved successfully!|%%COUNT%% rows saved successfully!', array('%%COUNT%%' => count($cid)))); } break; case 'copyrows': if ($this->listFieldsRows) { if (count($cid) < 1) { $_CB_framework->enqueueMessage(CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => 'copy')), 'error'); return; } $dataModelClass = $this->class; foreach ($cid as $id) { $dataModelValue = $id; /** @var $row TableInterface */ $row = $this->createLoadClass($dataModelClass, $dataModelValue); if (!$row) { $_CB_framework->enqueueMessage(CBTxt::T('No row data found'), 'error'); return; } if ($row->canCopy()) { if (!$row->copy()) { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_COPY_ROW_ID_ID_BECAUSE_ERROR', 'Cannot copy row id [id] because: [error]', array('[id]' => $dataModelValue, '[error]' => $row->getError())), 'error'); return; } } else { $_CB_framework->enqueueMessage(CBTxt::T('CANNOT_COPY_ROW_ID_ID_BECAUSE_ERROR', 'Cannot copy row id [id] because: [error]', array('[id]' => $dataModelValue, '[error]' => $row->getError())), 'error'); return; } } $_CB_framework->enqueueMessage(CBTxt::T('ROW_COUNT_COPIED_SUCCESS', 'Row copied successfully!|%%COUNT%% rows copied successfully!', array('%%COUNT%%' => count($cid)))); } break; case 'action': if ($this->listFieldsRows) { if (count($cid) != 1) { $_CB_framework->enqueueMessage(CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => isset($task_parsed[1]) ? $task_parsed[1] : 'action')), 'error'); return; } if (isset($task_parsed[1])) { if (isset($task_parsed[2])) { $field = $task_parsed[2]; } else { $field = 'tid'; } $baseUrl = 'index.php?option=' . $this->_options['option'] . '&view=' . $this->_options['view']; if (isset($this->_options['pluginid'])) { $baseUrl .= '&cid=' . $this->_options['pluginid']; } $url = $baseUrl . '&table=' . $this->_tableBrowserModel->attributes('name') . '&action=' . urlencode($task_parsed[1]) . '&' . urlencode($field) . '=' . urlencode($cid[0]); cbRedirect($url); } } break; default: break; } //TBD cbRedirect( $_CB_framework->backendUrl( 'index.php?option=com_comprofiler&task=showPlugins', $msg ) ); }
/** * Handles the backend plugin edition * * @param string $option * @param string $action * @param SimpleXMLElement $element * @param string $mode * @return string HTML * * @throws \LogicException */ public function drawView($option, $action, $element, $mode) { global $_CB_Backend_Menu; $ui = $this->clientId == 1 ? 2 : 1; $context = new Context(); $pluginParams = $context->getParams(); $interfaceUi = $ui == 2 ? 'admin' : 'frontend'; $adminActionsModel = $element->getChildByNameAttr('actions', 'ui', $interfaceUi); if (!$adminActionsModel) { $adminActionsModel = $element->getChildByNameAttr('actions', 'ui', 'all'); } if (!$adminActionsModel) { throw new \LogicException('No ' . $interfaceUi . ' actions defined in XML'); } // Check permission if specified: if (!Access::authorised($adminActionsModel)) { return CBTxt::T("Access to these actions is not authorized by the permissions of your user groups."); } // General-purpose extenders: $extenders = $adminActionsModel->xpath('extend'); /** @var SimpleXMLElement[] $extenders */ foreach ($extenders as $k => $extends) { $error = RegistryEditView::extendXMLnode($extenders[$k], $element, null, $context->getPluginObject()); if ($error) { echo $error; } } $found = false; $actionPath = array(); if ($action) { $actionsModel = $adminActionsModel->getChildByNameAttr('action', 'name', $action); $found = $actionsModel != null; if ($found) { $requests = explode(' ', $actionsModel->attributes('request')); $values = explode(' ', $actionsModel->attributes('action')); $actionPath = array(); for ($i = 0, $n = count($requests); $i < $n; $i++) { $actionPath[$requests[$i]] = $values[$i]; } } } if (!$found) { // EVENT: select the event from URL and compute the selected $actionPath $found = false; $actionsModel = null; foreach ($adminActionsModel->children() as $actionsModel) { /** @var SimpleXMLElement $actionsModel */ $request = $actionsModel->attributes('request'); if ($request) { $requests = explode(' ', $request); $values = explode(' ', $actionsModel->attributes('action')); $actionPath = array(); for ($i = 0, $n = count($requests); $i < $n; $i++) { $actionPath[$requests[$i]] = $this->input->get($requests[$i], null, GetterInterface::STRING); // Temporary fix for older versions of CBSubs before CBSubs 4.0.0 stable to avoid warnings on ajax version checks: if ($requests[$i] === 'view' && $actionPath['view'] === null) { $actionPath['view'] = $this->input->get('task', null, GetterInterface::STRING); } if ($actionPath[$requests[$i]] != $values[$i]) { break; } } if ($i == $n) { $found = true; break; } } } } if (!$found) { $actionPath = array(); // try finding first default one: if ($ui == 2) { $actionsModel = $adminActionsModel->getChildByNameAttr('action', 'request', ''); } if (!isset($actionsModel)) { return CBTxt::T('AHAWOW_REQUESTED_ACTION_NOT_DEFINED_IN_XML', "Requested action '[ACTION]' not defined in XML.", array('[ACTION]' => htmlspecialchars($action))); } } // Check permission if specified: if (!isset($actionsModel) || !Access::authorised($actionsModel)) { return CBTxt::T("This action is not authorized by the permissions of your user groups."); } if (!isset($actionPath['view'])) { $actionPath['view'] = $ui == 2 ? 'editPlugin' : ''; //TODO: 2nd should come from target routing } elseif ($actionPath['view'] != 'editPlugin') { $actionPath['act'] = ''; } // EVENT: fetch the input parameters from URL: $parametersNames = explode(' ', $actionsModel->attributes('requestparameters')); $parametersValues = array(); foreach ($parametersNames as $paraNam) { $parametersValues[$paraNam] = null; if (strpos($paraNam, '[') === false) { if (trim($paraNam)) { $parametersValues[$paraNam] = $this->input->get($paraNam, '', GetterInterface::STRING); } } else { $matches = null; preg_match_all('/(.*)(?:\\[(.*)\\])+/', $paraNam, $matches); if (is_array($matches) && count($matches) >= 3 && count($matches[2]) >= 1) { $parametersValues[$paraNam] = $this->input->get($matches[1][0] . '.' . $matches[2][0], null, GetterInterface::STRING); } } } $keyValues = array(); // Action-specific general extenders: $extenders = $adminActionsModel->xpath('actionspecific/extend'); /** @var SimpleXMLElement[] $extenders */ foreach ($extenders as $k => $extends) { $error = RegistryEditView::extendXMLnode($extenders[$k], $element, $actionsModel, $context->getPluginObject()); if ($error) { echo $error; } } // First extend what can be extended so the showview's below have a complete XML tree: /** @var $actionItem SimpleXMLElement */ foreach ($actionsModel->xpath('extend') as $actionItem) { $error = RegistryEditView::extendXMLnode($actionItem, $element, $actionsModel, $context->getPluginObject()); if ($error) { echo $error; } } /** @var $actionItem SimpleXMLElement */ foreach ($actionsModel->children() as $actionItem) { // CONTROLLER: select the controller: switch ($actionItem->getName()) { case 'extend': // Treated just above. break; case 'showview': $viewName = $actionItem->attributes('view'); $showviewType = $actionItem->attributes('type'); $viewMode = $actionItem->attributes('mode'); // MODEL: load data to view: $dataModel = $actionItem->getElementByPath('data'); if ($dataModel) { $dataModelType = $dataModel->attributes('type'); $cbDatabase = $this->db; if (in_array($dataModelType, array('sql:row', 'sql:multiplerows', 'sql:field', 'parameters'))) { $xmlsql = new XmlQuery($cbDatabase, null, $pluginParams); $data = $xmlsql->loadObjectFromData($dataModel); if ($data === null) { return 'showview::sql:row: load failed: ' . $cbDatabase->getErrorMsg(); } $dataModelValueName = $dataModel->attributes('value'); $dataModelValueType = $dataModel->attributes('valuetype'); // if the value of key is a parameter name, replace it with the corresponding parameter: $dataModelValueTypeArray = explode(':', $dataModelValueType); if ($dataModelValueTypeArray[0] == 'request') { if (isset($parametersValues[$dataModelValueName])) { $dataModelValue = $parametersValues[$dataModelValueName]; // database escaping to int is done at request time $keyValues[$dataModelValueName] = $dataModelValue; unset($parametersValues[$dataModelValueName]); } else { echo sprintf('showview::sql::row %s: request %s not in parameters of action.', $dataModel->attributes('name'), $dataModelValueName); } } if ($dataModelType == 'sql:field') { $data = new Registry($data); } } elseif ($dataModelType == 'class') { $dataModelClass = $dataModel->attributes('class'); $dataModelValue = $dataModel->attributes('value'); $dataModelValueName = $dataModelValue; $dataModelValueType = $dataModel->attributes('valuetype'); $dataModelValueTypeArray = explode(':', $dataModelValueType); if ($dataModelValueTypeArray[0] == 'request') { if (isset($parametersValues[$dataModelValueName])) { $dataModelValue = $parametersValues[$dataModelValueName]; $keyValues[$dataModelValueName] = $dataModelValue; unset($parametersValues[$dataModelValueName]); } else { echo sprintf('showview::sql::row %s: request %s not in parameters of action.', $dataModel->attributes('name'), $dataModelValue); } } if (strpos($dataModelClass, '::') === false) { $data = new $dataModelClass($cbDatabase); // normal clas="className" /** @var $data TableInterface */ $data->load($dataModelValue); } else { $dataModelSingleton = explode('::', $dataModelClass); // class object loader from singleton: class="loaderClass::loadStaticMethor" with 1 parameter, the key value. if (is_callable($dataModelSingleton)) { if (is_callable(array($dataModelSingleton[0], 'getInstance'))) { $instance = call_user_func_array(array($dataModelSingleton[0], 'getInstance'), array(&$cbDatabase)); $rows = call_user_func_array(array($instance, $dataModelSingleton[1]), array($dataModelValue)); } else { $rows = call_user_func_array($dataModelSingleton, array($dataModelValue)); } } else { echo sprintf('showview::class %s: missing singleton class creator %s.', $dataModel->attributes('name'), $dataModelClass); $std = new \stdClass(); $rows = array($std); } $data = $rows[0]; } } else { $data = null; echo 'showview: Data model type ' . $dataModelType . ' is not implemented !'; } } else { if ($this->_data instanceof TableInterface || $this->_data instanceof \comprofilerDBTable) { $data = $this->_data; $dataModelType = 'sql:row'; } elseif ($this->_data instanceof ParamsInterface) { $data = $this->_data; $dataModelType = 'sql:row'; } else { $data = null; $dataModelType = null; } } // VIEW: select view: $allViewsModels = $element->getElementByPath('views'); if ($viewName && (!$showviewType || $showviewType == 'view')) { ////// $viewModel = $allViewsModels->getChildByNameAttributes( 'view', array( 'name' => $viewName ) ); $xpathUi = '/*/views/view[@ui="' . $interfaceUi . '" and @name="' . $viewName . '"]'; $xpathAll = '/*/views/view[@ui="all" and @name="' . $viewName . '"]'; $viewModel = $element->xpath($xpathUi); if (!$viewModel) { $viewModel = $element->xpath($xpathAll); } if (!$viewModel) { $viewModel = RegistryEditView::xpathWithAutoLoad($element, $xpathUi); } if (!$viewModel) { $viewModel = RegistryEditView::xpathWithAutoLoad($element, $xpathAll); } /* if ( ! $viewModel ) { $viewModel = RegistryEditView::xpathWithAutoLoad( $element, '/ * / views/view[not(@ui) and @name="' . $viewName . '"]' ); } */ if ($viewModel) { $viewModel = $viewModel[0]; } else { return 'XML:showview: View ' . $viewName . ' not defined in ui ' . $interfaceUi . ' in XML'; } } elseif ($showviewType == 'xml') { // e.g.: <showview name="gateway_paymentstatus_information" mode="view" type="xml" file="processors/{payment_method}/edit.gateway" path="/*/views/view[@name="paymentstatusinformation"]" mandatory="false" /> $fromNode = $actionItem->attributes('path'); $fromFile = $actionItem->attributes('file'); if ($fromNode && $fromFile !== null) { // $this->substituteName( $fromFile, true ); // $this->substituteName( $fromNode, false ); $fromFile = $context->getPluginPath() . '/' . $fromFile . '.xml'; if ($fromFile === '' || is_readable($fromFile)) { if ($fromFile === '') { $fromRoot = $element; } else { $fromRoot = new SimpleXMLElement($fromFile, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0), true); } $viewModel = $fromRoot->xpath($fromNode); if (!$viewModel) { trigger_error('Admin:showview: View ' . $viewName . ': file ' . $fromFile . ', path: ' . $fromNode . ' does not exist or is empty.', E_USER_NOTICE); } $viewModel = $viewModel[0]; } else { throw new \LogicException('Admin:showview: View ' . $viewName . ': file ' . $fromFile . ' does not exist or is not readable.'); } } else { throw new \LogicException('Admin:showview: View ' . $viewName . ' file or path not defined..', E_USER_NOTICE); } } else { throw new \LogicException('Admin:showview: View ' . $viewName . ' not of supported type.', E_USER_NOTICE); } $viewUi = $viewModel->attributes('ui'); if ($viewUi & $viewUi != 'all' && $viewUi != $interfaceUi) { throw new \LogicException('showview: View ' . $viewName . ' not allowed for ' . $interfaceUi); } $extendedParser = $allViewsModels->getElementByPath('extendxmlparser'); $actionPath = array_merge($actionPath, $keyValues); $options = array_merge($this->getBaseOptions(), $actionPath, $parametersValues); if ($ui == 2) { $options = array_merge($options, $actionPath, $parametersValues); } $cbprevstate = $this->input->get('cbprevstate', null, GetterInterface::STRING); $params = new RegistryEditController($this->input, $this->db, new Registry(), $viewModel, $element, $context->getPluginObject()); $displayData = $this->bindInput($viewMode, $data); // Set the parameters with the $displayData : $registry = new Registry(); $registry->load($displayData); $registry->setStorage($displayData); $params->setRegistry($registry); $params->setPluginParams($pluginParams); $params->setOptions($options); if ($extendedParser) { $params->setExtendedViewParser($extendedParser); } $extenders = $allViewsModels->xpath('extend'); foreach ($extenders as $extends) { RegistryEditView::extendXMLnode($extends, $element, $actionsModel, $context->getPluginObject()); } $viewType = $viewModel->attributes('type'); switch ($viewType) { case 'params': if ($mode == 'edit') { if ($viewMode == 'edit' || $viewMode == 'show') { $viewTypeMode = $viewMode == 'edit' ? 'param' : 'view'; if ($ui == 2) { $htmlOutput = $this->input->get('no_html', 0, GetterInterface::COMMAND) != 1 && $this->input->get('format', null, GetterInterface::COMMAND) != 'raw'; ActionViewAdmin::editPluginView($options, $actionPath, $viewModel, $displayData, $params, $context->getPluginObject(), $viewTypeMode, $cbprevstate, $htmlOutput); $settings = null; $html = null; } else { /** @global \stdClass $_CB_Backend_Menu : 'show' : only displays close button, 'edit' : special close button */ global $_CB_Backend_Menu; $_CB_Backend_Menu = new \stdClass(); $html = ''; outputCbTemplate(); outputCbJs(); // $_CB_framework->outputCbJQuery( '' ); initToolTip(); $htmlFormatting = $viewModel->attributes('viewformatting'); if (!$htmlFormatting) { global $ueConfig; if (isset($ueConfig['use_divs']) && $ueConfig['use_divs'] == 1) { $htmlFormatting = 'div'; } else { $htmlFormatting = 'table'; } } $settings = $params->draw(null, null, null, null, null, null, false, $viewTypeMode, $htmlFormatting); } if ($ui == 2) { $_CB_Backend_Menu->mode = $viewMode; // Implemented in lower level in RegistryEditView: $toolbarMenu = $viewModel->getElementByPath( 'toolbarmenu' ); } if ($ui != 2) { $actionView = new ActionView(); $buttonSaveText = $actionsModel->attributes('label'); if (!$buttonSaveText) { $buttonSaveText = 'Save'; } $buttonSaveText = CBTxt::Th($buttonSaveText); // CBTxt::Th("Save"); For translation strings extraction $warning = null; if ($viewTypeMode == 'param') { $settings .= '<div class="cbControlButtonsLine">' . "\n\t" . '<span class="cb_button_wrapper">' . '<button type="submit" name="actbutton" value="' . 'save' . $action . '" class="button cbregButton cbregSaveButton">' . $buttonSaveText . '</button>' . '</span>' . "\n\t" . '</div>' . "\n"; $postedActionPath = $actionPath; unset($postedActionPath['view']); $formHiddens = array_merge($this->getBaseOptions(), array('act' => 'save' . $action), $postedActionPath); } else { $formHiddens = null; } $html .= $actionView->drawForm($settings, $warning, $formHiddens, array_merge($this->_getParams, array('act' => $action)), RegistryEditView::buildClasses($viewModel)); return $html; } } else { echo 'showview::params: mode is ' . $mode . ' but view mode is ' . $viewMode . ' instead of edit.'; } } elseif (in_array($mode, array('apply', 'save', 'savenew', 'savecopy'))) { $this->savePluginView($options, $actionPath, $keyValues, $parametersValues, $viewModel, $data, $params, $mode, $dataModelType, $context->getPluginObject(), $dataModel, $pluginParams, $cbprevstate, $ui); if ($ui == 2 && $mode == 'apply') { // We arrive here only in case of saving error, as redirect (performed in savePluginView) would loose the inputs: return $this->drawView($option, $action, $element, 'edit'); } } else { echo 'showview::params: view type params mode ' . $mode . ' is not implemented !'; } break; default: echo 'showview::not-params: type of view ' . $viewType . ' is not implemented !'; break; } break; default: echo 'action::not-showview: child xml element "' . $actionItem->getName() . '" of action is not implemented !'; break; } } return null; }
/** * Outputs legacy plugin views * * @deprecated 2.0 Use XML * * @param PluginTable $row * @param string $option * @param string $task * @param int $uid * @param string $action * @param SimpleXMLElement $element * @param string $mode * @param Registry $pluginParams * @return mixed|null */ public function editPluginView($row, $option, $task, $uid, $action, $element, $mode, $pluginParams) { global $_CB_framework, $_CB_database, $_PLUGINS; if (!$row->id) { $_CB_framework->enqueueMessage(CBTxt::T('Plugin id not found.'), 'error'); return null; } if (!$element) { $_CB_framework->enqueueMessage(CBTxt::T('No plugin XML found.'), 'error'); return null; } $adminHandlerModel = $element->getChildByNameAttr('handler', 'ui', 'admin'); if (!$adminHandlerModel || $row->element == 'cbpaidsubscriptions') { $adminActionsModel = $element->getChildByNameAttr('actions', 'ui', 'admin'); if ($adminActionsModel) { // New CB 2.0 method: $savedPluginId = $_PLUGINS->_loading; $_PLUGINS->_loading = (int) $row->id; /** @var ActionController $actionController */ /** @see CBLib\AhaWow\Controller\ActionController::__construct() */ $actionController = Application::DI()->get('CBLib\\AhaWow\\Controller\\ActionController'); $actionController->setData($row); $displayMode = $mode == 'applyPlugin' ? 'apply' : ($mode == 'savePlugin' ? 'save' : 'edit'); echo $actionController->drawView($option, null, $element, $displayMode); $_PLUGINS->_loading = $savedPluginId; return null; } else { return null; } } $class = $adminHandlerModel->attributes('class'); if ($class) { if (!class_exists($class)) { $_CB_framework->enqueueMessage(CBTxt::T('ADMIN_HANDLER_CLASS_CLASS_DOES_NOT_EXIST', 'Admin handler class [class] does not exist.', array('[class]' => $class)), 'error'); return null; } $handler = new $class($_CB_database); /** @var stdClass|CBController_plugin|cbpaidAdminView $handler */ return $handler->editPluginView($row, $option, $task, $uid, $action, $element, $mode, $pluginParams); } else { // new method in CB 1.2.3: $args = array(&$row, $option, $task, $uid, $action, &$element, $mode, &$pluginParams); return $_PLUGINS->call($row->id, 'editPluginView', 'get' . $row->element . 'Tab', $args, null, true); } }