public function file_history($attachment) { if ($this->is_back()) { $x = ModuleManager::get_instance('/Base_Box|0'); if (!$x) { trigger_error('There is no base box module instance', E_USER_ERROR); } return $x->pop_main(); } Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); $id = $attachment['id']; $tb =& $this->init_module(Utils_TabbedBrowser::module_name()); $tb->start_tab('File history'); $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'hua' . $id); $gb->set_inline_display(); $gb->set_table_columns(array(array('name' => __('Deleted'), 'order' => 'deleted', 'width' => 10), array('name' => __('Date'), 'order' => 'upload_on', 'width' => 25), array('name' => __('Who'), 'order' => 'upload_by', 'width' => 25), array('name' => __('Attachment'), 'order' => 'uaf.original'))); $gb->set_default_order(array(__('Date') => 'DESC')); $ret = $gb->query_order_limit('SELECT uaf.id,uaf.deleted,uaf.filestorage_id,uaf.created_on as upload_on,uaf.created_by as upload_by,uaf.original FROM utils_attachment_file uaf WHERE uaf.attach_id=' . $id, 'SELECT count(*) FROM utils_attachment_file uaf WHERE uaf.attach_id=' . $id); while ($row = $ret->FetchRow()) { $r = $gb->get_new_row(); if ($row['deleted']) { $r->add_action($this->create_confirm_callback_href(__('Are you sure you want to restore attached file?'), array($this, 'restore_file'), array($row['id'])), 'restore', __('Restore')); } $view_link = ''; $lb = array(); $lb['aid'] = $id; $lb['crypted'] = $attachment['crypted']; $lb['original'] = $row['original']; $lb['id'] = $row['id']; $lb['filestorage_id'] = $row['filestorage_id']; $file = '<a ' . Utils_AttachmentCommon::get_file_leightbox($lb, $view_link) . '>' . $row['original'] . '</a>'; $r->add_data($row['deleted'] ? __('Yes') : __('No'), Base_RegionalSettingsCommon::time2reg($row['upload_on']), Base_UserCommon::get_user_label($row['upload_by']), $file); } $this->display_module($gb); $tb->end_tab(); $tb->start_tab('File access history'); $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'hda' . $id); $gb->set_inline_display(); $gb->set_table_columns(array(array('name' => __('Create date'), 'order' => 'created_on', 'width' => 15), array('name' => __('Download date'), 'order' => 'download_on', 'width' => 15), array('name' => __('Who'), 'order' => 'created_by', 'width' => 15), array('name' => __('IP Address'), 'order' => 'ip_address', 'width' => 15), array('name' => __('Host Name'), 'order' => 'host_name', 'width' => 15), array('name' => __('Method description'), 'order' => 'description', 'width' => 20), array('name' => __('Remote'), 'order' => 'remote', 'width' => 10))); $gb->set_default_order(array(__('Create date') => 'DESC')); $query = 'SELECT uad.created_on,uad.download_on,(SELECT l.login FROM user_login l WHERE uad.created_by=l.id) as created_by,uad.remote,uad.ip_address,uad.host_name,uad.description FROM utils_attachment_download uad INNER JOIN utils_attachment_file uaf ON uaf.id=uad.attach_file_id WHERE uaf.attach_id=' . $id; $query_qty = 'SELECT count(*) FROM utils_attachment_download uad INNER JOIN utils_attachment_file uaf ON uaf.id=uad.attach_file_id WHERE uaf.attach_id=' . $id; if (Base_AclCommon::check_permission('Attachments - view full download history')) { $ret = $gb->query_order_limit($query, $query_qty); } else { print 'You are allowed to see your own downloads only'; $who = ' AND uad.created_by=' . Acl::get_user(); $ret = $gb->query_order_limit($query . $who, $query_qty . $who); } while ($row = $ret->FetchRow()) { $r = $gb->get_new_row(); $r->add_data(Base_RegionalSettingsCommon::time2reg($row['created_on']), $row['remote'] != 1 ? Base_RegionalSettingsCommon::time2reg($row['download_on']) : '', $row['created_by'], $row['ip_address'], $row['host_name'], $row['description'], $row['remote'] == 0 ? 'no' : 'yes'); } $this->display_module($gb); $tb->end_tab(); $this->display_module($tb); $this->caption = 'Note history'; return true; }