Exemple #1
0
 /**
  *
  * @return
  * @param object $id [optional]
  * @param object $safinstancesId [optional]
  */
 public function deleteNode($id = 0, $safinstancesId = 0, $rollback = false, $firstCall = true)
 {
     // init
     $pageContent = new Pagdivspage();
     $newStatus = $rollback ? 'restored' : 'deleted';
     if ($firstCall) {
         $this->numberNodesDeleted = 0;
     }
     // delete node
     $where = 'id = ' . $id . ' AND safinstances_id = ' . $safinstancesId . ' AND id != 0';
     if ($this->isLogicalDelete()) {
         $data = array("isDeleted" => !$rollback, "status" => $newStatus, "datemodified" => new Zend_Db_Expr('now()'));
         $this->numberNodesDeleted += $this->update($data, $where);
     } else {
         $pageContent->setPhysicalDelete();
         $this->numberNodesDeleted += $this->delete($where);
     }
     // delete content of the node
     $pageContent->deleteContentFromPage($id, $rollback);
     // get the kids now if any
     $this->setFilter('isDeleted', $rollback);
     $kids = $this->toArrayLoop(Sydney_Tools::getSafinstancesId(), $id);
     if (count($kids) > 0) {
         foreach ($kids as $kid) {
             $this->deleteNode($kid['id'], Sydney_Tools::getSafinstancesId(), $rollback, false);
         }
     }
     if ($firstCall) {
         return $this->numberNodesDeleted;
     }
 }