Пример #1
0
 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;
     }
 }
Пример #2
0
 public function executeCommand()
 {
     $note = $this->_receiver;
     //解析post数据
     $params = array();
     //解析main input的内容
     $i_helper = new Lds_Helper_MainInput($this->_param['note-data']);
     $i_helper->parse();
     $dueDate = $i_helper->makeDate();
     $content = $i_helper->getString();
     $params['content'] = $content;
     if ($dueDate !== null) {
         $params['dueDate'] = $dueDate;
     }
     $params['user_id'] = $this->_param['user_id'];
     //必须设置category,未指定则放置于系统分类Inbox中
     if (isset($this->_param['categorys']) && $this->_param['categorys'] != '') {
         $params['categorys'] = $this->_param['categorys'];
     } else {
         $params['categorys'] = 'Inbox';
     }
     //确保内容不为空
     if ($params['content'] != null || $params['content'] != '') {
         //在数据库中新建note
         $data = $note->createNote($params);
         //为加入双链表中准备数据
         $note_id = $data['note_id'];
         $cate_id = $data['category_id'];
         //存入双链顺序表
         $list = LinkedList_Factory::factory('database');
         $list->pushInto($note_id, $cate_id);
         //数据库需要时间戳
         //TODO : 添加时解析时间和日期尚为解决
         if (isset($data['dueDate']) && $data['dueDate'] !== null) {
             $data['dueDate'] = Lds_Helper_MainInput::dateFormater($data['dueDate']);
         }
         //fi
     } else {
         $data = 'content can not be null.';
     }
     return $data;
 }
Пример #3
0
 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;
 }
Пример #4
0
 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
 }
Пример #5
0
 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;
 }