Esempio n. 1
0
 private function bindTagByString($event, $eventId)
 {
     preg_match_all('/#([^#^\\s^:]{1,})([\\s\\:\\,\\;]{0,1})/', $event, $result);
     $this->tagModel = F::load_model('tag', array());
     foreach ($result[1] as $value) {
         $tagId = $this->tagModel->getTagIdByName($value);
         $this->bindTag($tagId, $eventId);
     }
 }
Esempio n. 2
0
 /**
  * 删除事件
  *
  * @access public
  * @param int $userId
  * @param int $eventId
  * @return void
  */
 public function deleteEvent($userId, $eventId)
 {
     #判断删除权限
     $eventInfo = $this->getEventInfo($eventId);
     if ($eventInfo['createUserId'] != $userId) {
         throw new Exception('只有事件创建者才可删除.', 203);
     }
     #删除事件
     F::db()->execute('update event set status = 0 where id = ?', array($eventId));
     #判断删除事件后是否依然具有相关标签信息
     preg_match_all('/#([^#^\\s^:]{1,})([\\s\\:\\,\\;]{0,1})/', $eventInfo['eventContent'], $result);
     foreach ($result[0] as $eventTagIndex) {
         $eventTagIndex = str_replace('\'', '', $eventTagIndex);
         $exist = F::db()->query('select id from event where content like ' . "'%{$eventTagIndex}%'" . ' and user_id = ? and status = 1 limit 1', array($eventInfo['userId']))->fetch_column('id');
         if (!$exist) {
             #去除相关标签
             $tagName = str_replace('#', '', $eventTagIndex);
             $tagId = $this->tagModel->getTagIdByName($tagName);
             $this->unbindTag($eventInfo['userId'], $tagId);
         }
     }
     unset($eventInfo);
 }