BUG 9090 ZImbra Trigger Issues

Now all Triggers uses in correct way Server param and Upload trigger does not use any more http_request instead use curl.
This commit is contained in:
Hugo Loza
2012-04-27 16:39:51 -04:00
parent 692cbe3f28
commit 6d7a14a5f0
2 changed files with 222 additions and 209 deletions

View File

@@ -21,7 +21,7 @@ class Zimbra {
protected $_preauth_expiration = 0; // 0 indicates using the default preauth expiration as defined on the server
protected $_dev; // boolean indicating whether this is development or not
protected $_protocol; // which protocol to use when building the URL
protected $_server1 = 'ip-10-73-18-235.ec2.internal'; // hostname of zimbra server
protected $_server1;// = 'ip-10-73-18-235.ec2.internal'; // hostname of zimbra server
protected $_server; // displayname of zimbra server
protected $_path = '/service/soap';
protected $_timestamp;
@@ -55,11 +55,12 @@ class Zimbra {
$this->_preAuthKey = $preAuthKey;
$this->_protocol = "http://"; // could also be http://
$this->_server = $serverUrl; //'zimbra.hostname.edu';
$this->_server1 = $serverUrl; //'zimbra.hostname.edu';
$this->_username = $username;
$this->_timestamp = time() . '000';
}
// end __construct
// end __construct
/**
* sso
@@ -84,7 +85,7 @@ class Zimbra {
}
}
// end sso
// end sso
/**
* createAccount
@@ -99,10 +100,10 @@ class Zimbra {
$soap = '<CreateAccountRequest xmlns="urn:zimbraAccount">
<name>' . $name . '@' . $this->_server1 . '</name>
<password>' . $password . '</password>' . $option_string . '
<session/>
</CreateAccountRequest>';
<name>' . $name . '@' . $this->_server1 . '</name>
<password>' . $password . '</password>' . $option_string . '
<session/>
</CreateAccountRequest>';
$response = $this->soapRequest($soap);
@@ -134,7 +135,7 @@ class Zimbra {
return $this->hmacsha1($this->_preAuthKey, $string);
}
// end getPreAuth
// end getPreAuth
/**
* hmacsha1
@@ -167,7 +168,7 @@ class Zimbra {
return bin2hex($hmac);
}
// end hmacsha1
// end hmacsha1
/**
* connect
@@ -195,14 +196,14 @@ class Zimbra {
if ($this->_admin) {
$body = '<AuthRequest xmlns="urn:zimbraAdmin">
<name>' . $this->_admin_username . '</name>
<password>' . $this->_admin_password . '</password>
</AuthRequest>';
<name>' . $this->_admin_username . '</name>
<password>' . $this->_admin_password . '</password>
</AuthRequest>';
} else {
$body = '<AuthRequest xmlns="urn:zimbraAccount">
<account by="name">' . $this->_username . '@' . $this->_server1 . '</account>
<preauth timestamp="' . $this->_timestamp . '" expires="' . $this->_preauth_expiration . '">' . $preauth . '</preauth>
</AuthRequest>';
<account by="name">' . $this->_username . '@' . $this->_server1 . '</account>
<preauth timestamp="' . $this->_timestamp . '" expires="' . $this->_preauth_expiration . '">' . $preauth . '</preauth>
</AuthRequest>';
}
$response = $this->soapRequest($body, $header, true);
@@ -223,7 +224,7 @@ class Zimbra {
}
}
// end connect
// end connect
/**
* administerUser
@@ -243,8 +244,8 @@ class Zimbra {
$this->_username = $username;
$body = '<DelegateAuthRequest xmlns="urn:zimbraAdmin">
<account by="name">' . $this->_username . '@' . $this->_server . '</account>
</DelegateAuthRequest>';
<account by="name">' . $this->_username . '@' . $this->_server . '</account>
</DelegateAuthRequest>';
$response = $this->soapRequest($body, $header);
if ($response) {
$tmp = $this->makeXMLTree($response);
@@ -259,7 +260,7 @@ class Zimbra {
}
}
// end administerUser
// end administerUser
/**
* getInfo
@@ -285,7 +286,7 @@ class Zimbra {
}
}
// end getInfo
// end getInfo
/**
* getMessages
@@ -302,8 +303,8 @@ class Zimbra {
$option_string = $this->buildOptionString($options);
$soap = '<SearchRequest xmlns="urn:zimbraMail" types="message"' . $option_string . '>
<query>' . $search . '</query>
</SearchRequest>';
<query>' . $search . '</query>
</SearchRequest>';
$response = $this->soapRequest($soap);
if ($response) {
$array = $this->makeXMLTree($response);
@@ -313,7 +314,7 @@ class Zimbra {
}
}
// end getMessages
// end getMessages
/**
* getContacts
@@ -330,8 +331,8 @@ class Zimbra {
$option_string = $this->buildOptionString($options);
$soap = '<SearchRequest xmlns="urn:zimbraMail" types="contact"' . $option_string . '>
<query>' . $search . '</query>
</SearchRequest>';
<query>' . $search . '</query>
</SearchRequest>';
$response = $this->soapRequest($soap);
if ($response) {
$array = $this->makeXMLTree($response);
@@ -341,26 +342,26 @@ class Zimbra {
}
}
// end getContacts
// end getContacts
/* getAppointments
*
* get the Appointments in folder
*
* @since version 1.0
* @access public
* @param string $search folder to retrieve from
* @param array $options options to apply to retrieval
* @return array array of messages
*/
* get the Appointments in folder
*
* @since version 1.0
* @access public
* @param string $search folder to retrieve from
* @param array $options options to apply to retrieval
* @return array array of messages
*/
public function getAppointments($search='in:calendar', $options=array('limit' => 50, 'fetch' => 'none')) {
$option_string = $this->buildOptionString($options);
$soap = '<SearchRequest xmlns="urn:zimbraMail" types="appointment"' . $option_string . '>
<query>' . $search . '</query>
</SearchRequest>';
<query>' . $search . '</query>
</SearchRequest>';
$response = $this->soapRequest($soap);
if ($response) {
$array = $this->makeXMLTree($response);
@@ -370,25 +371,25 @@ class Zimbra {
}
}
// end getAppointments
// end getAppointments
/* getTasks
*
* get the Tasks in folder
*
* @since version 1.0
* @access public
* @param string $search folder to retrieve from
* @param array $options options to apply to retrieval
* @return array array of messages
*/
* get the Tasks in folder
*
* @since version 1.0
* @access public
* @param string $search folder to retrieve from
* @param array $options options to apply to retrieval
* @return array array of messages
*/
public function getTasks($search='in:tasks', $options=array('limit' => 50, 'fetch' => 'none')) {
$option_string = $this->buildOptionString($options);
$soap = '<SearchRequest xmlns="urn:zimbraMail" types="task"' . $option_string . '>
<query>' . $search . '</query>
</SearchRequest>';
<query>' . $search . '</query>
</SearchRequest>';
$response = $this->soapRequest($soap);
if ($response) {
$array = $this->makeXMLTree($response);
@@ -398,7 +399,7 @@ class Zimbra {
}
}
// end getTasks
// end getTasks
/**
* getMessageContent
@@ -412,8 +413,8 @@ class Zimbra {
*/
public function getMessageContent($id) {
$soap = '<GetMsgRequest xmlns="urn:zimbraMail">
<m id="' . $id . '" html="1">*</m>
</GetMsgRequest>';
<m id="' . $id . '" html="1">*</m>
</GetMsgRequest>';
$response = $this->soapRequest($soap);
if ($response) {
@@ -454,7 +455,7 @@ class Zimbra {
return $subscribed;
}
// end getSubscribedCalendars
// end getSubscribedCalendars
/**
* getSubscribedTaskLists
@@ -476,7 +477,7 @@ class Zimbra {
return $subscribed;
}
// end getSubscribedCalendars
// end getSubscribedCalendars
/**
* getFolder
@@ -493,8 +494,8 @@ class Zimbra {
//$folder_option_string = $this->buildOptionString($folder_options);
$soap = '<GetFolderRequest xmlns="urn:zimbraMail" visible="1">
<folder path="' . $folderName . '"/>
</GetFolderRequest>';
<folder path="' . $folderName . '"/>
</GetFolderRequest>';
$response = $this->soapRequest($soap);
if ($response) {
$array = $this->makeXMLTree($response);
@@ -510,7 +511,7 @@ class Zimbra {
}
}
// end getFolder
// end getFolder
/**
* getPrefrences
@@ -537,7 +538,7 @@ class Zimbra {
}
}
// end getPreferences
// end getPreferences
/**
* setPrefrences
@@ -557,8 +558,8 @@ class Zimbra {
}
$soap = '<ModifyPrefsRequest xmlns="urn:zimbraAccount">
' . $option_string . '
</ModifyPrefsRequest>';
' . $option_string . '
</ModifyPrefsRequest>';
$response = $this->soapRequest($soap);
if ($response) {
return true;
@@ -567,7 +568,7 @@ class Zimbra {
}
}
// end setPreferences
// end setPreferences
/**
* emailChannel
@@ -635,18 +636,18 @@ class Zimbra {
}
/* include_once 'portal_functions.php';
$roles = getRoles($this->_username);
$roles = getRoles($this->_username);
if(in_array('faculty', $roles) || in_array('employee', $roles))
{
$tpl->parse('main.away_message');
} */
if(in_array('faculty', $roles) || in_array('employee', $roles))
{
$tpl->parse('main.away_message');
} */
$tpl->parse('main');
$tpl->out('main');
}
// end emailChannel
// end emailChannel
/**
* builOptionString
@@ -666,7 +667,7 @@ class Zimbra {
return $options_string;
}
// end buildOptionString
// end buildOptionString
/**
* extractAuthToken
@@ -705,7 +706,7 @@ class Zimbra {
return $session_id;
}
// end extractSessionID
// end extractSessionID
/**
* extractErrorCode
@@ -724,7 +725,7 @@ class Zimbra {
return $session_id;
}
// end extractErrorCode
// end extractErrorCode
/**
* makeBytesPretty
@@ -741,7 +742,7 @@ class Zimbra {
if ($bytes < 1024)
$size = $bytes . ' B';
elseif ($bytes < 1024 * 1024)
$size = round($bytes / 1024, 1) . ' KB';
$size = round($bytes / 1024, 1) . ' KB';
else
$size = round(($bytes / 1024) / 1024, 1) . ' MB';
@@ -752,7 +753,7 @@ class Zimbra {
return $size;
}
// end makeBytesPretty
// end makeBytesPretty
/**
* message
@@ -769,7 +770,7 @@ class Zimbra {
}
}
// end message
// end message
/**
* soapRequest
@@ -790,15 +791,15 @@ class Zimbra {
if ($header == false) {
$header = '<context xmlns="urn:zimbra">
<authToken>' . $this->auth_token . '</authToken>
<sessionId id="' . $this->session_id . '">' . $this->session_id . '</sessionId>
</context>';
<authToken>' . $this->auth_token . '</authToken>
<sessionId id="' . $this->session_id . '">' . $this->session_id . '</sessionId>
</context>';
}
$soap_message = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>' . $header . '</soap:Header>
<soap:Body>' . $body . '</soap:Body>
</soap:Envelope>';
<soap:Header>' . $header . '</soap:Header>
<soap:Body>' . $body . '</soap:Body>
</soap:Envelope>';
$this->message('SOAP message:<textarea>' . $soap_message . '</textarea>');
curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $soap_message);
@@ -820,7 +821,7 @@ class Zimbra {
return $response;
}
// end soapRequest
// end soapRequest
/**
* getNumSOAPCalls
@@ -835,7 +836,7 @@ class Zimbra {
return $this->_num_soap_calls;
}
// end getNumSOAPCalls
// end getNumSOAPCalls
/**
* makeXMLTree
@@ -896,7 +897,7 @@ class Zimbra {
return $ret;
}
// end makeXMLTree
// end makeXMLTree
/**
* &composeArray
@@ -926,7 +927,7 @@ class Zimbra {
return $array;
}
// end composeArray
// end composeArray
/**
* noop
@@ -969,39 +970,41 @@ class Zimbra {
$role = $unserializeOp1['role'];
$location = $unserializeOp1['location'];
$ptst = $unserializeOp1['ptst'];
$startDate = $unserializeOp1['startDate'];
$endDate = $unserializeOp1['endDate'];
$timeZone = $unserializeOp1['tz'];
$dateFormat=$allDay=="1"?"Ymd":"Ymd\THis";
$startDate = date($dateFormat,strtotime($unserializeOp1['startDate']));
$endDate = date($dateFormat,strtotime($unserializeOp1['endDate']));
$timeZone = $allDay=="1"?"":$unserializeOp1['tz'];
$explodeEmail = explode(';', $userEmail);
$explodeFriendlyName = explode(';', $atFriendlyName);
$countExplodeEmail = count($explodeEmail);
$soap = '<CreateAppointmentRequest xmlns="urn:zimbraMail"><m>
<su>' . $subject . '</su>';
<su>' . $subject . '</su>';
for ($i = 0; $i < $countExplodeEmail; $i++) {
$soap.= '<e p="' . $friendlyName . '" a="' . $explodeEmail[$i] . '" t="t"></e>';
}
$soap.='<inv>
<comp fb="' . $schedule . '" fba="' . $schedule . '" name="' . $appointmentName . '" allDay ="' . $allDay . '" isOrg="' . $isOrg . '" loc="' . $location . '">
<s tz="' . $timeZone . '" d="' . $startDate . '"/>
<e tz="' . $timeZone . '" d="' . $endDate . '"/>
<or a="' . $username . '@' . $domainName . '" d="' . $friendlyName . '"></or>';
<comp fb="' . $schedule . '" fba="' . $schedule . '" name="' . $appointmentName . '" allDay ="' . $allDay . '" isOrg="' . $isOrg . '" loc="' . $location . '">
<s tz="' . $timeZone . '" d="' . $startDate . '"/>
<e tz="' . $timeZone . '" d="' . $endDate . '"/>
<or a="' . $username . '@' . $domainName . '" d="' . $friendlyName . '"></or>';
for ($i = 0; $i < $countExplodeEmail; $i++) {
$soap.='<at role="' . $role . '" ptst="' . $ptst . '" d="' . $explodeFriendlyName[$i] . '" rsvp="' . $rsvp . '" cutype="' . $cutype . '" a="' . $explodeEmail[$i] . '"></at>';
}
$soap.= '</comp>
</inv>
<mp ct="multipart/alternative">
<mp ct="text/plain">
<content>
this is a sample Contents
</content>
</mp>
</mp>
</m>
</CreateAppointmentRequest>';
</inv>
<mp ct="multipart/alternative">
<mp ct="text/plain">
<content>
this is a sample Contents
</content>
</mp>
</mp>
</m>
</CreateAppointmentRequest>';
//G::pr($soap);die;
$response = $this->soapRequest($soap);
if ($response) {
$array = $this->makeXMLTree($response);
@@ -1012,7 +1015,7 @@ class Zimbra {
}
}
// end addAppointments
// end addAppointments
/**
* addTask
@@ -1035,35 +1038,35 @@ class Zimbra {
$allDay = $unserializeOp1['allDay'];
$class = $unserializeOp1['class'];
$location = $unserializeOp1['location'];
$dueDate = $unserializeOp1['dueDate'];
$dueDate = date("Ymd",strtotime($unserializeOp1['dueDate']));
$status = $unserializeOp1['status'];
$percent = $unserializeOp1['percent'];
$soap = '<CreateTaskRequest xmlns="urn:zimbraMail">
<m l="15">
<su>' . $subject . '</su>
<e p="' . $friendlyName . '" a="' . $userEmail . '" t="t"></e>
<inv>
<comp allDay="' . $allDay . '"
name="' . $taskName . '"
class="' . $class . '"
priority="' . $priority . '"
percentComplete="' . $percent . '"
status="' . $status . '"
loc="' . $location . '">
<dueDate d="' . $dueDate . '"/>
</comp>
</inv>
<mp ct="multipart/alternative">
<mp ct="text/plain">
<content/>
</mp>
</mp>
</m>
</CreateTaskRequest>';
<m l="15">
<su>' . $subject . '</su>
<e p="' . $friendlyName . '" a="' . $userEmail . '" t="t"></e>
<inv>
<comp allDay="' . $allDay . '"
name="' . $taskName . '"
class="' . $class . '"
priority="' . $priority . '"
percentComplete="' . $percent . '"
status="' . $status . '"
loc="' . $location . '">
<dueDate d="' . $dueDate . '"/>
</comp>
</inv>
<mp ct="multipart/alternative">
<mp ct="text/plain">
<content/>
</mp>
</mp>
</m>
</CreateTaskRequest>';
$response = $this->soapRequest($soap);
if ($response) {
$array = $this->makeXMLTree($response);
@@ -1074,7 +1077,7 @@ class Zimbra {
}
}
// end addTask
// end addTask
/**
* addContacts
@@ -1096,13 +1099,13 @@ class Zimbra {
$otherDataValue = $unserializeOp1['otherDataValue'];
$soap = '<CreateContactRequest xmlns="urn:zimbraMail">
<cn>
<a n="firstName">' . $firstName . '</a>
<a n="lastName">' . $lastName . '</a>
<a n="email">' . $email . '</a>
<a n="' . $otherData . '">' . $otherDataValue . '</a>
</cn>
</CreateContactRequest>';
<cn>
<a n="firstName">' . $firstName . '</a>
<a n="lastName">' . $lastName . '</a>
<a n="email">' . $email . '</a>
<a n="' . $otherData . '">' . $otherDataValue . '</a>
</cn>
</CreateContactRequest>';
$response = $this->soapRequest($soap);
if ($response) {
@@ -1114,17 +1117,17 @@ class Zimbra {
}
}
// end addContacts
// end addContacts
/**
* addFolder
*
* add Folder in a BriefCase
*
* @since version 1.0
* @access public
* @param
* @return
*/
* addFolder
*
* add Folder in a BriefCase
*
* @since version 1.0
* @access public
* @param
* @return
*/
public function addFolder($serializeOp1) {
$unserializeOp1 = unserialize($serializeOp1);
@@ -1133,9 +1136,9 @@ class Zimbra {
$folderColor = $unserializeOp1['color'];
$soap = '<CreateFolderRequest xmlns="urn:zimbraMail">
<folder name="' . $folderName . '" color="' . $folderColor . '" view="document">
</folder>
</CreateFolderRequest>';
<folder name="' . $folderName . '" color="' . $folderColor . '" view="document">
</folder>
</CreateFolderRequest>';
$response = $this->soapRequest($soap);
if ($response) {
@@ -1147,31 +1150,31 @@ class Zimbra {
}
}
// end addFolder
// end addFolder
/**
* uploadDocument
*
* add Folder in a BriefCase
*
* @since version 1.0
* @access public
* @param
* @return
*/
* uploadDocument
*
* add Folder in a BriefCase
*
* @since version 1.0
* @access public
* @param
* @return
*/
public function upload($folderId, $UploadId, $fileVersion='', $docId='') {
if ($fileVersion == '' && $docId == '') {
$soap = '<SaveDocumentRequest xmlns="urn:zimbraMail">
<doc l="' . $folderId . '">
<upload id="' . $UploadId . '"/>
</doc>
</SaveDocumentRequest>';
<doc l="' . $folderId . '">
<upload id="' . $UploadId . '"/>
</doc>
</SaveDocumentRequest>';
} else {
$soap = '<SaveDocumentRequest xmlns="urn:zimbraMail">
<doc l="' . $folderId . '" ver="' . $fileVersion . '" id="' . $docId . '" >
<upload id="' . $UploadId . '"/>
</doc>
</SaveDocumentRequest>';
<doc l="' . $folderId . '" ver="' . $fileVersion . '" id="' . $docId . '" >
<upload id="' . $UploadId . '"/>
</doc>
</SaveDocumentRequest>';
}
$response = $this->soapRequest($soap);
@@ -1186,7 +1189,7 @@ class Zimbra {
}
}
// end uploadDocument
// end uploadDocument
/**
* getDocId
@@ -1200,8 +1203,8 @@ class Zimbra {
*/
public function getDocId($folderId, $fileName) {
$soap = '<GetItemRequest xmlns="urn:zimbraMail">
<item l="' . $folderId . '" name="' . $fileName . '" />
</GetItemRequest>';
<item l="' . $folderId . '" name="' . $fileName . '" />
</GetItemRequest>';
$response = $this->soapRequest($soap);
if (is_array($response)) {
@@ -1215,7 +1218,7 @@ class Zimbra {
}
}
// end getDocId
// end getDocId
}
// end Zimbra class

View File

@@ -31,7 +31,7 @@
* @name getZimbraFolder
* @label Get Attributes for specified FolderName
*
* @param string | $ServerUrl | Server name and port where Zimbra exists | http://localhost:7070/service/soap
* @param string | $ServerUrl | Server name and port where Zimbra exists | zimbra.server:port
* @param string | $username | Valid username to connect to Zimbra server
* @param string | $preAuthKey | Server Key for SSO authentication
* @param string | $folderName | Folder Name
@@ -66,7 +66,7 @@ function getZimbraFolder($ServerUrl, $username, $preAuthKey, $folderName) {
* @name getZimbraContactList
* @label Get Contact Lists from Zimbra Server
*
* @param string | $ServerUrl | Server name and port where Zimbra exists | http://localhost:7070/service/soap
* @param string | $ServerUrl | Server name and port where Zimbra exists | zimbra.server:port
* @param string | $username| Valid username to connect to Zimbra server
* @param string | $preAuthKey | Server Key for SSO authentication
*
@@ -98,7 +98,7 @@ function getZimbraContactList($ServerUrl, $username, $preAuthKey) {
* @name getZimbraTaskList
* @label Get Task Lists from Zimbra Server
*
* @param string | $ServerUrl | Server name and port where Zimbra exists | http://localhost:7070/service/soap
* @param string | $ServerUrl | Server name and port where Zimbra exists | zimbra.server:port
* @param string | $username| Valid username to connect to Zimbra server
* @param string | $preAuthKey | Server Key for SSO authentication
*
@@ -128,12 +128,12 @@ function getZimbraTaskList($ServerUrl, $username, $preAuthKey) {
/**
* @method
*
* Get Appointment List
* Get Appointment List
*
* @name getZimbraAppointmentList
* @label Get Appointment Lists from Zimbra Server
*
* @param string | $ServerUrl | Server name and port where Zimbra exists | http://localhost:7070/service/soap
* @param string | $ServerUrl | Server name and port where Zimbra exists | zimbra.server:port
* @param string | $username| Valid username to connect to Zimbra server
* @param string | $preAuthKey | Server Key for SSO authentication
*
@@ -168,11 +168,11 @@ function getZimbraAppointmentList($ServerUrl, $username, $preAuthKey) {
* @name createZimbraFolder
* @label Create Specified Folder with Attributes in Briefcase Tab
*
* @param string | $ServerUrl | Server name and port where Zimbra exists | http://localhost:7070/service/soap
* @param string | $ServerUrl | Server name and port where Zimbra exists | zimbra.server:port
* @param string | $username | Valid username to connect to Zimbra server
* @param string | $preAuthKey | Server Key for SSO authentication
* @param string | $folderName | Folder Name
* @param string | $color | Color of Folder
* @param string | $color | Color of Folder
*
* @return string | $result | Response
*
@@ -199,12 +199,12 @@ function createZimbraFolder($ServerUrl, $username, $preAuthKey, $folderName, $co
/**
* @method
*
* Create Contacts
* Create Contacts
*
* @name createZimbraContacts
* @label Create Contacts in Address Book
*
* @param string | $ServerUrl | Server name and port where Zimbra exists | http://localhost:7070/service/soap
* @param string | $ServerUrl | Server name and port where Zimbra exists | zimbra.server:port
* @param string | $username | Valid username to connect to Zimbra server
* @param string | $preAuthKey | Server Key for SSO authentication
* @param string | $firstName | First Name
@@ -245,10 +245,10 @@ function createZimbraContacts($ServerUrl, $username, $preAuthKey, $firstName, $l
* @name createZimbraTask
* @label Create Task
*
* @param string | $ServerUrl | Server name and port where Zimbra exists | http://localhost:7070/service/soap
* @param string | $ServerUrl | Server name and port where Zimbra exists | zimbra.server:port
* @param string | $username | Valid username to connect to Zimbra server
* @param string | $preAuthKey | Server Key for SSO authentication
* @param string | $subject | Mail Subject
* @param string | $subject | Mail Subject
* @param string | $taskName | Task Name
* @param string | $friendlyName | Friendly Name of the User
* @param string | $userEmail | Email Address of the User
@@ -264,14 +264,13 @@ function createZimbraContacts($ServerUrl, $username, $preAuthKey, $firstName, $l
*
*/
function createZimbraTask($ServerUrl, $username, $preAuthKey, $subject, $taskName, $friendlyName, $userEmail, $priority, $allDay, $class, $location, $dueDate, $status, $percent) {
$serializeOp = array();
$serializeOp = array('subject' => $subject, 'taskName' => $taskName, 'friendlyName' => $friendlyName, 'userEmail' => $userEmail, 'priority' => $priority, 'allDay' => $allDay, 'class' => $class, 'location' => $location, 'dueDate' => $dueDate, 'status' => $status, 'percent' => $percent);
$serializeOp1 = serialize($serializeOp);
$zimbra = new Zimbra($username, $ServerUrl, $preAuthKey);
$connectionResult = $zimbra->connect();
$connectionResult = $zimbra->connect();
if (!$connectionResult) {
return "Check userName or Server URL";
}
@@ -292,10 +291,10 @@ function createZimbraTask($ServerUrl, $username, $preAuthKey, $subject, $taskNam
* @name createZimbraAppointment
* @label Create Appointment
*
* @param string | $ServerUrl | Server name and port where Zimbra exists | http://localhost:7070/service/soap
* @param string | $ServerUrl | Server name and port where Zimbra exists | zimbra.server:port
* @param string | $username | Valid username to connect to Zimbra server
* @param string | $preAuthKey | Server Key for SSO authentication
* @param string | $subject | Mail Subject
* @param string | $subject | Mail Subject
* @param string | $appointmentName | Appointment Name
* @param string | $friendlyName | Organizer's Friendly Name
* @param string | $userEmail | Email Address of the Attendee(s) seperated by ';'
@@ -345,7 +344,7 @@ function createZimbraAppointment($ServerUrl, $username, $preAuthKey, $subject, $
* @name uploadZimbraFile
* @label Upload File/Document to Zimbra Server
*
* @param string | $ServerUrl | Server name and port where Zimbra exists | http://localhost:7070/service/soap
* @param string | $ServerUrl | Server name and port where Zimbra exists | zimbra.server:port
* @param string | $username | Valid username to connect to Zimbra server
* @param string | $preAuthKey | Server Key for SSO authentication
* @param string | $folderName | Folder Name
@@ -357,42 +356,53 @@ function createZimbraAppointment($ServerUrl, $username, $preAuthKey, $subject, $
function uploadZimbraFile($ServerUrl, $username, $preAuthKey, $folderName, $fileLocation) {
$header_array = array("ENCTYPE" => "multipart/form-data");
$credentials = "root:solutions";
$options = array(headers => $header_array,
httpauth => $credentials,
httpauthtype => HTTP_AUTH_BASIC); //1. test without the credentials
$file = $fileLocation;
$oZimbraObj = new Zimbra($username, $ServerUrl, $preAuthKey);
$connectResult = $oZimbraObj->connect();
$sAuthToken = $oZimbraObj->auth_token;
$cookie = array('ZM_AUTH_TOKEN' => $sAuthToken, 'ZM_TEST' => true);
$cookie = 'ZM_AUTH_TOKEN=' . $sAuthToken. '; ZM_TEST='. true;
$url = "http://$ServerUrl/service/upload?fmt=raw";
$request = new HttpRequest($url, HTTP_METH_POST);
$request->setCookies($cookie);
$request->addPostFile("uploadFile", $file); // 2. test without 1st parameter
$request->addPostFields(array($options));
$sendResult = $request->send();
// gettin Upload ID
$aResponce = (array) $sendResult;
$counter = 0;
foreach ($aResponce as $values) {
$counter++;
if ($counter == 2) {
$sResponce = $values;
}
$params = array (
'uploadFile' => "@$file"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
//curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt ($ch, CURLOPT_COOKIESESSION, true);
curl_setopt ($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt ($ch, CURLOPT_HEADER, true);
curl_setopt ($ch, CURLOPT_NOPROGRESS, false);
curl_setopt ($ch, CURLOPT_VERBOSE, true);
curl_setopt ($ch, CURLOPT_HTTPHEADER,$header_array);
if( ! $response = curl_exec($ch))
{
return "Upload error. Connection Error";
}
//G::pr($response);
$header_size = curl_getinfo($ch,CURLINFO_HEADER_SIZE);
$result['header'] = substr($response, 0, $header_size);
$result['body'] = substr( $response, $header_size );
$result['http_code'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
$result['last_url'] = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
$aString = array();
$aExplode = explode(",", $sResponce);
$aExplode = explode(",", $result['body']);
$uploadID = substr($aExplode[2], 1, -2);
// gettin FOlder ID
curl_close($ch);
// gettin FOlder ID
$FolderResult = $oZimbraObj->getFolder($folderName);
if (isset($FolderResult['id'])) {