Example #1
0
/**
 * Check Log
 *
 * This function finds that last tag for the current release and shows you 
 * any changes between them
 *
 * @param The git module directory
 * @return String of `git log` output
 */
function checklog($moddir)
{
    $repo = Git::open($moddir);
    $ltags = $repo->list_tags();
    if ($ltags === false) {
        return 'No Tags found!';
    }
    list($rawname, $ver, $supported) = freepbx::check_xml_file($moddir);
    //Get current module version
    preg_match('/(\\d*\\.\\d*)\\./i', $ver, $matches);
    $rver = $matches[1];
    //cycle through the tags and create a new array with relavant tags
    $tagArray = array();
    foreach ($ltags as $tag) {
        if (preg_match('/release\\/(.*)/i', $tag, $matches)) {
            if (strpos($matches[1], $rver) !== false) {
                $tagArray[] = $matches[1];
            }
        }
    }
    if (!empty($tagArray)) {
        usort($tagArray, "freepbx::version_compare_freepbx");
        $htag = array_pop($tagArray);
        $tagref = $repo->show_ref_tag($htag);
        return $repo->log($tagref, 'HEAD');
    }
    return;
}
Example #2
0
    if ($module == "framework") {
        $moduleDir = $moduleDir . '/amp_conf/htdocs/admin';
        $module = "amp";
    }
    foreach (glob($moduleDir . "/i18n/*", GLOB_ONLYDIR) as $langDir) {
        $lang = basename($langDir);
        if (file_exists($langDir . "/LC_MESSAGES/" . $module . ".mo")) {
            $file = $langDir . "/LC_MESSAGES/" . $module . ".mo";
            if (!file_exists($fwlangpacksReop . "/mo/" . $lang)) {
                mkdir($fwlangpacksReop . "/mo/" . $lang);
            }
            freepbx::out("\tProcessing " . $lang . ".mo in " . $module);
            copy($file, $fwlangpacksReop . "/mo/" . $lang . "/" . $module . ".mo");
        }
        if (file_exists($langDir . "/LC_MESSAGES/" . $module . ".po")) {
            $file = $langDir . "/LC_MESSAGES/" . $module . ".po";
            if (!file_exists($fwlangpacksReop . "/po/" . $lang)) {
                mkdir($fwlangpacksReop . "/po/" . $lang);
            }
            freepbx::out("\tProcessing " . $lang . ".po in " . $module);
            copy($file, $fwlangpacksReop . "/po/" . $lang . "/" . $module . ".po");
        }
    }
    $repo->checkout($branch);
    if ($stashed) {
        $repo->apply_stash();
        $repo->drop_stash();
    }
}
freepbx::out("Finished!");
Example #3
0
        //TODO: check to make sure the author/committer isn't 'root'
        try {
            $repo->push("origin", "release/" . $mver);
        } catch (Exception $e) {
            freepbx::out($e->getMessage());
            freepbx::out("Module " . $module . " will not be pushed!");
            continue;
        }
        freepbx::out("Done");
        freepbx::outn("\tMaster is the same supported release as this branch. Merging this release into master...");
        if (!$vars['debug']) {
            $repo->checkout("master");
            $merged = $repo->pull("origin", "release/" . $mver);
            if (!$merged) {
                freepbx::out("\t\tMerge from release/" . $mver . " into master failed");
                freepbx::out("Module " . $module . " will not be tagged!");
                continue;
            }
            $repo->push("origin", "master");
            $repo->checkout("release/" . $mver);
        }
        freepbx::out("Done");
        freepbx::outn("\tChecking you back into " . $activeb . "...");
        $repo->checkout($activeb);
        freepbx::out("Done");
        break;
    default:
        freepbx::showHelp('update_language.php', $help);
        exit(0);
        break;
}
Example #4
0
#!/usr/bin/env php
<?php 
require_once 'libraries/freepbx.php';
$help = array();
$help[] = array('--directory', 'Directory Location of modules root, always assumed to be ../freepbx from this location');
$freepbx_conf = freepbx::getFreePBXConfig();
if (is_array($freepbx_conf) && !empty($freepbx_conf)) {
    foreach ($freepbx_conf as $key => $value) {
        if (isset($value) && $value != '') {
            $vars[$key] = $value;
        }
    }
}
$vars['directory'] = !empty($vars['repo_directory']) ? $vars['repo_directory'] : '';
$vars['directory'] = !empty($vars['directory']) ? $vars['directory'] : dirname(dirname(__FILE__)) . '/freepbx';
$modules = glob($vars['directory'] . '/*', GLOB_ONLYDIR);
foreach ($modules as $mod_dir) {
    freepbx::outn("Attempting to open module " . basename($mod_dir) . "...");
    try {
        $repo = Git::open($mod_dir);
        freepbx::out("Done");
    } catch (Exception $e) {
        freepbx::out($e->getMessage());
        continue;
    }
    $remote = $repo->get_remote_uri('origin');
    if (preg_match('/org\\/freep12/i', $remote)) {
        $newuri = preg_replace('/org\\/freep12/i', 'org/freepbx', $remote);
        $repo->update_remote('origin', $newuri);
    }
}
Example #5
0
 public static function get_license_from_link($licenseLink)
 {
     // Do we ALREADY have this licence? If so, we don't
     // need to download it.
     $lic = basename($licenseLink);
     if (file_exists(__DIR__ . "/licences/{$lic}")) {
         freepbx::out(" Done! (Cached {$lic})");
         return file_get_contents(__DIR__ . "/licences/{$lic}");
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $licenseLink);
     $licenseText = curl_exec($ch);
     $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     switch ($httpStatusCode) {
         case '200':
             freepbx::out(" Done! (Retrieved {$licenseLink})");
             return $licenseText;
         default:
             freepbx::out("An error occurred trying to get license from " . $licenseLink);
     }
     return false;
 }
