Ejemplo n.º 1
0
 public function run()
 {
     $options = $this->_config->getOptions();
     if (!empty($options['no_tree'])) {
         print Horde_Yaml::dump($this->_config->getComponent()->getDependencies());
     } else {
         $this->_dependencies->listTree($this->_config->getComponent(), $options);
     }
 }
Ejemplo n.º 2
0
 /**
  * Pass the error and environment data on to Hoptoad
  *
  * @package default
  * @author Rich Cavanaugh
  */
 public static function notifyHoptoad($api_key, $message, $file, $line, $trace, $error_class = null)
 {
     $req =& new HTTP_Request("http://hoptoadapp.com/notices/", array("method" => "POST", "timeout" => 2));
     $req->addHeader('Accept', 'text/xml, application/xml');
     $req->addHeader('Content-type', 'application/x-yaml');
     array_unshift($trace, "{$file}:{$line}");
     if (isset($_SESSION)) {
         $session = array('key' => session_id(), 'data' => $_SESSION);
     } else {
         $session = array();
     }
     $url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
     $body = array('api_key' => $api_key, 'error_class' => $error_class, 'error_message' => $message, 'backtrace' => $trace, 'request' => array("params" => $_REQUEST, "url" => $url), 'session' => $session, 'environment' => $_SERVER);
     $req->setBody(Horde_Yaml::dump(array("notice" => $body)));
     $req->sendRequest();
 }
Ejemplo n.º 3
0
 /**
  * Will process the output by serializing in the best way possible based on the request's accept headers.
  * To output as an RSS/Atom feed, a descriptor may be provided to map the array data to the feed's properties
  * and to supply additional information. The descriptor must contain the following keys:
  * [feedTitle] Feed's title, static value
  * [feedDescription] Feed's description, static value
  * [entryTitleKey] Key to lookup for each entry to find the title
  * [entryUrlKey] Key to lookup to find the URL of each entry
  * [entryModificationKey] Key to lookup to find the modification date
  * [entryObjectDescriptors] Optional. Array containing two key names, object key and object type to lookup missing information (url and title)
  */
 function output_serialized($data, $feed_descriptor = null)
 {
     foreach ($this->get_accept_types(!is_null($feed_descriptor)) as $name => $full) {
         switch ($name) {
             case 'json':
                 header("Content-Type: {$full}");
                 $data = json_encode($data);
                 if ($data === false) {
                     $error = '';
                     switch (json_last_error()) {
                         case JSON_ERROR_NONE:
                             $error = 'json_encode - No errors';
                             break;
                         case JSON_ERROR_DEPTH:
                             $error = 'json_encode - Maximum stack depth exceeded';
                             break;
                         case JSON_ERROR_STATE_MISMATCH:
                             $error = 'json_encode - Underflow or the modes mismatch';
                             break;
                         case JSON_ERROR_CTRL_CHAR:
                             $error = 'json_encode - Unexpected control character found';
                             break;
                         case JSON_ERROR_SYNTAX:
                             $error = 'json_encode - Syntax error, malformed JSON';
                             break;
                         case JSON_ERROR_UTF8:
                             $error = 'json_encode - Malformed UTF-8 characters, possibly incorrectly encoded';
                             break;
                         default:
                             $error = 'json_encode - Unknown error';
                             break;
                     }
                     throw new Exception($error);
                 }
                 if (isset($_REQUEST['callback'])) {
                     $data = $_REQUEST['callback'] . '(' . $data . ')';
                 }
                 echo $data;
                 return;
             case 'yaml':
                 header("Content-Type: {$full}");
                 echo Horde_Yaml::dump($data);
                 return;
             case 'rss':
                 $rsslib = TikiLib::lib('rss');
                 $writer = $rsslib->generate_feed_from_data($data, $feed_descriptor);
                 $writer->setFeedLink($this->tikiUrl($_SERVER['REQUEST_URI']), 'rss');
                 header('Content-Type: application/rss+xml');
                 echo $writer->export('rss');
                 return;
             case 'atom':
                 $rsslib = TikiLib::lib('rss');
                 $writer = $rsslib->generate_feed_from_data($data, $feed_descriptor);
                 $writer->setFeedLink($this->tikiUrl($_SERVER['REQUEST_URI']), 'atom');
                 header('Content-Type: application/atom+xml');
                 echo $writer->export('atom');
                 return;
             case 'html':
                 header("Content-Type: {$full}");
                 echo $data;
                 return;
         }
     }
 }
