Example #1
0
File: file.php Project: Jintha/cama
 function create_new_version($version, $branch, $reason, $dontbranch = false, $svnupdate = false)
 {
     global $wpdb;
     $hole = DH_Hole::get($this->hole_id);
     // Branch our copy
     if ($dontbranch === false && $branch) {
         if ($hole && $this->exists($hole)) {
             $target = $this->file($hole, $this->version_id);
             @wp_mkdir_p(dirname($target));
             @copy($this->file($hole), $target);
         }
     }
     // Sort out any SVN business
     if ($this->svn && $svnupdate) {
         $options = get_option('drainhole_options');
         if ($options && isset($options['svn']) && $options['svn']) {
             include dirname(__FILE__) . '/svn.php';
             $svn = new DH_SVN($this->svn, $options['svn']);
             $svn->update($this->file($hole));
             if ($svn->version()) {
                 $version = $svn->version();
             }
         }
     }
     // Store details in a version branch
     if ($dontbranch === false) {
         $version = DH_Version::create($this, $version, $this->hits - DH_Version::total_hits($this->id), '', $reason);
         // Update our details
         $wpdb->query("UPDATE {$wpdb->prefix}drainhole_files SET updated_at=NOW(), version_id='{$version}' WHERE id={$this->id}");
     } else {
         $wpdb->query("UPDATE {$wpdb->prefix}drainhole_version SET version='{$version}', created_at=NOW() WHERE id={$this->version_id}");
     }
     return true;
 }