public function execute($params) { $id = $this->get('id', true); $sheet_model = new stickiesSheetModel(); $data = array(); if (waRequest::post('name') !== null) { $data['name'] = waRequest::post('name'); } if (waRequest::post('background_id') !== null) { $data['background_id'] = waRequest::post('background_id'); } if (!$data) { throw new waAPIException('invalid_param', 'Nothing to update'); } if ($sheet_model->available($id)) { if ($sheet_model->updateById($id, $data)) { $method = new stickiesSheetGetInfoMethod(); $this->response = $method->getResponse(true); } else { throw new waAPIException('server_error', 500); } } else { throw new waAPIException('access_denied', "Not enough rights to work with current board", 403); } }
protected function viewAction() { $items = $this->sticky_model->getFieldsByField(array('id' => $this->sticky_id)); $sticky = array_shift($items); $this->sticky_model->available($sticky['id']); $sheet = $this->sheet_model->getById($sticky['sheet_id']); $this->response = array('sticky' => $sticky, 'sheet' => $sheet); }
public function delete($id) { $sheet_id = $this->available($id); $res = $this->deleteByField(array('id' => $id, 'sheet_id' => $sheet_id)); $sheet = new stickiesSheetModel(); $sheet->refresh($sheet_id, $this->countByField('sheet_id', $sheet_id)); return $res; }
public function execute() { $fields = waRequest::get('fields', 'name', 'string'); if (!$fields) { $fields = 'name'; } $sheet_model = new stickiesSheetModel(); $this->response = $sheet_model->get(false, $fields); $this->response['_element'] = 'sheet'; }
public function execute() { $id = $this->get('id', true); $sheet_model = new stickiesSheetModel(); $this->checkRights($id); $sheet = $sheet_model->getById($id); if (!$sheet) { throw new waAPIException('invalid_param', 'Sheet not found', 404); } $this->response = $sheet; }
protected function checkRights($sheet_id) { $sheet_model = new stickiesSheetModel(); $sheet = $sheet_model->getById($sheet_id); if (!$sheet) { throw new waAPIException('invalid_param', 'Sheet not found', 404); } if (!$this->getRights('sheet.' . $sheet_id)) { throw new waAPIException('access_denied', "Not enough rights to work with current board", 403); } return true; }
public function init() { $this->addItem('add_sheet', _w('Allow add new board'), 'checkbox'); // Add sheets $sheet_model = new stickiesSheetModel(); $sheets = $sheet_model->get(true); $items = array(); foreach ($sheets as $sheet) { $items[$sheet['id']] = !empty($sheet['name']) ? $sheet['name'] : "<" . _w('no name') . ">"; } $this->addItem('sheet', _w('Available boards'), 'list', array('items' => $items, 'position' => 'right')); }
public function execute() { $name = $this->post('name', true); $sheet_model = new stickiesSheetModel(); $sheet_id = $sheet_model->create($name, waRequest::post('background_id')); if ($sheet_id) { $_GET['id'] = $sheet_id; $method = new stickiesSheetGetInfoMethod(); $this->response = $method->getResponse(true); } else { throw new waAPIException('server_error', 500); } }
public function execute() { $id = (int) $this->post('id', true); $sheet_model = new stickiesSheetModel(); if ($sheet_model->available($id)) { if ($sheet_model->deleteById($id)) { $this->response = true; } else { throw new waAPIException('server_error', 500); } } else { throw new waAPIException('access_denied', "Not enough rights to work with current board", 403); } }
protected function deleteAction() { if ($this->sheet_model->deleteById($this->sheet_id)) { $this->response['sheet_id'] = $this->sheet_id; // Delete rights $right_model = new waContactRightsModel(); $right_model->deleteByField(array('app_id' => wa()->getApp(), 'name' => 'sheet.' . $this->sheet_id)); $this->log('board_delete', 1); } else { $this->errors = _w("Not enough rights to work with current board"); } }
<?php $sheet_model = new stickiesSheetModel(); $sheet_model->create(_w('My stickies'), null, false);