Changeset 14808
- Timestamp:
- 06/29/08 01:09:50 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
events/phpframework/piece_framework/trunk/libs/Phwittr/Self.php
r14793 r14808 67 67 $user = $mapper->findById($id); 68 68 if (is_null($user)) { 69 throw new Phwittr_ User_Exception();69 throw new Phwittr_Self_Exception(); 70 70 } 71 71 … … 121 121 } 122 122 123 // }}} 124 // {{{ update 125 126 /** 127 * ステータスを更新する 128 * 129 * @param string $comment 130 * @return mixed 131 */ 132 public function update($comment) 133 { 134 $status = Piece_ORM::createObject('Statuses'); 135 $status->userId = $this->id; 136 $status->comment = $comment; 137 $status->replyUserId = $this->_findReplyUserId($comment); 138 $status->createdAt = date('Y-m-d H:i:s'); 139 140 $mapper = Piece_ORM::getMapper('Statuses'); 141 return $mapper->insert($status); 142 } 143 144 // }}} 145 // {{{ delete 146 147 /** 148 * ステータスを削除する 149 * 150 * @param integer $id 151 * @return mixed 152 */ 153 public function delete($id) 154 { 155 $criteria->id = $id; 156 $criteria->userId = $this->id; 157 158 $mapper = Piece_ORM::getMapper('Statuses'); 159 $result = $mapper->deleteByIdAndUserId($criteria); 160 if (!$result) { 161 throw new Phwittr_Self_Exception(); 162 } 163 164 return $result; 165 } 166 123 167 /**#@-*/ 124 168 … … 126 170 * @access private 127 171 */ 172 173 // }}} 174 // {{{ _findReplyUserIdByComment 175 176 /** 177 * コメントから返信先ユーザIdを取得する 178 * 179 * @param string $comment 180 * @return mixed 181 */ 182 private function _findReplyUserId($comment) 183 { 184 $replyUserId = null; 185 if (preg_match('/^@([0-9a-zA-Z_]{1,20}+).*$/', $comment, $matches)) { 186 $replyUserName = $matches[1]; 187 188 $mapper = Piece_ORM::getMapper('Users'); 189 $replyUser = $mapper->findByUserName($replyUserName); 190 if ($replyUser) { 191 $replyUserId = $replyUser->id; 192 } 193 } 194 195 return $replyUserId; 196 } 128 197 129 198 /**#@-*/
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)