コード例 #1
0
ファイル: Driver.php プロジェクト: jubinpatel/horde
 /**
  * Saves a record fo the configured driver and checks/sets needCommit()
  * Also first checks to ensure permission to save record is available.
  *
  * @param array $info  Data to be passed to backend driver for storage
  *
  * @return mixed  True on success, PEAR::Error on error
  */
 function saveRecord(&$info)
 {
     // Check to see if this is a new domain
     if ($info['rectype'] == 'soa' && $info['zonename'] != $_SESSION['beatnik']['curdomain']['zonename']) {
         // Make sure the user has permissions to add domains
         if (!Beatnik::hasPermission('beatnik:domains', Horde_Perms::EDIT)) {
             throw new Beatnik_Exception(_('You do not have permission to create new domains.'));
         }
         // Create a dummy old domain for comparison purposes
         $oldsoa['serial'] = 0;
     } else {
         $oldsoa =& $_SESSION['beatnik']['curdomain'];
         // Check for permissions to edit the record in question
         if ($info['rectype'] == 'soa') {
             $node = 'beatnik:domains:' . $info['zonename'];
             if (!Beatnik::hasPermission($node, Horde_Perms::EDIT, 1)) {
                 throw new Beatnik_Exception(_('You do not have permssion to edit the SOA of this zone.'));
             }
         } else {
             $node = 'beatnik:domains:' . $_SESSION['beatnik']['curdomain']['zonename'];
             if (!Beatnik::hasPermission($node, Horde_Perms::EDIT, 2)) {
                 throw new Beatnik_Exception(_('You do not have permssion to edit this record.'));
             }
         }
     }
     // Save the changes to the backend
     // FIXME: Modify saveRecord() to return the new (possibly changed) ID of the
     // record and then use that ID to update permissions
     $return = $this->_saveRecord($info);
     $oldsoa =& $_SESSION['beatnik']['curdomain'];
     if ($info['rectype'] == 'soa' && $oldsoa['serial'] < $info['serial']) {
         // Clear the commit flag (if set)
         Beatnik::needCommit($oldsoa['zonename'], false);
     } else {
         Beatnik::needCommit($oldsoa['zonename'], true);
     }
     // Check to see if an SOA was just added or updated.
     // If so, make it the current domain.
     if ($info['rectype'] == 'soa') {
         $_SESSION['beatnik']['curdomain'] = $this->getDomain($info['zonename']);
     }
     return true;
 }