Esempio n. 1
3
 public function delete($id)
 {
     $item = R::findOne('ecatalog', 'id=?', [$id]);
     R::trash($item);
     @unlink('upload/' . $item['pdf_path']);
     @unlink('upload/' . $item['cover_path']);
     $this->slim->redirect($this->slim->request()->getRootUri() . '/ecatalog');
 }
Esempio n. 2
1
 public function delete($id)
 {
     $item = R::findOne('news', 'id=?', [$id]);
     R::trash($item);
     @unlink('upload/' . $item['picture']);
     @unlink('upload/' . $item['thumb']);
     $this->slim->redirect($this->slim->request()->getRootUri() . '/news');
 }
Esempio n. 3
1
 public function delete($roomId, $id)
 {
     $item = R::findOne('room_pattern', 'id=?', [$id]);
     @unlink('upload/' . $item->picture);
     @unlink('upload/' . $item->thumb);
     R::trash($item);
     $this->slim->redirect($this->slim->request()->getRootUri() . '/room/' . $roomId . '/pattern');
 }
Esempio n. 4
0
 public function trash($bean)
 {
     if (is_string($bean) || is_numeric($bean)) {
         return R::trash($this->type, $bean);
     }
     return R::trash($bean);
 }
Esempio n. 5
0
 public function remove()
 {
     $bean = R::findOne('group', ' name = ? ', [$this->name]);
     if ($bean !== null) {
         R::trash($bean);
         return true;
     }
     return false;
 }
Esempio n. 6
0
 public function deleteUser(Request $request, Response $response, array $args)
 {
     $name = $args['name'];
     if (empty($name)) {
         $this->flash->addMessage('flash', 'No user specified');
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('users'));
     }
     $user = R::findOne('users', ' email = ? ', [$name]);
     if (!empty($user)) {
         R::trash($user);
         $this->flash->addMessage('flash', "{$name} deleted");
     } else {
         $this->flash->addMessage('flash', "{$name} User not found");
     }
     return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('users'));
 }
Esempio n. 7
0
 public function replace()
 {
     $user = App::user();
     $existingBeans = R::findAll('territory', ' number = :number ', ['number' => $this->number]);
     foreach ($existingBeans as $bean) {
         $copy = R::dispense('territoryedit');
         $copy->geoJson = $bean->geoJson;
         $copy->name = $bean->name;
         $copy->number = $bean->number;
         $copy->locality = $bean->locality;
         $copy->congregation = $bean->congregation;
         $copy->created = $bean->created;
         $copy->createdBy = $bean->createdBy;
         $copy->archived = time();
         $copy->archivedBy = $user->id;
         R::store($copy);
         R::trash($bean);
     }
     $bean = R::dispense('territory');
     $bean->geoJson = $this->geoJson;
     $bean->name = $this->name;
     $bean->number = $this->number;
     $bean->locality = $this->locality;
     $bean->congregation = $this->congregation;
     $bean->created = time();
     $bean->createdBy = $user->id;
     R::store($bean);
     $this->_bean = $bean;
     return $this;
 }
Esempio n. 8
0
 /**
  * Delete the loaded bean
  * @throws NoBeanException
  */
 public function deleteBean()
 {
     if ($this->currentBean == null) {
         throw new NoBeanException();
     }
     R::trash($this->currentBean);
 }
Esempio n. 9
0
 public function removeLab($id, $school_id = null)
 {
     $sql = ' id = ? ';
     $bindings = [(int) $id];
     if (null !== $school_id) {
         $sql .= ' AND school_id = ? ';
         $bindings[] = (int) $school_id;
     }
     $lab = R::findOne('lab', $sql, $bindings);
     if (null !== $lab) {
         if ($lab->attachment && is_writable($this->filesPath . '/' . $lab->attachment)) {
             unlink($this->filesPath . '/' . $lab->attachment);
         }
         R::trash($lab);
     }
 }
Esempio n. 10
0
 public function removeTeacher($id)
 {
     R::trash('teacher', $id);
 }
Esempio n. 11
0
 /**
  * Delete bean from database
  */
 public function delete()
 {
     R::trash($this->_bean);
 }
Esempio n. 12
0
 public function delete($id)
 {
     $item = R::findOne('employee', 'id=?', [$id]);
     R::trash($item);
     $this->slim->redirect($this->slim->request()->getRootUri() . '/employee');
 }
Esempio n. 13
0
 /**
  * @param string $currencyFromCode
  * @param string $currencyToCode
  *
  * @return array
  */
 public static function deletePair($currencyFromCode, $currencyToCode)
 {
     $pair = self::getPairFromDb(self::checkCurrency($currencyFromCode), self::checkCurrency($currencyToCode));
     RedBean::trash($pair);
     return ['success' => true];
 }
