function execute($cron = '') { $sql = "SELECT * from phpgw_lang WHERE app_name = 'property' AND lang='no' ORDER BY message_id ASC"; $this->db->query($sql, __LINE__, __FILE__); $i = 0; while ($this->db->next_record()) { $str .= $this->db->f('message_id') . "\t"; $str .= $this->db->f('app_name') . "\t"; $str .= $this->db->f('lang') . "\t"; $str .= $this->db->f('content') . "\n"; $i++; } _debug_array($str); /* $filename= 'phpgw_no_lang'; $size=strlen($str); $browser = CreateObject('phpgwapi.browser'); $browser->content_header($filename,'application/txt',$size); echo $str; */ $this->receipt['message'][] = array('msg' => $i . ' tekster lagt til'); if (!$cron) { $this->confirm($execute = false); } }
function addAccount($_hookValues) { #_debug_array($_hookValues); $username = $_hookValues['account_lid']; $userPassword = $_hookValues['new_passwd']; #_debug_array($this->profileData); $imapAdminUsername = $this->profileData['imapAdminUsername']; $imapAdminPW = $this->profileData['imapAdminPW']; $folderNames = array("user.{$username}", "user.{$username}.Trash", "user.{$username}.Sent"); // create the mailbox if ($mbox = @imap_open($this->getMailboxString(), $imapAdminUsername, $imapAdminPW)) { // create the users folders foreach ($folderNames as $mailBoxName) { if (imap_createmailbox($mbox, imap_utf7_encode("{" . $this->profileData['imapServer'] . "}{$mailBoxName}"))) { if (!imap_setacl($mbox, $mailBoxName, $username, "lrswipcd")) { # log error message } } } imap_close($mbox); } else { _debug_array(imap_errors()); return false; } // subscribe to the folders if ($mbox = @imap_open($this->getMailboxString(), $username, $userPassword)) { imap_subscribe($mbox, $this->getMailboxString('INBOX')); imap_subscribe($mbox, $this->getMailboxString('INBOX.Sent')); imap_subscribe($mbox, $this->getMailboxString('INBOX.Trash')); imap_close($mbox); } else { # log error message } }
public function __construct($wsdl, $options, $userid, $debug = false) { if ($debug) { $this->debug = true; } try { $BrukerService = new BrukerService($wsdl, $options); } catch (Exception $e) { if ($this->debug) { echo $e->getMessage(); echo '<br>wsdl: ' . $wsdl; echo '<br>options:'; _debug_array($options); } } if (isset($BrukerService) && $BrukerService) { $ctx = new UserContext(); $ctx->appid = 'portico'; $ctx->onBehalfOfId = $userid; $ctx->userid = $userid; $ctx->transactionid = $GLOBALS['phpgw_info']['server']['install_id']; // KAN UTELATES. BENYTTES I.F.M SUPPORT. LEGG INN EN FOR DEG UNIK ID. $request = new retrieveBruker(); $request->userContext = $ctx; $request->userid = $userid; $response = $BrukerService->retrieveBruker($request); $Bruker = $response->return; $this->login = $Bruker->ou; // organisasjons nr } }
function test_receive() { require_once 'SMSReceive.php'; $options = array(); $options['soap_version'] = SOAP_1_2; $options['location'] = $this->pswin_param['receive_url']; $options['uri'] = "http://localhost/~sn5607/savannah_trunk/sms/inc/plugin/gateway/pswin/soap.php"; $options['trace'] = 1; $options['proxy_host'] = $this->pswin_param['proxy_host']; $options['proxy_port'] = $this->pswin_param['proxy_port']; $options['encoding'] = 'iso-8859-1'; //'UTF-8'; $wdsl = PHPGW_SERVER_ROOT . '/sms/inc/plugin/gateway/pswin/Receive.wdsl'; $receive = new SMSReceive($wdsl, $options); $Position = new GSMPosition(); $Position->City = 'Bergen'; $IncomingSMSMessage = new IncomingSMSMessage(); $IncomingSMSMessage->ReceiverNumber = '26112'; $IncomingSMSMessage->SenderNumber = '90665164'; $IncomingSMSMessage->Text = 'Dette er en testmelding'; $IncomingSMSMessage->Network = ''; $IncomingSMSMessage->Address = 'Firstname;middlename;lastname;address;ZipCode;City;RegionNumber;CountyNumber'; $IncomingSMSMessage->Position = $Position; $ReceiveSMSMessage = new ReceiveSMSMessage(); $ReceiveSMSMessage->m = $IncomingSMSMessage; $ReturnValue = $receive->ReceiveSMSMessage($ReceiveSMSMessage); $result = $ReturnValue->ReceiveSMSMessageResult; _debug_array($result); die; }
function list_servers($data = '', &$total) { if (gettype($data) == 'array') { if ($this->debug) { _debug_array($data); } list($start, $sort, $order, $query, $limit) = $data; } return $this->is->get_list($start, $sort, $order, $query, $limit, $total); }
function read_sessiondata() { $data = $GLOBALS['phpgw']->session->appsession('session_data', 'forum'); if ($this->debug) { echo '<br>Read:'; _debug_array($data); } $this->view = $data['view']; $this->location = $data['location']; $this->cat_id = $data['cat_id']; $this->forum_id = $data['forum_id']; }
function read_sessiondata() { $data = $GLOBALS['phpgw']->session->appsession('session_data', 'news_admin_export'); if ($this->debug) { echo '<br>Read:'; _debug_array($data); } $this->start = $data['start']; $this->query = $data['query']; $this->sort = $data['sort']; $this->order = $data['order']; }
function edit($values = 0, $view = False) { //echo "<p>notes.ui.edit():"; _debug_array($values); if (!is_array($values)) { $id = $values > 0 ? $values : get_var('id', array('POST', 'GET')); $values = array(); } else { $id = $values['id']; } if ($id > 0) { $content = $this->bo->read_single($id); } else { $content = array(); } if ($this->debug) { echo '<p>edit: id=$id, values = ' . _debug_array($values); } if ($values['save']) { $this->bo->save($values); return $this->index(); } elseif ($values['done']) { return $this->index(); } elseif ($values['delete']) { return $this->delete($values['id']); } elseif ($values['reset']) { $content = array(); } elseif ($values['cats']) { Header('Location: ' . $GLOBALS['phpgw']->link('/index.php?menuaction=preferences.uicategories.index&cats_app=et_notes&cats_level=True&global_cats=True')); $GLOBALS['phpgw']->common->phpgw_exit(); } if ($view) { $content['header'] = 'Notes - View note for'; $this->tpl->read('et_notes.view'); $no_button['content'] = $no_button['cat_id'] = $no_button['access'] = True; // make the tpl readonly $no_button['delete'] = !$this->bo->check_perms($this->bo->grants[$content['owner']], PHPGW_ACL_DELETE); $no_button['edit'] = !$this->bo->check_perms($this->bo->grants[$content['owner']], PHPGW_ACL_EDIT); } else { if ($content['id'] <= 0) { $no_button['delete'] = True; $content['header'] = 'Notes - Add note for'; $content['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; } else { $no_button['reset'] = True; $no_button['delete'] = !$this->bo->check_perms($this->bo->grants[$content['owner']], PHPGW_ACL_DELETE); $content['header'] = 'Notes - Edit note for'; } } $content['user'] = $GLOBALS['phpgw_info']['user']['fullname']; $this->tpl->exec('et_notes.ui.edit', $content, '', $no_button, array('id' => $id)); }
function read_sessiondata() { $data = $GLOBALS['phpgw']->session->appsession('session_data', 'addressbook'); if ($this->debug) { echo '<br />Read:'; _debug_array($data); } $this->start = $data['start']; $this->limit = $data['limit']; $this->query = $data['query']; $this->sort = $data['sort']; $this->order = $data['order']; $this->filter = $data['filter']; $this->cat_id = $data['cat_id']; }
function read_sessiondata() { $data = $GLOBALS['phpgw']->session->appsession('session_data', 'admin_cats'); if ($this->debug) { echo '<br>Read:'; _debug_array($data); } $this->start = $data['start']; $this->query = $data['query']; $this->sort = $data['sort']; $this->order = $data['order']; if (isset($data['cat_id'])) { $this->cat_id = $data['cat_id']; } }
function read_sessiondata() { $source = $GLOBALS['phpgw']->session->appsession('developer_source_lang', 'developer_tools'); if ($this->debug) { echo '<br>Read:'; _debug_array($source); } $target = $GLOBALS['phpgw']->session->appsession('developer_target_lang', 'developer_tools'); if ($this->debug) { echo '<br>Read:'; _debug_array($target); } $src_file = $GLOBALS['phpgw']->session->appsession('developer_source_file', 'developer_tools'); $tgt_file = $GLOBALS['phpgw']->session->appsession('developer_target_file', 'developer_tools'); $tgt_lang = $GLOBALS['phpgw']->session->appsession('developer_t_lang', 'developer_tools'); $loaded_apps = $GLOBALS['phpgw']->session->appsession('developer_loaded_apps', 'developer_tools'); $src_apps = $GLOBALS['phpgw']->session->appsession('developer_src_apps', 'developer_tools'); $missing = $GLOBALS['phpgw']->session->appsession('developer_missing_lang', 'developer_tools'); $this->set_sessiondata($source, $target, $src_file, $tgt_file, $tgt_lang, $loaded_apps, $src_apps, $missing); }
function updateAccount($_hookValues) { if (!($uidnumber = (int) $_hookValues['account_id'])) { return false; } $ds = $GLOBALS['phpgw']->ldap->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_host'], $GLOBALS['phpgw_info']['server']['ldap_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_root_pw']); if (!is_resource($ds)) { return false; } $filter = '(&(objectclass=posixaccount)(uidnumber=' . $uidnumber . '))'; $justthese = array('dn', 'objectclass', 'dbmailUID', 'dbmailGID', 'mail'); $sri = ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); if ($info = ldap_get_entries($ds, $sri)) { if (!in_array('dbmailuser', $info[0]['objectclass']) && !in_array('dbmailUser', $info[0]['objectclass']) && $info[0]['mail']) { $newData['objectclass'] = $info[0]['objectclass']; unset($newData['objectclass']['count']); $newData['objectclass'][] = 'dbmailuser'; sort($newData['objectclass']); $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['phpgw_info']['server']['install_id'])); $newData['dbmailUID'] = !empty($this->domainName) ? $_hookValues['account_lid'] . '@' . $this->domainName : $_hookValues['account_lid']; if (!ldap_modify($ds, $info[0]['dn'], $newData)) { #print ldap_error($ds); } return true; } else { $newData = array(); $newData['dbmailUID'] = !empty($this->domainName) ? $_hookValues['account_lid'] . '@' . $this->domainName : $_hookValues['account_lid']; $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['phpgw_info']['server']['install_id'])); if (!ldap_modify($ds, $info[0]['dn'], $newData)) { print ldap_error($ds); _debug_array($newData); exit; #return false; } } } return false; }
public function index() { if (!$this->acl_read) { echo lang('no access'); $GLOBALS['phpgw']->common->phpgw_exit(); } $app = phpgw::get_var('app', 'string', 'GET'); //get session's values $data = phpgwapi_cache::session_get($app, 'id_debug'); if (isset($data)) { //clear session phpgwapi_cache::session_clear($app, 'id_debug'); //replace '<' and '>' if (is_array($data)) { self::_my_print_rec($data, 0); } else { $data = htmlspecialchars($data); } _debug_array($data); } else { echo "empty session's value"; } $GLOBALS['phpgw']->common->phpgw_exit(); }
function _debug_sqsof() { $data = array('start' => $this->start, 'query' => $this->query, 'sort' => $this->sort, 'order' => $this->order, 'cat_id' => $this->cat_id); echo '<br>UI:<br>'; _debug_array($data); }
$GLOBALS['phpgw_setup']->html->login_form(); $GLOBALS['phpgw_setup']->html->show_footer(); exit; } $GLOBALS['phpgw_setup']->loaddb(); /* Add cleaning of app_sessions per skeeter, but with a check for the table being there, just in case */ /* $GLOBALS['phpgw_setup']->clear_session_cache(); */ // Database actions $setup_info = $GLOBALS['phpgw_setup']->detection->get_versions(); $GLOBALS['phpgw_info']['setup']['stage']['db'] = $GLOBALS['phpgw_setup']->detection->check_db($setup_info); if ($GLOBALS['phpgw_info']['setup']['stage']['db'] != 1) { $setup_info = $GLOBALS['phpgw_setup']->detection->get_versions(); $setup_info = $GLOBALS['phpgw_setup']->detection->get_db_versions($setup_info); $GLOBALS['phpgw_info']['setup']['stage']['db'] = $GLOBALS['phpgw_setup']->detection->check_db($setup_info); if ($GLOBALS['DEBUG']) { _debug_array($setup_info); } } if ($GLOBALS['DEBUG']) { echo 'Stage: ' . $GLOBALS['phpgw_info']['setup']['stage']['db']; } // begin DEBUG code //$GLOBALS['phpgw_info']['setup']['stage']['db'] = 0; //$action = 'Upgrade'; // end DEBUG code switch (@get_var('action', array('POST'))) { case 'Uninstall all applications': $subtitle = lang('Deleting Tables'); $submsg = lang('Are you sure you want to delete your existing tables and data?') . '.'; $subaction = lang('uninstall'); $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'predrop';
function decrypt($encrypteddata, $bypass = false) { if ($this->debug) { echo '<br>' . time() . ' crypto->decrypt() crypted data: ---->>>>' . $encrypteddata; } if ($encrypteddata === '' || is_null($encrypteddata)) { // an empty string is always a usless empty string return $encrypteddata; } /* Disable all encryption if the admin didn't set it up */ if ($this->enabled && !$bypass) { $data = $this->hex2bin($encrypteddata); mcrypt_generic_init($this->td, $this->key, $this->iv); $data = mdecrypt_generic($this->td, $data); if ($this->debug) { echo '<br>' . time() . ' crypto->decrypt() decrypted data: ---->>>>' . $data; } $test = stripslashes($data); if ($test) { if ($this->debug) { echo '<br>' . time() . ' crypto->decrypt() stripping slashes' . "\n"; } $data = $test; } unset($test); if ($this->debug) { echo '<br>' . time() . ' crypto->decrypt() data: ---->>>>' . $data . "\n"; } } else { /* No mcrypt == insecure ! */ $data = $encrypteddata; } $newdata = @unserialize($data); if ($newdata || is_array($newdata)) { if ($this->debug) { echo '<br>' . time() . ' crypto->decrypt() found serialized "' . gettype($newdata) . '". Unserializing...' . "\n"; echo '<br>' . time() . ' crypto->decrypt() returning: '; _debug_array($newdata); } return $newdata; } else { if ($this->debug) { echo '<br>' . time() . ' crypto->decrypt() found UNserialized "' . gettype($data) . '". No unserialization...' . "\n"; echo '<br>' . time() . ' crypto->decrypt() returning: ' . $data; } return $data; } }
function get_link($app_link_id, $id = '', $app2 = '', $id2 = '') { if ($this->debug) { echo "<p>solink.get_link('{$app_link_id}',{$id},'{$app2}','{$id2}')</p>\n"; } $sql = "SELECT * FROM {$this->db_name} WHERE "; if (intval($app_link_id) > 0) { $sql .= 'link_id=' . intval($app_link_id); } else { if ($app_link_id == '' || $id == '' || $app2 == '' || $id2 == '') { return False; } $vars2addslashes = array('app_link_id', 'id', 'app2', 'id2'); foreach ($vars2addslashes as $var) { ${$var} = $this->db->db_addslashes(${$var}); } $sql .= "(link_app1='{$app_link_id}' AND link_id1='{$id}' AND link_app2='{$app2}' AND link_id2='{$id2}') OR" . "(link_app2='{$app_link_id}' AND link_id2='{$id}' AND link_app1='{$app2}' AND link_id1='{$id2}')"; } $this->db->query($sql, __LINE__, __FILE__); if ($this->db->next_record()) { if ($this->debug) { _debug_array($this->db->Record); } return $this->db->Record; } return False; }
function read($app, &$phpgw_baseline) { $file = PHPGW_SERVER_ROOT . "/{$app}/setup/tables_current.inc.php"; $phpgw_baseline = array(); if ($app != '' && file_exists($file)) { include $file; } else { return False; } if ($this->debug >= 5) { echo "<p>read({$app}): file='{$file}', phpgw_baseline ="; _debug_array($phpgw_baseline); } return True; }
function show($post_vars = '') { if ($this->debug) { echo "<p>etemplate.editor.show: content="; _debug_array($post_vars); } if (!is_array($post_vars)) { $post_vars = array(); } if (!is_array($this->extensions) && isset($post_vars['**extensions**'])) { $this->extensions = $post_vars['**extensions**']; unset($post_vars['**extensions**']); } if (isset($_GET['name']) && !$this->etemplate->read($_GET) || isset($post_vars['name']) && !$this->etemplate->read($post_vars)) { $msg = lang('Error: Template not found !!!'); if (isset($post_vars['name'])) { $post_vars['version'] = ''; // trying it without version if ($this->etemplate->read($post_vars)) { $msg = lang('only an other Version found !!!'); } } } if (!$msg && isset($post_vars['delete'])) { $this->delete(array(), 'show'); return; } if (isset($post_vars['edit'])) { $this->edit(); return; } list($app) = explode('.', $this->etemplate->name); if ($app && $app != 'etemplate') { $GLOBALS['phpgw']->translation->add_app($app); // load translations for app } $content = $this->etemplate->as_array() + array('msg' => $msg); $show = new etemplate('etemplate.editor.show'); if (!$msg && isset($post_vars['values']) && !isset($post_vars['vals'])) { $cont = $post_vars['cont']; for ($r = 1; list($key, $val) = @each($cont); ++$r) { $vals["@{$r}"] = $key; $vals["A{$r}"] = is_array($val) ? htmlspecialchars(serialize($val)) . '#SeR#' : $val; } $show->data[$show->rows]['A']['name'] = 'etemplate.editor.values'; $show->data[$show->rows]['A']['size'] = 'vals'; $content['vals'] = $vals; } else { $show->data[$show->rows]['A']['obj'] =& $this->etemplate; $vals = $post_vars['vals']; $olds = $post_vars['olds']; for ($r = 1; isset($vals["A{$r}"]); ++$r) { $content['cont'][$olds["@{$r}"]] = substr($vals["A{$r}"], -5) == '#SeR#' ? unserialize(substr($vals["A{$r}"], 0, -5)) : $vals["A{$r}"]; } } $show->exec('etemplate.editor.show', $content, array(), '', array('olds' => $vals, '**extensions**' => $this->extensions), ''); }
private function _add_sql($data) { $error = false; $table = $this->table; $fields = $this->fields; if (!$table) { throw new Exception("Tabell er ikke angitt"); } if (!$fields) { throw new Exception("Felter er ikke definert"); } $primary_key = array(); $remove_keys = array(); foreach ($this->metadata as $key => $info) { if (isset($info->primary_key) && $info->primary_key) { if (!($_value = $data[array_search($key, $fields)])) { throw new Exception("Fant ikke verdi for feltet 'primary key' {$key}"); } $primary_key[] = "{$key}='{$_value}'"; $remove_keys[] = $key; } } unset($key); unset($info); unset($_value); $filtermethod = implode(' AND ', $primary_key); $value_set = array(); foreach ($fields as $key => $field) { if (isset($this->metadata[$field])) { $value_set[$field] = $this->validate_value($data[$key], $field); } } $this->db->query("SELECT count(*) as cnt FROM {$table} WHERE {$filtermethod}", __LINE__, __FILE__); $this->db->next_record(); if ($this->db->f('cnt')) { foreach ($remove_keys as $remove_key) { unset($value_set[$remove_key]); } $this->warnings[] = "ID finnes fra før: {$filtermethod}, oppdaterer"; $value_set = $this->db->validate_update($value_set); $sql = "UPDATE {$table} SET {$value_set} WHERE {$filtermethod}"; $action = 'updated'; } else { $this->warnings[] = "ID fantes ikke fra før: {$filtermethod}"; $cols = implode(',', array_keys($value_set)); $values = $this->db->validate_insert(array_values($value_set)); $sql = "INSERT INTO {$table} ({$cols}) VALUES ({$values})"; $action = 'inserted'; } if ($this->debug) { _debug_array($sql); } else { $ok = $this->db->query($sql, __LINE__, __FILE__); } if ($ok) { $this->messages[] = "Successfully {$action} record: " . implode(', ', $primary_key); } else { $this->errors[] = "Error importing record: " . implode(', ', $primary_key); } return $ok; }
/** * Render a confirmation form for clear all cache (user,and system) * * @return null */ public function clear_cache() { $GLOBALS['phpgw_info']['flags']['menu_selection'] .= '::clear_cache'; $account_id = phpgw::get_var('account_id', 'int'); if (phpgw::get_var('cancel', 'bool', 'POST') || $GLOBALS['phpgw']->acl->check('group_access', phpgwapi_acl::GROUP_MANAGERS, 'admin')) { $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'admin.uimainscreen.mainscreen')); } $dir = new DirectoryIterator($GLOBALS['phpgw_info']['server']['temp_dir']); $myfilearray = array(); if (is_object($dir)) { foreach ($dir as $file) { if ($file->isDot() || !$file->isFile() || !$file->isReadable() || strcasecmp(substr($file->getFilename(), 0, 12), 'phpgw_cache_') != 0) { continue; } $file_name = $file->getFilename(); $myfilearray[] = array('last_modified' => date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], $file->getMTime()), 'file_path' => $file->getPathname()); } } if (phpgw::get_var('confirm', 'bool', 'POST')) { foreach ($myfilearray as $delete_file) { unlink($delete_file['file_path']); } $myfilearray = array(); $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'admin.uimainscreen.mainscreen')); } if ($myfilearray) { _debug_array($myfilearray); } $GLOBALS['phpgw']->xslttpl->set_root(PHPGW_APP_TPL); $GLOBALS['phpgw']->xslttpl->add_file('confirm_delete'); $GLOBALS['phpgw_info']['flags']['app_header'] = lang('administration') . ': ' . lang('clear cache'); $data = array('form_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uiaccounts.clear_cache', 'account_id' => $account_id)), 'lang_yes' => lang('yes'), 'lang_no' => lang('no'), 'lang_confirm_msg' => lang('are you sure you want to clear cache')); $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('delete' => $data)); }
function search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND') { if (!is_array($criteria)) { $query = $criteria ? ' WHERE ' . $criteria : ''; } else { $criteria = $this->data2db($criteria); foreach ($this->db_cols as $db_col => $col) { //echo "testing col='$col', criteria[$col]='".$criteria[$col]."'<br>"; if (array_key_exists($col, $criteria) && ($empty || $criteria[$col] != '')) { if ($criteria[$col] === NULL) { $query .= ($query ? " {$op} " : ' WHERE ') . "{$db_col} IS NULL"; } else { $query .= ($query ? " {$op} " : ' WHERE ') . $db_col . ($wildcard || strstr($criteria[$col], '*') || strstr($criteria[$col], '?') ? " LIKE '{$wildcard}" . strtr(str_replace('_', '\\_', addslashes($criteria[$col])), '*?', '%_') . "{$wildcard}'" : "='" . addslashes($criteria[$col]) . "'"); } } } } $this->db->query($sql = 'SELECT ' . ($only_keys ? implode(',', $this->db_key_cols) : '*') . ($extra_cols != '' ? ",{$extra_cols}" : '') . " FROM {$this->table_name} {$query}" . ($order_by != '' ? " ORDER BY {$order_by}" : ''), __LINE__, __FILE__); if ($this->debug) { echo "<p>search(only_keys={$only_keys},order_by='{$order_by}',wildcard='{$wildcard}',empty={$empty})<br>sql = '{$sql}'</p>\n"; echo "<br>criteria = "; _debug_array($criteria); } $arr = array(); $cols = $only_keys ? $this->db_key_cols : $this->db_cols; for ($n = 0; $this->db->next_record(); ++$n) { $row = array(); foreach ($cols as $db_col => $col) { $row[$col] = $this->db->f($db_col); } $arr[] = $this->db2data($row); } return $n ? $arr : False; }
function _send_soap_($method_name, $args, $url, $debug = True) { $method_name = str_replace('.', '_', $method_name); list($uri, $hostpart) = $this->_split_url($url); if (!$args) { $arr = ''; } elseif (@is_array($args)) { while (list($key, $val) = @each($args)) { if (@is_array($val)) { while (list($x, $y) = each($val)) { $tmp[] = CreateObject('phpgwapi.soapval', $x, 'string', $y); } $ele[] = CreateObject('phpgwapi.soapval', $key, 'array', $tmp); $complex = True; } else { $ele[] = CreateObject('phpgwapi.soapval', $key, 'string', $val); } } $arr[] = CreateObject('phpgwapi.soapval', '', 'struct', $ele); } else { $arr[] = CreateObject('phpgwapi.soapval', '', 'string', $args); } $this->request = $arr; $soap_message = CreateObject('phpgwapi.soapmsg', $method_name, $this->request); $soap = CreateObject('phpgwapi.soap_client', $uri, $hostpart); $soap->username = $this->sessionid; $soap->password = $this->kp3; if ($r = $soap->send($soap_message, $method_name)) { _debug_array(htmlentities($soap->outgoing_payload)); _debug_array(htmlentities($soap->incoming_payload)); $this->debug('<hr>I got this value back<br><pre>' . htmlentities($r->serialize()) . '</pre><hr>', $debug); $this->result = $r->decode(); return $this->result; } else { _debug_array($soap->outgoing_payload); $this->debug('Fault Code: ' . $r->ernno . ' Reason "' . $r->errstring . '"<br>', $debug); } }
/** * Rename a file * @param object $from path_parts * @param object $to path_parts * @return boolean. True if copy is ok, False otherwise. */ public function rename($from, $to) { $fileid = $this->get_file_id($from); $bra5ServiceGet = new Bra5ServiceGet(); $bra5ServiceGet->getDocument(new Bra5StructGetDocument($this->secKey, $fileid)); $document = $bra5ServiceGet->getResult()->getGetDocumentResult(); foreach ($document->Attributes as &$Attribute) { if ($Attribute->getName() == 'Tittel') { $Attribute->setValue(array($to->fake_name_clean)); } } $bra5ServiceUpdate = new Bra5ServiceUpdate(); $ok = false; if (!($ok = $bra5ServiceUpdate->updateDocument(new Bra5StructUpdateDocument($this->secKey, $document)))) { _debug_array($bra5ServiceUpdate->getResult()); } return $ok; }
protected function import_data() { if (!$this->identificator) { throw new Exception("Missing identificator in dataset"); } $identificator_arr = explode("::", $this->identificator); switch ($identificator_arr[0]) { case 'location': if (!$this->location_id) { throw new Exception("No valid location selected for : {$identificator_arr[2]}"); } else { if ($GLOBALS['phpgw']->locations->get_id($identificator_arr[1], $identificator_arr[2]) != $this->location_id) { throw new Exception("No valid location selected for : {$identificator_arr[2]}"); } } break; case 'table': if (!$this->table) { throw new Exception("Table not selected"); } else { if ($identificator_arr[1] != $this->table) { throw new Exception("Not the intended target? got: {$identificator_arr[1]} , expected: {$this->table}"); } } break; case 'conversion': if (!$this->conv_type) { throw new Exception("Conversion not selected"); } else { if ($identificator_arr[1] != $this->conv_type) { throw new Exception("Not the intended target? got: {$identificator_arr[1]} , expected: {$this->conv_type}"); } } break; default: throw new Exception("No valid location"); } $metadata = array(); if ($this->table && $this->fields) { $_permission = $this->valid_tables[$this->table]['permission']; if (!($_permission & PHPGW_ACL_ADD)) { throw new Exception("No ADD-right for {$this->table}"); } $metadata = $this->db->metadata($this->table); if (phpgw::get_var('debug', 'bool')) { _debug_array($metadata); } foreach ($this->fields as $field) { if ($field && !isset($metadata[$field])) { $this->messages[] = "Feltet '{$field}' finnes ikke i tabellen '{$this->table}'"; } } $this->import_conversion->set_table($this->table); $this->import_conversion->set_metadata($metadata); } if ($this->fields) { $found_field = false; foreach ($this->fields as $field) { if ($field && !$found_field) { $found_field = true; } } if (!$found_field) { throw new Exception("Felter er ikke definert"); } $this->import_conversion->fields = $this->fields; } $start_time = time(); $datalines = $this->csvdata; $ok = true; $_ok = false; $this->db->transaction_begin(); //Do your magic... foreach ($datalines as $data) { $_ok = $this->import_conversion->add($data); if (!$_ok) { $ok = false; } } if ($ok) { $this->messages[] = "Imported data. (" . (time() - $start_time) . " seconds)"; if ($this->debug) { $this->db->transaction_abort(); $this->messages[] = "Dry Run: transaction abortet"; } else { $this->db->transaction_commit(); } return true; } else { $this->errors[] = "Import of data failed. (" . (time() - $start_time) . " seconds)"; $this->db->transaction_abort(); return false; } }
function RenameTable($oProc, &$aTables, $sOldTableName, $sNewTableName) { if ($GLOBALS['DEBUG']) { echo '<br>RenameTable(): Fetching old sequence for: ' . $sOldTableName; } $this->GetSequenceForTable($oProc, $sOldTableName, $sSequenceName); if ($GLOBALS['DEBUG']) { echo ' - ' . $sSequenceName; } if ($GLOBALS['DEBUG']) { echo '<br>RenameTable(): Fetching sequence field for: ' . $sOldTableName; } $this->GetSequenceFieldForTable($oProc, $sOldTableName, $sField); if ($GLOBALS['DEBUG']) { echo ' - ' . $sField; } if ($sSequenceName) { $oProc->m_odb->query("SELECT last_value FROM seq_{$sOldTableName}", __LINE__, __FILE__); $oProc->m_odb->next_record(); $lastval = $oProc->m_odb->f(0); if ($GLOBALS['DEBUG']) { echo '<br>RenameTable(): dropping old sequence: ' . $sSequenceName . ' used on field: ' . $sField; } $this->DropSequenceForTable($oProc, $sOldTableName); if ($lastval) { $lastval = ' start ' . $lastval; } $this->GetSequenceSQL($sNewTableName, $sSequenceSQL); if ($GLOBALS['DEBUG']) { echo '<br>RenameTable(): Making new sequence using: ' . $sSequenceSQL . $lastval; } $oProc->m_odb->query($sSequenceSQL . $lastval, __LINE__, __FILE__); if ($GLOBALS['DEBUG']) { echo '<br>RenameTable(): Altering column default for: ' . $sField; } $oProc->m_odb->query("ALTER TABLE {$sOldTableName} ALTER {$sField} SET DEFAULT nextval('seq_" . $sNewTableName . "')", __LINE__, __FILE__); } // renameing existing indexes and primary keys $indexes = $oProc->m_odb->Link_ID->MetaIndexes($sOldTableName, True); if ($GLOBALS['DEBUG']) { echo '<br>RenameTable(): Fetching indexes: '; _debug_array($indexes); } foreach ($indexes as $name => $data) { $new_name = str_replace($sOldTableName, $sNewTableName, $name); $sql = "ALTER TABLE {$name} RENAME TO {$new_name}"; if ($GLOBALS['DEBUG']) { echo "<br>RenameTable(): Renaming the index '{$name}': {$sql}"; } $oProc->m_odb->query($sql); } return !!$oProc->m_odb->query("ALTER TABLE {$sOldTableName} RENAME TO {$sNewTableName}"); }
function add_langs($appname, $DEBUG = False, $force_en = False) { $langs = $this->get_langs($DEBUG); if ($force_en && !@in_array('en', $langs)) { $langs[] = 'en'; } if ($DEBUG) { echo '<br>add_langs(): chose these langs: '; _debug_array($langs); } $GLOBALS['phpgw_setup']->db->transaction_begin(); while (list($null, $lang) = each($langs)) { if ($DEBUG) { echo '<br>add_langs(): Working on: ' . $lang . ' for ' . $appname; } $appfile = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP . 'phpgw_' . strtolower($lang) . '.lang'; if (file_exists($appfile)) { if ($DEBUG) { echo '<br>add_langs(): Including: ' . $appfile; } $raw_file = file($appfile); while (list($null, $line) = @each($raw_file)) { list($message_id, $app_name, $GLOBALS['phpgw_setup']->db_lang, $content) = explode("\t", $line); $message_id = $GLOBALS['phpgw_setup']->db->db_addslashes(chop(substr($message_id, 0, MAX_MESSAGE_ID_LENGTH))); /* echo '<br>APPNAME:' . $app_name . ' PHRASE:' . $message_id; */ $app_name = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($app_name)); $GLOBALS['phpgw_setup']->db_lang = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($GLOBALS['phpgw_setup']->db_lang)); $content = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($content)); $GLOBALS['phpgw_setup']->db->query("SELECT COUNT(*) FROM phpgw_lang WHERE message_id='{$message_id}' and lang='" . $GLOBALS['phpgw_setup']->db_lang . "'", __LINE__, __FILE__); $GLOBALS['phpgw_setup']->db->next_record(); if ($GLOBALS['phpgw_setup']->db->f(0) == 0) { if ($message_id && $content) { if ($DEBUG) { echo "<br>add_langs(): adding - INSERT INTO phpgw_lang VALUES ('{$message_id}','{$app_name}','" . $GLOBALS['phpgw_setup']->db_lang . "','{$content}')"; } $GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_lang VALUES ('{$message_id}','{$app_name}','" . $GLOBALS['phpgw_setup']->db_lang . "','{$content}')", __LINE__, __FILE__); } } } } } $GLOBALS['phpgw_setup']->db->transaction_commit(); }
function action() { $params = get_var('params', array('POST', 'GET')); $show_upload_box = get_var('show_upload_boxes', 'GET'); if ($show_upload_box) { $GLOBALS['phpgw']->preferences->read(); $GLOBALS['phpgw']->preferences->change('filemanager', 'show_upload_boxes', $show_upload_box); $GLOBALS['phpgw']->preferences->save_repository(); $this->bofilemanager->show_upload_boxes = $show_upload_box; } if (UI_DEBUG) { echo 'uifilemanager -> Debug mode <br />'; _debug_array($_POST); } $functions = array('rename', 'delete', 'go', 'copy', 'move', 'download', 'newdir', 'newfile', 'edit', 'edit_comments', 'apply_edit_comment', 'apply_edit_name', 'cancel', 'upload', 'execute', 'update', 'research', 'compare', 'next', 'first', 'last', 'prev'); $bo_functions = array('apply_edit_comment', 'apply_edit_name', 'copy', 'delete', 'move', 'newdir', 'newfile', 'upload', 'download', 'execute', 'update'); $link_data = array('menuaction' => 'filemanager.uifilemanager.index', 'path' => urlencode($this->bofilemanager->path)); $var_msg = ''; if (is_array($params)) { foreach ($params as $true => $action) { $action = $true == 'execute' ? $true : $action; if ($action != '' && in_array($action, $functions)) { if (in_array($action, array('first', 'next', 'prev', 'last', 'research'))) { $link_data['menuaction'] = 'filemanager.uifilemanager.history'; $link_data['vers'] = urlencode($this->bofilemanager->vers); $link_data['file'] = urlencode($this->bofilemanager->file); $link_data['history_path'] = urlencode($this->bofilemanager->path); $link_data['history_file'] = urlencode($this->bofilemanager->file); $link_data['collapse'] = urlencode($this->bofilemanager->collapse); $link_data['mime_type'] = urlencode($this->bofilemanager->mime_type); } switch ($action) { case 'rename': $link_data['rename_files'] = True; $edit = $this->bofilemanager->get_fileman(); $this->bofilemanager->save_sessiondata($edit, 'changes'); if (!$this->bofilemanager->settings['name']) { $GLOBALS['phpgw']->preferences->read(); $GLOBALS['phpgw']->preferences->change('filemanager', 'name', 'name'); $GLOBALS['phpgw']->preferences->save_repository(); } break; case 'research': $link_data['from_rev'] = urlencode($this->bofilemanager->from_rev); $link_data['to_rev'] = urlencode($this->bofilemanager->to_rev); break; case 'first': break; case 'next': $link_data['page'] = urlencode($this->bofilemanager->page + 1); break; case 'prev': $link_data['page'] = urlencode($this->bofilemanager->page - 1); break; case 'last': $link_data['page'] = urlencode($this->bofilemanager->pages); break; case 'compare': $link_data['menuaction'] = 'filemanager.uifilemanager.compare'; $link_data['file'] = urlencode($this->bofilemanager->file); $link_data['collapse'] = urlencode($this->bofilemanager->collapse); $link_data['page'] = urlencode($this->bofilemanager->page); $link_data['pages'] = urlencode($this->bofilemanager->pages); break; case 'edit_comments': $link_data['edit_comments'] = True; $edit = $this->bofilemanager->get_fileman(); $this->bofilemanager->save_sessiondata($edit, 'changes'); if (!$this->bofilemanager->settings['comment']) { $GLOBALS['phpgw']->preferences->read(); $GLOBALS['phpgw']->preferences->change('filemanager', 'comment', 'comment'); $GLOBALS['phpgw']->preferences->save_repository(); } break; case 'edit': $link_data['menuaction'] = 'filemanager.uiaction_edit.edit'; break; case 'go': $link_data['path'] = urlencode($this->bofilemanager->todir); break; case 'cancel': $this->bofilemanager->unset_sessiondata(); $var_msg = lang('action canceled'); break; default: if (in_array($action, $bo_functions)) { //echo ' bofunction: f_' . $action; $f_function = 'f_' . $action; $msg = $this->bofilemanager->{$f_function}(); if ($action == 'newfile' && !is_array($msg)) { $link_data['menuaction'] = 'filemanager.uiaction_edit.edit'; $link_data['edit_file'] = urlencode($this->bofilemanager->createfile); } elseif (is_array($msg)) { $var_msg = implode("\n", $msg); } } break; } } elseif ($action != '') { $var_msg = lang('unsupported action'); } } } $link_data['msg'] = $var_msg; $GLOBALS['phpgw']->redirect_link('/index.php', $link_data); }
/** * Clear all values from the cache? * * @todo document me properly */ function clear_cache() { $SHM_KEY = ftok(PHPGW_SHM_LOCK, 'R'); $shmid = @sem_get($SHM_KEY, 1024, 0644 | IPC_CREAT); sem_acquire($shmid); $data = $this->get_value($this->hashid); _debug_array($data); foreach ($data as $k => $v) { $id = $this->mem_exist($v['shmid']); $this->delete_mem($id); $this->close_mem($id); } $data = array(); $this->store_value($this->hashid, $data); sem_release($shmid); }
function _debug_sqsof() { $data = array('view' => $this->bo->view, 'location' => $this->bo->location, 'cat_id' => $this->bo->cat_id, 'forum_id' => $this->bo->forum_id); echo '<br>UI:'; _debug_array($data); }