Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2029

Přidáno uživatelem Jan Dubina před asi 11 roky(ů)

Upravy:
fixes #588: Propojeni s vtiger CRM
fixes #614: Automaticke predvyplnovani formularu pomoci GET pozadavku

Zobrazit rozdíly:

freenetis/branches/1.1/application/controllers/export.php
$filter_form = new Filter_form('m');
$filter_form->autoload();
$member = new Member_Model();
try
......
{
$items = array();
}
$filename = __('Members') . '.csv';
break;
......
try
{
$invoices = $invoice_model->get_all_invoices_export(0, 0, 'id', 'asc', $filter);
$invoices = $invoice_model->get_all_invoices_export($filter);
}
catch (Exception $e)
{
......
try
{
$invoices = $invoice_model->get_all_invoices_export(0, 0, 'id', 'asc', $filter);
$invoices = $invoice_model->get_all_invoices_export($filter);
}
catch (Exception $e)
{
freenetis/branches/1.1/application/controllers/members.php
if (!$hide_grid && $this->acl_check_view(get_class($this), 'members'))
{
// export contacts
$grid->add_new_button(
'export/vcard/members' . server::query_string(),
'Export contacts', array
(
'title' => __('Export contacts'),
'class' => 'popup_link'
)
);
// csv export of members
$grid->add_new_button(
'export/csv/members' . server::query_string(),
......
'members_whitelists/show_by_member/'.$member->id, __('Whitelists')
);
}
// export contacts
$member_links[] = html::anchor(
'export/vcard/' . $member_id . server::query_string(),
__('Export contacts'),
array
(
'title' => __('Export contacts'),
'class' => 'popup_link'
)
);
$member_links[] = html::anchor(
'members/registration_export/'.$member->id,
freenetis/branches/1.1/application/controllers/scheduler.php
$this->fee_deduction();
}
//synchronize with vtiger CRM
self::vtiger_sync();
// set state of module (last activation time)
Settings::set('cron_state', date('Y-m-d H:i:s'));
}
......
}
}
/**
* Synchronize members and users to vtiger CRM.
* Runs every 30 minutes if Vtiger integration is enabled in settings.
*
* @author Jan Dubina
*/
private static function vtiger_sync()
{
if(Settings::get('vtiger_integration') && date('i') == '30')
{
try
{
Members_Controller::vtiger_sync();
}
catch (Exception $e)
{
self::log_error('vtiger_synchronization', $e);
}
}
}
}
freenetis/branches/1.1/application/controllers/settings.php
{
private $links;
/**
* Definitions of modules and their dependencies
*
* @author Michal Kliment
* @var array
*/
public static $modules = array
(
'allowed_subnets' => array
(
'name' => 'allowed_subnets_enabled',
'dependencies' => array('redirection')
),
'approval' => array
(
'name' => 'approval_enabled',
'dependencies' => array()
),
'connection_request' => array
(
'name' => 'connection_request_enable',
'dependencies' => array('networks'),
),
'email' => array
(
'name' => 'email_enabled',
'dependencies' => array()
),
'finance' => array
(
'name' => 'finance_enabled',
'dependencies' => array()
),
'forgotten_password' => array
(
'name' => 'forgotten_password',
'dependencies' => array('email')
),
'membership_interrupt' => array
(
'name' => 'membership_interrupt_enabled',
'dependencies' => array()
),
'monitoring' => array
(
'name' => 'monitoring_enabled',
'dependencies' => array('networks')
),
'networks' => array
(
'name' => 'networks_enabled',
'dependencies' => array()
),
'phone_invoices' => array
(
'name' => 'users_enabled',
'dependencies' => array()
),
'qos' => array
(
'name' => 'qos_enabled',
'dependencies' => array()
),
'redirection' => array
(
'name' => 'redirection_enabled',
'dependencies' => array('networks')
),
'self_registration' => array
(
'name' => 'self_registration',
'dependencies' => array()
),
'sms' => array
(
'name' => 'sms_enabled',
'dependencies' => array()
),
'ulogd' => array
(
'name' => 'ulogd_enabled',
'dependencies' => array('networks')
),
'users' => array
(
'name' => 'users_enabled',
'dependencies' => array()
),
'voip' => array
(
'name' => 'voip_enabled',
'dependencies' => array()
),
'works' => array
(
'name' => 'works_enabled',
'dependencies' => array('approval')
),
);
/**
* Test whether module is enabled
*
* @author Michal Kliment
* @param type $module
* @return type
* @throws Exception
*/
private static function isModuleEnabled($module)
{
if (isset(self::$modules[$module]['name']))
return Settings::get(self::$modules[$module]['name']);
else
throw new Exception('Unknown module: '.$module);
}
/**
* Disable given module
*
* @author Michal Kliment
* @param type $module
* @return type
* @throws Exception
*/
private static function disableModule($module)
{
if (isset(self::$modules[$module]['name']))
return Settings::set(self::$modules[$module]['name'], 0);
else
throw new Exception('Unknown module: '.$module);
}
/**
* Contruct of controller sets tabs names
......
$this->sections['users'] = __('Users');
// are finance enabled
if (self::isModuleEnabled('finance'))
if (Settings::get('finance_enabled'))
$this->sections['finance'] = __('Finance');
// is approval enabled
if (self::isModuleEnabled('approval'))
if (Settings::get('approval_enabled'))
$this->sections['approval'] = __('Approval');
// are networks enabled
if (self::isModuleEnabled('networks'))
if (Settings::get('networks_enabled'))
$this->sections['networks'] = __('Networks');
if (self::isModuleEnabled('email'))
if (Settings::get('email_enabled'))
$this->sections['email'] = __('Email');
// are SMS enabled
if (self::isModuleEnabled('sms'))
if (Settings::get('sms_enabled'))
$this->sections['sms'] = __('SMS');
// is voip enabled
if (self::isModuleEnabled('voip'))
if (Settings::get('voip_enabled'))
$this->sections['voip'] = __('VoIP');
$this->sections['notifications'] = __('Notifications');
// is QoS enabled
if (self::isModuleEnabled('qos'))
if (Settings::get('qos_enabled'))
$this->sections['qos'] = __('QoS');
// is monitoring enabled
if (self::isModuleEnabled('monitoring'))
if (Settings::get('monitoring_enabled'))
$this->sections['monitoring'] = __('Monitoring');
$this->sections['logging'] = __('Logging');
......
// creating of new forge
$this->form = new Forge('settings/system');
$this->form->set_attr('id', 'settings-system-form');
$this->form->group('System variables');
......
->options(arr::bool())
->default(Settings::get('grid_hide_on_first_load'))
->help('grid_hide_on_first_load');
$form_modules = array();
$this->form->group(__('Modules').' '.help::hint('modules'));
$this->form->group(__('Modules').' '.help::hint('modules'));;
// self-registration
$form_modules['self_registration'] = $this->form->radio('self_registration')
$this->form->radio('self_registration')
->label('Self-registration')
->options(arr::bool())
->default(Settings::get('self_registration'));
// connection requests
$form_modules['connection_request'] = $this->form->radio('connection_request_enable')
$this->form->radio('connection_request_enable')
->label('Connection requests')
->options(arr::bool())
->default(Settings::get('connection_request_enable'));
// forgotten password
$form_modules['forgotten_password'] = $this->form->radio('forgotten_password')
$this->form->radio('forgotten_password')
->label('Forgotten password')
->options(arr::bool())
->default(Settings::get('forgotten_password'));
// membership interrupts
$form_modules['membership_interrupt'] = $this->form->radio('membership_interrupt_enabled')
$this->form->radio('membership_interrupt_enabled')
->label('Membership interrupt')
->options(arr::bool())
->default(Settings::get('membership_interrupt_enabled'));
// finance
$form_modules['finance'] = $this->form->radio('finance_enabled')
$this->form->radio('finance_enabled')
->label('Finance')
->options(arr::bool())
->default(Settings::get('finance_enabled'));
// approval
$form_modules['approval'] = $this->form->radio('approval_enabled')
$this->form->radio('approval_enabled')
->label('Approval')
->options(arr::bool())
->default(Settings::get('approval_enabled'));
// Works
$form_modules['works'] = $this->form->radio('works_enabled')
$this->form->radio('works_enabled')
->label('Works')
->options(arr::bool())
->default(Settings::get('works_enabled'));
// Phone invoice
$form_modules['phone_invoices'] = $this->form->radio('phone_invoices_enabled')
$this->form->radio('phone_invoices_enabled')
->label('Phone invoices')
->options(arr::bool())
->default(Settings::get('phone_invoices_enabled'));
// e-mail
$form_modules['email'] = $this->form->radio('email_enabled')
$this->form->radio('email_enabled')
->label('E-mail')
->options(arr::bool())
->default(Settings::get('email_enabled'));
// SMS
$form_modules['sms'] = $this->form->radio('sms_enabled')
$this->form->radio('sms_enabled')
->label('SMS')
->options(arr::bool())
->default(Settings::get('sms_enabled'));
// VoIP
$form_modules['voip'] = $this->form->radio('voip_enabled')
$this->form->radio('voip_enabled')
->label('VoIP')
->options(arr::bool())
->default(Settings::get('voip_enabled'));
// Network
$form_modules['networks'] = $this->form->radio('networks_enabled')
$this->form->radio('networks_enabled')
->label('Networks')
->options(arr::bool())
->default(Settings::get('networks_enabled'));
// QoS
$form_modules['qos'] = $this->form->radio('qos_enabled')
$this->form->radio('qos_enabled')
->label('QoS')
->options(arr::bool())
->default(Settings::get('qos_enabled'));
// Monitoring
$form_modules['monitoring'] = $this->form->radio('monitoring_enabled')
$this->form->radio('monitoring_enabled')
->label('Monitoring')
->options(arr::bool())
->default(Settings::get('monitoring_enabled'));
// Redirection
$form_modules['redirection'] = $this->form->radio('redirection_enabled')
$this->form->radio('redirection_enabled')
->label('Redirection')
->options(arr::bool())
->default(Settings::get('redirection_enabled'));
// add info about modules dependencies
foreach ($form_modules as $module => $item)
{
// module have at least one dependency
if (count(self::$modules[$module]['dependencies']))
{
$form_modules[$module]->additional_info(
__('Require module') . ': <b>' .
implode(', ', array_map(
'__', self::$modules[$module]['dependencies'])
) . '</b>'
);
}
}
$this->form->group('Module settings');
......
$issaved = $issaved && Settings::set($name, $value);
}
foreach (self::$modules as $module => $module_info)
// without networks disabled monitoring, ulogd, connection request and redirection
if (!Settings::get('networks_enabled'))
{
foreach ($module_info['dependencies'] as $dependency)
{
if (self::isModuleEnabled($module) && !self::isModuleEnabled($dependency))
{
status::error(__('Cannot enable module %s, enabled module %s is required.', array($module, $dependency)));
self::disableModule($module);
break;
}
}
Settings::set('monitoring_enabled', FALSE);
Settings::set('ulogd_enabled', FALSE);
Settings::set('connection_request_enable', FALSE);
Settings::set('redirection_enabled', FALSE);
}
// without redirection allowed subnet cannot be enabled
if (!Settings::get('redirection_enabled'))
{
Settings::set('allowed_subnets_enabled', FALSE);
}
// without approval works cannot be enabled
if (!Settings::get('approval_enabled'))
{
Settings::set('works_enabled', FALSE);
}
// without email forgotten password cannot be enabled
if (!Settings::get('email_enabled'))
{
Settings::set('forgotten_password', FALSE);
}
if ($issaved)
// if all action were succesfull
{
freenetis/branches/1.1/application/i18n/cs_CZ/texts.php
'connection request has been succesfully approved' => 'Žádost o připojení byla úspěšně schválena.',
'connection requests' => 'Požadavky na připojení',
'connection requests are not enabled' => 'Požadavky na připojení nejsou povoleny.',
'connection to vtiger server has failed' => 'Nepodařilo se připojit k Vtiger serveru',
'connection test expired' => 'Testovací připojení vypršelo',
'connections' => 'Připojení',
'constant symbol' => 'Konstantní symbol',
......
'dns configuration files were successfully generated' => 'Konfigurační soubory pro DNS byly úspěšně vygenerovány',
'dns servers' => 'DNS servery',
'do export' => 'Exportuj',
'do not call' => 'Nevolat',
'do not send emails' => 'Nezasílat e-maily',
'do transfer' => 'Proveď transakci',
'do you really want to activate notifications' => 'Chcete opravdu aktivovat upozornění?',
'do you really want to delete these' => 'Chcete opravdu smazat smazat těchto',
......
'email already exists in database' => 'E-mail je již v databázi',
'e-mail from' => 'E-mail Od',
'e-mail to' => 'E-mail Komu',
'employees' => 'Zaměstnanci',
'empty' => 'Prázdný',
'empty input' => 'Prázdný vstup',
'empty variable symbol' => 'Prázný variablní symbol',
......
'error' => 'Chyba',
'error - wrong arguments' => 'Chyba - špatné argumenty',
'error - wrong data' => 'Chyba - špatná data',
'error - wrong vtiger fields settings' => 'Chyba - špatné nastavení názvů sloupců pro Vtiger',
'error - bad template' => 'Chyba - špatná šablona',
'error - amount has to be positive' => 'Chyba - částka musí být kladná.',
'error - bad file' => 'Chyba - špatný soubor.',
......
'error - some fees have not been recounted' => 'Chyba - některé členské příspěvky nebyly přepočítány.',
'error - some fees have not been deducted' => 'Chyba - některé členské příspěvky nebyly strženy.',
'error - voip not enabled' => 'Chyba - VoIP není povoleno',
'error - vtiger webservice is not responding' => 'Chyba - Vtiger webová služba neodpovídá',
'error during automatic activation of notification messages' => 'Chyba během automatické aktivace upozorňovacích zpráv',
'error during automatical deduction of members fees, please use manual deduction of fees' => 'Chyba během automatického strhávání členských příspěvků, proveďte prosím stržení manuálně',
'error during automatical deduction of entrance fees, please use manual deduction of fees' => 'Chyba během automatického strhávání vstupních příspěvků, proveďte prosím stržení manuálně',
......
'notification settings have been successfully updated' => 'Nastavení upozornění bylo úspěšně upraveno.',
'notification settings have not been updated' => 'Nastavení upozornění nebylo upraveno.',
'notifications' => 'Upozornění',
'notify owner' => 'Upozornit majitele',
'november' => 'Listopad',
'now you can login using account name and password you entered during installation' => 'Nyní se můžete přihlásit pomocí uživatelského jména a hesla, které jste zadali při instalaci.',
'number' => 'Číslo',
......
'user "%s" has activated notification message "%s"' => 'Uživatel "%s" aktivoval upozorňovací zprávu "%s"',
'user "%s" has deactivated notification message "%s"' => 'Uživatel "%s" deaktivoval upozorňovací zprávu "%s"',
'user acceptation' => 'Potvrzení uživatelem',
'user access key' => 'Přístupový klíč uživatele',
'user can disable redirection' => 'Uživatel může zrušit přesměrování',
'user-cancelable' => 'Zrušitelná uživatelem',
'user cannot be deleted, he has some dependent items in database' => 'Uživatel nelze smazat, má závislé objekty v databázi.',
......
'voip number must be a number' => 'VoIP číslo musí být číslo',
'voip settings' => 'Nastavení VoIP',
'vpn calls' => 'VPN volání',
'vtiger integration' => 'Integrace CRM Vtiger',
'vtiger field names' => 'Názvy polí v CRM Vtiger',
'wait please' => 'Počkejte prosím',
'waiting for registration' => 'Čekám na registraci',
'warning' => 'Varování',
freenetis/branches/1.1/application/libraries/Settings.php
*/
// redirection is enabled by default
'redirection_enabled' => TRUE,
// minimal membership interrupt period is 1 month
'membership_interrupt_minimum' => 1,
/**
* VTIGER SETTINGS
*/
// vtiger field names - members
'vtiger_member_fields' => '{"name":"accountname","acc_type":"accountype","entrance_date":"",
"organization_identifier":"","var_sym":"","type":"",
"street":"bill_street","town":"bill_city","country":"bill_country",
"zip_code":"bill_code","phone1":"phone","phone2":"","phone3":"",
"email1":"email1","email2":"","email3":"","employees":"employees",
"do_not_send_emails":"emailoptout","notify_owner":"notify_owner",
"comment":"description","id":""}',
// vtiger field names - users
'vtiger_user_fields' => '{"name":"firstname","middle_name":"","surname":"lastname",
"pre_title":"","post_title":"","member_id":"account_id",
"street":"mailingstreet","town":"mailingcity",
"country":"mailingcountry","zip_code":"mailingzip","phone1":"phone",
"phone2":"","phone3":"","email1":"email1","email2":"","email3":"",
"birthday":"birthday","do_not_call":"donotcall",
"do_not_send_emails":"emailoptout","notify_owner":"notify_owner",
"comment":"description","id":""}',
'redirection_port_self_cancel' => 80,
/**
freenetis/branches/1.1/application/libraries/forge/Form_Dropdown.php
$this->data['selected'] = $this->input_value($this->name);
}
/**
* Runs validation and returns the element HTML.
*
* @return string
*/
public function html()
{
// sets selected value to a value of GET parameter with same name (request #614)
$value = Input::instance()->get($this->name());
if(!empty($value))
{
$key = array_search(urldecode($value), $this->data['options']);
if ($key !== false)
$this->selected ($key);
}
// Make sure validation runs
$this->validate();
return $this->html_element();
}
} // End Form Dropdown
freenetis/branches/1.1/application/libraries/forge/Form_Input.php
*/
public function html()
{
// sets input value to a value of GET parameter with same name (request #614)
$value = Input::instance()->get($this->name());
if(!empty($value))
$this->value ($value);
// Make sure validation runs
$this->validate();
......
// Fetch the method for this object
$method = $this->method;
if (func_num_args() > 0)
{
$name = func_get_arg(0);
......
$value = $input->$method($name);
return (isset($value[$matches[3]])) ? $value[$matches[3]] : '';
}
return $input->$method($name);
}
else
......
* @return void
*/
protected function load_value()
{
if (is_bool($this->is_valid))
{
if (is_bool($this->is_valid))
return;
if ($name = $this->name)
......
// Validation has already run
if (is_bool($this->is_valid))
return $this->is_valid;
// No data to validate
if ($this->input_value() == FALSE)
return $this->is_valid = FALSE;
// Load the submitted value
$this->load_value();
freenetis/branches/1.1/application/libraries/vtwsclib/Vtiger/Net/HTTP_Client.php
<?php
require_once(APPPATH.'libraries/vtwsclib/third-party/curl_http_client.php');
require_once(APPPATH.'libraries/vtwsclib/third-party/Zend/Json.php');
class Vtiger_HTTP_Client extends Curl_HTTP_Client {
var $_serviceurl = '';
function __construct($url) {
if(!function_exists('curl_exec')) {
die('Vtiger_HTTP_Client: Curl extension not enabled!');
}
parent::__construct();
$this->_serviceurl = $url;
$useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$this->set_user_agent($useragent);
// Escape SSL certificate hostname verification
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
}
function doPost($postdata=false, $decodeResponseJSON=false, $timeout=20) {
if($postdata === false) $postdata = Array();
$resdata = $this->send_post_data($this->_serviceurl, $postdata, null, $timeout);
if($resdata && $decodeResponseJSON) $resdata = $this->__jsondecode($resdata);
return $resdata;
}
function doGet($getdata=false, $decodeResponseJSON=false, $timeout=20) {
if($getdata === false) $getdata = Array();
$queryString = '';
foreach($getdata as $key=>$value) {
$queryString .= '&' . urlencode($key)."=".urlencode($value);
}
$resdata = $this->fetch_url("$this->_serviceurl?$queryString", null, $timeout);
if($resdata && $decodeResponseJSON) $resdata = $this->__jsondecode($resdata);
return $resdata;
}
function __jsondecode($indata) {
return Zend_Json::decode($indata);
}
function __jsonencode($indata) {
return Zend_Json::encode($indata);
}
}
?>
freenetis/branches/1.1/application/libraries/vtwsclib/Vtiger/WSClient.php
<?php
require_once(APPPATH.'libraries/vtwsclib/Vtiger/Net/HTTP_Client.php');
require_once(APPPATH.'libraries/vtwsclib/Vtiger/WSVersion.php');
/**
* Vtiger Webservice Client
*/
class Vtiger_WSClient {
// Webserice file
var $_servicebase = 'webservice.php';
// HTTP Client instance
var $_client = false;
// Service URL to which client connects to
var $_serviceurl = false;
// Webservice user credentials
var $_serviceuser= false;
var $_servicekey = false;
// Webservice login validity
var $_servertime = false;
var $_expiretime = false;
var $_servicetoken=false;
// Webservice login credentials
var $_sessionid = false;
var $_userid = false;
// Last operation error information
var $_lasterror = false;
/**
* Constructor.
*/
function __construct($url) {
$this->_serviceurl = $this->getWebServiceURL($url);
$this->_client = new Vtiger_HTTP_Client($this->_serviceurl);
}
/**
* Destructor.
*/
function __destruct() {
$this->__doLogout();
}
/**
* Return the client library version.
*/
function version() {
global $wsclient_version;
return $wsclient_version;
}
/**
* Reinitialize the client.
*/
function reinitalize() {
$this->_client = new Vtiger_HTTP_Client($this->_serviceurl);
}
/**
* Get the URL for sending webservice request.
*/
function getWebServiceURL($url) {
if(stripos($url, $this->_servicebase) === false) {
if(strripos($url, '/') != (strlen($url)-1)) {
$url .= '/';
}
$url .= $this->_servicebase;
}
return $url;
}
/**
* Get actual record id from the response id.
*/
function getRecordId($id) {
$ex = explode('x', $id);
return $ex[1];
}
/**
* Check if result has any error.
*/
function hasError($result) {
if(isset($result['success']) && $result['success'] === true) {
$this->_lasterror = false;
return false;
}
$this->_lasterror = $result['error'];
return true;
}
/**
* Get last operation error
*/
function lastError() {
return $this->_lasterror;
}
/**
* Perform the challenge
* @access private
*/
function __doChallenge($username) {
$getdata = Array(
'operation' => 'getchallenge',
'username' => $username
);
$resultdata = $this->_client->doGet($getdata, true);
if($this->hasError($resultdata)) {
return false;
}
$this->_servertime = $resultdata['result']['serverTime'];
$this->_expiretime = $resultdata['result']['expireTime'];
$this->_servicetoken = $resultdata['result']['token'];
return true;
}
/**
* Check and perform login if requried.
*/
function __checkLogin() {
if(!$this->_expiretime || (time() > $this->_expiretime))
$this->doLogin($this->_serviceuser, $this->_servicekey);
}
/**
* Do Logout Operation
* @access private
*/
function __doLogout() {
$getdata = Array(
'operation' => 'logout',
'sessionName' => $this->_sessionid
);
$resultdata = $this->_client->doGet($getdata, true);
if($this->hasError($resultdata)) {
if (isset($resultdata['result']['message']) && $resultdata['result']['message'] == 'successfull')
return false;
}
return true;
}
/**
* JSONify input data.
*/
function toJSON($input) {
return $this->_client->__jsondecode($input);
}
/**
* Convert input data to JSON String.
*/
function toJSONString($input) {
return $this->_client->__jsonencode($input);
}
/**
* Do Login Operation
*/
function doLogin($username, $vtigerUserAccesskey) {
// Do the challenge before login
if($this->__doChallenge($username) === false) return false;
$postdata = Array(
'operation' => 'login',
'username' => $username,
'accessKey' => md5($this->_servicetoken.$vtigerUserAccesskey)
);
$resultdata = $this->_client->doPost($postdata, true);
if($this->hasError($resultdata)) {
return false;
}
$this->_serviceuser = $username;
$this->_servicekey = $vtigerUserAccesskey;
$this->_sessionid = $resultdata['result']['sessionName'];
$this->_userid = $resultdata['result']['userId'];
return true;
}
/**
* Do Query Operation.
*/
function doQuery($query) {
// Perform re-login if required.
$this->__checkLogin();
// Make sure the query ends with ;
$query = trim($query);
if(strripos($query, ';') != strlen($query)-1) $query .= ';';
$getdata = Array(
'operation' => 'query',
'sessionName' => $this->_sessionid,
'query' => $query
);
$resultdata = $this->_client->doGet($getdata, true);
if($this->hasError($resultdata)) {
return $resultdata;
}
return $resultdata['result'];
}
/**
* Do Query Operation - returns more than 100 results.
*/
function doQueryNotLimited($query) {
// Perform re-login if required.
$this->__checkLogin();
$query = trim($query);
$limit_pos = stripos($query, 'limit');
$count = 0;
$result_limit = 100;
if ($limit_pos === false)
{
$select_pos = stripos($query, 'select ') + 7; //strlen('select ')
$from_pos = stripos($query, ' from');
$count_query = substr_replace($query, 'count(*)', $select_pos, $from_pos - $select_pos);
$result = $this->doQuery($count_query);
if ($result && array_key_exists(0, $result) &&
array_key_exists('count', $result[0]))
$count = $result[0]['count'];
}
if (($limit_pos !== false) || ($count <= $result_limit))
return $this->doQuery($query);
$reps = ceil($count / $result_limit);
$results = array();
//remove ; from the end of query
if (substr($query, -1) == ';')
$query = substr_replace ($query, '', strlen ($query) - 1, 1);
for ($i = 0; $i < $reps; $i++)
{
//add limit
$query_limited = $query . ' LIMIT ' . ($i * $result_limit) . ', ' . $result_limit;
// Perform re-login if required.
$this->__checkLogin();
$result = $this->doQuery($query_limited);
if (!$result)
return false;
$results = array_merge($results, $result);
}
return $results;
}
/**
* Get Result Column Names.
*/
function getResultColumns($result) {
$columns = Array();
if(!empty($result)) {
$firstrow= $result[0];
foreach($firstrow as $key=>$value) $columns[] = $key;
}
return $columns;
}
/**
* List types available Modules.
*/
function doListTypes() {
// Perform re-login if required.
$this->__checkLogin();
$getdata = Array(
'operation' => 'listtypes',
'sessionName' => $this->_sessionid
);
$resultdata = $this->_client->doGet($getdata, true);
if($this->hasError($resultdata)) {
return false;
}
$modulenames = $resultdata['result']['types'];
$returnvalue = Array();
foreach($modulenames as $modulename) {
$returnvalue[$modulename] =
Array ( 'name' => $modulename );
}
return $returnvalue;
}
/**
* Describe Module Fields.
*/
function doDescribe($module) {
// Perform re-login if required.
$this->__checkLogin();
$getdata = Array(
'operation' => 'describe',
'sessionName' => $this->_sessionid,
'elementType' => $module
);
$resultdata = $this->_client->doGet($getdata, true);
if($this->hasError($resultdata)) {
return false;
}
return $resultdata['result'];
}
/**
* Retrieve details of record.
*/
function doRetrieve($record) {
// Perform re-login if required.
$this->__checkLogin();
$getdata = Array(
'operation' => 'retrieve',
'sessionName' => $this->_sessionid,
'id' => $record
);
$resultdata = $this->_client->doGet($getdata, true);
if($this->hasError($resultdata)) {
return false;
}
return $resultdata[result];
}
/**
* Do Create Operation
*/
function doCreate($module, $valuemap) {
// Perform re-login if required.
$this->__checkLogin();
// Assign record to logged in user if not specified
if(!isset($valuemap['assigned_user_id'])) {
$valuemap['assigned_user_id'] = $this->_userid;
}
$postdata = Array(
'operation' => 'create',
'sessionName' => $this->_sessionid,
'elementType' => $module,
'element' => $this->toJSONString($valuemap)
);
$resultdata = $this->_client->doPost($postdata, true);
if($this->hasError($resultdata)) {
return false;
}
return $resultdata['result'];
}
/**
* Do CreateBulk Operation
*/
function doCreateBulk($module, $valuemaps) {
// Assign record to logged in user if not specified
foreach ($valuemaps as &$valuemap)
if(!isset($valuemap['assigned_user_id'])) {
$valuemap['assigned_user_id'] = $this->_userid;
}
$postdata = Array(
'operation' => 'create_bulk',
'sessionName' => $this->_sessionid,
'elementType' => $module,
'element' => $this->toJSONString($valuemaps)
);
// Perform re-login if required.
$this->__checkLogin();
$resultdata = $this->_client->doPost($postdata, true);
if($this->hasError($resultdata)) {
return $resultdata;
}
return $resultdata['result'];
}
/**
* Do Update Operation
*/
function doUpdate($valuemap) {
// Perform re-login if required.
$this->__checkLogin();
// Assign record to logged in user if not specified
if(!isset($valuemap['modifiedby'])) {
$valuemap['modifiedby'] = $this->_userid;
}
$postdata = Array(
'operation' => 'update',
'sessionName' => $this->_sessionid,
'element' => $this->toJSONString($valuemap)
);
$resultdata = $this->_client->doPost($postdata, true);
if($this->hasError($resultdata)) {
return false;
}
return $resultdata['result'];
}
/**
* Do UpdateBulk Operation
*/
function doUpdateBulk($module,$valuemaps) {
// Assign record to logged in user if not specified
foreach ($valuemaps as &$valuemap)
if(!isset($valuemap['modifiedby'])) {
$valuemap['modifiedby'] = $this->_userid;
}
$postdata = Array(
'operation' => 'update_bulk',
'sessionName' => $this->_sessionid,
'elementType' => $module,
'element' => $this->toJSONString($valuemaps)
);
// Perform re-login if required.
$this->__checkLogin();
$resultdata = $this->_client->doPost($postdata, true);
if($this->hasError($resultdata)) {
return false;
}
return $resultdata['result'];
}
/**
* Do Delete Operation
*/
function doDelete($id) {
// Perform re-login if required.
$this->__checkLogin();
$postdata = Array(
'operation' => 'delete',
'sessionName' => $this->_sessionid,
'id' => $id
);
$resultdata = $this->_client->doPost($postdata, true);
if($this->hasError($resultdata)) {
return false;
}
return true;
}
/**
* Invoke custom operation
*
* @param String $method Name of the webservice to invoke
* @param Object $type null or parameter values to method
* @param String $params optional (POST/GET)
*/
function doInvoke($method, $params = null, $type = 'POST') {
// Perform re-login if required
$this->__checkLogin();
$senddata = Array(
'operation' => $method,
'sessionName' => $this->_sessionid
);
if(!empty($params)) {
foreach($params as $k=>$v) {
if(!isset($senddata[$k])) {
$senddata[$k] = $v;
}
}
}
$resultdata = false;
if(strtoupper($type) == "POST") {
$resultdata = $this->_client->doPost($senddata, true);
} else {
$resultdata = $this->_client->doGet($senddata, true);
}
if($this->hasError($resultdata)) {
return false;
}
return $resultdata['result'];
}
}
?>
freenetis/branches/1.1/application/libraries/vtwsclib/Vtiger/WSVersion.php
<?php
$wsclient_version = '1.1';
?>
freenetis/branches/1.1/application/libraries/vtwsclib/third-party/Zend/Exception.php
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* @category Zend
* @package Zend
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Exception extends Exception
{}
freenetis/branches/1.1/application/libraries/vtwsclib/third-party/Zend/Json/Decoder.php
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Json
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Zend_Json
*/
require_once APPPATH.'libraries/vtwsclib/third-party/Zend/Json.php';
/**
* Zend_Json_Exception
*/
require_once APPPATH.'libraries/vtwsclib/third-party/Zend/Json/Exception.php';
/**
* Decode JSON encoded string to PHP variable constructs
*
* @category Zend
* @package Zend_Json
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Json_Decoder
{
/**
* Parse tokens used to decode the JSON object. These are not
* for public consumption, they are just used internally to the
* class.
*/
const EOF = 0;
const DATUM = 1;
const LBRACE = 2;
const LBRACKET = 3;
const RBRACE = 4;
const RBRACKET = 5;
const COMMA = 6;
const COLON = 7;
/**
* Use to maintain a "pointer" to the source being decoded
*
* @var string
*/
protected $_source;
/**
* Caches the source length
*
* @var int
*/
protected $_sourceLength;
/**
* The offset within the souce being decoded
*
* @var int
*
*/
protected $_offset;
/**
* The current token being considered in the parser cycle
*
* @var int
*/
protected $_token;
/**
* Flag indicating how objects should be decoded
*
* @var int
* @access protected
*/
protected $_decodeType;
/**
* Constructor
*
* @param string $source String source to decode
* @param int $decodeType How objects should be decoded -- see
* {@link Zend_Json::TYPE_ARRAY} and {@link Zend_Json::TYPE_OBJECT} for
* valid values
* @return void
*/
protected function __construct($source, $decodeType)
{
// Set defaults
$this->_source = $source;
$this->_sourceLength = strlen($source);
$this->_token = self::EOF;
$this->_offset = 0;
// Normalize and set $decodeType
if (!in_array($decodeType, array(Zend_Json::TYPE_ARRAY, Zend_Json::TYPE_OBJECT)))
{
$decodeType = Zend_Json::TYPE_ARRAY;
}
$this->_decodeType = $decodeType;
// Set pointer at first token
$this->_getNextToken();
}
/**
* Decode a JSON source string
*
* Decodes a JSON encoded string. The value returned will be one of the
* following:
* - integer
* - float
* - boolean
* - null
* - StdClass
* - array
* - array of one or more of the above types
*
* By default, decoded objects will be returned as associative arrays; to
* return a StdClass object instead, pass {@link Zend_Json::TYPE_OBJECT} to
* the $objectDecodeType parameter.
*
* Throws a Zend_Json_Exception if the source string is null.
*
* @static
* @access public
* @param string $source String to be decoded
* @param int $objectDecodeType How objects should be decoded; should be
* either or {@link Zend_Json::TYPE_ARRAY} or
* {@link Zend_Json::TYPE_OBJECT}; defaults to TYPE_ARRAY
* @return mixed
* @throws Zend_Json_Exception
*/
public static function decode($source = null, $objectDecodeType = Zend_Json::TYPE_ARRAY)
{
if (null === $source) {
throw new Zend_Json_Exception('Must specify JSON encoded source for decoding');
} elseif (!is_string($source)) {
throw new Zend_Json_Exception('Can only decode JSON encoded strings');
}
$decoder = new self($source, $objectDecodeType);
return $decoder->_decodeValue();
}
/**
* Recursive driving rountine for supported toplevel tops
*
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff