/** * Trashed Project Objects * * @param void * @return null */ function trash() { $this->wireframe->current_menu_item = 'trash'; if (!$this->logged_user->isAdministrator() && !$this->logged_user->getSystemPermission('manage_trash')) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if if ($this->request->isSubmitted()) { $action = $this->request->post('action'); if (!in_array($action, array('restore', 'delete'))) { $this->httpError(HTTP_ERR_BAD_REQUEST, 'Invalid action'); } // if $object_ids = $this->request->post('objects'); $objects = ProjectObjects::findByIds($object_ids, STATE_DELETED, VISIBILITY_PRIVATE); db_begin_work(); foreach ($objects as $object) { if ($action == 'restore') { $object->restoreFromTrash(); } else { $object->delete(); } // if } // foreach db_commit(); } // if $per_page = 30; $page = (int) $this->request->get('page'); if ($page < 1) { $page = 1; } // if list($objects, $pagination) = ProjectObjects::paginateTrashed($this->logged_user, $page, $per_page); $this->smarty->assign(array('objects' => $objects, 'pagination' => $pagination)); if (is_foreachable($objects)) { $this->wireframe->addPageAction(lang('Empty Trash'), assemble_url('trash_empty'), null, array('method' => 'post', 'confirm' => lang('Are you sure that you want to empty trash?'))); } // if }