/** * Get the record to view/edit. It is cached as long as the instance * exists, unless we force a reload. * * @param bool $force Whether or not to force the fetching of the record * * @return array The record for viewing/editting */ public function getRecord($force = false) { // if we are not forcing a fetch and we already have a cached record, return it if ($force === false && $this->m_record !== null) { return $this->m_record; } $record = $this->getRejectInfo(); // Check reject info first if ($record == null) { // If reject info not set - do select $atkstoretype = ''; $sessionmanager = SessionManager::getInstance(); if ($sessionmanager) { $atkstoretype = $sessionmanager->stackVar('atkstore'); } switch ($atkstoretype) { case 'session': $record = $this->getRecordFromSession(); break; default: $record = $this->getRecordFromDb(); break; } } // cache the record $this->m_record = $record; return $record; }
/** * Get an instance of the columnconfig class. * * @param Node $node * @param string $id * @param bool $forceNew force new instance? * * @return ColumnConfig An instance of the columnconfig class */ public static function getConfig($node, $id = null, $forceNew = false) { static $s_instances = []; $sm = SessionManager::getInstance(); if ($id == null) { $id = $node->atkNodeUri(); } if (!isset($s_instances[$id]) || $forceNew) { $cc = new self(); $s_instances[$id] = $cc; $cc->setNode($node); $colcfg = $sm != null ? $sm->pageVar('atkcolcfg_' . $id) : null; if (!is_array($colcfg) || $forceNew) { // create new Tools::atkdebug('New colconfig initialising'); $cc->init(); } else { // inherit old config from session. Tools::atkdebug('Resuming colconfig from session'); $cc->m_colcfg =& $colcfg; } // See if there are any url params which influence this colcfg. $cc->doUrlCommands(); } if ($sm != null) { $sm->pageVar('atkcolcfg_' . $id, $s_instances[$id]->m_colcfg); } return $s_instances[$id]; }
/** * Surrounds the grid by a form if needed. * * @param string $result grid HTML * * @return string grid HTML */ protected function renderForm($result) { if (!$this->getGrid()->isUpdate() && !$this->getGrid()->isEmbedded()) { $sm = SessionManager::getInstance(); $result = '<form id="' . $this->getGrid()->getFormName() . '" name="' . $this->getGrid()->getFormName() . '" method="post" action="' . Config::getGlobal('dispatcher') . '">' . $sm->formState() . $result . '</form>'; } return $result; }
/** * Get the start of the form. * * @return string HTML The forms' start */ public function getFormStart($record = null) { $sm = SessionManager::getInstance(); $formstart = '<form name="entryform" id="entryform" action="' . Config::getGlobal('dispatcher') . '" method="get" onsubmit="return globalSubmit(this,false)">'; $formstart .= $sm->formState(SessionManager::SESSION_NESTED); $formstart .= '<input type="hidden" name="atkselector" value="' . $this->getNode()->primaryKey($record) . '">'; $formstart .= '<input type="hidden" class="atksubmitaction" />'; return $formstart; }
/** * Implements the {stacktrace} plugin for use in templates. * * The {stacktrace} tag does not output anything. Instead, it loads * a stacktrace into the template variables {$stacktrace}, which is * an array of elements, each with a 'title' and 'url' field. * * <b>Example:</b> * <code> * {stacktrace} * * {foreach from=$stacktrace item=item} * <a href="{$item.url}">{$item.title}</a> * {/foreach} * </code> * * @author Ivo Jansch <*****@*****.**> */ function smarty_function_stacktrace($params, $smarty) { $sessionManager = SessionManager::getInstance(); if (is_object($sessionManager)) { $smarty->assign('stacktrace', $sessionManager->stackTrace()); return ''; } return ''; }
/** * Implements the {atkmessages} plugin for use in templates. * * The {atkmessages} tag does not output anything. Instead, it loads * the messages into the template variable {$atkmessages}, which is * an array of elements, each with a single message. * * <b>Example:</b> * <code> * {atkmessages} * * {foreach from=$atkmessages item=message} * {$message.message}<br> * {/foreach} * </code> * * @author Patrick van der Velden <*****@*****.**> */ function smarty_function_atkmessages($params, $smarty) { $sessionManager = SessionManager::getInstance(); if (is_object($sessionManager)) { $msgs = MessageQueue::getMessages(); $smarty->assign('atkmessages', $msgs); if (empty($msgs)) { Tools::atkdebug('No messages in MessageQueue'); } return ''; } return ''; }
/** * Pops tree's on the session. */ public function sessionTree() { global $ATK_VARS; $postTree = $ATK_VARS['atktree']; $sm = SessionManager::getInstance(); $sessionTree = $sm->getValue('atktree'); if ($postTree != '' && $sessionTree != $postTree) { $sm->globalVar('atktree', $postTree); $realTree = $postTree; } else { $realTree = $sessionTree; // use the last known tree } $ATK_VARS['atktree'] = $realTree; // postvars now should contain the last Knowtree }
/** * The method returns a complete html page containing the feedback info. * * @param string $action The action for which feedback is provided * @param int $actionstatus The status of the action for which feedback is * provided * @param string $message An optional message to display in addition to the * default feedback information message. * * @return string The feedback page as an html String. */ public function feedbackPage($action, $actionstatus, $message = '') { $node = $this->m_node; $ui = $this->getUi(); $params['content'] = '<br>' . Tools::atktext('feedback_' . $action . '_' . Tools::atkActionStatus($actionstatus), $node->m_module, $node->m_type); if ($message) { $params['content'] .= ' <br>' . $message; } $sm = SessionManager::getInstance(); if ($sm->atkLevel() > 0) { $params['formstart'] = '<form method="get">' . $sm->formState(SessionManager::SESSION_BACK); $params['buttons'][] = '<input type="submit" class="btn btn-default btn_cancel" value="<< ' . Tools::atktext('back') . '">'; $params['formend'] = '</form>'; } $output = $ui->renderAction($action, $params); return $ui->renderBox(array('title' => $node->actionTitle($action), 'content' => $output)); }
/** * The action method. */ public function action_editcopy() { Tools::atkdebug('node::action_editcopy()'); $record = $this->getCopyRecord(); // allowed to editcopy record? if (!$this->allowed($record)) { $this->renderAccessDeniedPage(); return; } $db = $this->m_node->getDb(); if (!$this->m_node->copyDb($record)) { $db->rollback(); $location = $this->m_node->feedbackUrl('editcopy', self::ACTION_FAILED, $record, $db->getErrorMsg()); $this->m_node->redirect($location); } else { $db->commit(); $this->clearCache(); $sm = SessionManager::getInstance(); $location = $sm->sessionUrl(Tools::dispatch_url($this->m_node->atkNodeUri(), 'edit', array('atkselector' => $this->m_node->primaryKey($record))), SessionManager::SESSION_REPLACE); $this->m_node->redirect($location); } }
/** * Given an confirmed delete, determine where the record * needs to be deleted (session or dabase), delete it * and redirect to the feedback url. */ protected function _doDelete() { $atkstoretype = ''; $sessionmanager = SessionManager::getInstance(); if ($sessionmanager) { $atkstoretype = $sessionmanager->stackVar('atkstore'); } switch ($atkstoretype) { case 'session': $result = $this->_doDeleteSession(); break; default: $result = $this->_doDeleteDb(); break; } if ($result === true) { $location = $this->m_node->feedbackUrl('delete', self::ACTION_SUCCESS); } else { $location = $this->m_node->feedbackUrl('delete', self::ACTION_FAILED, null, $result); } $this->m_node->redirect($location); }
/** * Get the start of the form. * * @return string HTML The forms' start */ public function getFormStart() { $sm = SessionManager::getInstance(); $formstart = '<form id="entryform" name="entryform" enctype="multipart/form-data" action="' . Config::getGlobal('dispatcher') . '"' . ' method="post" onsubmit="return globalSubmit(this,false)" class="form-horizontal" role="form" autocomplete="off">' . $sm->formState($this->getUpdateSessionStatus()); $formstart .= '<input type="hidden" name="' . $this->getNode()->getEditFieldPrefix() . 'atkaction" value="' . $this->getUpdateAction() . '" />'; $formstart .= '<input type="hidden" name="' . $this->getNode()->getEditFieldPrefix() . 'atkprevaction" value="' . $this->getNode()->m_action . '" />'; $formstart .= '<input type="hidden" name="' . $this->getNode()->getEditFieldPrefix() . 'atkcsrftoken" value="' . $this->getCSRFToken() . '" />'; $formstart .= '<input type="hidden" class="atksubmitaction" />'; return $formstart; }
public function run() { $sessionManager = SessionManager::getInstance(); $sessionManager->start(); if (Config::getGlobal('session_autorefresh') && array_key_exists(Config::getGlobal('session_autorefresh_key'), $_GET)) { die(session_id()); } $securityManager = SecurityManager::getInstance(); if ($securityManager->authenticate()) { $this->bootModules(); $indexPageClass = Config::getGlobal('indexPage'); /** @var IndexPage $indexPage */ $indexPage = new $indexPageClass($this); $indexPage->generate(); } }
/** * Handle the error. * * @param string $errorMessage * @param string $debugMessage */ public function handle($errorMessage, $debugMessage) { $sessionManager = SessionManager::getInstance(); $sessionData =& SessionManager::getSession(); $txt_app_title = Tools::atktext('app_title'); if ($this->params['mailto'] != '') { // only if enabled.. $atk = Atk::getInstance(); $subject = '[' . $_SERVER['SERVER_NAME'] . "] {$txt_app_title} error"; $defaultfrom = sprintf('%s <%s@%s>', $txt_app_title, Config::getGlobal('identifier', 'atk'), $_SERVER['SERVER_NAME']); $from = Config::getGlobal('mail_sender', $defaultfrom); $body = "Hello,\n\nAn error seems to have occurred in the atk application named '{$txt_app_title}'.\n"; $body .= "\nThe errormessage was:\n\n" . implode("\n", is_array($errorMessage) ? $errorMessage : array()) . "\n"; $body .= "\nA detailed report follows:\n"; $body .= "\nPHP Version: " . phpversion() . "\n\n"; $body .= "\nDEBUGMESSAGES\n" . str_repeat('-', 70) . "\n"; $lines = []; for ($i = 0, $_ = count($debugMessage); $i < $_; ++$i) { $lines[] = $this->_wordwrap(Tools::atk_html_entity_decode(preg_replace('(\\[<a.*</a>\\])', '', $debugMessage[$i]))); } $body .= implode("\n", $lines); if (is_array($_GET)) { $body .= "\n\n_GET\n" . str_repeat('-', 70) . "\n"; foreach ($_GET as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 20 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } if (function_exists('getallheaders')) { $request = getallheaders(); if (count($request) > 0) { $body .= "\n\nREQUEST INFORMATION\n" . str_repeat('-', 70) . "\n"; foreach ($request as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } } if (is_array($_POST)) { $body .= "\n\n_POST\n" . str_repeat('-', 70) . "\n"; foreach ($_POST as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 20 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } if (is_array($_COOKIE)) { $body .= "\n\n_COOKIE\n" . str_repeat('-', 70) . "\n"; foreach ($_COOKIE as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 20 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } $body .= "\n\nATK CONFIGURATION\n" . str_repeat('-', 70) . "\n"; foreach ($GLOBALS as $key => $value) { if (substr($key, 0, 7) == 'config_') { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } $body .= "\n\nMODULE CONFIGURATION\n" . str_repeat('-', 70) . "\n"; foreach ($atk->g_modules as $modname => $modpath) { $modexists = file_exists($modpath) ? ' (path exists)' : ' (PATH DOES NOT EXIST!)'; $body .= $this->_wordwrap($modname . ':' . str_repeat(' ', max(1, 20 - strlen($modname))) . var_export($modpath, 1) . $modexists) . "\n"; } $body .= "\n\nCurrent User:\n" . str_repeat('-', 70) . "\n"; $user = SecurityManager::atkGetUser(); if (is_array($user) && count($user)) { foreach ($user as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } else { $body .= "Not known\n"; } if (is_object($sessionManager)) { $body .= "\n\nATK SESSION\n" . str_repeat('-', 70); $body .= "\nNamespace: " . $sessionManager->getNameSpace() . "\n"; if (isset($sessionData[$sessionManager->getNameSpace()]['stack'])) { $stack = $sessionData[$sessionManager->getNameSpace()]['stack']; for ($i = 0; $i < count($stack); ++$i) { $body .= "\nStack level {$i}:\n"; $item = isset($stack[$i]) ? $stack[$i] : null; if (is_array($item)) { foreach ($item as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } } } if (isset($sessionData[$sessionManager->getNameSpace()]['globals'])) { $ns_globals = $sessionData[$sessionManager->getNameSpace()]['globals']; if (count($ns_globals) > 0) { $body .= "\nNamespace globals:\n"; foreach ($ns_globals as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } } if (isset($sessionData['globals'])) { $globals = $sessionData['globals']; if (count($globals) > 0) { $body .= "\nGlobals:\n"; foreach ($globals as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } } } $body .= "\n\nSERVER INFORMATION\n" . str_repeat('-', 70) . "\n"; foreach ($_SERVER as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 20 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } //TODO: replace with some mailer object mail($this->params['mailto'], $subject, $body, "From: {$from}"); } }
/** * If the auto-select flag is set and only one record exists we immediately * return with the selected record. * * @param DataGrid $grid data grid * * @return bool auto-select active? */ protected function autoSelectRecord($grid) { $node = $this->getNode(); if (!$node->hasFlag(Node::NF_AUTOSELECT)) { return false; } $grid->loadRecords(); if ($grid->getCount() != 1) { return false; } $sm = SessionManager::getInstance(); if ($sm->atkLevel() > 0 && $grid->getPostvar('atkprevlevel', 0) > $sm->atkLevel()) { $backUrl = $sm->sessionUrl(Config::getGlobal('dispatcher') . '?atklevel=' . $sm->newLevel(SessionManager::SESSION_BACK)); $node->redirect($backUrl); } else { $records = $grid->getRecords(); // There's only one record and the autoselect flag is set, so we // automatically go to the target. $parser = new StringParser(rawurldecode(Tools::atkurldecode($grid->getPostvar('atktarget')))); // For backwardscompatibility reasons, we also support the '[pk]' var. $records[0]['pk'] = $node->primaryKey($records[0]); $target = $parser->parse($records[0], true); $node->redirect($sm->sessionUrl($target, SessionManager::SESSION_NESTED)); } return true; }
/** * Determine the url for the feedbackpage. * * Output is dependent on the feedback configuration. If feedback is not * enabled for the action, this method returns an empty string, so the * result of this method can be passed directly to the redirect() method * after completing the action. * * The $record parameter is ignored by the default implementation, but * derived classes may override this method to perform record-specific * feedback. * * @param string $action The action that was performed * @param int $status The status of the action. * @param array $record The record on which the action was performed. * @param string $message An optional message to pass to the feedbackpage, * for example to explain the reason why an action * failed. * @param int $levelskip Number of levels to skip * * @return string The feedback url. */ public function feedbackUrl($action, $status, $record = [], $message = '', $levelskip = null) { $sm = SessionManager::getInstance(); $vars = []; $atkNodeUri = ''; $sessionStatus = SessionManager::SESSION_BACK; if (isset($this->m_feedback[$action]) && Tools::hasFlag($this->m_feedback[$action], $status) || $status == ActionHandler::ACTION_FAILED) { $vars = array('atkaction' => 'feedback', 'atkfbaction' => $action, 'atkactionstatus' => $status, 'atkfbmessage' => $message); $atkNodeUri = $this->atkNodeUri(); $sessionStatus = SessionManager::SESSION_REPLACE; // The level skip given is based on where we should end up after the // feedback action is shown to the user. This means that the feedback // action should be shown one level higher in the stack, hence the -1. // Default the feedback action is shown on the current level, so in that // case we have a simple SessionManager::SESSION_REPLACE with a level skip of null. $levelskip = $levelskip == null ? null : $levelskip - 1; } $dispatch_url = Tools::dispatch_url($atkNodeUri, Tools::atkArrayNvl($vars, 'atkaction', ''), $vars); return $sm->sessionUrl($dispatch_url, $sessionStatus, $levelskip); }
/** * Get/generate CSRF token for the current session stack. * * http://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29_Prevention_Cheat_Sheet * * @return string CSRF token */ public function getCSRFToken() { // retrieve earlier generated token from the session stack $token = SessionManager::getInstance()->globalStackVar('ATK_CSRF_TOKEN'); if ($token != null) { return $token; } // generate and store token in sesion stack $token = md5(uniqid(rand(), true)); SessionManager::getInstance()->globalStackVar('ATK_CSRF_TOKEN', $token); return $token; }
/** * Get debugger data. * * @param bool $clean * @param int $stackId * * @return array Array with data */ public function &getDebuggerData($clean = false, $stackId = null) { $sm = SessionManager::getInstance(); if ($stackId == null) { $stackId = $sm->atkStackID(); } if (is_object($sm)) { $session =& $sm->getSession(); if ($clean) { $session['debugger'] = []; } $var =& $session['debugger'][$stackId]; return $var; } $data = []; return $data; }
/** * Get records for a recordlist without actually rendering the recordlist. * * @param array $recordset the list of records * @param array $actions the default actions array * @param array $suppressList fields we don't display * * @return string The rendered recordlist */ private function getRecordlistData($recordset, $actions, $suppressList = array()) { $grid = $this->getGrid(); $page = $this->getPage(); $sm = SessionManager::getInstance(); $edit = $grid->isEditing(); $page->register_script(Config::getGlobal('assets_url') . 'javascript/recordlist.js'); $listName = $grid->getName(); $defaulthighlight = Config::getGlobal('highlight'); $selectcolor = Config::getGlobal('select'); /* retrieve list array */ $list = $this->listArray($recordset, '', $actions, $suppressList); /* Check if some flags are still valid or not... */ $hasMRA = $grid->hasFlag(DataGrid::MULTI_RECORD_ACTIONS); if ($hasMRA && (count($list['mra']) == 0 || count($list['rows']) == 0)) { $hasMRA = false; } $hasSearch = $grid->hasFlag(DataGrid::SEARCH) && !$grid->isEditing(); if ($hasSearch && count($list['search']) == 0) { $hasSearch = false; } if ($grid->hasFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS) && (count($grid->getNode()->m_priority_actions) == 0 || count($list['rows']) == 0)) { $grid->removeFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS); } else { if ($grid->hasFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS)) { $grid->removeFlag(DataGrid::MULTI_RECORD_ACTIONS); if ($grid->getNode()->m_priority_max == 0) { $grid->getNode()->m_priority_max = $grid->getNode()->m_priority_min + count($list['rows']) - 1; } } } $hasActionCol = $this->_hasActionColumn($list, $hasSearch); $orientation = Config::getGlobal('recordlist_orientation'); /* * *********** */ /* HEADER ROW */ /* * *********** */ $headercols = []; if ($hasActionCol && count($list['rows']) == 0) { if ($orientation == 'left' || $orientation == 'both') { // empty cell above search button, if zero rows // if $orientation is empty, no search button is shown, so no empty cell is needed $headercols[] = array('content' => ' '); } } if (!$edit && ($hasMRA || $grid->hasFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS))) { $headercols[] = array('content' => ''); // Empty leader on top of mra action list. } if (($orientation == 'left' || $orientation == 'both') && ($hasActionCol && count($list['rows']) > 0)) { $headercols[] = array('content' => ''); } foreach (array_values($list['heading']) as $head) { if (!$grid->hasFlag(DataGrid::SORT) || empty($head['order'])) { $headercols[] = array('content' => $head['title']); } else { $call = $grid->getUpdateCall(array('atkorderby' => $head['order'], 'atkstartat' => 0)); $headercols[] = array('content' => $this->_getHeadingAnchorHtml($call, $head['title'])); } } if (($orientation == 'right' || $orientation == 'both') && ($hasActionCol && count($list['rows']) > 0)) { $headercols[] = array('content' => ''); } if ($hasActionCol && count($list['rows']) == 0) { if ($orientation == 'right' || $orientation == 'both') { // empty cell above search button, if zero rows // if $orientation is empty, no search button is shown, so no empty cell is needed $headercols[] = array('content' => ' '); } } /* * *********** */ /* SORT ROW */ /* * *********** */ $sortcols = []; $sortstart = ''; $sortend = ''; if ($grid->hasFlag(DataGrid::EXTENDED_SORT)) { $call = htmlentities($grid->getUpdateCall(array('atkstartat' => 0), [], 'ATK.DataGrid.extractExtendedSortOverrides')); $button = '<input type="button" value="' . Tools::atktext('sort') . '" onclick="' . $call . '">'; if (!$edit && ($hasMRA || $grid->hasFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS))) { $sortcols[] = array('content' => ''); // Empty leader on top of mra action list. } if ($orientation == 'left' || $orientation == 'both') { $sortcols[] = array('content' => $button); } foreach (array_keys($list['heading']) as $key) { if (isset($list['sort'][$key])) { $sortcols[] = array('content' => $list['sort'][$key]); } } if ($orientation == 'right' || $orientation == 'both') { $sortcols[] = array('content' => $button); } } /* * *********** */ /* SEARCH ROW */ /* * *********** */ $searchcols = []; $searchstart = ''; $searchend = ''; if ($hasSearch) { $call = htmlentities($grid->getUpdateCall(array('atkstartat' => 0), [], 'ATK.DataGrid.extractSearchOverrides')); $buttonType = $grid->isEmbedded() ? 'button' : 'submit'; $button = '<input type="' . $buttonType . '" class="btn btn-default btn_search" value="' . Tools::atktext('search') . '" onclick="' . $call . ' return false;">'; if ($grid->hasFlag(DataGrid::EXTENDED_SEARCH)) { $button .= ' ' . Tools::href(Config::getGlobal('dispatcher') . '?atknodeuri=' . $grid->getActionNode()->atkNodeUri() . '&atkaction=' . $grid->getActionNode()->getExtendedSearchAction(), '(' . Tools::atktext('search_extended') . ')', SessionManager::SESSION_NESTED); } $button = '<div class="search-buttons">' . $button . '</div>'; // $searchstart = '<a name="searchform"></a>'; $searchstart = ''; if (!$edit && ($hasMRA || $grid->hasFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS))) { $searchcols[] = array('content' => ''); } if ($orientation == 'left' || $orientation == 'both') { $searchcols[] = array('content' => $button); } foreach (array_keys($list['heading']) as $key) { if (isset($list['search'][$key])) { $searchcols[] = array('content' => $list['search'][$key]); } else { $searchcols[] = array('content' => ''); } } if ($orientation == 'right' || $orientation == 'both') { $searchcols[] = array('content' => $button); } } /* * **************************************** */ /* MULTI-RECORD-(PRIORITY-)ACTIONS FORM DATA */ /* * **************************************** */ $liststart = ''; $listend = ''; if (!$edit && ($hasMRA || $grid->hasFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS))) { $page->register_script(Config::getGlobal('assets_url') . 'javascript/formselect.js'); if ($hasMRA) { $liststart .= '<script language="javascript" type="text/javascript">var ' . $listName . ' = new Object();</script>'; } } /* * ***** */ /* ROWS */ /* * ***** */ $records = []; $keys = array_keys($actions); $actionurl = count($actions) > 0 ? $actions[$keys[0]] : ''; $actionloader = "rl_a['" . $listName . "'] = {};"; $actionloader .= "\nrl_a['" . $listName . "']['base'] = '" . $sm->sessionVars($grid->getActionSessionStatus(), 1, $actionurl) . "';"; $actionloader .= "\nrl_a['" . $listName . "']['embed'] = " . ($grid->isEmbedded() ? 'true' : 'false') . ';'; for ($i = 0, $_i = count($list['rows']); $i < $_i; ++$i) { $record = []; /* Special rowColor method makes it possible to change the row color based on the record data. * the method can return a simple value (which will be used for the normal row color), or can be * an array, in which case the first element will be the normal row color, and the second the mouseover * row color, example: function rowColor(&$record, $num) { return array('red', 'blue'); } */ $method = 'rowColor'; $bgn = ''; $bgh = $defaulthighlight; if (method_exists($grid->getNode(), $method)) { $bgn = $grid->getNode()->{$method}($recordset[$i], $i); if (is_array($bgn)) { list($bgn, $bgh) = $bgn; } } $record['class'] = $grid->getNode()->rowClass($recordset[$i], $i); foreach ($grid->getNode()->getRowClassCallback() as $callback) { $record['class'] .= ' ' . call_user_func_array($callback, array($recordset[$i], $i)); } /* alternate colors of rows */ $record['background'] = $bgn; $record['highlight'] = $bgh; $record['rownum'] = $i; $record['id'] = $listName . '_' . $i; $record['type'] = $list['rows'][$i]['type']; /* multi-record-priority-actions -> priority selection */ if (!$edit && $grid->hasFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS)) { $select = '<select name="' . $listName . '_atkselector[]" class="form-control select-standard">' . '<option value="' . htmlentities($list['rows'][$i]['selector']) . '"></option>'; for ($j = $grid->getNode()->m_priority_min; $j <= $grid->getNode()->m_priority_max; ++$j) { $select .= '<option value="' . $j . '">' . $j . '</option>'; } $select .= '</select>'; $record['cols'][] = array('content' => $select, 'type' => 'mrpa'); } elseif (!$edit && $hasMRA) { if (count($list['rows'][$i]['mra']) > 0) { switch ($grid->getMRASelectionMode()) { case Node::MRA_SINGLE_SELECT: $inputHTML = '<input type="radio" name="' . $listName . '_atkselector[]" value="' . $list['rows'][$i]['selector'] . '" class="atkradiobutton" onclick="if (this.disabled) this.checked = false">'; break; case Node::MRA_NO_SELECT: $inputHTML = '<input type="checkbox" disabled="disabled" checked="checked">' . '<input type="hidden" name="' . $listName . '_atkselector[]" value="' . $list['rows'][$i]['selector'] . '">'; break; case Node::MRA_MULTI_SELECT: default: $inputHTML = '<input type="checkbox" name="' . $listName . '_atkselector[' . $i . ']" value="' . $list['rows'][$i]['selector'] . '" class="atkcheckbox" onclick="if (this.disabled) this.checked = false">'; } $record['cols'][] = array('content' => $inputHTML . ' <script language="javascript" type="text/javascript">' . $listName . '["' . htmlentities($list['rows'][$i]['selector']) . '"] = new Array("' . implode($list['rows'][$i]['mra'], '","') . '"); </script>', 'type' => 'mra'); } else { $record['cols'][] = array('content' => ''); } } else { if ($edit && $list['rows'][$i]['edit']) { $liststart .= '<input type="hidden" name="atkdatagriddata_AE_' . $i . '_AE_atkprimkey" value="' . htmlentities($list['rows'][$i]['selector']) . '">'; } } $str_actions = '<span class="actions">'; $actionloader .= "\nrl_a['" . $listName . "'][" . $i . '] = {};'; $icons = Config::getGlobal('recordlist_icons'); foreach ($list['rows'][$i]['actions'] as $name => $url) { if (substr($url, 0, 11) == 'javascript:') { $call = substr($url, 11); $actionloader .= "\nrl_a['{$listName}'][{$i}]['{$name}'] = function() { {$call}; };"; } else { $actionloader .= "\nrl_a['{$listName}'][{$i}]['{$name}'] = '{$url}';"; } $module = $grid->getNode()->m_module; $nodetype = $grid->getNode()->m_type; $actionKeys = array('action_' . $module . '_' . $nodetype . '_' . $name, 'action_' . $nodetype . '_' . $name, 'action_' . $name, $name); $link = htmlentities($this->text($actionKeys)); if ($icons == true) { $normalizedName = strtolower(str_replace('-', '_', $name)); $icon = Config::get($module, 'icon_' . $nodetype . '_' . $normalizedName, false); if (!$icon) { $icon = Config::getGlobal('icon_' . $nodetype . '_' . $normalizedName, false); } if (!$icon) { $icon = Config::getGlobal('icon_' . $normalizedName, false); } if ($icon) { $link = '<i class="' . $icon . '" title="' . $link . '"></i>'; } } $confirmtext = 'false'; if (Config::getGlobal('recordlist_javascript_delete') && $name == 'delete') { $confirmtext = "'" . $grid->getNode()->confirmActionText($name) . "'"; } $str_actions .= $this->_renderRecordActionLink($url, $link, $listName, $i, $name, $confirmtext); } $str_actions .= '</span>'; /* actions (left) */ if ($orientation == 'left' || $orientation == 'both') { if (!empty($list['rows'][$i]['actions'])) { $record['cols'][] = array('content' => $str_actions, 'type' => 'actions'); } else { if ($hasActionCol) { $record['cols'][] = array('content' => ''); } } } /* columns */ foreach ($list['rows'][$i]['data'] as $html) { $record['cols'][] = array('content' => $html, 'type' => 'data'); } /* actions (right) */ if ($orientation == 'right' || $orientation == 'both') { if (!empty($list['rows'][$i]['actions'])) { $record['cols'][] = array('content' => $str_actions, 'type' => 'actions'); } else { if ($hasActionCol) { $record['cols'][] = array('content' => ''); } } } $records[] = $record; } $page->register_scriptcode($actionloader); $this->m_actionloader = $actionloader; /*************/ /* TOTAL ROW */ /*************/ $totalcols = []; if (count($list['total']) > 0) { if (!$edit && ($hasMRA || $grid->hasFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS))) { $totalcols[] = array('content' => ''); } if (($orientation == 'left' || $orientation == 'both') && ($hasActionCol && count($list['rows']) > 0)) { $totalcols[] = array('content' => ''); } foreach (array_keys($list['heading']) as $key) { $totalcols[] = array('content' => isset($list['total'][$key]) ? $list['total'][$key] : ''); } if (($orientation == 'right' || $orientation == 'both') && ($hasActionCol && count($list['rows']) > 0)) { $totalcols[] = array('content' => ''); } } /* * ********************************************** */ /* MULTI-RECORD-PRIORITY-ACTION FORM (CONTINUED) */ /* * ********************************************** */ $mra = ''; if (!$edit && $grid->hasFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS)) { $target = $sm->sessionUrl(Config::getGlobal('dispatcher') . '?atknodeuri=' . $grid->getActionNode()->atkNodeUri(), SessionManager::SESSION_NESTED); /* multiple actions -> dropdown */ if (count($grid->getNode()->m_priority_actions) > 1) { $mra = '<select name="' . $listName . '_atkaction" class="form-control select-standard">' . '<option value="">' . Tools::atktext('with_selected') . ':</option>'; foreach ($grid->getNode()->m_priority_actions as $name) { $mra .= '<option value="' . $name . '">' . Tools::atktext($name) . '</option>'; } $mra .= '</select> ' . $this->getCustomMraHtml() . '<input type="button" class="btn" value="' . Tools::atktext('submit') . '" onclick="atkSubmitMRPA(\'' . $listName . '\', this.form, \'' . $target . '\')">'; } else { $mra = $this->getCustomMraHtml() . '<input type="hidden" name="' . $listName . '_atkaction" value="' . $grid->getNode()->m_priority_actions[0] . '">' . '<input type="button" class="btn" value="' . Tools::atktext($grid->getNode()->m_priority_actions[0]) . '" onclick="atkSubmitMRPA(\'' . $listName . '\', this.form, \'' . $target . '\')">'; } } elseif (!$edit && $hasMRA) { $postvars = $grid->getNode()->m_postvars; $target = $sm->sessionUrl(Config::getGlobal('dispatcher') . '?atknodeuri=' . $grid->getNode()->atkNodeUri() . '&atktarget=' . (!empty($postvars['atktarget']) ? $postvars['atktarget'] : '') . '&atktargetvar=' . (!empty($postvars['atktargetvar']) ? $postvars['atktargetvar'] : '') . '&atktargetvartpl=' . (!empty($postvars['atktargetvartpl']) ? $postvars['atktargetvartpl'] : ''), SessionManager::SESSION_NESTED); $mra = count($list['rows']) > 1 && $grid->getMRASelectionMode() == Node::MRA_MULTI_SELECT ? '<a href="javascript:void(0)" onclick="updateSelection(\'' . $listName . '\', $(this).up(\'form\'), \'all\')">' . Tools::atktext('select_all') . '</a> | ' . '<a href="javascript:void(0)" onclick="updateSelection(\'' . $listName . '\', $(this).up(\'form\'), \'none\')">' . Tools::atktext('deselect_all') . '</a> | ' . '<a href="javascript:void(0)" onclick="updateSelection(\'' . $listName . '\', $(this).up(\'form\'), \'invert\')">' . Tools::atktext('select_invert') . '</a> ' : ''; $module = $grid->getNode()->m_module; $nodetype = $grid->getNode()->m_type; /* multiple actions -> dropdown */ if (count($list['mra']) > 1) { $default = $this->getGrid()->getMRADefaultAction(); $mra .= '<select name="' . $listName . '_atkaction" onchange="javascript:updateSelectable(\'' . $listName . '\', this.form)" class="form-control select-standard">' . '<option value="">' . Tools::atktext('with_selected') . '</option>'; foreach ($list['mra'] as $name) { if ($grid->getNode()->allowed($name)) { $actionKeys = array('action_' . $module . '_' . $nodetype . '_' . $name, 'action_' . $nodetype . '_' . $name, 'action_' . $name, $name); $mra .= '<option value="' . $name . '"'; if ($default == $name) { $mra .= 'selected="selected"'; } $mra .= '>' . Tools::atktext($actionKeys, $grid->getNode()->m_module, $grid->getNode()->m_type) . '</option>'; } } $embedded = $this->getGrid()->isEmbedded() ? 'true' : 'false'; $mra .= '</select> ' . $this->getCustomMraHtml() . '<input type="button" class="btn" value="' . Tools::atktext('submit') . '" onclick="atkSubmitMRA(\'' . $listName . '\', this.form, \'' . $target . '\', ' . $embedded . ', false)">'; } else { if ($grid->getNode()->allowed($list['mra'][0])) { $name = $list['mra'][0]; $actionKeys = array('action_' . $module . '_' . $nodetype . '_' . $name, 'action_' . $nodetype . '_' . $name, 'action_' . $name, $name); $embedded = $this->getGrid()->isEmbedded() ? 'true' : 'false'; $mra .= '<input type="hidden" name="' . $listName . '_atkaction" value="' . $name . '">' . $this->getCustomMraHtml() . '<input type="button" class="btn" value="' . Tools::atktext($actionKeys, $grid->getNode()->m_module, $grid->getNode()->m_type) . '" onclick="atkSubmitMRA(\'' . $listName . '\', this.form, \'' . $target . '\', ' . $embedded . ', false)">'; } } } else { if ($edit) { $mra = '<input type="button" class="btn" value="' . Tools::atktext('save') . '" onclick="' . htmlentities($this->getGrid()->getSaveCall()) . '">'; } } $recordListData = array('rows' => $records, 'header' => $headercols, 'search' => $searchcols, 'sort' => $sortcols, 'total' => $totalcols, 'searchstart' => $searchstart, 'searchend' => $searchend, 'sortstart' => $sortstart, 'sortend' => $sortend, 'liststart' => $liststart, 'listend' => $listend, 'listid' => $listName, 'mra' => $mra, 'editing' => $this->getGrid()->isEditing()); // print_r($recordListData); return $recordListData; }
public function validate(&$record, $mode) { $sessionmanager = SessionManager::getInstance(); $storetype = null; if ($sessionmanager) { $storetype = $sessionmanager->stackVar('atkstore'); } if ($storetype !== 'session' && !$this->_isSelectableRecord($record, $mode)) { Tools::triggerError($record, $this->fieldName(), 'error_integrity_violation'); } }
/** * This method returns an html page containing a recordlist to select * records from. The recordlist can be searched, sorted etc. like an * admin screen. * * @return string The html select page. */ public function multiSelectPage() { // add the postvars to the form global $g_stickyurl; $sm = SessionManager::getInstance(); $g_stickyurl[] = 'atktarget'; $g_stickyurl[] = 'atktargetvar'; $g_stickyurl[] = 'atktargetvartpl'; $GLOBALS['atktarget'] = $this->getNode()->m_postvars['atktarget']; $GLOBALS['atktargetvar'] = $this->getNode()->m_postvars['atktargetvar']; $GLOBALS['atktargetvartpl'] = $this->getNode()->m_postvars['atktargetvartpl']; $params['header'] = Tools::atktext('title_multiselect', $this->getNode()->m_module, $this->getNode()->m_type); $actions['actions'] = []; $actions['mra'][] = 'multiselect'; $grid = DataGrid::create($this->getNode(), 'multiselect'); /* * At first the changes below looked like the solution for the error * on the contact multiselect page. Except this is not the case, because * the MRA actions will not be shown, which is a must. */ if (is_array($actions['actions'])) { $grid->setDefaultActions($actions['actions']); } else { $grid->setDefaultActions($actions); } $grid->removeFlag(DataGrid::EXTENDED_SEARCH); $grid->addFlag(DataGrid::MULTI_RECORD_ACTIONS); $params['list'] = $grid->render(); if ($sm->atkLevel() > 0) { $backlinkurl = $sm->sessionUrl(Config::getGlobal('dispatcher') . '?atklevel=' . $sm->newLevel(SessionManager::SESSION_BACK)); $params['footer'] = '<br><div style="text-align: center"><input type="button" class="btn btn-default" onclick="window.location=\'' . $backlinkurl . '\';" value="' . Tools::atktext('cancel') . '"></div>'; } $output = $this->getUi()->renderList('multiselect', $params); return $this->getUi()->renderBox(array('title' => $this->getNode()->actionTitle('multiselect'), 'content' => $output)); }
/** * This method returns an html page that can be used as a search form. * * @param array $record A record containing default values that will be * entered in the searchform. * * @return string The html search page. */ public function searchPage($record = null) { $node = $this->m_node; $page = $this->getPage(); $page->register_script(Config::getGlobal('assets_url') . 'javascript/tools.js'); $ui = $this->getUi(); if (is_object($ui)) { $sm = SessionManager::getInstance(); $params = []; $params['formstart'] = '<form name="entryform" action="' . Config::getGlobal('dispatcher') . '" method="post">'; $params['formstart'] .= $sm->formState(SessionManager::SESSION_REPLACE); $params['formstart'] .= '<input type="hidden" name="atkaction" value="search">'; $params['formstart'] .= '<input type="hidden" name="atknodeuri" value="' . $node->atkNodeUri() . '">'; $params['formstart'] .= '<input type="hidden" name="atkstartat" value="0">'; // start at first page after new search $params['content'] = $this->invoke('searchForm', $record); $params['buttons'] = $node->getFormButtons('search'); $params['formend'] = '</form>'; $output = $ui->renderAction('search', $params); $total = $ui->renderBox(array('title' => $node->actionTitle('search'), 'content' => $output)); return $total; } else { Tools::atkerror('ui object failure'); } return ''; }
/** * Returns a JavaScript call to save the current grid's contents when in edit mode. * * @return string JavaScript call (might need escaping when used in HTML code) */ public function getSaveCall() { $sm = SessionManager::getInstance(); $url = $sm->sessionUrl(Tools::dispatch_url($this->getNode()->atkNodeUri(), 'multiupdate', array('output' => 'json')), SessionManager::SESSION_PARTIAL); return 'ATK.DataGrid.save(' . Json::encode($this->getName()) . ', ' . Json::encode($url) . ');'; }
/** * Retrieve all known information about the currently logged-in user. * * @param $key string * * @return array Array with userinfo, or "" if no user is logged in. */ public static function atkGetUser($key = '') { $sm = SessionManager::getInstance(); $session = SessionManager::getSession(); $user = ''; $session_auth = is_object($sm) ? $sm->getValue('authentication', 'globals') : []; if (Config::getGlobal('authentication_session') && Tools::atkArrayNvl($session, 'login', 0) == 1 && $session_auth['authenticated'] == 1 && !empty($session_auth['user'])) { $user = $session_auth['user']; if (!isset($user['access_level']) || empty($user['access_level'])) { $user['access_level'] = 0; } } if ($key) { return $user[$key]; } return $user; }
/** * Makes a session-aware href url. * When using hrefs in the editform, you can set saveform to true. This will save your * form variables in the session and restore them whenever you come back. * * @param string $url the url to make session aware * @param string $name the name to display (will not be escaped!) * @param int $sessionstatus the session flags * (SessionManager::SESSION_DEFAULT (default)|SessionManager::SESSION_NEW|SessionManager::SESSION_REPLACE| * SessionManager::SESSION_NESTED|SessionManager::SESSION_BACK) * @param bool $saveform wether or not to save the form * @param string $extraprops extra props you can add in the link such as * 'onChange="doSomething()"' * @static * * @return string the HTML link for the session aware URI */ public static function href($url, $name = '', $sessionstatus = SessionManager::SESSION_DEFAULT, $saveform = false, $extraprops = '') { $sm = SessionManager::getInstance(); if ($saveform) { $str = 'atkSubmit("' . self::atkurlencode($sm->sessionUrl($url, $sessionstatus)) . '", true);'; return '<a href="javascript:void(0)" onclick="' . htmlentities($str) . '" ' . $extraprops . '>' . $name . '</a>'; } else { $str = $sm->sessionUrl($url, $sessionstatus); return '<a href="' . htmlentities($str) . '" ' . $extraprops . '>' . $name . '</a>'; } }
/** * If a search action has been defined and a search only returns one result * the user will be automatically redirected to the search action. * * @param DataGrid $grid data grid * * @return bool redirect active? */ protected function redirectToSearchAction($grid) { $node = $this->getNode(); $search = $grid->getPostvar('atksearch'); // check if we are searching and a search action has been defined if (!is_array($search) || count($search) == 0 || !is_array($node->m_search_action) || count($node->m_search_action) == 0) { return false; } // check if there is only a single record in the result $grid->loadRecords(); if ($grid->getCount() != 1) { return false; } $records = $grid->getRecords(); foreach ($node->m_search_action as $action) { if (!$node->allowed($action, $records[0])) { continue; } // reset search so we can back to the normal admin screen if we want $grid->setPostvar('atksearch', array()); $sm = SessionManager::getInstance(); $url = $sm->sessionUrl(Tools::dispatch_url($node->atkNodeUri(), $action, array('atkselector' => $node->primaryKey($records[0]))), SessionManager::SESSION_NESTED); if ($grid->isUpdate()) { $script = 'document.location.href = ' . Json::encode($url) . ';'; $node->getPage()->register_loadscript($script); } else { $node->redirect($url); } return true; } return false; }
/** * Stops building the action box and returns the page builder. * * @return PageBuilder */ public function endActionBox() { if ($this->m_sessionStatus !== null) { $sm = SessionManager::getInstance(); $this->m_params['formend'] = $sm->formState($this->m_sessionStatus) . $this->m_params['formend']; } $this->m_pageBuilder->actionBox($this->m_params, $this->m_title, $this->m_template); return $this->m_pageBuilder; }
/** * Get the sessionmanager to use. * * @return mixed Sessionmanager or false if we don't have a session */ protected static function getSessionManager() { $sessionmanager = SessionManager::getInstance(); if (!$sessionmanager) { return false; } else { return $sessionmanager; } }
/** * the real import function * import the uploaded csv file for real. */ public function doExport() { $enclosure = $this->m_postvars['enclosure']; $delimiter = $this->m_postvars['delimiter']; $source = $this->m_postvars; $list_includes = []; foreach ($source as $name => $value) { $pos = strpos($name, 'export_'); if (is_integer($pos) and $pos == 0) { $list_includes[] = substr($name, strlen('export_')); } } $sm = SessionManager::getInstance(); $sessionData =& SessionManager::getSession(); $session_back = $sessionData['default']['stack'][$sm->atkStackID()][$sm->atkLevel() - 1]; $atkorderby = $session_back['atkorderby']; $node = $this->m_node; $node_bk = $node; $num_atts = count($node_bk->m_attribList); $atts =& $node_bk->m_attribList; foreach ($atts as $name => $object) { $att = $node_bk->getAttribute($name); if (in_array($name, $list_includes) && $att->hasFlag(Attribute::AF_HIDE_LIST)) { $att->removeFlag(Attribute::AF_HIDE_LIST); } elseif (!in_array($name, $list_includes)) { $att->addFlag(Attribute::AF_HIDE_LIST); } } $rl = new CustomRecordList(); $flags = ($node_bk->hasFlag(Node::NF_MRA) ? RecordList::RL_MRA : 0) | ($node_bk->hasFlag(Node::NF_MRPA) ? RecordList::RL_MRPA : 0); $node_bk->m_postvars = $session_back; if (isset($session_back['atkdg']['admin']['atksearch'])) { $node_bk->m_postvars['atksearch'] = $session_back['atkdg']['admin']['atksearch']; } if (isset($session_back['atkdg']['admin']['atksearchmode'])) { $node_bk->m_postvars['atksearchmode'] = $session_back['atkdg']['admin']['atksearchmode']; } $atkfilter = Tools::atkArrayNvl($source, 'atkfilter', ''); $condition = $session_back['atkselector'] . ($session_back['atkselector'] != '' && $atkfilter != '' ? ' AND ' : '') . $atkfilter; $recordset = $node_bk->select($condition)->orderBy($atkorderby)->includes($list_includes)->mode('export')->getAllRows(); if (method_exists($this->m_node, 'assignExportData')) { $this->m_node->assignExportData($list_includes, $recordset); } $recordset_new = []; foreach ($recordset as $row) { foreach ($row as $name => $value) { if (in_array($name, $list_includes)) { $value = str_replace("\r\n", '\\n', $value); $value = str_replace("\n", '\\n', $value); $value = str_replace("\t", '\\t', $value); $row[$name] = $value; } } $recordset_new[] = $row; } $filename = 'export_' . strtolower(str_replace(' ', '_', $this->getUi()->nodeTitle($node))); $rl->render($node_bk, $recordset_new, '', $enclosure, $enclosure, "\r\n", 1, '', '', array('filename' => $filename), 'csv', $source['generatetitlerow'], true, $delimiter); return true; }
/** * Returns a link for removing the currently selected criteria. If * nothing (valid) is selected nothing is returned. * * @param string $current currently loaded criteria * * @return string forget url */ public function getForgetCriteria($current) { if (empty($current) || $this->loadCriteria($current) == null) { return; } else { $sm = SessionManager::getInstance(); return $sm->sessionUrl(Tools::dispatch_url($this->m_node->atkNodeUri(), $this->m_action, array('forget_criteria' => $current)), SessionManager::SESSION_REPLACE); } }
/** * Here we prepare our record for updating or return false, * indicating that we need to insert the record instead of updating it. * * @param array &$record The record to prepare * * @return bool If the record wasn't prepared we return false, otherwise true */ public function prepareUpdateRecord(&$record) { $sessionManager = SessionManager::getInstance(); // The keys to update the record on $updatekey1 = $this->m_postvars['updatekey1']; $updatekey1val = $this->getValueFromRecord($record, $updatekey1); $allFields = $sessionManager->pageVar('allFields'); foreach ($allFields as $allField) { $allFieldsValues[$allField] = $this->m_postvars[$allField]; } $this->m_importNode->m_postvars['atksearchmode'] = 'exact'; // if (!in_array($allFieldValue)) $this->m_importNode->m_fuzzyFilters[] = $allFieldValue; $dbrec = $this->m_importNode->searchDb(array($updatekey1 => $updatekey1val)); if (count($dbrec) == 1) { $record[$this->m_importNode->primaryKeyField()] = $dbrec[0][$this->m_importNode->primaryKeyField()]; $record['atkprimkey'] = $dbrec[0]['atkprimkey']; return true; } return false; }