Ejemplo n.º 4
0
 private function _yamlOutput($cli, $id, $output)
 {
     $output = $this->_convertDates($output);
     if (class_exists('Horde_Yaml')) {
         $this->_messageOutput($cli, $id, Horde_Yaml::dump($output));
     } else {
         $this->_messageOutput($cli, $id, print_r($output, true));
     }
 }
Ejemplo n.º 5
0
$assigned_modules_for_export = $modlib->getModulesForExport();
$smarty->assign('modules_for_export', $assigned_modules_for_export);
if (!isset($_REQUEST['export_type'])) {
    $_REQUEST['export_type'] = 'prefs';
}
$smarty->assign('export_type', $_REQUEST['export_type']);
if (isset($_REQUEST['export'])) {
    if ($_REQUEST['export_type'] === 'prefs') {
        $export_yaml = Horde_Yaml::dump(array('preferences' => $_REQUEST['prefs_to_export']), array('indent' => 1, 'wordwrap' => 0));
    } else {
        if ($_REQUEST['export_type'] === 'modules') {
            $modules_to_export = array();
            foreach ($_REQUEST['modules_to_export'] as $k => $v) {
                $modules_to_export[] = $assigned_modules_for_export[$k];
            }
            $export_yaml = Horde_Yaml::dump(array('objects' => $modules_to_export), array('indent' => 1, 'wordwrap' => 0));
        } else {
            $export_yaml = '';
            // something went wrong?
        }
    }
    $export_yaml = preg_replace('/^---\\n/', '', $export_yaml);
    $export_yaml = "{CODE(caption=>YAML,wrap=>0)}\n" . $export_yaml . "{CODE}\n";
    include_once 'lib/wiki-plugins/wikiplugin_code.php';
    $export_yaml = wikiplugin_code($export_yaml, array('caption' => 'Wiki markup', 'colors' => 'tiki'), null, array());
    $export_yaml = preg_replace('/~[\\/]?np~/', '', $export_yaml);
    $smarty->assign('export_yaml', $export_yaml);
    $smarty->assign('prefs_to_export', $_REQUEST['prefs_to_export']);
    $smarty->assign('modules_to_export', $_REQUEST['modules_to_export']);
}
ask_ticket('admin-inc-profiles');
Ejemplo n.º 6
0
 /**
  * Will process the output by serializing in the best way possible based on the request's accept headers.
  * To output as an RSS/Atom feed, a descriptor may be provided to map the array data to the feed's properties
  * and to supply additional information. The descriptor must contain the following keys:
  * [feedTitle] Feed's title, static value
  * [feedDescription] Feed's description, static value
  * [entryTitleKey] Key to lookup for each entry to find the title
  * [entryUrlKey] Key to lookup to find the URL of each entry
  * [entryModificationKey] Key to lookup to find the modification date
  * [entryObjectDescriptors] Optional. Array containing two key names, object key and object type to lookup missing information (url and title)
  */
 function output_serialized($data, $feed_descriptor = null)
 {
     foreach ($this->get_accept_types(!is_null($feed_descriptor)) as $name => $full) {
         switch ($name) {
             case 'json':
                 header("Content-Type: {$full}");
                 $data = json_encode($data);
                 if (isset($_REQUEST['callback'])) {
                     $data = $_REQUEST['callback'] . '(' . $data . ')';
                 }
                 echo $data;
                 return;
             case 'yaml':
                 header("Content-Type: {$full}");
                 echo Horde_Yaml::dump($data);
                 return;
             case 'rss':
                 $rsslib = TikiLib::lib('rss');
                 $writer = $rsslib->generate_feed_from_data($data, $feed_descriptor);
                 $writer->setFeedLink($this->tikiUrl($_SERVER['REQUEST_URI']), 'rss');
                 header('Content-Type: application/rss+xml');
                 echo $writer->export('rss');
                 return;
             case 'atom':
                 $rsslib = TikiLib::lib('rss');
                 $writer = $rsslib->generate_feed_from_data($data, $feed_descriptor);
                 $writer->setFeedLink($this->tikiUrl($_SERVER['REQUEST_URI']), 'atom');
                 header('Content-Type: application/atom+xml');
                 echo $writer->export('atom');
                 return;
             case 'html':
                 header("Content-Type: {$full}");
                 echo $data;
                 return;
         }
     }
 }
