public function execute() { $sheet_id = $this->get('sheet_id', true); $this->checkRights($sheet_id); $sticky_model = new stickiesStickyModel(); $this->response = $sticky_model->getBySheetId($sheet_id); $this->response['_element'] = 'sticky'; }
protected function getSticky($id) { $sticky_model = new stickiesStickyModel(); $sticky = $sticky_model->getById($id); if (!$sticky) { throw new waAPIException('invalid_param', 'Sticky not found', 404); } $this->checkRights($sticky['sheet_id']); return $sticky; }
public function execute() { $id = (int) $this->get('id', true); $sticky_model = new stickiesStickyModel(); $sticky = $sticky_model->getById($id); if (!$sticky) { throw new waAPIException('invalid_param', 'Sticky not found', 404); } $this->checkRights($sticky['sheet_id']); $this->response = $sticky; }
public function execute() { $id = $this->post('id', true); $this->getSticky($id); $sticky_model = new stickiesStickyModel(); if ($sticky_model->delete($id)) { $this->response = true; } else { throw new waAPIException('server_error', 500); } }
public function execute() { $sheet_id = $this->get('sheet_id', true); $this->checkRights($sheet_id); $data = array('position_top' => max(0, waRequest::post('position_top', 2000 + rand(0, 1000), 'int')), 'position_left' => max(0, waRequest::post('position_left', 2000 + rand(0, 1000), 'int')), 'color' => waRequest::post('color', 'default'), 'size_height' => max(150, waRequest::post('size_height', 150)), 'size_width' => max(150, waRequest::post('size_width', 150)), 'content' => $this->post('content', true), 'font_size' => waRequest::post('font_size', 16)); $sticky_model = new stickiesStickyModel(); $sticky_id = $sticky_model->create($sheet_id, $data); if ($sticky_id) { $_GET['id'] = $sticky_id; $method = new stickiesSheetGetInfoMethod(); $this->response = $method->getResponse(true); } else { throw new waAPIException('server_error', 500); } }
protected function modifyAction() { if ($this->sticky_id) { $data = array(); $fields = array('content' => waRequest::TYPE_STRING, 'size' => waRequest::TYPE_INT, 'color' => waRequest::TYPE_STRING, 'font_size' => waRequest::TYPE_INT, 'position_top' => waRequest::TYPE_INT, 'position_left' => waRequest::TYPE_INT, 'size_width' => waRequest::TYPE_INT, 'size_height' => waRequest::TYPE_INT, 'sheet_id' => waRequest::TYPE_INT); foreach ($fields as $field => $type) { $value = waRequest::post($field, false, $type); if ($value !== false) { $data[$field] = $value; } } if (isset($data['size']) && $data['size']) { $data['size_height'] = $data['size_width'] = $data['size']; unset($data['size']); } $sticky = $this->sticky_model->getById($this->sticky_id); if ($sticky) { // if ( isset($data['size_width']) && $data['size_width'] != $sticky['size_width'] || // isset($data['size_height']) && $data['size_height'] != $sticky['size_height']) // { // $this->log('sticky_resize', 1); // } // if ( isset($data['position_top']) && $data['position_top'] != $sticky['position_top'] || // isset($data['position_left']) && $data['position_left'] != $sticky['position_left']) // { // $this->log('sticky_move', 1); // } if (isset($data['sheet_id']) && $data['sheet_id'] != $sticky['sheet_id']) { $this->log('sticky_move_to_board', 1); } if (isset($data['content']) && $data['content'] != $sticky['content']) { $this->log('sticky_edit', 1); } } if ($res = $this->sticky_model->modify($this->sticky_id, $data)) { $data['id'] = $this->sticky_id; $this->response = $data; } else { $this->response = $res; $this->errors = _w('Error while save sticky'); } } else { $this->errors = _w('Invalid sticky ID'); } }
protected function viewAction() { //mobile version $this->response = array(); if ($this->sheet_id) { $stickies_model = new stickiesStickyModel(); $this->response['stickies'] = $stickies_model->getBySheetId($this->sheet_id, array('id', 'content', 'color')); foreach ($this->response['stickies'] as &$sticky) { if (strlen($sticky['content']) > 120) { $sticky['content'] = mb_substr($sticky['content'], 0, 80, 'utf-8') . '...'; } } unset($sticky); $this->response['current_sheet'] = $this->sheet_model->getById($this->sheet_id); } else { $this->response['stickies'] = array(); } }
public function execute() { $id = $this->get('id', true); $this->getSticky($id); $data = waRequest::post(); if (isset($data['id'])) { unset($data['id']); } if (isset($data['sheet_id'])) { $this->checkRights($data['sheet_id']); } $sticky_model = new stickiesStickyModel(); if ($sticky_model->modify($id, $data)) { $method = new stickiesSheetGetInfoMethod(); $this->response = $method->getResponse(true); } else { throw new waAPIException('server_error', 500); } }
public function deleteById($value) { $res = false; if ($this->available($value)) { $sticky_model = new stickiesStickyModel(); $sticky_model->deleteByField('sheet_id', $value); $res = parent::deleteById($value); } return $res; }