Ejemplo n.º 1
0
/**
 * 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 '';
}
Ejemplo n.º 2
0
 /**
  * The real import function actually imports the importfile.
  *
  * @param bool $nopost
  */
 public function doImport($nopost = false)
 {
     ini_set('max_execution_time', 300);
     $db = $this->m_importNode->getDb();
     $fileid = $this->m_postvars['fileid'];
     $file = $this->getTmpFileDestination($fileid);
     $validated = $this->getValidatedRecords($file);
     if (!$this->m_postvars['novalidatefirst'] && $this->showErrors($validated['importerrors'])) {
         $db->rollback();
         return;
     }
     $this->addRecords($validated['importerrors'], $validated['validatedrecs']);
     if (!$this->m_postvars['novalidatefirst'] && $this->showErrors($validated['importerrors'])) {
         $db->rollback();
         return;
     }
     $db->commit();
     // clean-up
     @unlink($file);
     // clear recordlist cache
     $this->clearCache();
     // register message
     $messageQueue = MessageQueue::getInstance();
     $count = count((array) $validated['validatedrecs']['add']) + count((array) $validated['validatedrecs']['update']);
     if ($count == 0) {
         $messageQueue->addMessage(sprintf($this->m_node->text('no_records_to_import'), $count), MessageQueue::AMQ_GENERAL);
     } else {
         if ($count == 1) {
             $messageQueue->addMessage($this->m_node->text('successfully_imported_one_record'), MessageQueue::AMQ_SUCCESS);
         } else {
             $messageQueue->addMessage(sprintf($this->m_node->text('successfully_imported_x_records'), $count), MessageQueue::AMQ_SUCCESS);
         }
     }
     $this->m_node->redirect();
 }