Example #1
0
 /**
  * Delete the given relationship
  *
  * @param Relationship $relationship
  * @return boolean
  */
 public function deleteRelationship(Relationship $relationship)
 {
     if ($this->openBatch) {
         $this->openBatch->delete($relationship);
         return true;
     }
     return $this->runCommand(new Command\DeleteRelationship($this, $relationship));
 }
Example #2
0
 public function actionDelete()
 {
     if (array_key_exists("batchIds", $_POST)) {
         $batchIds = (array) $_POST["batchIds"];
         $batch = new Batch();
         $batch->organizationId = Yii::app()->user->getOrgId();
         /*this is important to avoid one moderator to edit/delete other org batches*/
         foreach ($batchIds as $bId) {
             $batch->id = $bId;
             $batch->delete();
         }
         $this->render('delete');
     } else {
         Yii::app()->end();
     }
 }
 /**
  * @throws \ValidationException
  * @throws null
  */
 public function testBranchDelete_DeleteManyObjects_ObjectsDeleted()
 {
     $objects = array();
     for ($i = 0; $i < 100; $i++) {
         $human = new Human();
         $human->Name = 'Proud Owner ' . $i;
         $human->write();
         $dog = new Dog();
         $dog->Name = 'Pup ' . $i;
         $dog->Color = 'Fifty Shade No. ' . $i;
         $dog->Owner($human);
         $dog->write();
         $objects[] = $human;
         $objects[] = $dog;
     }
     $batch = new \Batch();
     $batch->delete($objects);
     $this->assertEquals(0, Dog::get()->Count());
     $this->assertEquals(0, Human::get()->Count());
 }
<?php

require_once './global.inc.php';
verify_oauth_session_exists();
if (HttpSession::currentUser()->getOrganization()->access_level < 4) {
    echo "Access denied";
    die;
}
$id = $_POST["id"];
$result = Batch::delete($id);
echo json_encode($result);