Exemple #1
0
 /**
  * Backend area (only rightpane) with a form to delete multiple logs
  * @return void
  */
 public function deleteMultiple()
 {
     $idlogs = $this->req->req('l', array());
     if (count($idlogs) <= 0) {
         $this->_indexRedirect();
     }
     $catched_messages = array('type' => 'delete_multiple');
     $ok = $error = 0;
     foreach ($idlogs as $idlog) {
         if (!$this->log_sql_item->loadById($idlog)) {
             $this->_setSystemLogMessage('log_is_not_loaded', array('multiple' => TRUE, 'idlog' => $idlog));
             $catched_messages['log'][$idlog] = 'error_log_is_not_loaded';
             ++$error;
             continue;
         }
         try {
             if ($this->log_sql_item->delete() == TRUE) {
                 // no log message for successful deletion -> otherwise you could never delete all messages
                 //$this->_setUserLogMessage('delete_log_success', array('multiple' => TRUE, 'idlog' => $idlog));
                 $catched_messages['log'][$idlog] = 'ok_delete_log_success';
                 ++$ok;
             }
         } catch (Exception $e) {
             switch ($e->getCode()) {
                 // 0 = fatal, 1 = error
                 case 0:
                 case 1:
                     $code = 'error';
                     break;
                     // 2 = warning
                 // 2 = warning
                 case 2:
                     $code = 'warning';
                     break;
             }
             $catched_messages['log'][$idlog] = $code . '_' . $e->getMessage();
             $this->_setUserLogMessage($e->getMessage(), array('multiple' => TRUE, 'idlog' => $idlog), $code);
             ++$error;
         }
     }
     if ($error > 0) {
         // store catched messages to session
         $msghash = md5(time());
         $this->_setVarToSession($msghash, $catched_messages, 'msg', TRUE);
         $msgcode = $ok > 0 ? 'warning_some_actions_failed' : 'error_all_actions_failed';
     } else {
         $msghash = '';
         $msgcode = 'ok_action_successful';
     }
     $this->http_header->redirect($this->url->urlGet(array('area' => $this->config_area['area_name'] . '_index', 'msghash' => $msghash, 'msgcode' => $msgcode)));
 }
Exemple #2
0
 /**
  * Initialize the storage of the LogItem in the database
  * @return bool Returns true if item is saved successful, otherwise false
  * @param SF_MODEL_LogSqlItem $item LogItem
  */
 protected function _saveLogItemToDB($item)
 {
     return $item->save();
 }