/** * When question is deleted * then decrease i_qcount but do it in such a way * that it cannot go below zero * Also if deleted question happends to be the one in the 'a_latest' * then also remove a_latest as well as set i_qid to 0 * * @todo if a_latest is removed we really * need to replace it with another question * that is the "new latest" which would be one * posted before this one in the same category * * @param \Lampcms\Question $Q * * @return $this */ public function removeQuestion(\Lampcms\Question $Q) { $id = $Q->getCategoryId(); if ($id > 0) { $qid = $Q->getResourceId(); $this->Mongo->CATEGORY->update(array('id' => $id, 'i_qcount' => array('$gt' => 0)), array('$inc' => array('i_qcount' => -1))); $this->Mongo->CATEGORY->update(array('id' => $id, 'i_qid' => $qid), array('$set' => array('i_qid' => 0, 'a_latest' => null))); } return $this; }
/** * When question is deleted * then decrease i_qcount but do it in such a way * that it cannot go below zero * Also if deleted question happends to be the one in the 'a_latest' * then also remove a_latest as well as set i_qid to 0 * * @todo if a_latest is removed we really * need to replace it with another question * that is the "new latest" which would be one * posted before this one in the same category * * @param \Lampcms\Question $Q * * @return $this */ public function removeQuestion(\Lampcms\Question $Q) { $id = $Q->getCategoryId(); $qid = $Q->getResourceId(); $this->removeQuestionById($qid, $id); return $this; }