public function test() { eval('function hook_tokens($type, $tokens, array $data = array(), array $options = array()) {}'); $config = ['hook' => 'tokens', 'module' => 'system']; $module_handler = $this->getMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface'); $plugin = new ImplementHook($config, uniqID(), [], $module_handler); $plugin->setTarget($this->target); $plugin->execute(); $module = $this->target->getPath('.module'); $function = $this->target->open($module)->children(Filter::isFunction('foo_tokens'))->get(0); $this->assertInstanceOf('\\Pharborist\\Functions\\FunctionDeclarationNode', $function); $this->assertEquals('foo_tokens', $function->getName()->getText()); $parameters = $function->getParameters(); $this->assertCount(4, $parameters); $this->assertNull($parameters[0]->getTypeHint()); $this->assertEquals('type', $parameters[0]->getName()); $this->assertNull($parameters[0]->getValue()); $this->assertNull($parameters[1]->getTypeHint()); $this->assertEquals('tokens', $parameters[1]->getName()); $this->assertNull($parameters[1]->getValue()); $this->assertInstanceOf('\\Pharborist\\TokenNode', $parameters[2]->getTypeHint()); $this->assertSame(T_ARRAY, $parameters[2]->getTypeHint()->getType()); $this->assertEquals('data', $parameters[2]->getName()); $this->assertInstanceOf('\\Pharborist\\Types\\ArrayNode', $parameters[2]->getValue()); $this->assertInstanceOf('\\Pharborist\\TokenNode', $parameters[3]->getTypeHint()); $this->assertSame(T_ARRAY, $parameters[3]->getTypeHint()->getType()); $this->assertEquals('options', $parameters[3]->getName()); $this->assertInstanceOf('\\Pharborist\\Types\\ArrayNode', $parameters[3]->getValue()); }
public function test() { $indexer = new Classes([], 'class', [], $this->db, $this->target); $indexer->build(); $this->container->get('plugin.manager.drupalmoduleupgrader.indexer')->method('createInstance')->with('class')->willReturn($indexer); $config = ['class' => '\\Drupal\\foo\\MyBaz', 'destination' => '~/src/MyBaz.php', 'parent' => '\\Drupal\\Core\\Baz\\BazBase', 'interfaces' => ['\\Drupal\\Core\\Baz\\BazInterface', '\\Drupal\\Core\\Executable\\ExecutableInterface'], 'doc' => 'This is my bazzifier. There are many like it, but this one is mine.']; $plugin = new CreateClass($config, uniqID(), []); $plugin->setTarget($this->target); $plugin->execute(); $this->assertTrue($indexer->has('MyBaz')); $classes = $indexer->get('MyBaz'); $this->assertCount(1, $classes); /** @var \Pharborist\Objects\ClassNode $class */ $class = $classes->get(0); $this->assertInstanceOf('\\Pharborist\\Objects\\ClassNode', $class); $this->assertEquals('\\Drupal\\foo\\MyBaz', $class->getName()->getAbsolutePath()); $this->assertEquals('MyBaz', $class->getName()->getText()); $parent = $class->getExtends(); $this->assertInstanceOf('\\Pharborist\\Namespaces\\NameNode', $parent); $this->assertEquals('BazBase', $parent->getText()); return; $interfaces = $class->getImplementList(); $this->assertCount(2, $interfaces->getItems()); $this->assertEquals('BazInterface', $interfaces->get(0)->getText()); $this->assertEquals('ExecutableInterface', $interfaces->get(1)->getText()); }
public function test() { $class = ClassNode::create('Foobaz'); $indexer = $this->getMock('\\Drupal\\drupalmoduleupgrader\\IndexerInterface'); $indexer->method('get')->with('Foobaz')->willReturn(new NodeCollection([$class])); $this->container->get('plugin.manager.drupalmoduleupgrader.indexer')->method('createInstance')->with('class')->willReturn($indexer); $config = ['definition' => '\\Drupal\\Core\\Block\\BlockPluginInterface::blockForm', 'target' => 'Foobaz']; $plugin = new Implement($config, uniqID(), []); $plugin->setTarget($this->target); try { // We expect a CodeManagerIOException because we're implementing the // method on a class that is not officially part of the target's code. // That's OK, though. $plugin->execute(); } catch (IOException $e) { } $this->assertTrue($class->hasMethod('blockForm')); $method = $class->getMethod('blockForm'); $this->assertInstanceOf('\\Pharborist\\Objects\\ClassMethodNode', $method); $parameters = $method->getParameters(); $this->assertCount(2, $parameters); $this->assertEquals($parameters[0]->getName(), 'form'); $this->assertNull($parameters[0]->getTypeHint()); $this->assertEquals($parameters[1]->getName(), 'form_state'); $type = $parameters[1]->getTypeHint(); $this->assertInstanceOf('\\Pharborist\\Namespaces\\NameNode', $type); $this->assertEquals('Drupal\\Core\\Form\\FormStateInterface', $type->getText()); }
public function __construct() { parent::__construct(); $this->abonnements = new \Doctrine\Common\Collections\ArrayCollection(); $this->favorites = new \Doctrine\Common\Collections\ArrayCollection(); $this->playlists = new \Doctrine\Common\Collections\ArrayCollection(); $this->comments = new \Doctrine\Common\Collections\ArrayCollection(); $this->uniqID = uniqID(); }
public function test() { $class = ClassNode::create('Wambooli'); $indexer = $this->getMock('\\Drupal\\drupalmoduleupgrader\\IndexerInterface'); $indexer->method('get')->with('Wambooli')->willReturn(new NodeCollection([$class])); $this->container->get('plugin.manager.drupalmoduleupgrader.indexer')->method('createInstance')->with('class')->willReturn($indexer); $config = ['source' => 'Wambooli', 'destination' => 'Drupal\\foo\\Wambooli']; $plugin = new PSR4($config, uniqID(), []); $plugin->setTarget($this->target); $plugin->execute(); $url = $this->target->getPath('src/Wambooli.php'); $this->assertFileExists($url); }
public function test() { $config = ['key' => 'foo.settings/baz', 'value' => 'wambooli', 'in' => '~/foo.settings.yml']; $plugin = new Define($config, uniqID(), []); $plugin->setTarget($this->target); $plugin->execute(); $url = $this->dir->getChild('foo.settings.yml')->url(); $this->assertFileExists($url); $expected = <<<END foo.settings: baz: wambooli END; $this->assertEquals($expected, file_get_contents($url)); }
public function test() { $permissions = ['bazify' => ['title' => 'Do snazzy bazzy things']]; $indexer = $this->getMockBuilder('\\Drupal\\drupalmoduleupgrader\\Plugin\\DMU\\Indexer\\Functions')->disableOriginalConstructor()->getMock(); $indexer->method('has')->with('hook_permission')->willReturn(TRUE); $indexer->method('hasExecutable')->with('hook_permission')->willReturn(TRUE); $indexer->method('execute')->with('hook_permission')->willReturn($permissions); $this->container->get('plugin.manager.drupalmoduleupgrader.indexer')->method('createInstance')->with('function')->willReturn($indexer); $config = ['hook' => 'permission', 'destination' => '~/foo.permissions.yml']; $plugin = new HookToYAML($config, uniqID(), []); $plugin->setTarget($this->target); $plugin->execute(); $url = $this->dir->getChild('foo.permissions.yml')->url(); $this->assertFileExists($url); $this->assertSame(YAML::encode($permissions), file_get_contents($url)); }
public function queueObject($object) { global $redis; $wrapped = serialize($object); $allQueues = new RedisTtlSortedSet('redisQ:allQueues'); $objectQueues = new RedisTtlSortedSet('objectQueues'); $queues = $allQueues->getMembers(); $multi = $redis->multi(); // Store an instance of the object $objectID = 'redisQ:objectID:' . uniqID() . md5($wrapped); $objectQueues->add(time(), $objectID); $multi->setex($objectID, 9600, $wrapped); // Add objectID to all queues foreach ($queues as $queueID) { $multi->lPush($queueID, $objectID); $multi->expire($queueID, 9600); } $multi->exec(); }
/** * Smarty {html_tabs} function plugin * * Type: function<br> * Name: html_tabs<br> * Date: Jun 6, 2004<br> * Purpose: return tabs<br> * Input:<br> * - tabs = array of tab objects (required) * - path = path to pages (optional, default "") * - selected = selected tab (optional, default actual page) * - no_select = no tab is selected (optional, default false) * - anchor_extra_html = extra html into <A> tags (optional , default '') * - div_id = ID attr of main div element (optional, default "swTabs") * - div_class = CLASS attr of main div element (optional, default none) * * Examples: {html_tabs tabs=$tabs} * @author Karel Kozlik <*****@*****.**> * @version 1.0 * @param array * @param Smarty * @return string */ function smarty_function_html_tabs($params, &$smarty) { global $sess, $_SERVER; $path = ''; $selected = NULL; $no_select = false; $anchor_extra_html = ''; $div_class = ''; extract($params); if (empty($tabs)) { $smarty->trigger_error("html_tabs: missing 'tabs' parameter", E_USER_NOTICE); return; } if (!$selected) { $selected = basename($_SERVER['SCRIPT_FILENAME']); } if (!isset($div_id)) { $div_id = "swTabs"; } $out = '<div '; if ($div_id) { $out .= 'id="' . $div_id . '" '; } if ($div_class) { $out .= 'class="' . $div_class . '" '; } $out .= '><ul>'; foreach ($tabs as $i => $value) { if ($value->is_enabled()) { if ($value->get_page() == $selected and !$no_select) { $out .= '<li class="swActiveTab"><div class="swTabsL"></div><strong><span>' . $value->get_name() . '</span></strong><div class="swTabsR"></div></li>'; } else { $separator = strpos($path . $value->get_page(), "?") ? "&" : "?"; $out .= '<li><div class="swTabsL"></div><a href="' . htmlspecialchars($sess->url($path . $value->get_page() . $separator . "kvrk=" . uniqID("")), ENT_QUOTES) . '" ' . $anchor_extra_html . ' class="tabl"><span>' . $value->get_name() . '</span></a><div class="swTabsR"></div></li>'; } //if ($value->get_page()==$selected) } // if ($value->is_enabled()) } //foreach $out .= '</ul></div>'; return $out; }
function action_default(&$errors) { global $data, $sess, $sess_ms_act_row; $this->controler->set_timezone(); $data->set_act_row($sess_ms_act_row); if (false === ($this->im = $data->get_IMs($this->user_id->get_uid()))) { return false; } $this->pager['url'] = $_SERVER['PHP_SELF'] . "?kvrk=" . uniqid("") . "&act_row="; $this->pager['pos'] = $data->get_act_row(); $this->pager['items'] = $data->get_num_rows(); $this->pager['limit'] = $data->get_showed_rows(); $this->pager['from'] = $data->get_res_from(); $this->pager['to'] = $data->get_res_to(); foreach ($this->im as $k => $v) { $this->im[$k]['url_reply'] = $sess->url($this->opt['im_sending_script'] . "?kvrk=" . uniqid("") . "&im_sip_addr=" . rawURLEncode($v['raw_src_addr'])); $this->im[$k]['url_dele'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&im_dele_id=" . rawURLEncode($v['mid'])); } return true; }
public function testDocComment() { $class = ClassNode::create('Wambooli'); $class->setDocComment(DocCommentNode::create('Double wambooli!')); $this->assertInstanceOf('\\Pharborist\\DocCommentNode', $class->getDocComment()); $indexer = $this->getMock('\\Drupal\\drupalmoduleupgrader\\IndexerInterface'); $indexer->method('get')->with('Wambooli')->willReturn(new NodeCollection([$class])); $this->container->get('plugin.manager.drupalmoduleupgrader.indexer')->method('createInstance')->with('class')->willReturn($indexer); $config = ['type' => 'class', 'id' => 'Wambooli', 'note' => 'You need to rewrite this thing because I said so!']; $plugin = new Notify($config, uniqID(), []); $plugin->setTarget($this->target); $plugin->execute(); $comment = $class->getDocComment(); $this->assertInstanceOf('\\Pharborist\\DocCommentNode', $comment); $expected = <<<END Double wambooli! You need to rewrite this thing because I said so! END; $this->assertEquals($expected, $comment->getCommentText()); }
public function test() { $callback = Parser::parseSnippet('function foo_submit(&$form, &$form_state) {}'); $function_indexer = $this->getMock('\\Drupal\\drupalmoduleupgrader\\IndexerInterface'); $function_indexer->method('get')->with('foo_submit')->willReturn(new NodeCollection([$callback])); $class = ClassNode::create('FooForm'); $class_indexer = $this->getMock('\\Drupal\\drupalmoduleupgrader\\IndexerInterface'); $class_indexer->method('get')->with('FooForm')->willReturn(new NodeCollection([$class])); $this->container->get('plugin.manager.drupalmoduleupgrader.indexer')->method('createInstance')->willReturnCallback(function ($which) use($class_indexer, $function_indexer) { switch ($which) { case 'class': return $class_indexer; case 'function': return $function_indexer; default: break; } }); $config = ['callback' => 'foo_submit', 'destination' => 'FooForm::submitForm']; $plugin = new FormCallbackToMethod($config, uniqID(), []); $plugin->setTarget($this->target); try { // We expect a CodeManagerIOException because we're implementing the // method on a class that is not officially part of the target's code. // That's OK, though. $plugin->execute(); } catch (IOException $e) { } $this->assertTrue($class->hasMethod('submitForm')); $parameters = $class->getMethod('submitForm')->getParameters(); $this->assertCount(2, $parameters); $this->assertEquals('form', $parameters[0]->getName()); $this->assertInstanceOf('\\Pharborist\\TokenNode', $parameters[0]->getTypeHint()); $this->assertSame(T_ARRAY, $parameters[0]->getTypeHint()->getType()); $this->assertInstanceOf('\\Pharborist\\TokenNode', $parameters[0]->getReference()); $this->assertEquals('form_state', $parameters[1]->getName()); $this->assertInstanceOf('\\Pharborist\\Namespaces\\NameNode', $parameters[1]->getTypeHint()); $this->assertEquals('Drupal\\Core\\Form\\FormStateInterface', $parameters[1]->getTypeHint()->getText()); $this->assertNull($parameters[1]->getReference()); }
public function test() { $code = <<<'END' <?php variable_get('foo'); END; $this->dir->getChild('foo.module')->setContent(rtrim($code)); $indexer = new FunctionCalls([], 'function', ['exclude' => []], $this->db, $this->target); $indexer->build(); $this->container->get('plugin.manager.drupalmoduleupgrader.indexer')->method('createInstance')->with('function_call')->willReturn($indexer); $config = ['type' => 'function_call', 'id' => 'variable_get', 'note' => 'This is no longer kosher!']; $plugin = new Disable($config, uniqID(), []); $plugin->setTarget($this->target); $plugin->execute(); $expected = <<<END <?php // This is no longer kosher! // variable_get('foo'); END; // trim() makes the test pass. Go figure. $this->assertEquals($expected, trim($this->dir->getChild('foo.module')->getContent())); }
/** * assign variables to smarty */ function pass_values_to_html() { global $smarty, $sess; $sort_urls = array(); $get_params = implode("&", $this->get_params); if ($get_params) { $get_params = "&" . $get_params; } foreach ($this->sort_columns as $v) { $sort_urls[$v] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&u_sort_" . $v . "=1" . $get_params); $smarty->assign_by_ref($this->opt['smarty_vars'] . "_" . $v, $sort_urls[$v]); } $smarty->assign_by_ref($this->opt['smarty_vars'], $sort_urls); $smarty->assign($this->opt['smarty_order'], $this->get_sort_col()); $smarty->assign($this->opt['smarty_dir'], $this->get_sort_dir()); }
function get_domains(&$errors) { global $data, $sess; $filter = array(); if (is_a($this->filter, "apu_base_class")) { $filter = $this->filter->get_filter(); // $data->set_act_row($this->filter->get_act_row()); } $opt = array(); if (false === ($this->assigned_ids = $data->get_domains_of_admin($this->controler->user_id->get_uid(), $opt))) { return false; } $opt = array("filter" => $filter, "return_all" => true, "get_domain_names" => true); if (false === ($domains = $data->get_domains($opt, $errors))) { return false; } $this->assigned_domains = array(); $this->unassigned_domains = array(); foreach ($domains as $k => $v) { if ($v['id'] == '0') { continue; } //skip default domain if (in_array($v['id'], $this->assigned_ids)) { $domains[$k]['url_unassign'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&da_unassign=1&" . $this->controler->domain_to_get_param($v['id'])); $this->assigned_domains[] =& $domains[$k]; } else { $domains[$k]['url_assign'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&da_assign=1&" . $this->controler->domain_to_get_param($v['id'])); $this->unassigned_domains[] =& $domains[$k]; } } return true; }
<?php /** * Logout * * @author Karel Kozlik * @version $Id: logout.php,v 1.3 2007/02/14 16:36:40 kozlik Exp $ * @package serweb * @subpackage user_pages */ $_phplib_page_open = array("sess" => "phplib_Session"); /** include all others necessary files */ require "prepend.php"; $_SESSION['auth']->logout(); if (isset($sess_admin) and $sess_admin) { //when admins logged out from user's "my_account page" $sess->unregister("sess_admin"); Header("Location: " . $sess->url($config->admin_pages_path . "index.php?kvrk=" . uniqID("") . "&logout=1")); } else { Header("Location: " . $sess->url("index.php?kvrk=" . uniqID("") . "&logout=1")); } $sess->delete(); page_close();
function print_tabs($tabs, $path="", $selected=null){ global $config, $sess, $PATH_TRANSLATED; if (!$selected){ $selected=basename($PATH_TRANSLATED); } ?> <div id="swTabs"> <ul> <? foreach($tabs as $i => $value){ if ($value->enabled){ if ($value->page==$selected){?> <li id="swActiveTab"><div class="swTabsL"></div><strong><?echo $value->name;?></strong><div class="swTabsR"></div></li> <? } else{?> <li><div class="swTabsL"></div><a href="<?$sess->purl($path.$value->page."?kvrk=".uniqID(""));?>" class="tabl"><?echo $value->name;?></a><div class="swTabsR"></div></li> <? }//if ($value->page==$selected) }// if ($value->enabled) } //foreach ?> </ul> </div> <? } //end function print_tabs
/** * assign variables to smarty */ function pass_values_to_html() { global $smarty, $sess; $smarty->assign_by_ref($this->opt['smarty_action'], $this->smarty_action); $smarty->assign_by_ref($this->opt['smarty_pager'], $this->pager); $smarty->assign_by_ref($this->opt['smarty_domains'], $this->domains); $smarty->assign($this->opt['smarty_url_new_domain'], $sess->url($this->opt['script_create'] . "?kvrk=" . uniqID("") . "&new=1")); }
function pass_values_to_html() { global $smarty, $sess; if (!$this->acc_res) { $this->acc_res = array(); } $smarty->assign_by_ref($this->opt['smarty_pager'], $this->pager); $smarty->assign_by_ref($this->opt['smarty_result'], $this->acc_res); $smarty->assign($this->opt['smarty_url_delete'], $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&acc_delete=" . RawURLEncode($this->opt['instance_id']) . "×tamp=" . time())); $smarty->assign($this->opt['smarty_url_cvs_export'], $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&acc_export=" . RawURLEncode($this->opt['instance_id']))); }
/** * perform action edit layout file * * @param array $errors array with error messages * @return array return array of $_GET params fo redirect or FALSE on failure */ function action_edit_layout_file(&$errors) { global $sess; $this->smarty_action = "edit_layout"; $this->url_back_to_default = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&back_to_default_layout=1&filename=" . RawURLEncode($this->filename)); return true; }
function get_usrloc(&$errors) { global $data, $sess; if (false === ($this->usrloc = $data->get_usrloc($this->user_id->get_uid(), $errors))) { return false; } foreach ($this->usrloc as $key => $val) { $this->usrloc[$key]['url_dele'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&ul_dele_id=" . rawURLEncode($val['uri'])); // $this->usrloc[$key]['url_edit'] = $sess->url($_SERVER['PHP_SELF']."?kvrk=".uniqID("")."&ul_edit_id=".rawURLEncode($val['uri'])); } return true; }
/** * Method obtain a list of admins of domain and store it into * variable $this->admins * * @param array $errors array with error messages * @return bool return TRUE on success, FALSE on failure */ function get_admins(&$errors) { global $data, $sess, $config; $an =& $config->attr_names; if (!isset($this->domain_attrs[$an['admin']])) { $admins = array(); } else { $admins = $this->domain_attrs[$an['admin']]; } if (!count($admins)) { $this->admins = array(); return true; } $o = array("only_users" => $admins, "get_user_aliases" => false, "return_all" => true); if (false === ($this->admins = $data->get_users(array(), $o))) { return false; } foreach ($this->admins as $k => $v) { $this->admins[$k]['url_unset_admin'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&do_unset_admin=" . RawURLEncode($this->opt['instance_id']) . "&" . $v['get_param']); } return true; }
/** * Do a reload of current page * * This function send header "Location" and finish execution of script * * @param array $get_param array of GET parameters send in the URL * @return none this function finish execution of script */ function reload($get_param) { global $sess; /* collect all get params to one string */ $get_param = implode('&', array_merge($this->global_get_params_to_str_array(), $get_param)); /* send header */ if (!$this->url_for_reload) { $this->url_for_reload = $_SERVER['PHP_SELF']; } $param_separator = strpos($this->url_for_reload, "?") !== false ? "&" : "?"; $url = $this->url_for_reload . $param_separator . "kvrk=" . uniqID("") . ($get_param ? '&' . $get_param : ''); if ($sess instanceof Session) { Header("Location: " . $sess->url($url)); } else { Header("Location: " . $url); } /* break the script execution */ page_close(); exit; }
/** * assign variables to smarty */ function pass_values_to_html() { global $smarty, $sess; $smarty->assign_by_ref($this->opt['smarty_action'], $this->smarty_action); $smarty->assign_by_ref($this->opt['smarty_attrs'], $this->smarty_attrs); $smarty->assign_by_ref($this->opt['smarty_groups'], $this->attr_groups); $smarty->assign_by_ref($this->opt['smarty_pager'], $this->pager); $smarty->assign($this->opt['smarty_show_groups'], empty($this->session['hide_groups'])); $smarty->assign_by_ref($this->opt['smarty_url_toggle_groups'], $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&toggle_grp=1")); $smarty->assign_by_ref($this->opt['smarty_url_export_sql'], $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&export=sql")); $smarty->assign_by_ref($this->opt['smarty_url_export_xml'], $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&export=xml")); }
} else { $msg = "Could not login"; break; } $log->log( " register session variables phplib_id = $phplib_id "); $sess->register('pre_uid'); $sess->register('uname'); $sess->register('udomain'); $sess->register("adomain"); $pre_uid=$phplib_id; $udomain=$temp_udomain; $adomain=$temp_udomain; $log->log( "session adomain = $adomain"); $uname=$_POST['uname']; Header("Location: ".$sess->url("user.php?kvrk=".uniqID(""))); page_close(); exit; } } while (false); $opts = $data->get_domain_options(null,null); $udomain_values = $opts[0]; $udomain_output = $opts[1]; $smarty->assign("udomain_values", $udomain_values); $smarty->assign("udomain_output", $udomain_output);
public function testHas() { $this->assertTrue($this->indexer->has($this->info['class']['expectID'][0])); $this->assertFalse($this->indexer->has(uniqID())); }
function process($tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace) { switch ($functionName) { case $this->TimingPointName: $children = $functionChildren; $parameters = $functionParameters; $id = false; if (isset($parameters["id"])) { $id = $tpl->elementValue($parameters["id"], $rootNamespace, $currentNamespace, $functionPlacement); } $startDescription = "debug-timing-point START: {$id}"; eZDebug::addTimingPoint($startDescription); if (is_array($children)) { foreach (array_keys($children) as $childKey) { $child =& $children[$childKey]; $tpl->processNode($child, $textElements, $rootNamespace, $currentNamespace); } } $endDescription = "debug-timing-point END: {$id}"; eZDebug::addTimingPoint($endDescription); break; case $this->AccumulatorName: $children = $functionChildren; $parameters = $functionParameters; $id = false; if (isset($parameters["id"])) { $id = $tpl->elementValue($parameters["id"], $rootNamespace, $currentNamespace, $functionPlacement); } $name = false; if (isset($parameters["name"])) { $name = $tpl->elementValue($parameters["name"], $rootNamespace, $currentNamespace, $functionPlacement); } // Assign a name (as $functionName) which will be used in the debug output. $name = ($name === false and $id === false) ? $functionName : $name; // To uniquely identify this accumulator. $id = $id === false ? uniqID($functionName . '_') : $id; eZDebug::accumulatorStart($id, 'Debug-Accumulator', $name); if (is_array($children)) { foreach (array_keys($children) as $childKey) { $child =& $children[$childKey]; $tpl->processNode($child, $textElements, $rootNamespace, $currentNamespace); } } eZDebug::accumulatorStop($id); break; case $this->LogName: $parameters = $functionParameters; if (isset($parameters['var'])) { $var = $tpl->elementValue($parameters['var'], $rootNamespace, $currentNamespace, $functionPlacement); } if (isset($parameters['msg'])) { $msg = $tpl->elementValue($parameters['msg'], $rootNamespace, $currentNamespace, $functionPlacement); } if (isset($var) && isset($msg)) { eZDebug::writeDebug($var, $msg); } elseif (isset($msg)) { eZDebug::writeDebug($msg); } elseif (isset($var)) { eZDebug::writeDebug($var); } break; case $this->TraceName: $children = $functionChildren; $id = false; // If we have XDebug we start the trace, execute children and stop it // if not we just execute the children as normal if (extension_loaded('xdebug')) { $parameters = $functionParameters; if (isset($parameters["id"])) { $id = $tpl->elementValue($parameters["id"], $rootNamespace, $currentNamespace, $functionPlacement); } if (!$id) { $id = 'template-debug'; } // If we already have a file, make sure it is truncated if (file_exists($id . '.xt')) { $fd = fopen($id, '.xt', 'w'); fclose($fd); } xdebug_start_trace($id); if (is_array($children)) { foreach (array_keys($children) as $childKey) { $child =& $children[$childKey]; $tpl->processNode($child, $textElements, $rootNamespace, $currentNamespace); } } xdebug_stop_trace(); } elseif (is_array($children)) { foreach (array_keys($children) as $childKey) { $child =& $children[$childKey]; $tpl->processNode($child, $textElements, $rootNamespace, $currentNamespace); } } break; } }
function get_phonebook_entries($user, $opt, &$errors) { global $config, $sess; if (!$this->connect_to_db($errors)) { return false; } /* backward compatibility */ if (!is_array($opt)) { $pbid = $opt; $opt_get_user_status = true; $opt_get_aliases = true; $o_order_by = ""; $o_order_desc = ""; } else { $pbid = isset($opt['pbid']) ? $opt['pbid'] : null; $opt_get_user_status = isset($opt['get_user_status']) ? (bool) $opt['get_user_status'] : true; $opt_get_aliases = isset($opt['get_user_aliases']) ? (bool) $opt['get_user_aliases'] : true; $o_order_by = isset($opt['order_by']) ? $opt['order_by'] : ""; $o_order_desc = !empty($opt['order_desc']) ? "desc" : ""; } if (!is_null($pbid)) { $qw = " and id!=" . $this->sql_format($pbid, "n") . " "; } else { $qw = ""; } /* get num rows */ $q = "select count(*) from " . $config->data_sql->table_phonebook . " where " . $this->get_indexing_sql_where_phrase($user) . $qw; $res = $this->db->query($q); if (DB::isError($res)) { log_errors($res, $errors); return false; } $row = $res->fetchRow(DB_FETCHMODE_ORDERED); $this->set_num_rows($row[0]); $res->free(); /* if act_row is bigger then num_rows, correct it */ $this->correct_act_row(); $q = "select id, fname, lname, sip_uri,\n\t\t trim(concat(lname, ' ', fname)) as name\n\t\t from " . $config->data_sql->table_phonebook . " \n\t\t\twhere " . $this->get_indexing_sql_where_phrase($user) . $qw; if ($o_order_by) { $q .= " order by " . $o_order_by . " " . $o_order_desc; } $q .= $this->get_sql_limit_phrase(); $res = $this->db->query($q); if (DB::isError($res)) { log_errors($res, $errors); return false; } $out = array(); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $out[$row->id]['id'] = $row->id; $out[$row->id]['l_name'] = $row->lname; $out[$row->id]['f_name'] = $row->fname; $out[$row->id]['name'] = $row->name; $out[$row->id]['sip_uri'] = $row->sip_uri; $out[$row->id]['url_ctd'] = "javascript: open_ctd_win('" . rawURLEncode($row->sip_uri) . "');"; $out[$row->id]['url_dele'] = $sess->url("phonebook.php?kvrk=" . uniqID("") . "&dele_id=" . $row->id); $out[$row->id]['url_edit'] = $sess->url("phonebook.php?kvrk=" . uniqID("") . "&edit_id=" . $row->id); if ($opt_get_user_status) { $out[$row->id]['status'] = $this->get_status($row->sip_uri, null); } if ($opt_get_aliases) { $out[$row->id]['aliases'] = ''; if (false === ($aliases = $this->get_aliases_by_uri($row->sip_uri, null))) { continue; } $alias_arr = array(); foreach ($aliases as $val) { $alias_arr[] = $val->username; } $out[$row->id]['aliases'] = implode(", ", $alias_arr); $out[$row->id]['uris'] = $aliases; } } $res->free(); return $out; }
/** * Method obtain a list of customers and store it into variable $this->customers * * @param array $errors array with error messages * @return bool return TRUE on success, FALSE on failure */ function get_customers(&$errors) { global $data, $sess_cu_act_row, $sess; $data->set_act_row($sess_cu_act_row); $opt = array(); if ($this->action['action'] == 'edit') { $opt['exclude'] = $this->act_id; } if (is_a($this->sorter, "apu_base_class")) { $opt['order_by'] = $this->sorter->get_sort_col(); $opt['order_desc'] = $this->sorter->get_sort_dir(); } if (false === ($this->customers = $data->get_customers($opt, $errors))) { return false; } $this->pager['url'] = $_SERVER['PHP_SELF'] . "?kvrk=" . uniqid("") . "&act_row="; $this->pager['pos'] = $data->get_act_row(); $this->pager['items'] = $data->get_num_rows(); $this->pager['limit'] = $data->get_showed_rows(); $this->pager['from'] = $data->get_res_from(); $this->pager['to'] = $data->get_res_to(); foreach ($this->customers as $key => $val) { $this->customers[$key]['url_dele'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&cu_dele_id=" . $val['primary_key']['cid']); $this->customers[$key]['url_edit'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&cu_edit_id=" . $val['primary_key']['cid']); } return true; }
function format_items_for_output() { global $sess; $out = array(); $i = 0; foreach ($this->item_list as $value => $label) { if ($value == $this->item_id and !is_null($this->item_id)) { continue; } $out[$i]['label'] = $label; $out[$i]['value'] = $value; $out[$i]['url_dele'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&at_dele=1&item=" . RawURLEncode($value)); $out[$i]['url_edit'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&at_edit=1&item=" . RawURLEncode($value)); $i++; } return $out; }