Example #6
0
            freepbx::out("Done");
        }
        $organizationApi = $client->api('organization');
        $paginator = new Github\ResultPager($client);
        $parameters = array('freepbx');
        $repos = $paginator->fetchAll($organizationApi, 'repositories', $parameters);
        $core = array();
        foreach ($repos as $repo) {
            $core[] = $repo['name'];
        }
        $paginator = new Github\ResultPager($client);
        $parameters = array('FreePBX-ContributedModules');
        $repos = $paginator->fetchAll($organizationApi, 'repositories', $parameters);
        $contrib = array();
        foreach ($repos as $repo) {
            $contrib[] = $repo['name'];
        }
        if (in_array($rawname, $core)) {
            $org = "freepbx";
        } elseif (in_array($rawname, $contrib)) {
            $org = "FreePBX-ContributedModules";
        } else {
            exit;
        }
        $repo = $client->api('repo')->update($org, $rawname, array('name' => $rawname, 'description' => "Module of FreePBX (" . trim($name) . ") :: " . trim(strip_tags(str_replace(array("\r", "\n"), '', $description))), 'default_branch' => 'release/13.0', 'homepage' => 'http://www.freepbx.org', "has_issues" => false, "has_wiki" => false, "had_downloads" => false));
        break;
    default:
        freepbx::showHelp('merge.php', $help);
        exit(0);
        break;
}
Example #7
0
                        $repo->commit_author("Updated " . $lang, $authors[0]);
                    } else {
                        freepbx::out('No Changes needed on ' . $lang, 1);
                    }
                } else {
                    freepbx::out('WARNING: Adding ' . $lang . ' for ' . $module . " last authored by " . $authors[0], 1);
                    add_language($lang, $langDirectory, $langRepoPath);
                    copy_po($langpath . "/" . $module . ".po", $langDirectory . "/" . $lang . "/LC_MESSAGES/" . $module . ".po");
                    make_mo($langDirectory . "/" . $lang . "/LC_MESSAGES/" . $module . ".po", $lang, $langRepoPath);
                    $repo->add();
                    $repo->commit_author("Updated " . $lang, $authors[0]);
                }
            }
        }
    } else {
        freepbx::out('WARNING: Module ' . $module . ' is missing. Attempting to checkout');
    }
    $repo->push('origin', 'master');
    $repo->checkout($ab);
}
class languages
{
    public $weblate_repo = null;
    public $module_repo = null;
}
function add_language($lang, $langDirectory)
{
    mkdir($langDirectory . "/" . $lang . "/LC_MESSAGES", 0777, true);
}
function copy_po($src, $target)
{
Example #8
0
 if (is_link($directory)) {
     freepbx::out("Confused. {$directory} is a symbolic link. Please resolve then run this again");
     exit(1);
 }
 if (empty($vars['username'])) {
     $username = freepbx::getInput("FreePBX Username");
 } else {
     $username = $vars['username'];
 }
 if (empty($vars['password'])) {
     $password = freepbx::getPassword("FreePBX Password", true);
 } else {
     $password = $vars['password'];
 }
 try {
     $freepbx = new freepbx($username, $password);
 } catch (Exception $e) {
     freepbx::out("Invalid Username/Password Combination");
     exit(1);
 }
 if (isset($options['keys'])) {
     $pkeys = explode(",", $options['keys']);
 } else {
     $pkeys = array("freepbx");
 }
 $force = isset($options['force']) ? true : false;
 $branch = isset($options['switch']) && !empty($options['switch']) ? $options['switch'] : 'develop';
 foreach ($pkeys as $k) {
     $freepbx->setupDevRepos($directory, $force, $mode, $branch, $k);
 }
 $freepbx->setupSymLinks($directory);
Example #9
0
function update_devtools()
{
    $mypath = __DIR__;
    freepbx::outn("Updating devtools\n\tOpening devtools...");
    //Attempt to open the module as a git repo, bail if it's not a repo
    try {
        $repo = Git::open($mypath);
        freepbx::out("Done");
    } catch (Exception $e) {
        freepbx::out($e->getMessage());
        exit;
    }
    freepbx::outn("\tIm going to update the master branch now...");
    $stashable = $repo->add_stash();
    $repo->fetch();
    try {
        $merged = $repo->pull('origin', 'master');
    } catch (\Exception $e) {
        $merged = false;
    }
    if (!$merged) {
        freepbx::out("\t\t\tMerge from master to this branch failed");
        freepbx::out("Module " . $module . " will not be tagged!");
        exit;
    }
    if ($stashable) {
        $repo->apply_stash();
        $repo->drop_stash();
    }
    freepbx::out("Done. Thanks for using FreePBX!");
}
Example #10
0
                            freepbx::out($e->getMessage());
                            freepbx::out("Module " . $module . " will not be tagged!");
                            continue;
                        }
                        freepbx::out("Done");
                    }
                }
            }
        }
    }
    try {
        $repo->push($vars['remote'], $repo->active_branch());
    } catch (Exception $e) {
        freepbx::out($e->getMessage());
        freepbx::out("Module " . $module . " will not be tagged!");
        continue;
    }
    freepbx::out("Done");
    if (!empty($stash)) {
        freepbx::outn("\tRestoring Uncommited changes...");
        try {
            $repo->apply_stash();
            $repo->drop_stash();
        } catch (Exception $e) {
            freepbx::out("Failed to restore stash!, Please check your directory");
            freepbx::out("Module " . $module . " will not be tagged!");
            continue;
        }
        freepbx::out("Done");
    }
}
Example #11
0
 public static function get_license_from_link($licenseLink)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $licenseLink);
     $licenseText = curl_exec($ch);
     $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     switch ($httpStatusCode) {
         case '200':
             return $licenseText;
             break;
         default:
             freepbx::out("An error occurred trying to get license from " . $licenseLink);
             break;
     }
     return false;
 }