Ejemplo n.º 7
0
 public function testNumericStrings()
 {
     $value = array('foo' => '73,123');
     $this->assertSame($value, Horde_Yaml::load(Horde_Yaml::dump($value)));
 }
Ejemplo n.º 8
0
 /**
  * Run the module.
  *
  * @param Horde_Cli $cli       The CLI handler.
  * @param mixed     $options   An array of options.
  * @param mixed     $arguments An array of arguments.
  * @param array     &$world    A list of initialized dependencies.
  *
  * @return NULL
  */
 public function run($cli, $options, $arguments, &$world)
 {
     if (!isset($arguments[1])) {
         $action = 'read';
     } else {
         $action = $arguments[1];
     }
     switch ($action) {
         case 'read':
             $parser = $world['format']->create('Xml', $arguments[2]);
             if (empty($arguments[4])) {
                 if (file_exists($arguments[3])) {
                     $contents = file_get_contents($arguments[3]);
                     $data = $parser->load($contents);
                     $id = $arguments[3];
                 } else {
                     $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('%s is no local file!'), $arguments[3]), 'cli.error');
                 }
             } else {
                 $ks_data = $world['storage']->getData($arguments[3]);
                 $part = $ks_data->fetchPart($arguments[4], $arguments[5]);
                 rewind($part);
                 $xml = quoted_printable_decode(stream_get_contents($part));
                 $data = $parser->load($xml);
                 $id = $arguments[3] . ':' . $arguments[4] . '[' . $arguments[5] . ']';
             }
             if (class_exists('Horde_Yaml')) {
                 $this->_formatOutput($cli, $id, Horde_Yaml::dump($data));
             } else {
                 $this->_formatOutput($cli, $id, print_r($data, true));
             }
             break;
         default:
             $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('Action %s not supported!'), $action), 'cli.error');
             break;
     }
 }
Ejemplo n.º 9
0
 /**
  *  Given a php structure, returns a valid YAML string representation.
  *
  *  @param mixed PHP data
  *  @return string YAML equivalent.
  */
 public static function dump($phpData)
 {
     if (function_exists('yaml_emit')) {
         return yaml_emit($phpData);
     } else {
         if (function_exists('syck_dump')) {
             // php-lib-c version, much faster!
             return syck_dump($phpData);
         } else {
             // php version
             return Horde_Yaml::dump($phpData);
         }
     }
 }
