本文整理汇总了PHP中Project::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::delete方法的具体用法?PHP Project::delete怎么用?PHP Project::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCRUD
public function testCRUD()
{
//CREATE Test
$newProject = new Project();
$projectName = 'This is a Test';
$newProject->setAttributes(array('name' => $projectName, 'description' => 'This project is for test purpose only', 'start_date' => '2010-11-15 15:00:00', 'end_date' => '2010-12-06 00:00:00', 'update_user_id' => 1, 'category' => 2, 'status' => 1, 'owner' => 1));
$this->assertTrue($newProject->save(false));
//READ Test
$readProject = Project::model()->findByPk($newProject->id);
$this->assertTrue($readProject instanceof Project);
$this->assertEquals($projectName, $readProject->name);
//UPDATE Test
$updateProjectName = 'Updated Name2';
$newProject->name = $updateProjectName;
$this->AssertTrue($newProject->save(false));
$updatedProject = Project::model()->findByPk($newProject->id);
$this->assertTrue($updatedProject instanceof Project);
$this->assertNotEquals($projectName, $updatedProject->name);
//DELETE Test
$deletedProjectId = $newProject->id;
$newProject->delete();
$deletedProject = Project::model()->findByPk($newProject->id);
$this->assertEquals(Null, $deletedProject);
//GetUserVote Test
$project = Project::model()->findByPk(18);
$this->assertTrue($project->getUserVote(7) == true);
//Vote Test
$this->assertTrue($project->vote(1, 1) == 1);
}
示例2: foreach
function delete_projects()
{
$projects = $this->get_projects();
foreach ($projects as $project) {
$this_project = new Project($project['id']);
$this_project->delete();
}
}
示例3: project_delete
/**
* Delete a project
* @route DELETE project/$id/$token (rewritten by codeigniter route)
* @param type $id
* @param type $token
*/
public function project_delete($id, $token)
{
$token_entry = new Token();
$token_entry->get_by_valid_token($token)->get();
$response = new stdClass();
if ($token_entry->exists() && $token_entry->user->get()->is_admin) {
$projects = new Project();
$projects->get_by_id($id);
$projects->delete();
$response->status = TRUE;
$this->response($response);
} else {
$response->status = FALSE;
$response->error = 'Token not found, not an admin or session expired';
$this->response($response);
}
}
示例4: delete
/**
* Delete project
*
* @param void
* @return null
*/
function delete()
{
if ($this->request->isApiCall() && !$this->request->isSubmitted()) {
$this->httpError(HTTP_ERR_BAD_REQUEST, null, true, $this->request->isApiCall());
}
// if
if ($this->active_project->isNew()) {
$this->httpError(HTTP_ERR_NOT_FOUND, null, true, $this->request->isApiCall());
}
// if
if (!$this->active_project->canDelete($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
}
// if
if ($this->request->isSubmitted()) {
$delete = $this->active_project->delete();
if ($delete && !is_error($delete)) {
if ($this->request->isApiCall()) {
$this->httpOk();
} else {
flash_success("Project ':name' has been deleted", array('name' => $this->active_project->getName()));
$this->redirectTo('projects');
}
// if
} else {
if ($this->request->isApiCall()) {
$this->serveData($delete);
} else {
flash_error("Failed to delete ':name' project", array('name' => $this->active_project->getName()));
$this->redirectTo('projects');
}
// if
}
// if
} else {
$this->httpError(HTTP_ERR_BAD_REQUEST, null, true, $this->request->isApiCall());
}
// if
}
示例5: delete_project
/**
* Delete a project and it's children
*
* @param Project $project
* @return void
*/
public static function delete_project($project)
{
$id = $project->id;
$project->delete();
/* Delete all children from the project */
Project\Issue::where('project_id', '=', $id)->delete();
Project\Issue\Comment::where('project_id', '=', $id)->delete();
Project\User::where('project_id', '=', $id)->delete();
User\Activity::where('parent_id', '=', $id)->delete();
}
示例6: Project
}
Session::checkLoginUser();
$project = new Project();
if (isset($_POST["add"])) {
$project->check(-1, CREATE, $_POST);
$newID = $project->add($_POST);
Event::log($newID, "project", 4, "maintain", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
if ($_SESSION['glpibackcreated']) {
Html::redirect($project->getFormURL() . "?id=" . $newID);
} else {
Html::back();
}
} else {
if (isset($_POST["delete"])) {
$project->check($_POST["id"], DELETE);
$project->delete($_POST);
Event::log($_POST["id"], "project", 4, "maintain", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
$project->redirectToList();
} else {
if (isset($_POST["restore"])) {
$project->check($_POST["id"], DELETE);
$project->restore($_POST);
Event::log($_POST["id"], "project", 4, "maintain", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
$project->redirectToList();
} else {
if (isset($_POST["purge"])) {
$project->check($_POST["id"], PURGE);
$project->delete($_POST, 1);
Event::log($_POST["id"], "project", 4, "maintain", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
$project->redirectToList();
} else {
示例7: Project
function test_delete()
{
//Arrange
$name = "Build a shed";
$motivation = "have storage";
$due_date = "2015-09-09";
$priority = 1;
$test_project = new Project($name, $motivation, $due_date, $priority);
$test_project->save();
$name2 = "Learn French";
$motivation2 = "To travel";
$test_project2 = new Project($name2, $motivation2, $due_date, $priority);
$test_project2->save();
//Act
$test_project->delete();
$result = Project::getAll();
//Assert
$this->assertEquals([$test_project2], $result);
}
示例8: Header
if ($object->id > 0)
{
$object->fetch_thirdparty();
}
/*
* Actions
*/
// Cancel
if (GETPOST("cancel") && ! empty($backtopage))
{
if (GETPOST("comefromclone")==1)
{
$result=$object->delete($user);
if ($result > 0)
{
Header("Location: index.php");
exit;
}
else
{
dol_syslog($object->error,LOG_DEBUG);
$mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>';
}
}
header("Location: ".$backtopage);
exit;
}
示例9: testProjectDelete
/**
* testProjectDelete
*
* @param int $id Id of project
* @return void
*
* @depends testProjectClose
* The depends says test is run only if previous is ok
*/
public function testProjectDelete($id)
{
global $conf, $user, $langs, $db;
$conf = $this->savconf;
$user = $this->savuser;
$langs = $this->savlangs;
$db = $this->savdb;
$localobject = new Project($this->savdb);
$result = $localobject->fetch($id);
$result = $localobject->delete($user);
print __METHOD__ . " id=" . $id . " result=" . $result . "\n";
$this->assertLessThan($result, 0);
return $result;
}
示例10:
include "layouts/forms/project.html";
break;
case "changeStatus":
case "delete":
if ($action == "changeStatus") {
/* Change status*/
$sMsg1 = $objProject->changeStatus($id, $_GET["status"]);
if ($sMsg1 == 1) {
$sMsg = $objMessages->changestatusIndication($moduleLabel);
} else {
$sMsg = $objMessages->errorIndication($moduleLabel, $action);
}
} else {
if ($action == "delete") {
/* Delete record */
$sMsg1 = $objProject->delete($id);
if ($sMsg1 == 1) {
$sMsg = $objMessages->addupdatesucessIndication($moduleLabel, $action);
} else {
$sMsg = $objMessages->errorIndication($moduleLabel, $action);
}
}
}
default:
/* List the customers */
$count = $objProject->getProjectCount();
if ($count > 0) {
$projectList = $objProject->getProjectList();
}
include "layouts/project.html";
}
示例11: Project
if (GETPOST('action') == 'confirm_reopen' && GETPOST('confirm') == 'yes')
{
$project = new Project($db);
$project->fetch(GETPOST("id"));
$result = $project->setValid($user);
if ($result <= 0)
{
$mesg='<div class="error">'.$project->error.'</div>';
}
}
if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer)
{
$project = new Project($db);
$project->fetch(GETPOST("id"));
$result=$project->delete($user);
if ($result > 0)
{
Header("Location: index.php");
exit;
}
else
{
dol_syslog($project->error,LOG_DEBUG);
$mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>';
}
}
/*
* View
示例12: deletePersonalProject
/**
* Delete personal project
* It doesnt delete the project If more than one user have this project as personal project.
* @param void
* @return null
*/
function deletePersonalProject()
{
$usersWithThatProject = count(Users::GetByPersonalProject($this->getPersonalProjectId()));
if ($this->personal_project && $usersWithThatProject == 1) {
$this->personal_project->delete();
}
// if
}
示例13: Project
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Open Source ACH. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////////////// */
include "code/includes.php";
$id = $_REQUEST['id'];
$part = $_REQUEST['part'];
$active_project = new Project();
$active_project->populateFromID($id);
$can_delete = FALSE;
// User must be owner and they must get to this page via the Delete link on the project page.
include "parts/includes.php";
if ($active_user->id == $active_project->user_id && substr($_SERVER['HTTP_REFERER'], 0, strlen("{$base_URL}/project/")) == "{$base_URL}/project/") {
$can_delete = TRUE;
$active_project->delete();
}
?>
<html>
<head>
<title>Deleting...</title>
<script language="JavaScript">
<?php
if ($can_delete) {
?>
alert("Project deleted.");
<?php
} else {
?>
示例14: Project
<?php
# delete_task.php
# 1. logic
Auth::kickout('login');
$project = new Project();
$project->load(['slug' => Route::param('slug')]);
$project->delete();
# 2. views
URL::redirect('/home');
示例15: delete
/**
* @param $id
*
* @return mixed|void
*/
public function delete($id)
{
$this->project = $this->project->find($id);
$this->project->delete();
}