function view_history()
 {
     $id = array_var($_GET, 'id');
     $manager = array_var($_GET, 'manager');
     $obj = get_object_by_manager_and_id($id, $manager);
     if (!$obj instanceof ApplicationDataObject) {
         flash_error(lang('object dnx'));
         ajx_current("empty");
         return;
     }
     // if
     if (!$obj->canView(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     if ($obj instanceof User && (logged_user()->getId() != $id && !logged_user()->isAdministrator())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $logs = ApplicationLogs::getObjectLogs($obj);
     $logs_read = ApplicationReadLogs::getObjectLogs($obj);
     tpl_assign('object', $obj);
     tpl_assign('logs', $logs);
     tpl_assign('logs_read', $logs_read);
 }
예제 #2
0
 function view_history()
 {
     $id = array_var($_GET, 'id');
     $obj = Objects::findObject($id);
     $isUser = $obj instanceof Contact && $obj->isUser() ? true : false;
     if (!$obj instanceof ApplicationDataObject) {
         flash_error(lang('object dnx'));
         ajx_current("empty");
         return;
     }
     // if
     if ($isUser && (logged_user()->getId() != $id && !logged_user()->isAdministrator())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     if (!$isUser && !$obj->canView(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $logs = ApplicationLogs::getObjectLogs($obj);
     $logs_read = ApplicationReadLogs::getObjectLogs($obj);
     tpl_assign('object', $obj);
     tpl_assign('logs', $logs);
     tpl_assign('logs_read', $logs_read);
 }
 function view_history()
 {
     $id = array_var($_GET, 'id');
     $obj = Objects::findObject($id);
     $page_size = 20;
     $limit = $page_size;
     // get submitted modification logs page
     $mod_page_submitted = array_var($_REQUEST, 'mod_page');
     $mod_page = $mod_page_submitted ? $mod_page_submitted : 1;
     $mod_offset = $page_size * ($mod_page - 1);
     // get submitted read logs page
     $view_page_submitted = array_var($_REQUEST, 'view_page');
     $view_page = $view_page_submitted ? $view_page_submitted : 1;
     $view_offset = $page_size * ($view_page - 1);
     $isUser = $obj instanceof Contact && $obj->isUser() ? true : false;
     if (!$obj instanceof ApplicationDataObject) {
         flash_error(lang('object dnx'));
         ajx_current("empty");
         return;
     }
     // if
     if ($isUser && (logged_user()->getId() != $id && !logged_user()->isAdministrator())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     if (!$isUser && !$obj->canView(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if logged user is guest don't show other users logs
     $extra_conditions = "";
     if (logged_user()->isGuest()) {
         $extra_conditions = " AND `created_by_id` = " . logged_user()->getId();
     }
     $logs = ApplicationLogs::getObjectLogs($obj, false, true, $limit, $mod_offset, $extra_conditions);
     $logs_read = ApplicationReadLogs::getObjectLogs($obj, $limit, $view_offset, $extra_conditions);
     // build modification logs pagination object
     $total_logs = ApplicationLogs::countObjectLogs($obj, false, true, $extra_conditions);
     $mod_logs_pagination = array('total_pages' => ceil($total_logs / $page_size), 'current_page' => $mod_page);
     // build read logs pagination object
     $total_read_logs = ApplicationReadLogs::countObjectLogs($obj, $extra_conditions);
     $view_logs_pagination = array('total_pages' => ceil($total_read_logs / $page_size), 'current_page' => $view_page);
     if ($mod_page_submitted || $view_page_submitted) {
         ajx_replace(true);
     }
     tpl_assign('object', $obj);
     tpl_assign('logs', $logs);
     tpl_assign('logs_read', $logs_read);
     tpl_assign('mod_logs_pagination', $mod_logs_pagination);
     tpl_assign('view_logs_pagination', $view_logs_pagination);
     tpl_assign('curtab', array_var($_REQUEST, 'curtab', ''));
 }