[Vtigercrm-commits] [vtiger-commits] r9141 - in /vtigercrm/trunk/soap: thunderbirdplugin.php vtigerolservice.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Mon Aug 28 04:30:32 EDT 2006
Author: richie
Date: Mon Aug 28 02:30:11 2006
New Revision: 9141
Log:
Security Implemented for Outlook and Thunderbird Plugin --Jeri
Modified:
vtigercrm/trunk/soap/thunderbirdplugin.php
vtigercrm/trunk/soap/vtigerolservice.php
Modified: vtigercrm/trunk/soap/thunderbirdplugin.php
==============================================================================
--- vtigercrm/trunk/soap/thunderbirdplugin.php (original)
+++ vtigercrm/trunk/soap/thunderbirdplugin.php Mon Aug 28 02:30:11 2006
@@ -1,382 +1,395 @@
-<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is: vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
-require_once("config.php");
-require_once('include/logging.php');
-require_once('include/nusoap/nusoap.php');
-require_once('include/database/PearDatabase.php');
-require_once('modules/Contacts/Contact.php');
-
-$log = &LoggerManager::getLogger('thunderbirdplugin');
-
-$accessDenied = "You are not authorized for performing this action";
-$NAMESPACE = 'http://www.vtiger.com/vtigercrm/';
-$server = new soap_server;
-
-$server->configureWSDL('vtigersoap');
-
-$server->register(
- 'create_session',
- array('user_name'=>'xsd:string','password'=>'xsd:string'),
- array('return'=>'xsd:string'),
- $NAMESPACE);
-
-$server->register(
- 'end_session',
- array('user_name'=>'xsd:string'),
- array('return'=>'xsd:string'),
- $NAMESPACE);
-
-$server->register(
- 'SearchContactsByEmail',
- array('username'=>'xsd:string','emailaddress'=>'xsd:string'),
- array('return'=>'tns:contactdetails'),
- $NAMESPACE);
-
-$server->register(
- 'GetContacts',
- array('username'=>'xsd:string'),
- array('return'=>'tns:contactdetails'),
- $NAMESPACE);
-
-$server->register(
- 'AddContact',
- array('user_name'=>'xsd:string',
- 'first_name'=>'xsd:string',
- 'last_name'=>'xsd:string',
- 'email_address'=>'xsd:string',
- 'account_name'=>'xsd:string',
- 'salutation'=>'xsd:string',
- 'title'=>'xsd:string',
- 'phone_mobile'=>'xsd:string',
- 'reports_to'=>'xsd:string',
- 'primary_address_street'=>'xsd:string',
- 'primary_address_city'=>'xsd:string',
- 'primary_address_state'=>'xsd:string' ,
- 'primary_address_postalcode'=>'xsd:string',
- 'primary_address_country'=>'xsd:string',
- 'alt_address_city'=>'xsd:string',
- 'alt_address_street'=>'xsd:string',
- 'alt_address_state'=>'xsd:string',
- 'alt_address_postalcode'=>'xsd:string',
- 'alt_address_country'=>'xsd:string',
- 'office_phone'=>'xsd:string',
- 'home_phone'=>'xsd:string',
- 'fax'=>'xsd:string',
- 'department'=>'xsd:string',
- 'description'=>'xsd:string'),
- array('return'=>'xsd:string'),
- $NAMESPACE);
-
-
-$server->register(
- 'track_email',
- array('user_name'=>'xsd:string', 'contact_ids'=>'xsd:string', 'date_sent'=>'xsd:date', 'email_subject'=>'xsd:string', 'email_body'=>'xsd:string'),
- array('return'=>'xsd:string'),
- $NAMESPACE);
-
-$server->wsdl->addComplexType(
- 'contactdetail',
- 'complexType',
- 'struct',
- 'all',
- '',
- array(
- 'id' => array('name'=>'id','type'=>'xsd:string'),
- 'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
- 'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
- 'emailaddress' => array('name'=>'emailaddress','type'=>'xsd:string'),
- 'accountname' => array('name'=>'accountname','type'=>'xsd:string'),
- 'middlename' => array('name'=>'middlename','type'=>'xsd:string'),
- 'birthdate'=> array('name'=>'birthdate','type'=>'xsd:string'),
- 'jobtitle'=> array('name'=>'jobtitle','type'=>'xsd:string'),
- 'department'=> array('name'=>'department','type'=>'xsd:string'),
- 'title' => array('name'=>'title','type'=>'xsd:string'),
- 'officephone'=> array('name'=>'officephone','type'=>'xsd:string'),
- 'homephone'=> array('name'=>'homephone','type'=>'xsd:string'),
- 'otherphone'=> array('name'=>'otherphone','type'=>'xsd:string'),
- 'fax'=> array('name'=>'fax','type'=>'xsd:string'),
- 'mobile'=> array('name'=>'mobile','type'=>'xsd:string'),
- 'asstname'=> array('name'=>'asstname','type'=>'xsd:string'),
- 'asstphone'=> array('name'=>'asstphone','type'=>'xsd:string'),
- 'reportsto'=> array('name'=>'reportsto','type'=>'xsd:string'),
- 'mailingstreet'=> array('name'=>'mailingstreet','type'=>'xsd:string'),
- 'mailingcity'=> array('name'=>'mailingcity','type'=>'xsd:string'),
- 'mailingstate'=> array('name'=>'mailingstate','type'=>'xsd:string'),
- 'mailingzip'=> array('name'=>'mailingzip','type'=>'xsd:string'),
- 'mailingcountry'=> array('name'=>'mailingcountry','type'=>'xsd:string'),
- 'otherstreet'=> array('name'=>'otherstreet','type'=>'xsd:string'),
- 'othercity'=> array('name'=>'othercity','type'=>'xsd:string'),
- 'otherstate'=> array('name'=>'otherstate','type'=>'xsd:string'),
- 'otherzip'=> array('name'=>'otherzip','type'=>'xsd:string'),
- 'othercountry'=> array('name'=>'othercountry','type'=>'xsd:string'),
- 'description'=> array('name'=>'description','type'=>'xsd:string'),
- 'category'=> array('name'=>'category','type'=>'xsd:string'),
- )
-);
-
-$server->wsdl->addComplexType(
- 'contactdetails',
- 'complexType',
- 'array',
- '',
- 'SOAP-ENC:Array',
- array(),
- array(
- array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:contactdetail[]')
- ),
- 'tns:contactdetail'
-);
-
-
-function SearchContactsByEmail($username,$emailaddress)
-{
- require_once('modules/Contacts/Contact.php');
-
- $seed_contact = new Contact();
- $output_list = Array();
-
- $response = $seed_contact->get_searchbyemailid($username,$emailaddress);
- $contactList = $response['list'];
-
- // create a return array of names and email addresses.
- foreach($contactList as $contact)
- {
- $output_list[] = Array(
- "id" => $contact[id],
- "firstname" => $contact[first_name],
- "lastname" => $contact[last_name],
- "emailaddress" => $contact[email1],
- "accountname" => $contact[account_name],
- );
- }
-
- //to remove an erroneous compiler warning
- $seed_contact = $seed_contact;
- return $output_list;
-}
-
-function track_email($user_name, $contact_ids, $date_sent, $email_subject, $email_body)
-{
- global $adb;
- require_once('modules/Users/User.php');
- require_once('modules/Emails/Email.php');
-
- $seed_user = new User();
- $user_id = $seed_user->retrieve_user_id($user_name);
-
- $email = new Email();
- //$log->debug($msgdtls['contactid']);
- $emailbody = str_replace("'", "''", $email_body);
- $emailsubject = str_replace("'", "''",$email_subject);
- $datesent = getDisplayDate($date_sent);
-
- $email->column_fields[subject] = $emailsubject;
- $email->column_fields[assigned_user_id] = $user_id;
- $email->column_fields[date_start] = $datesent;
- $email->column_fields[description] = htmlentities($emailbody);
- $email->column_fields[activitytype] = 'Emails';
- $email->save("Emails");
-
- $email->set_emails_contact_invitee_relationship($email->id,$contact_ids);
- $email->set_emails_se_invitee_relationship($email->id,$contact_ids);
- $email->set_emails_user_invitee_relationship($email->id,$user_id);
- $sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contact_ids."'";
- $result = $adb->query($sql);
- $camodulerow = $adb->fetch_array($result);
- if(isset($camodulerow))
- {
- $emailid = $camodulerow["email"];
- $query = 'insert into vtiger_emaildetails values ('.$email->id.',"","'.$emailid.'","","","","'.$contact_ids."@77|".'","OUTLOOK")';
- $adb->query($query);
- }
- return $email->id;
-}
-
-
-function GetContacts($username)
-{
- global $adb;
- global $log;
- require_once('modules/Contacts/Contact.php');
-
- $seed_contact = new Contact();
- $output_list = Array();
-
- $query = $seed_contact->get_contactsforol($username);
- $result = $adb->query($query);
-
- while($contact = $adb->fetch_array($result))
- {
- if($contact["birthdate"] == "0000-00-00")
- {
- $contact["birthdate"] = "";
- }
- if($contact["salutation"] == "--None--")
- {
- $contact["salutation"] = "";
- }
-
- $namelist = explode(" ", $contact["last_name"]);
- if(isset($namelist))
- {
- if(count($namelist) >= 2)
- {
- $contact["last_name"] = $namelist[count($namelist)-1];
- for($i=0; $i<count($namelist)-2; $i++)
- {
- $middlename[] = $namelist[$i];
- }
- if(isset($middlename))
- {
- $middlename = implode(" ",$middlename);
- }
- }
- }
-
- $output_list[] = Array(
- "id" => $contact["id"],
- "title" => $contact["salutation"],
- "firstname" => $contact["first_name"],
- "middlename" => trim($middlename),
- "lastname" => trim($contact["last_name"]),
- "birthdate" => $contact["birthdate"],
- "emailaddress" => $contact["email"],
- "jobtitle" => $contact["title"],
- "department" => $contact["department"],
- "accountname" => $contact["account_name"],
- "officephone" => $contact["phone"],
- "homephone" => $contact["homephone"],
- "otherphone" => $contact["otherphone"],
- "fax" => $contact["fax"],
- "mobile" => $contact["mobile"],
- "asstname" => $contact["assistant_name"],
- "asstphone" => $contact["assistantphone"],
- "reportsto" => $contact["reports_to_name"],
- "mailingstreet" => $contact["mailingstreet"],
- "mailingcity" => $contact["mailingcity"],
- "mailingstate" => $contact["mailingstate"],
- "mailingzip" => $contact["mailingzip"],
- "mailingcountry" => $contact["mailingcountry"],
- "otherstreet" => $contact["otherstreet"],
- "othercity" => $contact["othercity"],
- "otherstate" => $contact["otherstate"],
- "otherzip" => $contact["otherzip"],
- "othercountry" => $contact["othercountry"],
- "description" => "",
- "category" => "",
- );
- }
- $log->debug("*******************");
- $log->fatal($output_list);
-
- //to remove an erroneous compiler warning
- $seed_contact = $seed_contact;
- return $output_list;
-}
-
-function retrieve_account_id($account_name,$user_id)
-{
-
- if($account_name=="")
- {
- return null;
- }
-
- $query = "select vtiger_account.accountname accountname,vtiger_account.accountid accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .$account_name."'";
-
-
- $db = new PearDatabase();
- $result= $db->query($query) or die ("Not able to execute insert");
-
- $rows_count = $db->getRowCount($result);
- if($rows_count==0)
- {
- require_once('modules/Accounts/Account.php');
- $account = new Account();
- $account->column_fields[accountname] = $account_name;
- $account->column_fields[assigned_user_id]=$user_id;
- //$account->saveentity("Accounts");
- $account->save("Accounts");
- //mysql_close();
- return $account->id;
- }
- else if ($rows_count==1)
- {
- $row = $db->fetchByAssoc($result, 0);
- //mysql_close();
- return $row["accountid"];
- }
- else
- {
- $row = $db->fetchByAssoc($result, 0);
- //mysql_close();
- return $row["accountid"];
- }
-
-}
-
-function AddContact($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country,$alt_address_city,$alt_address_street,$alt_address_state,$alt_address_postalcode,$alt_address_country,$office_phone="",$home_phone="",$fax="",$department="",$description="")
-{
- global $adb;
- global $current_user;
- require_once('modules/Users/User.php');
- require_once('modules/Contacts/Contact.php');
-
- $seed_user = new User();
- $user_id = $seed_user->retrieve_user_id($user_name);
- $current_user = $seed_user;
- $current_user->retrieve_entity_info($user_id,"Users");
-
- $contact = new Contact();
- $contact->column_fields[firstname]=$first_name;
- $contact->column_fields[lastname]=$last_name;
- $contact->column_fields[birthday]= getDisplayDate("0000-00-00");
- $contact->column_fields[email]=$email_address;
- $contact->column_fields[title]=$title;
- $contact->column_fields[department]=$department;
- $contact->column_fields[account_id]= retrieve_account_id($account_name,$user_id);
- $contact->column_fields[phone]= $office_phone;
- $contact->column_fields[homephone]= $home_phone;
- $contact->column_fields[fax]= $fax;
- $contact->column_fields[mobile]=$phone_mobile;
- $contact->column_fields[mailingstreet]=$primary_address_street;
- $contact->column_fields[mailingcity]=$primary_address_city;
- $contact->column_fields[mailingstate]=$primary_address_state;
- $contact->column_fields[mailingzip]=$primary_address_postalcode;
- $contact->column_fields[mailingcountry]=$primary_address_country;
- $contact->column_fields[otherstreet]=$alt_address_street;
- $contact->column_fields[othercity]=$alt_address_city;
- $contact->column_fields[otherstate]=$alt_address_state;
- $contact->column_fields[otherzip]=$alt_address_postalcode;
- $contact->column_fields[othercountry]=$alt_address_country;
- $contact->column_fields[assigned_user_id]=$user_id;
- $contact->column_fields[description]= "";
- $contact->save("Contacts");
-
- $contact = $contact;
- return $contact->id;
-}
-
-function create_session($user_name, $password)
-{
- return "TempSessionID";
-}
-
-function end_session($user_name)
-{
- return "Success";
-}
-
-
-$server->service($HTTP_RAW_POST_DATA);
-exit();
-?>
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is: vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+require_once("config.php");
+require_once('include/logging.php');
+require_once('include/nusoap/nusoap.php');
+require_once('include/database/PearDatabase.php');
+require_once('modules/Contacts/Contact.php');
+
+$log = &LoggerManager::getLogger('thunderbirdplugin');
+
+$accessDenied = "You are not authorized for performing this action";
+$NAMESPACE = 'http://www.vtiger.com/vtigercrm/';
+$server = new soap_server;
+
+$server->configureWSDL('vtigersoap');
+
+$server->register(
+ 'create_session',
+ array('user_name'=>'xsd:string','password'=>'xsd:string'),
+ array('return'=>'xsd:string'),
+ $NAMESPACE);
+
+$server->register(
+ 'end_session',
+ array('user_name'=>'xsd:string'),
+ array('return'=>'xsd:string'),
+ $NAMESPACE);
+
+$server->register(
+ 'SearchContactsByEmail',
+ array('username'=>'xsd:string','emailaddress'=>'xsd:string'),
+ array('return'=>'tns:contactdetails'),
+ $NAMESPACE);
+
+$server->register(
+ 'GetContacts',
+ array('username'=>'xsd:string'),
+ array('return'=>'tns:contactdetails'),
+ $NAMESPACE);
+
+$server->register(
+ 'AddContact',
+ array('user_name'=>'xsd:string',
+ 'first_name'=>'xsd:string',
+ 'last_name'=>'xsd:string',
+ 'email_address'=>'xsd:string',
+ 'account_name'=>'xsd:string',
+ 'salutation'=>'xsd:string',
+ 'title'=>'xsd:string',
+ 'phone_mobile'=>'xsd:string',
+ 'reports_to'=>'xsd:string',
+ 'primary_address_street'=>'xsd:string',
+ 'primary_address_city'=>'xsd:string',
+ 'primary_address_state'=>'xsd:string' ,
+ 'primary_address_postalcode'=>'xsd:string',
+ 'primary_address_country'=>'xsd:string',
+ 'alt_address_city'=>'xsd:string',
+ 'alt_address_street'=>'xsd:string',
+ 'alt_address_state'=>'xsd:string',
+ 'alt_address_postalcode'=>'xsd:string',
+ 'alt_address_country'=>'xsd:string',
+ 'office_phone'=>'xsd:string',
+ 'home_phone'=>'xsd:string',
+ 'fax'=>'xsd:string',
+ 'department'=>'xsd:string',
+ 'description'=>'xsd:string'),
+ array('return'=>'xsd:string'),
+ $NAMESPACE);
+
+
+$server->register(
+ 'track_email',
+ array('user_name'=>'xsd:string', 'contact_ids'=>'xsd:string', 'date_sent'=>'xsd:date', 'email_subject'=>'xsd:string', 'email_body'=>'xsd:string'),
+ array('return'=>'xsd:string'),
+ $NAMESPACE);
+
+$server->wsdl->addComplexType(
+ 'contactdetail',
+ 'complexType',
+ 'struct',
+ 'all',
+ '',
+ array(
+ 'id' => array('name'=>'id','type'=>'xsd:string'),
+ 'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
+ 'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
+ 'emailaddress' => array('name'=>'emailaddress','type'=>'xsd:string'),
+ 'accountname' => array('name'=>'accountname','type'=>'xsd:string'),
+ 'middlename' => array('name'=>'middlename','type'=>'xsd:string'),
+ 'birthdate'=> array('name'=>'birthdate','type'=>'xsd:string'),
+ 'jobtitle'=> array('name'=>'jobtitle','type'=>'xsd:string'),
+ 'department'=> array('name'=>'department','type'=>'xsd:string'),
+ 'title' => array('name'=>'title','type'=>'xsd:string'),
+ 'officephone'=> array('name'=>'officephone','type'=>'xsd:string'),
+ 'homephone'=> array('name'=>'homephone','type'=>'xsd:string'),
+ 'otherphone'=> array('name'=>'otherphone','type'=>'xsd:string'),
+ 'fax'=> array('name'=>'fax','type'=>'xsd:string'),
+ 'mobile'=> array('name'=>'mobile','type'=>'xsd:string'),
+ 'asstname'=> array('name'=>'asstname','type'=>'xsd:string'),
+ 'asstphone'=> array('name'=>'asstphone','type'=>'xsd:string'),
+ 'reportsto'=> array('name'=>'reportsto','type'=>'xsd:string'),
+ 'mailingstreet'=> array('name'=>'mailingstreet','type'=>'xsd:string'),
+ 'mailingcity'=> array('name'=>'mailingcity','type'=>'xsd:string'),
+ 'mailingstate'=> array('name'=>'mailingstate','type'=>'xsd:string'),
+ 'mailingzip'=> array('name'=>'mailingzip','type'=>'xsd:string'),
+ 'mailingcountry'=> array('name'=>'mailingcountry','type'=>'xsd:string'),
+ 'otherstreet'=> array('name'=>'otherstreet','type'=>'xsd:string'),
+ 'othercity'=> array('name'=>'othercity','type'=>'xsd:string'),
+ 'otherstate'=> array('name'=>'otherstate','type'=>'xsd:string'),
+ 'otherzip'=> array('name'=>'otherzip','type'=>'xsd:string'),
+ 'othercountry'=> array('name'=>'othercountry','type'=>'xsd:string'),
+ 'description'=> array('name'=>'description','type'=>'xsd:string'),
+ 'category'=> array('name'=>'category','type'=>'xsd:string'),
+ )
+);
+
+$server->wsdl->addComplexType(
+ 'contactdetails',
+ 'complexType',
+ 'array',
+ '',
+ 'SOAP-ENC:Array',
+ array(),
+ array(
+ array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:contactdetail[]')
+ ),
+ 'tns:contactdetail'
+);
+
+
+function SearchContactsByEmail($username,$emailaddress)
+{
+ require_once('modules/Contacts/Contact.php');
+
+ $seed_contact = new Contact();
+ $output_list = Array();
+
+ $response = $seed_contact->get_searchbyemailid($username,$emailaddress);
+ $contactList = $response['list'];
+
+ // create a return array of names and email addresses.
+ foreach($contactList as $contact)
+ {
+ $output_list[] = Array(
+ "id" => $contact[contactid],
+ "firstname" => $contact[firstname],
+ "lastname" => $contact[lastname],
+ "emailaddress" => $contact[email],
+ "accountname" => $contact[accountname],
+ );
+ }
+
+ //to remove an erroneous compiler warning
+ $seed_contact = $seed_contact;
+ return $output_list;
+}
+
+function track_email($user_name, $contact_ids, $date_sent, $email_subject, $email_body)
+{
+ global $adb;
+ require_once('modules/Users/User.php');
+ require_once('modules/Emails/Email.php');
+
+ $seed_user = new User();
+ $user_id = $seed_user->retrieve_user_id($user_name);
+
+ $email = new Email();
+ //$log->debug($msgdtls['contactid']);
+ $emailbody = str_replace("'", "''", $email_body);
+ $emailsubject = str_replace("'", "''",$email_subject);
+ $datesent = getDisplayDate($date_sent);
+
+ $email->column_fields[subject] = $emailsubject;
+ $email->column_fields[assigned_user_id] = $user_id;
+ $email->column_fields[date_start] = $datesent;
+ $email->column_fields[description] = htmlentities($emailbody);
+ $email->column_fields[activitytype] = 'Emails';
+ $email->save("Emails");
+
+ $email->set_emails_contact_invitee_relationship($email->id,$contact_ids);
+ $email->set_emails_se_invitee_relationship($email->id,$contact_ids);
+ $email->set_emails_user_invitee_relationship($email->id,$user_id);
+ $sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contact_ids."'";
+ $result = $adb->query($sql);
+ $camodulerow = $adb->fetch_array($result);
+ if(isset($camodulerow))
+ {
+ $emailid = $camodulerow["email"];
+ $query = 'insert into vtiger_emaildetails values ('.$email->id.',"","'.$emailid.'","","","","'.$contact_ids."@77|".'","OUTLOOK")';
+ $adb->query($query);
+ }
+ return $email->id;
+}
+
+
+function GetContacts($username)
+{
+ global $adb;
+ global $log;
+ require_once('modules/Contacts/Contact.php');
+
+ $seed_contact = new Contact();
+ $output_list = Array();
+
+ $query = $seed_contact->get_contactsforol($username);
+ $result = $adb->query($query);
+
+ while($contact = $adb->fetch_array($result))
+ {
+ if($contact["birthdate"] == "0000-00-00")
+ {
+ $contact["birthdate"] = "";
+ }
+ if($contact["salutation"] == "--None--")
+ {
+ $contact["salutation"] = "";
+ }
+
+ $namelist = explode(" ", $contact["lastname"]);
+ if(isset($namelist))
+ {
+ if(count($namelist) >= 2)
+ {
+ $contact["lastname"] = $namelist[count($namelist)-1];
+ for($i=0; $i<count($namelist)-2; $i++)
+ {
+ $middlename[] = $namelist[$i];
+ }
+ if(isset($middlename))
+ {
+ $middlename = implode(" ",$middlename);
+ }
+ }
+ }
+
+ $output_list[] = Array(
+ "id" => $contact["id"],
+ "title" => $contact["salutation"],
+ "firstname" => $contact["firstname"],
+ "middlename" => trim($middlename),
+ "lastname" => trim($contact["lastname"]),
+ "birthdate" => $contact["birthday"],
+ "emailaddress" => $contact["email"],
+ "jobtitle" => $contact["title"],
+ "department" => $contact["department"],
+ "accountname" => $contact["accountname"],
+ "officephone" => $contact["phone"],
+ "homephone" => $contact["homephone"],
+ "otherphone" => $contact["otherphone"],
+ "fax" => $contact["fax"],
+ "mobile" => $contact["mobile"],
+ "asstname" => $contact["assistant"],
+ "asstphone" => $contact["assistantphone"],
+ "reportsto" => $contact["reports_to_name"],
+ "mailingstreet" => $contact["mailingstreet"],
+ "mailingcity" => $contact["mailingcity"],
+ "mailingstate" => $contact["mailingstate"],
+ "mailingzip" => $contact["mailingzip"],
+ "mailingcountry" => $contact["mailingcountry"],
+ "otherstreet" => $contact["otherstreet"],
+ "othercity" => $contact["othercity"],
+ "otherstate" => $contact["otherstate"],
+ "otherzip" => $contact["otherzip"],
+ "othercountry" => $contact["othercountry"],
+ "description" => "",
+ "category" => "",
+ );
+ }
+ //to remove an erroneous compiler warning
+ $seed_contact = $seed_contact;
+ return $output_list;
+}
+
+function retrieve_account_id($account_name,$user_id)
+{
+
+ if($account_name=="")
+ {
+ return null;
+ }
+
+ $query = "select vtiger_account.accountname accountname,vtiger_account.accountid accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .$account_name."'";
+
+
+ $db = new PearDatabase();
+ $result= $db->query($query) or die ("Not able to execute insert");
+
+ $rows_count = $db->getRowCount($result);
+ if($rows_count==0)
+ {
+ require_once('modules/Accounts/Account.php');
+ $account = new Account();
+ $account->column_fields[accountname] = $account_name;
+ $account->column_fields[assigned_user_id]=$user_id;
+ //$account->saveentity("Accounts");
+ $account->save("Accounts");
+ //mysql_close();
+ return $account->id;
+ }
+ else if ($rows_count==1)
+ {
+ $row = $db->fetchByAssoc($result, 0);
+ //mysql_close();
+ return $row["accountid"];
+ }
+ else
+ {
+ $row = $db->fetchByAssoc($result, 0);
+ //mysql_close();
+ return $row["accountid"];
+ }
+
+}
+
+function AddContact($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country,$alt_address_city,$alt_address_street,$alt_address_state,$alt_address_postalcode,$alt_address_country,$office_phone="",$home_phone="",$fax="",$department="",$description="")
+{
+ global $adb;
+ global $current_user;
+ require_once('modules/Users/User.php');
+ require_once('modules/Contacts/Contact.php');
+
+ $seed_user = new User();
+ $user_id = $seed_user->retrieve_user_id($user_name);
+ $current_user = $seed_user;
+ $current_user->retrieve_entity_info($user_id,"Users");
+ require('user_privileges/user_privileges_'.$current_user->id.'.php');
+ require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+ if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+ {
+ $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and block <> 5";
+ }else
+ {
+ $profileList = getCurrentUserProfileList();
+ $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+ }
+ $result1 = $adb->query($sql1);
+ for($i=0;$i < $adb->num_rows($result1);$i++)
+ {
+ $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+ }
+
+ $contact = new Contact();
+ $contact->column_fields[firstname]=in_array('salutation',$permitted_lists) ? $first_name : "";
+ $contact->column_fields[lastname]=in_array('lastname',$permitted_lists) ? $last_name : "";
+ $contact->column_fields[birthday]=in_array('birthday',$permitted_lists) ? getDisplayDate("0000-00-00") : "";
+ $contact->column_fields[email]=in_array('email',$permitted_lists) ? $email_address : "";
+ $contact->column_fields[title]=in_array('title',$permitted_lists) ? $title : "";
+ $contact->column_fields[department]=in_array('department',$permitted_lists) ? $department : "";
+ $contact->column_fields[account_id]=in_array('account_id',$permitted_lists) ? retrieve_account_id($account_name,$user_id) : "";
+ $contact->column_fields[phone]=in_array('phone',$permitted_lists) ? $office_phone : "";
+ $contact->column_fields[homephone]=in_array('homephone',$permitted_lists) ? $home_phone : "";
+ $contact->column_fields[fax]=in_array('fax',$permitted_lists) ? $fax : "";
+ $contact->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $phone_mobile : "";
+ $contact->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $primary_address_street : "";
+ $contact->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $primary_address_city : "";
+ $contact->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $primary_address_state : "";
+ $contact->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $primary_address_postalcode : "";
+ $contact->column_fields[mailingcountry]=in_array('mailingcountry',$permitted_lists) ? $primary_address_country : "";
+ $contact->column_fields[otherstreet]=in_array('otherstreet',$permitted_lists) ? $alt_address_street : "";
+ $contact->column_fields[othercity]=in_array('othercity',$permitted_lists) ? $alt_address_city : "";
+ $contact->column_fields[otherstate]=in_array('otherstate',$permitted_lists) ? $alt_address_state : "";
+ $contact->column_fields[otherzip]=in_array('otherzip',$permitted_lists) ? $alt_address_postalcode : "";
+ $contact->column_fields[othercountry]=in_array('othercountry',$permitted_lists) ? $alt_address_country : "";
+ $contact->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
+ $contact->column_fields[description]= "";
+ $contact->save("Contacts");
+
+ $contact = $contact;
+ return $contact->id;
+}
+
+function create_session($user_name, $password)
+{
+ return "TempSessionID";
+}
+
+function end_session($user_name)
+{
+ return "Success";
+}
+
+
+$server->service($HTTP_RAW_POST_DATA);
+exit();
+?>
Modified: vtigercrm/trunk/soap/vtigerolservice.php
==============================================================================
--- vtigercrm/trunk/soap/vtigerolservice.php (original)
+++ vtigercrm/trunk/soap/vtigerolservice.php Mon Aug 28 02:30:11 2006
@@ -292,11 +292,11 @@
foreach($contactList as $contact)
{
$output_list[] = Array(
- "id" => $contact[id],
- "firstname" => $contact[first_name],
- "lastname" => $contact[last_name],
- "accountname" => $contact[account_name],
- "emailaddress" => $contact[email1],
+ "id" => $contact[contactid],
+ "firstname" => $contact[firstname],
+ "lastname" => $contact[lastname],
+ "accountname" => $contact[accountname],
+ "emailaddress" => $contact[email],
);
}
@@ -316,35 +316,35 @@
foreach($msgdtls as $msgdtl)
{
- if(isset($msgdtl))
- {
- $email = new Email();
- //$log->debug($msgdtls['contactid']);
- $email_body = str_replace("'", "''", $msgdtl['body']);
- $email_subject = str_replace("'", "''",$msgdtl['subject']);
- $date_sent = getDisplayDate($msgdtl['datesent']);
-
- $email->column_fields[subject] = $email_subject;
- $email->column_fields[assigned_user_id] = $user_id;
- $email->column_fields[date_start] = $date_sent;
- $email->column_fields[description] = htmlentities($email_body);
- $email->column_fields[activitytype] = 'Emails';
- $email->plugin_save = true;
- $email->save("Emails");
-
- $email->set_emails_contact_invitee_relationship($email->id,$contactid);
- $email->set_emails_se_invitee_relationship($email->id,$contactid);
- $email->set_emails_user_invitee_relationship($email->id,$user_id);
- $sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contactid."'";
- $result = $adb->query($sql);
- $camodulerow = $adb->fetch_array($result);
- if(isset($camodulerow))
- {
- $emailid = $camodulerow["email"];
- $query = 'insert into vtiger_emaildetails values ('.$email->id.',"","'.$emailid.'","","","","'.$contactid."@77|".'","OUTLOOK")';
- $adb->query($query);
- }
- return $email->id;
+ if(isset($msgdtl))
+ {
+ $email = new Email();
+ //$log->debug($msgdtls['contactid']);
+ $email_body = str_replace("'", "''", $msgdtl['body']);
+ $email_subject = str_replace("'", "''",$msgdtl['subject']);
+ $date_sent = getDisplayDate($msgdtl['datesent']);
+
+ $email->column_fields[subject] = $email_subject;
+ $email->column_fields[assigned_user_id] = $user_id;
+ $email->column_fields[date_start] = $date_sent;
+ $email->column_fields[description] = htmlentities($email_body);
+ $email->column_fields[activitytype] = 'Emails';
+ $email->plugin_save = true;
+ $email->save("Emails");
+
+ $email->set_emails_contact_invitee_relationship($email->id,$contactid);
+ $email->set_emails_se_invitee_relationship($email->id,$contactid);
+ $email->set_emails_user_invitee_relationship($email->id,$user_id);
+ $sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contactid."'";
+ $result = $adb->query($sql);
+ $camodulerow = $adb->fetch_array($result);
+ if(isset($camodulerow))
+ {
+ $emailid = $camodulerow["email"];
+ $query = 'insert into vtiger_emaildetails values ('.$email->id.',"","'.$emailid.'","","","","'.$contactid."@77|".'","OUTLOOK")';
+ $adb->query($query);
+ }
+ return $email->id;
}
else
{
@@ -409,7 +409,7 @@
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
- if(isPermitted("Contacts","EditView") == "yes")
+ if(isPermitted("Contacts","Delete") == "yes")
{
return "allowed";
}else
@@ -427,7 +427,7 @@
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
- if(isPermitted("Calendar","EditView") == "yes")
+ if(isPermitted("Calendar","Delete") == "yes")
{
return "allowed";
}else
@@ -502,12 +502,12 @@
$contact["salutation"] = "";
}
- $namelist = explode(" ", $contact["last_name"]);
+ $namelist = explode(" ", $contact["lastname"]);
if(isset($namelist))
{
if(count($namelist) >= 2)
{
- $contact["last_name"] = $namelist[count($namelist)-1];
+ $contact["lastname"] = $namelist[count($namelist)-1];
for($i=0; $i<count($namelist)-2; $i++)
{
$middlename[] = $namelist[$i];
@@ -522,20 +522,20 @@
$output_list[] = Array(
"id" => $contact["id"],
"title" => $contact["salutation"],
- "firstname" => $contact["first_name"],
+ "firstname" => $contact["firstname"],
"middlename" => trim($middlename),
- "lastname" => trim($contact["last_name"]),
- "birthdate" => $contact["birthdate"],
+ "lastname" => trim($contact["lastname"]),
+ "birthdate" => $contact["birthday"],
"emailaddress" => $contact["email"],
"jobtitle" => $contact["title"],
"department" => $contact["department"],
- "accountname" => $contact["account_name"],
+ "accountname" => $contact["accountname"],
"officephone" => $contact["phone"],
"homephone" => $contact["homephone"],
"otherphone" => $contact["otherphone"],
"fax" => $contact["fax"],
"mobile" => $contact["mobile"],
- "asstname" => $contact["assistant_name"],
+ "asstname" => $contact["assistant"],
"asstphone" => $contact["assistantphone"],
"reportsto" => $contact["reports_to_name"],
"mailingstreet" => $contact["mailingstreet"],
@@ -550,7 +550,7 @@
"othercountry" => $contact["othercountry"],
"description" => "",
"category" => "",
- );
+ );
}
//to remove an erroneous compiler warning
@@ -572,48 +572,69 @@
$contact = new Contact();
+ require('user_privileges/user_privileges_'.$current_user->id.'.php');
+ require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+ if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+ {
+ $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and block <> 5";
+ }else
+ {
+ $profileList = getCurrentUserProfileList();
+ $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+ }
+ $result1 = $adb->query($sql1);
+ for($i=0;$i < $adb->num_rows($result1);$i++)
+ {
+ $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+ }
+
foreach($cntdtls as $cntrow)
{
if(isset($cntrow))
{
- $contact->column_fields[salutation]=$cntrow["title"];
- $contact->column_fields[firstname]=$cntrow["firstname"];
-
- if($cntrow["middlename"] != "")
- {
- $contact->column_fields[lastname]=$cntrow["middlename"]." ".$cntrow["lastname"];
- }else
- {
- $contact->column_fields[lastname]=$cntrow["lastname"];
- }
-
- $contact->column_fields[birthday]= getDisplayDate($cntrow["birthdate"]);
- $contact->column_fields[email]=$cntrow["emailaddress"];
- $contact->column_fields[title]=$cntrow["jobtitle"];
- $contact->column_fields[department]=$cntrow["department"];
- $contact->column_fields[account_id]= retrieve_account_id($cntrow["accountname"],$user_id);
- $contact->column_fields[phone]= $cntrow["officephone"];
- $contact->column_fields[homephone]= $cntrow["homephone"];
- $contact->column_fields[otherphone]= $cntrow["otherphone"];
- $contact->column_fields[fax]= $cntrow["fax"];
- $contact->column_fields[mobile]=$cntrow["mobile"];
- $contact->column_fields[assistant]= $cntrow["asstname"];
- $contact->column_fields[assistantphone]= $cntrow["asstphone"];
- //$contact->column_fields[reports_to_id] =retrievereportsto($reportsto,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP
- $contact->column_fields[mailingstreet]=$cntrow["mailingstreet"];
- $contact->column_fields[mailingcity]=$cntrow["mailingcity"];
- $contact->column_fields[mailingstate]=$cntrow["mailingstate"];
- $contact->column_fields[mailingzip]=$cntrow["mailingzip"];
- $contact->column_fields[mailingcountry]=$cntrow["mailingcountry"];
- $contact->column_fields[otherstreet]=$cntrow["otherstreet"];
- $contact->column_fields[othercity]=$cntrow["othercity"];
- $contact->column_fields[otherstate]=$cntrow["otherstate"];
- $contact->column_fields[otherzip]=$cntrow["otherzip"];
- $contact->column_fields[othercountry]=$cntrow["othercountry"];
- $contact->column_fields[assigned_user_id]=$user_id;
- $contact->column_fields[description]= $cntrow["description"];
- $contact->save("Contacts");
- }
+ $contact->column_fields[salutation]=in_array('salutation',$permitted_lists) ? $cntrow["title"] : "";
+ $contact->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $cntrow["firstname"] : "";
+
+ if($cntrow["middlename"] != "")
+ {
+ $contact->column_fields[lastname]=$cntrow["middlename"]." ".$cntrow["lastname"];
+ }elseif($cntrow["middlename"] != "")
+ {
+ $contact->column_fields[lastname]=$cntrow["lastname"];
+ }else
+ {
+ $contact->column_fields[lastname]=$cntrow["firstname"]." ".$cntrow["middlename"]." ".$cntrow["lastname"];
+ }
+
+ $contact->column_fields[birthday]= in_array('birthday',$permitted_lists) ? getDisplayDate($cntrow["birthdate"]) : "";
+ $contact->column_fields[email]=in_array('email',$permitted_lists) ? $cntrow["emailaddress"] : "";
+ $contact->column_fields[title]=in_array('title',$permitted_lists) ? $cntrow["jobtitle"] : "";
+ $contact->column_fields[department]=in_array('department',$permitted_lists) ? $cntrow["department"] : "";
+ $contact->column_fields[account_id]= in_array('account_id',$permitted_lists) ? retrieve_account_id($cntrow["accountname"],$user_id) : "";
+ $contact->column_fields[phone]= in_array('phone',$permitted_lists) ? $cntrow["officephone"] : "";
+ $contact->column_fields[homephone]= in_array('homephone',$permitted_lists) ? $cntrow["homephone"] : "";
+ $contact->column_fields[otherphone]= in_array('otherphone',$permitted_lists) ? $cntrow["otherphone"] : "";
+ $contact->column_fields[fax]= in_array('fax',$permitted_lists) ? $cntrow["fax"] : "";
+ $contact->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $cntrow["mobile"] : "";
+ $contact->column_fields[assistant]= in_array('assistant',$permitted_lists) ? $cntrow["asstname"] : "";
+ $contact->column_fields[assistantphone]= in_array('assistantphone',$permitted_lists) ? $cntrow["asstphone"] : "";
+ //$contact->column_fields[reports_to_id] =retrievereportsto($reportsto,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP
+ $contact->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $cntrow["mailingstreet"] : "";
+ $contact->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $cntrow["mailingcity"] : "";
+ $contact->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $cntrow["mailingstate"] : "";
+ $contact->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $cntrow["mailingzip"] : "";
+ $contact->column_fields[mailingcountry]=in_array('mailingcountry',$permitted_lists) ? $cntrow["mailingcountry"] : "";
+ $contact->column_fields[otherstreet]=in_array('otherstreet',$permitted_lists) ? $cntrow["otherstreet"] : "";
+ $contact->column_fields[othercity]=in_array('othercity',$permitted_lists) ? $cntrow["othercity"] : "";
+ $contact->column_fields[otherstate]=in_array('otherstate',$permitted_lists) ? $cntrow["otherstate"] : "";
+ $contact->column_fields[otherzip]=in_array('otherzip',$permitted_lists) ? $cntrow["otherzip"] : "";
+ $contact->column_fields[othercountry]=in_array('othercountry',$permitted_lists) ? $cntrow["othercountry"] : "";
+ $contact->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
+ $contact->column_fields[description]= in_array('description',$permitted_lists) ? $cntrow["description"] : "";
+ $contact->save("Contacts");
+
+ }
}
$contact = $contact;
return $contact->id;
@@ -632,46 +653,66 @@
$current_user->retrieve_entity_info($user_id,"Users");
$contact = new Contact();
+ require('user_privileges/user_privileges_'.$current_user->id.'.php');
+ require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+ if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+ {
+ $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and block <> 5";
+ }else
+ {
+ $profileList = getCurrentUserProfileList();
+ $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+ }
+ $result1 = $adb->query($sql1);
+ for($i=0;$i < $adb->num_rows($result1);$i++)
+ {
+ $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+ }
foreach($cntdtls as $cntrow)
{
if(isset($cntrow))
{
$contact->retrieve_entity_info($cntrow["id"],"Contacts");
- $contact->column_fields[salutation]=$cntrow["title"];
- $contact->column_fields[firstname]=$cntrow["firstname"];
+ $contact->column_fields[salutation]=in_array('salutation',$permitted_lists) ? $cntrow["title"] : "";
+ $contact->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $cntrow["firstname"] : "";
if($cntrow["middlename"] != "")
{
$contact->column_fields[lastname]=$cntrow["middlename"]." ".$cntrow["lastname"];
+ }elseif($cntrow["lastname"] != "")
+ {
+ $contact->column_fields[lastname]=$cntrow["lastname"];
}else
{
- $contact->column_fields[lastname]=$cntrow["lastname"];
- }
- $contact->column_fields[birthday]= getDisplayDate($cntrow["birthdate"]);
- $contact->column_fields[email]=$cntrow["emailaddress"];
- $contact->column_fields[title]=$cntrow["jobtitle"];
- $contact->column_fields[department]=$cntrow["department"];
- $contact->column_fields[account_id]= retrieve_account_id($cntrow["accountname"],$user_id);
- $contact->column_fields[phone]= $cntrow["officephone"];
- $contact->column_fields[homephone]= $cntrow["homephone"];
- $contact->column_fields[otherphone]= $cntrow["otherphone"];
- $contact->column_fields[fax]= $cntrow["fax"];
- $contact->column_fields[mobile]=$cntrow["mobile"];
- $contact->column_fields[assistant]= $cntrow["asstname"];
- $contact->column_fields[assistantphone]= $cntrow["asstphone"];
+ $contact->column_fields[lastname]=$cntrow["firstname"]." ".$cntrow["middlename"]." ".$cntrow["lastname"];
+ }
+
+ $contact->column_fields[birthday]= in_array('birthday',$permitted_lists) ? getDisplayDate($cntrow["birthdate"]) : "";
+ $contact->column_fields[email]= in_array('email',$permitted_lists) ? $cntrow["emailaddress"] : "";
+ $contact->column_fields[title]= in_array('title',$permitted_lists) ? $cntrow["jobtitle"] : "";
+ $contact->column_fields[department]= in_array('department',$permitted_lists) ? $cntrow["department"] : "";
+ $contact->column_fields[account_id]= in_array('account_id',$permitted_lists) ? retrieve_account_id($cntrow["accountname"],$user_id) : "";
+ $contact->column_fields[phone]= in_array('phone',$permitted_lists) ? $cntrow["officephone"] : "";
+ $contact->column_fields[homephone]= in_array('homephone',$permitted_lists) ? $cntrow["homephone"] : "";
+ $contact->column_fields[otherphone]= in_array('otherphone',$permitted_lists) ? $cntrow["otherphone"] : "";
+ $contact->column_fields[fax]= in_array('fax',$permitted_lists) ? $cntrow["fax"] : "";
+ $contact->column_fields[mobile]= in_array('mobile',$permitted_lists) ? $cntrow["mobile"] : "";
+ $contact->column_fields[assistant]= in_array('assistant',$permitted_lists) ? $cntrow["asstname"] : "";
+ $contact->column_fields[assistantphone]= in_array('assistantphone',$permitted_lists) ? $cntrow["asstphone"] : "";
//$contact->column_fields[reports_to_id] =retrievereportsto($reportsto,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP
- $contact->column_fields[mailingstreet]=$cntrow["mailingstreet"];
- $contact->column_fields[mailingcity]=$cntrow["mailingcity"];
- $contact->column_fields[mailingstate]=$cntrow["mailingstate"];
- $contact->column_fields[mailingzip]=$cntrow["mailingzip"];
- $contact->column_fields[mailingcountry]=$cntrow["mailingcountry"];
- $contact->column_fields[otherstreet]=$cntrow["otherstreet"];
- $contact->column_fields[othercity]=$cntrow["othercity"];
- $contact->column_fields[otherstate]=$cntrow["otherstate"];
- $contact->column_fields[otherzip]=$cntrow["otherzip"];
- $contact->column_fields[othercountry]=$cntrow["othercountry"];
- $contact->column_fields[assigned_user_id]=$user_id;
- $contact->column_fields[description]= $cntrow["description"];
+ $contact->column_fields[mailingstreet]= in_array('mailingstreet',$permitted_lists) ? $cntrow["mailingstreet"] : "";
+ $contact->column_fields[mailingcity]= in_array('mailingcity',$permitted_lists) ? $cntrow["mailingcity"] : "";
+ $contact->column_fields[mailingstate]= in_array('mailingstate',$permitted_lists) ? $cntrow["mailingstate"] : "";
+ $contact->column_fields[mailingzip]= in_array('mailingzip',$permitted_lists) ? $cntrow["mailingzip"] : "";
+ $contact->column_fields[mailingcountry]= in_array('mailingcountry',$permitted_lists) ? $cntrow["mailingcountry"] : "";
+ $contact->column_fields[otherstreet]= in_array('otherstreet',$permitted_lists) ? $cntrow["otherstreet"] : "";
+ $contact->column_fields[othercity]= in_array('othercity',$permitted_lists) ? $cntrow["othercity"] : "";
+ $contact->column_fields[otherstate]= in_array('otherstate',$permitted_lists) ? $cntrow["otherstate"] : "";
+ $contact->column_fields[otherzip]= in_array('otherzip',$permitted_lists) ? $cntrow["otherzip"] : "";
+ $contact->column_fields[othercountry]= in_array('othercountry',$permitted_lists) ? $cntrow["othercountry"] : "";
+ $contact->column_fields[assigned_user_id]= in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
+ $contact->column_fields[description]= in_array('description',$permitted_lists) ? $cntrow["description"] : "";
$contact->id = $cntrow["id"];
$contact->mode = "edit";
$contact->save("Contacts");
@@ -743,7 +784,7 @@
function GetTasks($username)
{
- global $adb;
+ global $adb,$log;
require_once('modules/Calendar/Activity.php');
$seed_task = new Activity();
@@ -754,11 +795,11 @@
while($task = $adb->fetch_array($result))
{
- if($task["startdate"] == "0000-00-00" || $task["startdate"] == NULL)
+ if($task["date_start"] == "0000-00-00" || $task["date_start"] == NULL)
{
$task["startdate"] = "";
}
- if($task["duedate"] == "0000-00-00" || $task["duedate"] == NULL)
+ if($task["due_date"] == "0000-00-00" || $task["due_date"] == NULL)
{
$task["duedate"] = "";
}
@@ -821,15 +862,30 @@
$current_user = $seed_user;
$current_user->retrieve_entity_info($user_id,"Users");
+ require('user_privileges/user_privileges_'.$current_user->id.'.php');
+ require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+ if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+ {
+ $sql1 = "select fieldname,columnname from vtiger_field where tabid=9";
+ }else
+ {
+ $profileList = getCurrentUserProfileList();
+ $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=9 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+ }
+ $result1 = $adb->query($sql1);
+ for($i=0;$i < $adb->num_rows($result1);$i++)
+ {
+ $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+ }
+
$task = new Activity();
foreach($taskdtls as $taskrow)
{
-
-
//Currently only 3 status avail Note ************************************************
- if(isset($taskrow))
- {
+ if(isset($taskrow))
+ {
if($taskrow["status"] == "0")
{
$taskrow["status"] = "Not Started";
@@ -861,17 +917,17 @@
$taskrow["priority"] = "Medium";
}
- $task->column_fields[subject] = $taskrow["subject"];
- $task->column_fields[date_start]=getDisplayDate($taskrow["startdate"]);
- $task->column_fields[due_date]=getDisplayDate($taskrow["duedate"]);
- $task->column_fields[taskstatus]=$taskrow["status"];
- $task->column_fields[taskpriority]=$taskrow["priority"];
- $task->column_fields[description]=$taskrow["description"];
+ $task->column_fields[subject] = in_array('subject',$permitted_lists) ? $taskrow["subject"] : "";
+ $task->column_fields[date_start]= in_array('date_start',$permitted_lists) ? getDisplayDate($taskrow["startdate"]) : "";
+ $task->column_fields[due_date]= in_array('due_date',$permitted_lists) ? getDisplayDate($taskrow["duedate"]) : "";
+ $task->column_fields[taskstatus]= in_array('taskstatus',$permitted_lists) ? $taskrow["status"] : "";
+ $task->column_fields[taskpriority]= in_array('taskpriority',$permitted_lists) ? $taskrow["priority"] : "";
+ $task->column_fields[description]= in_array('description',$permitted_lists) ? $taskrow["description"] : "";
$task->column_fields[activitytype]="Task";
//$task->column_fields[contact_id]= retrievereportsto($contact_name,$user_id,null);
- $task->column_fields[assigned_user_id]=$user_id;
+ $task->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
$task->save("Calendar");
- }
+ }
}
return $task->id;
}
@@ -887,6 +943,23 @@
$current_user = $seed_user;
$current_user->retrieve_entity_info($user_id,"Users");
+ require('user_privileges/user_privileges_'.$current_user->id.'.php');
+ require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+ if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+ {
+ $sql1 = "select fieldname,columnname from vtiger_field where tabid=9";
+ }else
+ {
+ $profileList = getCurrentUserProfileList();
+ $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=9 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+ }
+ $result1 = $adb->query($sql1);
+ for($i=0;$i < $adb->num_rows($result1);$i++)
+ {
+ $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+ }
+
$task = new Activity();
foreach($taskdtls as $taskrow)
@@ -913,24 +986,24 @@
$taskrow["status"] = "Not Started";
}
- if($taskrow["priority"] == "2")
- {
- $taskrow["priority"] = "High";
- }else if($taskrow["priority"] == "0")
- {
- $taskrow["priority"] = "Low";
- }else if($taskrow["priority"] == "1")
- {
- $taskrow["priority"] = "Medium";
- }
-
+ if($taskrow["priority"] == "2")
+ {
+ $taskrow["priority"] = "High";
+ }else if($taskrow["priority"] == "0")
+ {
+ $taskrow["priority"] = "Low";
+ }else if($taskrow["priority"] == "1")
+ {
+ $taskrow["priority"] = "Medium";
+ }
+
$task->retrieve_entity_info($taskrow["id"],"Calendar");
- $task->column_fields[subject] = $taskrow["subject"];
- $task->column_fields[date_start] = getDisplayDate($taskrow["startdate"]);
- $task->column_fields[due_date] = getDisplayDate($taskrow["duedate"]);
- $task->column_fields[taskstatus] = $taskrow["status"];
- $task->column_fields[taskpriority] = $taskrow["priority"];
- $task->column_fields[description] = $taskrow["description"];
+ $task->column_fields[subject] = in_array('subject',$permitted_lists) ? $taskrow["subject"] : "";
+ $task->column_fields[date_start] = in_array('date_start',$permitted_lists) ? getDisplayDate($taskrow["startdate"]) : "";
+ $task->column_fields[due_date] = in_array('due_date',$permitted_lists) ? getDisplayDate($taskrow["duedate"]) : "";
+ $task->column_fields[taskstatus] = in_array('taskstatus',$permitted_lists) ? $taskrow["status"] : "";
+ $task->column_fields[taskpriority] = in_array('taskpriority',$permitted_lists) ? $taskrow["priority"] : "";
+ $task->column_fields[description] = in_array('description',$permitted_lists) ? $taskrow["description"] : "";
$task->column_fields[activitytype] = "Task";
//$task->column_fields[contact_id]= retrievereportsto($contact_name,$user_id,null);
$task->column_fields[assigned_user_id] = $user_id;
@@ -963,7 +1036,7 @@
function GetClndr($username)
{
- global $adb;
+ global $adb,$log;
require_once('modules/Calendar/Activity.php');
$seed_clndr = new Activity();
@@ -974,34 +1047,34 @@
while($clndr = $adb->fetch_array($result))
{
- if($clndr["startdate"] == "0000-00-00" || $clndr["startdate"] == NULL)
+ if($clndr["date_start"] == "0000-00-00" || $clndr["date_start"] == NULL)
{
- $clndr["startdate"] = "";
+ $clndr["date_start"] = "";
}
- if($clndr["duedate"] == "0000-00-00" || $clndr["duedate"] == NULL)
+ if($clndr["due_date"] == "0000-00-00" || $clndr["due_date"] == NULL)
{
- $clndr["duedate"] = "";
+ $clndr["due_date"] = "";
}
//this seperates the $$clndr["startdate"] into an array - YYYY-MM-DD
- $expldstartdate = explode("-", $clndr["startdate"]);
- $expldtimestart = explode(":", $clndr["startime"]);
-
- $expldduedate = explode("-", $clndr["duedate"]);
+ $expldstartdate = explode("-", $clndr["date_start"]);
+ $expldtimestart = explode(":", $clndr["time_start"]);
+
+ $expldduedate = explode("-", $clndr["due_date"]);
//this makes a timestamp out of the exploded date this number is in seconds
$startdtm = mktime($expldtimestart[0], $expldtimestart[1], 0, $expldstartdate[1], $expldstartdate[2], $expldstartdate[0]);
- $duedtm = mktime($expldtimestart[0]+$clndr["duehours"], $expldtimestart[1]+$clndr["dueminutes"], 0, $expldduedate[1], $expldduedate[2], $expldduedate[0]);
-
- $clndr["startdate"] = date("Y-m-d H:i:s", $startdtm);
- $clndr["duedate"] = date("Y-m-d H:i:s", $duedtm);
+ $duedtm = mktime($expldtimestart[0]+$clndr["duration_hours"], $expldtimestart[1]+$clndr["duration_minutes"], 0, $expldduedate[1], $expldduedate[2], $expldduedate[0]);
+
+ $clndr["date_start"] = date("Y-m-d H:i:s", $startdtm);
+ $clndr["due_date"] = date("Y-m-d H:i:s", $duedtm);
$output_list[] = Array(
"id" => $clndr["clndrid"],
"subject" => $clndr["subject"],
- "startdate" => $clndr["startdate"],
- "duedate" => $clndr["duedate"],
+ "startdate" => $clndr["date_start"],
+ "duedate" => $clndr["due_date"],
"location" => $clndr["location"],
"description" => $clndr["description"],
"contactname" => $clndr["firstname"]." ".$clndr["lastname"],
@@ -1014,7 +1087,7 @@
function AddClndr($username,$clndrdtls)
{
- global $current_user;
+ global $current_user,$adb;
require_once('modules/Users/User.php');
require_once('modules/Calendar/Activity.php');
@@ -1023,6 +1096,23 @@
$current_user = $seed_user;
$current_user->retrieve_entity_info($user_id,"Users");
+ require('user_privileges/user_privileges_'.$current_user->id.'.php');
+ require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+ if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+ {
+ $sql1 = "select fieldname,columnname from vtiger_field where tabid=16";
+ }else
+ {
+ $profileList = getCurrentUserProfileList();
+ $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=16 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+ }
+ $result1 = $adb->query($sql1);
+ for($i=0;$i < $adb->num_rows($result1);$i++)
+ {
+ $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+ }
+
$clndr = new Activity();
foreach($clndrdtls as $clndrow)
@@ -1044,16 +1134,16 @@
$stimeduemin = sprintf('%02d',$diff['minutes']);
}
- $clndr->column_fields[subject] = $clndrow["subject"];
- $clndr->column_fields[date_start]=getDisplayDate(trim($astartdtm[0]));
- $clndr->column_fields[due_date]=getDisplayDate(trim($aduedtm[0]));
- $clndr->column_fields[time_start]=$stimestart;
- $clndr->column_fields[duration_hours]=$stimeduehr;
- $clndr->column_fields[duration_minutes]=$stimeduemin;
- $clndr->column_fields[location]=$clndrow["location"];
- $clndr->column_fields[description]=$clndrow["description"];
+ $clndr->column_fields[subject] = in_array('subject',$permitted_lists) ? $clndrow["subject"] : "";
+ $clndr->column_fields[date_start]= in_array('date_start',$permitted_lists) ? getDisplayDate(trim($astartdtm[0])) : "";
+ $clndr->column_fields[due_date]= in_array('due_date',$permitted_lists) ? getDisplayDate(trim($aduedtm[0])) : "";
+ $clndr->column_fields[time_start]= in_array('time_start',$permitted_lists) ? $stimestart : "";
+ $clndr->column_fields[duration_hours]= in_array('duration_hours',$permitted_lists) ? $stimeduehr : "";
+ $clndr->column_fields[duration_minutes]= in_array('duration_minutes',$permitted_lists) ? $stimeduemin : "";
+ $clndr->column_fields[location]= in_array('location',$permitted_lists) ? $clndrow["location"] : "";
+ $clndr->column_fields[description]= in_array('description',$permitted_lists) ? $clndrow["description"] : "";
$clndr->column_fields[activitytype]="Meeting";
- $clndr->column_fields[assigned_user_id]=$user_id;
+ $clndr->column_fields[assigned_user_id]= in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
$clndr->save("Calendar");
}
}
@@ -1063,7 +1153,7 @@
function UpdateClndr($username,$clndrdtls)
{
global $current_user;
- global $adb;
+ global $adb,$log;
require_once('modules/Users/User.php');
require_once('modules/Calendar/Activity.php');
@@ -1071,6 +1161,23 @@
$user_id = $seed_user->retrieve_user_id($username);
$current_user = $seed_user;
$current_user->retrieve_entity_info($user_id,"Users");
+
+ require('user_privileges/user_privileges_'.$current_user->id.'.php');
+ require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+ if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+ {
+ $sql1 = "select fieldname,columnname from vtiger_field where tabid=16";
+ }else
+ {
+ $profileList = getCurrentUserProfileList();
+ $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=16 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+ }
+ $result1 = $adb->query($sql1);
+ for($i=0;$i < $adb->num_rows($result1);$i++)
+ {
+ $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+ }
$clndr = new Activity();
@@ -1094,16 +1201,16 @@
}
$clndr->retrieve_entity_info($clndrow["id"],"Calendar");
- $clndr->column_fields[subject] = $clndrow["subject"];
- $clndr->column_fields[date_start]=getDisplayDate(trim($astartdtm[0]));
- $clndr->column_fields[due_date]=getDisplayDate(trim($aduedtm[0]));
- $clndr->column_fields[time_start]=$stimestart;
- $clndr->column_fields[duration_hours]=$stimeduehr;
- $clndr->column_fields[duration_minutes]=$stimeduemin;
- $clndr->column_fields[location]=$clndrow["location"];
- $clndr->column_fields[description]=$clndrow["description"];
+ $clndr->column_fields[subject] = in_array('subject',$permitted_lists) ? $clndrow["subject"] : "";
+ $clndr->column_fields[date_start]= in_array('date_start',$permitted_lists) ? getDisplayDate(trim($astartdtm[0])) : "";
+ $clndr->column_fields[due_date]= in_array('due_date',$permitted_lists) ? getDisplayDate(trim($aduedtm[0])) : "";
+ $clndr->column_fields[time_start]= in_array('time_start',$permitted_lists) ? $stimestart : "";
+ $clndr->column_fields[duration_hours]= in_array('duration_hours',$permitted_lists) ? $stimeduehr : "";
+ $clndr->column_fields[duration_minutes]= in_array('duration_minutes',$permitted_lists) ? $stimeduemin : "";
+ $clndr->column_fields[location]= in_array('location',$permitted_lists) ? $clndrow["location"] : "";
+ $clndr->column_fields[description]= in_array('description',$permitted_lists) ? $clndrow["description"] : "";
$clndr->column_fields[activitytype]="Meeting";
- $clndr->column_fields[assigned_user_id]=$user_id;
+ $clndr->column_fields[assigned_user_id]= in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
$clndr->id = $clndrow["id"];
$clndr->mode="edit";
$clndr->save("Calendar");
More information about the vtigercrm-commits
mailing list