public function indexAction() { //从URL中获取请求的category_id $request = $this->getRequest(); $category_id = $request->getParam('category_id'); $user_id = $this->_user->user_id; $this->_db_user->load($user_id); $notes = new Database_Notes($this->_db); $category_name = $notes->categoryIdToName($category_id); try { if (!$notes->checkThisUserHasThisCategory($user_id, $category_id)) { throw new RuntimeException('This category is not belong to you.', '0x0002'); } } catch (RuntimeException $e) { Lds_Helper_Log::writeLog($e); Lds_Helper_Redirect::goTo('/', 'You Have not right to access this page', 3); } $param = array('user_id' => $this->_db_user->getId(), 'category_id' => $category_id); $command = new Command_GetNoteByCategoryId($notes, $param); $this->_db_user->setCommand($command); $notes = $this->_db_user->executeCommand(); $this->view->notes = $notes; $this->view->category_name = $category_name; $this->view->category_id = $category_id; var_dump($notes); }
public function executeCommand() { $note = $this->_receiver; $params = $this->_param; if (array_key_exists('user_id', $params)) { $user_id = $this->_param['user_id']; $category_id = (int) $this->_param['category_id']; //var_dump($user_id); //var_dump($category_id); //var_dump($category_id); $notes = $note->getAllNoteByCategoryIdAndUserId($category_id, $user_id); //预处理输出数据格式 foreach ($notes as &$note) { //去转义符 $note['content'] = stripslashes($note['content']); //格式化时间日期 if (isset($note['dueDate'])) { try { $note['dueDate'] = Lds_Helper_MainInput::dateFormater($note['dueDate']); } catch (Exception $e) { Lds_Helper_Log::writeLog($e); } } } if (count($notes) > 0) { //根据双链表对notes排序显示 $list = LinkedList_Factory::factory('array'); $list->setBaseArray($notes); $ordered_notes = $list->orderList(); var_dump('note'); var_dump($note); var_dump('noteorder'); var_dump($ordered_notes); //排序表出错,记录到日志并直接返回未排序的结果 if (count($notes) > count($ordered_notes)) { Lds_Helper_Log::writeLog('order wrong.category_id: ' . $category_id); return $notes; } else { return $ordered_notes; } } return null; } }
public function executeCommand() { $note = $this->_receiver; $note_id = $this->_param['note_id']; $user_id = $this->_param['user_id']; if ($this->checkPermission($user_id, 'note_id', $note_id)) { //解析post来的数据 $params = array(); $note->load($note_id); $data = $note->delNote(); $list = LinkedList_Factory::factory('database'); $list->outList($note_id, true, true); $old_data = $data; //var_dump($this->_mHistory); //$this->_mHistory->store(__CLASS__,$old_data,'undo'); $this->_mHistory->store($this, $old_data, 'undo'); } else { $data = 'permission denied'; Lds_Helper_Log::writeLog('This user delete note which not belong to him'); } return $data; }
public function executeCommand() { $note = $this->_receiver; $this->_db = Zend_Registry::get('db'); //解析post数据 $user_id = $this->_param['user_id']; $old_cate_id = $this->_param['old_category_id']; $new_cate_id = $this->_param['new_category_id']; $note_id = $this->_param['note_id']; if ($this->checkPermission($user_id, 'note_id', $note_id)) { //出入双链 $list = LinkedList_Factory::factory('database'); $list->outList($note_id, true, true); $list->pushInto($note_id, $new_cate_id); $ln_cate = new Database_NotesLinkCategorys($this->_db); return $ln_cate->changeCategoryFormTo($note_id, $old_cate_id, $new_cate_id); } else { Lds_Helper_Log::writeLog('This user delete note which not belong to him' . $user_id); return 'permission denied'; } //fi }
public function executeCommand() { $note = $this->_receiver; $user_id = $this->_param['user_id']; $index = $note_id = $this->_param['index']; $front = $this->_param['front']; $cate = $this->_param['categorys']; if ($this->checkPermission($user_id, 'note_id', $note_id)) { $list = LinkedList_Factory::factory('database'); //如果没有发送来前元素,则默认为是将该元素置顶 if (isset($front) && $front != null && $front != 'null') { $data = $list->placeAfter($index, $front); } else { $first = $list->findFirstNodeInDatabase(true, $cate); $data = $list->placeBefore($index, $first); } } else { $data = 'permission denied'; Lds_Helper_Log::writeLog('This user delete note which not belong to him'); } return $data; }
public function delHelper($user_id, $cate_id, $delAllNote) { if ($this->checkPermission($user_id, 'category_id', $cate_id)) { $noteLinkCate = new Database_NotesLinkCategorys($this->_db); //删除该category所拥有的所有note if ($delAllNote == 1) { $this->_receiver->delNotesByCategoryId($cate_id); //删除连接 $noteLinkCate->removeNoteCategoryLink($cate_id); var_dump('del note'); } else { var_dump('just del cate'); //把所有该名下的note转移到inbox下 $notes = $this->_receiver; //$notes = new Database_Notes($this->_db); $myNotes = $notes->getAllNoteByCategoryIdAndUserId($cate_id, $user_id); $new_cate_id = $notes->createCategoryToUser('Inbox', $user_id); foreach ($myNotes as $note) { $noteLinkCate->changeCategoryFormTo($note['note_id'], $cate_id, $new_cate_id); } } //如果不是系统所用则可以直接删除category本身 if ($cate_id > 10) { $cate_db = new Database_NotesCategorys($this->_db); $cate_db->delCategoryById($cate_id); } //删除连接 $userLinkCate = new Database_UserLinkCategory($this->_db); $userLinkCate->removeUserCategoryLink($cate_id); return true; } else { Lds_Helper_Log::writeLog('This user delete note which not belong to him' . $user_id); return 'permission denied'; } //fi }