Ejemplo n.º 10
0
$openSources = 0;
foreach ($sources as $key => $source) {
    if ($source['status'] == 'open') {
        $openSources++;
    }
}
if ($openSources == count($sources)) {
    $smarty->assign('openSources', 'all');
} elseif ($openSources > 0 && $openSources < count($sources)) {
    $smarty->assign('openSources', 'some');
} else {
    $smarty->assign('openSources', 'none');
}
$smarty->assign('tikiMajorVersion', substr($TWV->version, 0, 2));
$modified = $prefslib->getModifiedPrefsForExport(!empty($_REQUEST['export_show_added']) ? true : false);
$smarty->assign('modified_list', $modified);
if (!isset($_REQUEST['export_type'])) {
    $_REQUEST['export_type'] = 'prefs';
}
$smarty->assign('export_type', $_REQUEST['export_type']);
if (isset($_REQUEST['export']) && $_REQUEST['export_type'] === 'prefs') {
    $export_yaml = Horde_Yaml::dump(array('preferences' => $_REQUEST['prefs_to_export']), array('indent' => 1, 'wordwrap' => 0));
    $export_yaml = preg_replace('/^---\\n/', '', $export_yaml);
    $export_yaml = "{CODE(caption=>YAML,wrap=>0)}\n" . $export_yaml . "{CODE}\n";
    include_once 'lib/wiki-plugins/wikiplugin_code.php';
    $export_yaml = wikiplugin_code($export_yaml, array('caption' => 'Wiki markup', 'colors' => 'tikiwiki'));
    $export_yaml = preg_replace('/~[\\/]?np~/', '', $export_yaml);
    $smarty->assign('export_yaml', $export_yaml);
    $smarty->assign('prefs_to_export', $_REQUEST['prefs_to_export']);
}
ask_ticket('admin-inc-profiles');
Ejemplo n.º 11
0
 public function saveMenuAction($account, $menu, $digit, $action, $args)
 {
     $this->deleteMenuAction($account, $menu, $digit);
     $sql = 'INSERT INTO menu_entries (menu_id, digit, action_id, args) ' . 'VALUES((SELECT id FROM menus WHERE account_id = ' . '(SELECT id FROM accounts WHERE code = ?) AND name = ?), ?, ' . '(SELECT id FROM actions WHERE name = ?), ?)';
     $yamlargs = Horde_Yaml::dump($args);
     $values = array($account, $menu, $digit, $action, $yamlargs);
     $msg = 'SQL query in Shout_Driver_Sql#saveMenuAction(): ' . $sql;
     Horde::log($msg, 'DEBUG');
     $result = $this->_write_db->query($sql, $values);
     if ($result instanceof PEAR_Error) {
         throw new Shout_Exception($result);
     }
     return true;
 }
