function attachments_list() { $project_id = $_GET['project_id']; $active_project = Projects::findById($project_id); $tabs = new NamedList(); $tabs->add('overview', array('text' => str_excerpt($active_project->getName(), 25), 'url' => $active_project->getOverviewUrl())); event_trigger('on_project_tabs', array(&$tabs, &$this->logged_user, &$active_project)); $tabs->add('people', array('text' => lang('People'), 'url' => $active_project->getPeopleUrl())); $tabs->add('recent_pages', array('text' => lang('Recent Pages'), 'url' => assemble_url('recent_pages') . '&project_id=' . $active_project->getId())); $tabs->add('reminders', array('text' => lang('Notifications'), 'url' => assemble_url('reminders_list', array('project_id' => $active_project->getId())))); $tabs->add('calendar', array('text' => lang('Calendar'), 'url' => Calendar::getProjectCalendarUrl($active_project))); js_assign('active_project_id', $active_project->getId()); $this->smarty->assign('page_tabs', $tabs); /*$attachments = array(); $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $query = "select id from healingcrystals_project_objects where type='Comment' and project_id='" . $active_project->getId() . "' order by created_on desc"; $result = mysql_query($query, $link); while($comment = mysql_fetch_assoc($result)){ $comment_id = $comment['id']; $query_1 = "select id from healingcrystals_attachments where parent_id='" . $comment_id . "' and parent_type='Comment' order by name"; $result_1 = mysql_query($query_1, $link); while($attachment = mysql_fetch_assoc($result_1)){ $attachment_id = $attachment['id']; $attachments[] = new Attachment($attachment_id); } } mysql_close($link); $this->smarty->assign('attachments', $attachments);*/ $this->smarty->assign('page_tab', 'attachments'); $page = (int) $this->request->get('page'); if ($page < 1) { $page = 1; } list($attachments, $pagination) = Attachments::paginateByProject($active_project, $this->logged_user, $page); $this->smarty->assign(array('attachments' => $attachments, 'pagination' => $pagination, 'active_project' => $active_project)); }
/** * Show files index page * * @param void * @return null */ function index() { if ($this->request->isApiCall()) { if ($this->active_category->isLoaded()) { $this->serveData(Files::findByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility()), 'files'); } else { $this->serveData(Files::findByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()), 'files'); } // if } else { $per_page = 10; $page = (int) $this->request->get('page'); if ($page < 1) { $page = 1; } // if $show_attachments = $this->request->get('show_attachments'); if ($this->active_category->isLoaded()) { $this->wireframe->addBreadCrumb(clean($this->active_category->getName()), $this->active_category->getViewUrl()); list($files, $pagination) = Files::paginateByCategory($this->active_category, $page, $per_page, STATE_VISIBLE, $this->logged_user->getVisibility()); } else { if ($show_attachments) { $this->wireframe->addBreadCrumb(lang('All Attachments'), files_module_url($this->active_project, array('show_attachments' => true))); $this->setTemplate('attachments'); list($files, $pagination) = Attachments::paginateByProject($this->active_project, $this->logged_user, $page, $per_page); } else { $this->wireframe->addBreadCrumb(lang('All Files'), files_module_url($this->active_project, array('show_attachments' => true))); list($files, $pagination) = Files::paginateByProject($this->active_project, $page, $per_page, STATE_VISIBLE, $this->logged_user->getVisibility()); } // if } // if $this->smarty->assign(array('categories' => Categories::findByModuleSection($this->active_project, FILES_MODULE, 'files'), 'files' => $files, 'pagination' => $pagination, 'attachments_view' => $show_attachments ? true : false, 'mass_edit_url' => assemble_url('project_files_mass_edit', array('project_id' => $this->active_project->getId())), 'can_manage_categories' => $this->logged_user->isProjectLeader($this->active_project) || $this->logged_user->isProjectManager())); } // if }