Example #1
0
 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
 }
Example #2
0
 /** 
  * tag_id 转换成 tag_name
  * 
  * @param $tag_id
  * 
  * @return 
  */
 public function categoryIdToName($category_id)
 {
     $category_db = new Database_NotesCategorys($this->_db);
     if ($category_db->load($category_id)) {
         return $category_db->category_name;
     } else {
         return false;
     }
 }