Ejemplo n.º 12
0
    }
    if (!empty($_REQUEST['themes_layouts'])) {
        $pkg = $_REQUEST['themes_layouts'];
        $yaml .= YamlConfig::getThemesLayout($pkg);
    }
    if (!empty($_REQUEST['users_permissions'])) {
        $pkg = $_REQUEST['users_permissions'];
        $yaml .= YamlConfig::getUsersPermissions($pkg);
    }
    $gBitSmarty->assign('yaml', $yaml);
}
if (!empty($_REQUEST['submit_upload'])) {
    $gBitUser->verifyTicket();
    if (YamlConfig::processUploadFile($_REQUEST)) {
        // display log as valid yaml too - how sweet is that?
        $gBitSmarty->assign("config_log", Horde_Yaml::dump($_REQUEST['config_log']));
    }
}
// get data for forms
$activePackages = array('all' => 'ALL');
foreach ($gBitSystem->mPackages as $pkgname => $data) {
    if ($data['active_switch']) {
        $activePackages[$pkgname] = $pkgname;
    }
}
ksort($activePackages);
array_unshift($activePackages, 'None');
// requests NULL
$gBitSmarty->assign_by_ref('activePackages', $activePackages);
$layouts = array('all' => 'ALL');
foreach ($gBitThemes->getAllLayouts() as $package => $modules) {
Ejemplo n.º 13
0
 /**
  * Undocumented command that dumps all tasks in YAML format.  This is used
  * by the Rake file to allow tasks to optionally be run through Rake.
  */
 public function dumpYaml()
 {
     echo Horde_Yaml::dump($this->getTasks());
 }
Ejemplo n.º 14
0
<?php

/**
 * @package Yaml
 */
require_once dirname(dirname(__DIR__)) . '/Yaml/__autoload.php';
$array[] = 'Sequence item';
$array['The Key'] = 'Mapped value';
$array[] = array('A sequence', 'of a sequence');
$array[] = array('first' => 'A sequence', 'second' => 'of mapped values');
$array['Mapped'] = array('A sequence', 'which is mapped');
$array['A Note'] = 'What if your text is too long?';
$array['Another Note'] = 'If that is the case, the dumper will probably fold your text by using a block.  Kinda like this.';
$array['The trick?'] = 'The trick is that we overrode the default indent, 2, to 4 and the default wordwrap, 40, to 60.';
$array['Old Dog'] = "And if you want\n to preserve line breaks, \ngo ahead!";
echo "A PHP array run through Horde_Yaml::dump():\n";
var_dump(Horde_Yaml::dump($array, 4, 60));
Ejemplo n.º 15
0
<?php

require_once 'Horde/Autoloader/Default.php';
$g = new Horde_Service_Gravatar();
print Horde_Yaml::dump($g->getProfile('*****@*****.**'));
Ejemplo n.º 16
0
 public function formatYaml($yaml)
 {
     return Horde_Yaml::dump($yaml);
 }
Ejemplo n.º 17
0
    function getContent()
    {
        $builder = clone $this;
        foreach (array_keys($this->groups) as $group) {
            foreach (array_keys($this->groups) as $peer) {
                if ($group == $this->managingGroup) {
                    $builder->setPermissions($group, 'group', $peer, array('group_view', 'group_view_members', 'group_add_member', 'group_remove_member'));
                } else {
                    $builder->setPermissions($group, 'group', $peer, array('group_view', 'group_view_members'));
                }
            }
        }
        $data = array();
        if (count($builder->objects)) {
            $data['objects'] = $builder->objects;
        }
        if ($builder->groups) {
            $data['mappings'] = array();
            $data['permissions'] = array();
            foreach ($builder->groups as $internal => $full) {
                $groupDefinition = array('description' => $full);
                if ($this->autojoin[$internal]) {
                    $groupDefinition['autojoin'] = 'y';
                }
                if (isset($builder->permissions[$internal])) {
                    $groupDefinition['objects'] = $builder->permissions[$internal]['objects'];
                }
                $data['mappings'][$internal] = $full;
                $data['permissions'][$internal] = $groupDefinition;
            }
        }
        $self = $this;
        array_walk_recursive($data, function (&$entry) use($self) {
            if (is_string($entry)) {
                $entry = preg_replace_callback('/\\{(\\w+)\\}/', function ($matches) use($self) {
                    return $self->user($matches[1]);
                }, $entry);
            }
        });
        $yaml = Horde_Yaml::dump($data);
        return <<<SYNTAX

^The following profile was auto-generated. It may hurt your eyes when you try reading it.^
{CODE(caption="YAML")}
{$yaml}
{CODE}

SYNTAX;
    }
Ejemplo n.º 18
0
 function dump()
 {
     $clone = clone $this;
     $clone->clean();
     return Horde_Yaml::dump($clone->data);
 }
Ejemplo n.º 19
0
 public static function getUsersPermissions($pPackage)
 {
     global $gBitSystem, $gBitUser;
     // get a list of all groups and their users_permissions
     $data = array('users_permissions' => array());
     $listHash = array('only_root_groups' => TRUE, 'sort_mode' => !empty($_REQUEST['sort_mode']) ? $_REQUEST['sort_mode'] : 'group_name_asc');
     if (!empty($pPackage) && strtoupper($pPackage) != 'ALL') {
         $packages = array($pPackage);
     } else {
         $packages = array_keys($gBitSystem->mPackages);
     }
     $allPerms = $gBitUser->getGroupPermissions();
     $allGroups = $gBitUser->getAllGroups($listHash);
     foreach ($allPerms as $perm => $params) {
         if (in_array($params['package'], $packages)) {
             $data['users_permissions'][$perm] = array('description' => $params['perm_desc'], 'groups' => array());
             foreach ($allGroups as $group) {
                 if (in_array($perm, array_keys($group['perms']))) {
                     $data['users_permissions'][$perm]['groups'][] = $group['group_id'];
                 }
             }
         }
     }
     $ret = Horde_Yaml::dump($data);
     return $ret;
 }