Ejemplo n.º 1
0
 /**
  * Updates USER_TAGS collection
  * Takes into account the tags from the
  * Question for which the user just submitted
  * an answer.
  * This is run via shutdown function
  *
  * @return object $this
  */
 protected function addUserTags($uid)
 {
     d('cp');
     $Tags = UserTags::factory($this->Registry);
     d('cp');
     $Question = $this->Question;
     d('cp');
     $func = function () use($Tags, $uid, $Question) {
         $Tags->addTags($uid, $Question);
     };
     d('cp');
     runLater($func);
     d('cp');
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Now update tags counter to decrease tags count
  * but ONLY if deleted item is Question
  *
  * @return object $this;
  */
 protected function updateTags()
 {
     if (!$this->requested) {
         if ('QUESTIONS' === $this->collection) {
             $Question = $this->Resource;
             \Lampcms\Qtagscounter::factory($this->Registry)->removeTags($Question);
             if (0 === $this->Resource['i_sel_ans']) {
                 d('going to remove to Unanswered tags');
                 \Lampcms\UnansweredTags::factory($this->Registry)->remove($Question);
             }
         } else {
             $Question = new \Lampcms\Question($this->Registry);
             $Question->by_id($this->Resource->getQuestionId());
             d('tags: ' . print_r($Question['a_tags'], 1));
         }
         /**
          * Must extract uid from $this->Resource because in case
          * the resource is an answer, then the
          * $Question has different owner, thus
          * will remove user tags for the wrong user
          *
          */
         $uid = $this->Resource->getOwnerId();
         \Lampcms\UserTags::factory($this->Registry)->removeTags($Question, $uid);
     }
     return $this;
 }
 /**
  * Update USER_TAGS collection
  *
  * @return object $this
  */
 protected function addUserTags()
 {
     $UserTags = UserTags::factory($this->Registry);
     $uid = $this->Submitted->getUserObject()->getUid();
     $Question = $this->Question;
     if (count($Question['a_tags']) > 0) {
         $callable = function () use($UserTags, $uid, $Question) {
             $UserTags->addTags($uid, $Question);
         };
         d('cp');
         runLater($callable);
     }
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Update USER_TAGS and QUESTION_TAGS collections
  * to add new tags that belong to this questions
  *
  * @return object $this
  */
 protected function addNewTags()
 {
     if (count($this->aSubmitted) > 0) {
         \Lampcms\Qtagscounter::factory($this->Registry)->parse($this->Question);
         \Lampcms\UserTags::factory($this->Registry)->addTags($this->Question['i_uid'], $this->Question);
         \Lampcms\Relatedtags::factory($this->Registry)->addTags($this->Question);
         if (0 === $this->Question['i_sel_ans']) {
             d('going to add to Unanswered tags');
             \Lampcms\UnansweredTags::factory($this->Registry)->set($this->Question);
         }
     }
     return $this;
 }