예제 #1
0
 /**
  * Deletes a record from the SystemTable
  *
  * @param string $strSystemid
  * @param bool $bitRight
  * @param bool $bitDate
  * @return bool
  * @todo: remove first params, is always the current systemid. maybe mark as protected, currently only called by the test-classes
  *
  * * @todo find ussages and make private
  *
  */
 public final function deleteSystemRecord($strSystemid, $bitRight = true, $bitDate = true)
 {
     $bitResult = true;
     //Start a tx before deleting anything
     $this->objDB->transactionBegin();
     $strQuery = "DELETE FROM " . _dbprefix_ . "system WHERE system_id = ?";
     $bitResult = $bitResult && $this->objDB->_pQuery($strQuery, array($strSystemid));
     if ($bitRight) {
         $strQuery = "DELETE FROM " . _dbprefix_ . "system_right WHERE right_id = ?";
         $bitResult = $bitResult && $this->objDB->_pQuery($strQuery, array($strSystemid));
     }
     if ($bitDate) {
         $strQuery = "DELETE FROM " . _dbprefix_ . "system_date WHERE system_date_id = ?";
         $bitResult = $bitResult && $this->objDB->_pQuery($strQuery, array($strSystemid));
     }
     //end tx
     if ($bitResult) {
         $this->objDB->transactionCommit();
         class_logger::getInstance()->addLogRow("deleted system-record with id " . $strSystemid, class_logger::$levelInfo);
     } else {
         $this->objDB->transactionRollback();
         class_logger::getInstance()->addLogRow("deletion of system-record with id " . $strSystemid . " failed", class_logger::$levelWarning);
     }
     //flush the cache
     $this->flushCompletePagesCache();
     return $bitResult;
 }
예제 #2
0
 /**
  * Writes rights to the database.
  * Wrapper to the recursive function class_rights::setRightsRecursive($arrRights, $strSystemid)
  *
  * @param mixed $arrRights
  * @param string $strSystemid
  *
  * @see setRightsRecursive($arrRights, $strSystemid)
  * @throws class_exception
  * @return bool
  */
 public function setRights($arrRights, $strSystemid)
 {
     //start a new tx
     $this->flushRightsCache();
     $this->objDb->transactionBegin();
     $objInstance = class_objectfactory::getInstance()->getObject($strSystemid);
     if ($objInstance !== null && $objInstance instanceof interface_versionable) {
         $arrCurrPermissions = $this->getPlainRightRow($strSystemid);
         //create a changehistory entry
         $objLog = new class_module_system_changelog();
         $arrChanges = array(array("property" => "rightInherit", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_INHERIT], "newvalue" => $arrRights[self::$STR_RIGHT_INHERIT]), array("property" => "rightView", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_VIEW], "newvalue" => $arrRights[self::$STR_RIGHT_VIEW]), array("property" => "rightEdit", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_EDIT], "newvalue" => $arrRights[self::$STR_RIGHT_EDIT]), array("property" => "rightDelete", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_DELETE], "newvalue" => $arrRights[self::$STR_RIGHT_DELETE]), array("property" => "rightRight", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT]), array("property" => "rightRight1", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT1], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT1]), array("property" => "rightRight2", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT2], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT2]), array("property" => "rightRight3", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT3], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT3]), array("property" => "rightRight4", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT4], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT4]), array("property" => "rightRight5", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT5], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT5]), array("property" => "rightChangelog", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_CHANGELOG], "newvalue" => $arrRights[self::$STR_RIGHT_CHANGELOG]));
         $objLog->processChanges($objInstance, "editPermissions", $arrChanges);
     }
     $bitSave = $this->setRightsRecursive($arrRights, $strSystemid);
     if ($bitSave) {
         $this->objDb->transactionCommit();
         class_logger::getInstance()->addLogRow("saving rights of record " . $strSystemid . " succeeded", class_logger::$levelInfo);
     } else {
         $this->objDb->transactionRollback();
         class_logger::getInstance()->addLogRow("saving rights of record " . $strSystemid . " failed", class_logger::$levelError);
         throw new class_exception("saving rights of record " . $strSystemid . " failed", class_exception::$level_ERROR);
     }
     return $bitSave;
 }