Esempio n. 14
0
 /**
  *
  */
 public function delete()
 {
     R::trash($this->table);
 }
Esempio n. 15
0
 public function deleteRota(Request $request, Response $response, array $args)
 {
     $name = $args['name'];
     if (empty($name)) {
         $this->flash->addMessage('flash', 'No rota specified');
         return $response->withRedirect($this->router->pathFor('rotas'));
     }
     $rota = R::findOne('rotas', ' name = ? ', [$name]);
     if (!empty($rota)) {
         R::trash($rota);
         R::wipe($name);
         $this->flash->addMessage('flash', "{$name} deleted");
     } else {
         $this->flash->addMessage('flash', "{$name} Rota not found");
     }
     return $response->withRedirect($this->router->pathFor('rotas'));
 }
Esempio n. 16
0
 public function deleteProduct($productId)
 {
     $token = $this->slim->request->params('token');
     if (empty($token)) {
         header('Content-Type: application/json');
         echo json_encode(['error' => 'REQUIRE_AUTHORIZE'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
         exit;
     }
     $account = R::findOne("account", "token = ?", [$token]);
     if (!$account) {
         header('Content-Type: application/json');
         echo json_encode(['error' => 'AUTHORIZE_FAILED'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
         exit;
     }
     $item = R::findOne("account_product", "account_id=? AND product_id = ?", [$account['id'], $productId]);
     if (!$item) {
         header('Content-Type: application/json');
         echo json_encode(['error' => 'ACCOUNT_PRODUCT_NOT_FOUND'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
         exit;
     }
     R::trash($item);
     header('Content-Type: application/json');
     echo json_encode(['success' => true], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     exit;
 }
Esempio n. 17
0
 public function delete($id)
 {
     $item = R::findOne('product', 'id=?', [$id]);
     R::trash($item);
     R::exec('DELETE FROM account_product WHERE product_id = ?', [$id]);
     @unlink('upload/' . $item['picture']);
     // @unlink('upload/'.$item['thumb']);
     $this->slim->redirect($this->slim->request()->getRootUri() . '/product');
 }
Esempio n. 18
0
function clearDbToken()
{
    $payload = null;
    try {
        $payload = JWT::decode(getallheaders()['Authorization'], getJwtKey());
    } catch (Exception $e) {
    }
    if (null != $payload) {
        $user = R::load('user', $payload->uid);
        if (0 != $user->id) {
            $hash = getallheaders()['Authorization'];
            foreach ($user->ownToken as $token) {
                if ($hash == $token->token) {
                    R::trash($token);
                }
            }
            R::store($user);
        }
    }
}
Esempio n. 19
0
        $file = R::load('attachment', $data->fileId);
        if ($file->id) {
            $filename = $file->name;
            $before = $item->export();
            unlink('uploads/' . $file->filename);
            R::trash($file);
            R::store($item);
            logAction($actor->username . ' removed attachment ' . $filename . ' from item ' . $item->title, $before, $item, $itemId);
            $jsonResponse->addAlert('success', $filename . ' was deleted.');
            $jsonResponse->addBeans($item);
        }
    }
    $app->response->setBody($jsonResponse->asJson());
})->conditions(['itemId' => '\\d+']);
// Remove an item.
$app->post('/items/remove', function () use($app, $jsonResponse) {
    $data = json_decode($app->environment['slim.input']);
    if (validateToken(true)) {
        $item = R::load('item', $data->itemId);
        if ($item->id) {
            $before = $item->export();
            R::trash($item);
            renumberItems($item->lane_id, $item->position);
            $actor = getUser();
            logAction($actor->username . ' removed item ' . $item->title, $before, null, $data->itemId);
            $jsonResponse->addAlert('success', $item->title . ' was deleted.');
            $jsonResponse->addBeans(getBoards());
        }
    }
    $app->response->setBody($jsonResponse->asJson());
});
Esempio n. 20
0
 public function destroy()
 {
     return R::trash($this->bean);
 }
Esempio n. 21
0
 public function remove()
 {
     $bean = R::findOne('user', ' email = ? ', [$this->email]);
     if ($bean !== null) {
         R::trash($bean);
         return true;
     }
     return false;
 }
Esempio n. 22
0
 /**
  * @param $table
  * @return bool
  */
 public function remove($table)
 {
     R::trash($table);
     return true;
 }
Esempio n. 23
0
 public function removeAssetFromSchool($school_id, $assetId)
 {
     $asset = R::findOne('schoolasset', ' id = ? AND school_id = ? ', [$assetId, $school_id]);
     if (!$asset) {
         throw new InvalidArgumentException('No school asset found');
     }
     R::trash($asset);
 }
Esempio n. 24
0
 /**
  *
  * @param Request $request            
  * @param Response $response            
  * @param unknown $args            
  */
 public function resultsdelete(Request $request, Response $response, $args)
 {
     $id = $args['id'];
     $record = R::load(USER, $id);
     if ($record) {
         R::trash($record);
     }
     return $response->withRedirect($this->router->pathFor('results'));
 }
Esempio n. 25
0
        $autoAction = R::load('autoaction', $data->actionId);
        R::trash($autoAction);
        $actions = R::findAll('autoaction');
        $jsonResponse->addBeans($actions);
        $jsonResponse->addAlert('success', 'Automatic action removed.');
    }
    $app->response->setBody($jsonResponse->asJson());
});
// Toggle the expand/collapse state of a lane for the current user.
$app->post('/lanes/:laneId/toggle', function ($laneId) use($app, $jsonResponse) {
    if (validateToken()) {
        $user = getUser();
        $lane = R::load('lane', $laneId);
        $collapsed = R::findOne('collapsed', ' user_id = ? AND lane_id = ? ', [$user->id, $laneId]);
        if (null != $collapsed) {
            R::trash($collapsed);
            $jsonResponse->message = 'Expanded lane ' . $lane->name;
        } else {
            $collapsed = R::dispense('collapsed');
            $collapsed->userId = $user->id;
            $collapsed->laneId = $laneId;
            R::store($collapsed);
            $jsonResponse->message = 'Collapsed lane ' . $lane->name;
        }
        $jsonResponse->addBeans(getBoards());
    }
    $app->response->setBody($jsonResponse->asJson());
})->conditions(['laneId' => '\\d+']);
// Numbers only.
$app->post('/boards/:boardId/toggleActive', function ($boardId) use($app, $jsonResponse) {
    if (validateToken()) {
Esempio n. 26
0
 public function removeSoftware($id)
 {
     R::trash('software', $id);
 }
Esempio n. 27
0
 public function delete()
 {
     $bean = $this->bean();
     R::trash($bean);
     return $this;
 }
Esempio n. 28
0
 public function delete($id)
 {
     $item = R::findOne('contactdealer', 'id=?', [$id]);
     R::trash($item);
     $this->slim->redirect($this->slim->request()->getRootUri() . '/contactdealer');
 }
Esempio n. 29
0
 public function removePost($request, $response, $args)
 {
     $status = $this->secureRoute($request, $response);
     if ($status !== 200) {
         return $this->jsonResponse($response, $status);
     }
     $user = Auth::GetUser($request);
     $post = $this->loadPost($args['id']);
     if (!$post) {
         return $this->jsonResponse($response, 400);
     }
     if ($post->user_id !== $user->id && !$user->is_admin) {
         $this->apiJson->addAlert('error', 'You cannot remove this post.');
         return $this->jsonResponse($response, 403);
     }
     $title = $post->title;
     R::trash($post);
     $rss = new RssGenerator();
     $rss->updateRss();
     $data = $this->getUserPosts($user->id);
     $this->apiJson->setSuccess();
     $this->apiJson->addAlert('success', 'Post ' . $title . ' removed.');
     $this->apiJson->addData($data);
     return $this->jsonResponse($response);
 }
Esempio n. 30
0
            R::store($user);
            addUserToBoard($data->defaultBoard, $user);
            foreach ($data->boardAccess as $board) {
                addUserToBoard($board, $user);
            }
            logAction($actor->username . ' updated user ' . $user->username, $before, $user->export());
            $jsonResponse->addAlert('success', 'User updated.');
        }
        $jsonResponse->addBeans(getUsers());
        $jsonResponse->boards = R::exportAll(getBoards());
    }
    $app->response->setBody($jsonResponse->asJson());
});
// Remove a user.
$app->post('/users/remove', function () use($app, $jsonResponse) {
    $data = json_decode($app->environment['slim.input']);
    if (validateToken(true)) {
        $user = R::load('user', $data->userId);
        $actor = getUser();
        if ($user->id == $data->userId && $actor->isAdmin) {
            $before = $user->export();
            R::trash($user);
            R::exec('DELETE from board_user WHERE user_id = ?', [$data->userId]);
            logAction($actor->username . ' removed user ' . $before['username'], $before, null);
            $jsonResponse->addAlert('success', 'Removed user ' . $user->username . '.');
        }
        $jsonResponse->addBeans(getUsers());
        $jsonResponse->boards = R::exportAll(getBoards());
    }
    $app->response->setBody($jsonResponse->asJson());
});