Beispiel #1
0
 function photo_delete()
 {
     $return = "done";
     $ID = isset($_REQUEST['ID']) ? $_REQUEST['ID'] : "";
     $art = new \DB\SQL\Mapper($this->f3->get("DB"), "dir_items_photos");
     $art->load("ID='{$ID}'");
     $art->erase();
     return $GLOBALS["output"]['data'] = $return;
 }
Beispiel #2
0
 function edit($f3)
 {
     $video = new DB\SQL\Mapper($f3->get('db'), 'videos');
     $video->load(array('id=?', $f3->get('PARAMS.videoID')));
     if ($f3->get('POST.delete') == '1') {
         $video->erase();
     } else {
         $video->startTime = $f3->get('POST.startTime');
         $video->endTime = $f3->get('POST.endTime');
         $video->save();
     }
     $f3->reroute('@channelList');
 }
Beispiel #3
0
 function post_delete_food($f3)
 {
     $orm = new DB\SQL\Mapper($f3->get('DB'), 'MEAL');
     $selectIds = $f3->get('POST.selectId');
     $redirect = $f3->get("POST.destination");
     if (isset($selectIds)) {
         foreach ($selectIds as $meal) {
             $orm->load(array('id = ?', $meal));
             if (!$orm->dry()) {
                 $orm->erase();
             }
             $orm->reset();
         }
         AlertControl::message_info("Valitut annokset on poistettu");
         $f3->reroute($redirect);
     }
     $menuId = $f3->get('POST.menuId');
     $id = $f3->get('PARAMS.id');
     $orm->load(array('id=?', $id));
     $meal_name = $orm->name;
     $orm->erase();
     AlertControl::message_info("Annos {$meal_name} on poistettu");
     $f3->reroute("/menu/{$menuId}");
 }
Beispiel #4
0
 static function remove($ID)
 {
     $timer = new timer();
     $f3 = \base::instance();
     //	test_array($values);
     $art = new \DB\SQL\Mapper($f3->get("DB"), "dir_users");
     $art->load("ID='{$ID}'");
     $art->erase();
     $timer->_stop(__NAMESPACE__, __CLASS__, __FUNCTION__, func_get_args());
     return "done";
 }
Beispiel #5
0
 public function deleteShout($id)
 {
     $delete = new \DB\SQL\Mapper($this->db, $this->prefix . 'shoutbox');
     if ($delete->count(["id = ?", $id]) == 0) {
         return FALSE;
     }
     $delete->erase(["id = ?", $id]);
     return TRUE;
 }
Beispiel #6
0
 public function libraryBookFavDelete($params)
 {
     if (empty($params['id'][0]) or empty($params['id'][1])) {
         return FALSE;
     }
     if (in_array($params["id"][0], ["AU", "RC", "SE", "ST"])) {
         $mapper = new \DB\SQL\Mapper($this->db, $this->prefix . 'user_favourites');
         $mapper->load(array("uid=? AND item=? AND type=? AND bookmark=?", $_SESSION['userID'], $params["id"][1], $params["id"][0], array_key_exists("bookmark", $params) ? 1 : 0));
         if (NULL !== ($fid = $mapper->get('fid'))) {
             $mapper->erase();
             return TRUE;
         }
         unset($mapper);
         return FALSE;
     }
 }
Beispiel #7
0
        $table = $schema->createTable('pastes');
        $table->addColumn('data')->type_text();
        $table->addColumn('crdate')->type_datetime();
        $table->addColumn('lifetime')->type_datetime();
        $table->addColumn('uuid')->type_varchar(30)->index(true);
        $table->build();
        echo "installed";
    } else {
        echo "already installed";
    }
});
// stats and cleanup
$f3->route(array('GET @stats: /stats', 'GET @cleanup: /cleanup'), function (Base $f3, $params) {
    $mapper = new \DB\SQL\Mapper($f3->get('DB'), $f3->get('db_table'));
    if ($f3->get('ALIAS') == 'cleanup') {
        $f3->set('cleanup', $mapper->erase(array('lifetime < ?', date('Y-m-d H:i:s'))));
    }
    $f3->set('all', $mapper->count());
    $f3->set('old', $mapper->count(array('lifetime < ?', date('Y-m-d H:i:s'))));
    $f3->set('sub_tmpl', 'stats.html');
    echo \Template::instance()->render('layout.html');
});
// error handler
$f3->set('ONERROR', function (Base $f3) {
    $error = $f3->get('ERROR');
    while (ob_get_level()) {
        ob_end_clean();
    }
    if ($f3->get('AJAX')) {
        echo json_encode($error);
        exit;
Beispiel #8
0
 /**
  * Удаляет элементы связанные с нодом
  * @param int $pid id нода, для которого надо удалить элементы
  */
 private function deleteItems($pid)
 {
     $mapper = new \DB\SQL\Mapper($this->db, $this->table . '__items');
     // TODO: Сделать удаление связанных файлов (изображений)
     $res = $mapper->erase(array('pid=?', $pid));
     //echo $res, '<br>';
 }
Beispiel #9
0
 function edit($f3)
 {
     $db = $f3->get('db');
     $channel = new DB\SQL\Mapper($db, 'channels');
     $channel->load(array('id=?', $f3->get('PARAMS.channelID')));
     // Delete Channel
     if ($f3->get('POST.delete') == '1') {
         $channel->erase();
         $db->exec('DELETE FROM videos WHERE channel=?', $f3->get('PARAMS.channelID'));
         $db->exec('DELETE FROM schedule WHERE channel=?', $f3->get('PARAMS.channelID'));
         $f3->reroute('@channelList');
         // Update Name
     } else {
         $channel->name = $f3->get('POST.name');
         $channel->live = $f3->get('POST.live');
         $channel->save();
         $f3->reroute('@channelList');
     }
 }