171 lines
7.9 KiB
PHP
171 lines
7.9 KiB
PHP
<?php
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
|
/*****************************************************************************
|
|
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
|
* Version 1.1 ("License"); You may not use this file except in compliance
|
|
* with the License. You may obtain a copy of the License at
|
|
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
|
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
|
* either express or implied.
|
|
*
|
|
* You may:
|
|
* a) Use and distribute this code exactly as you received without payment or
|
|
* a royalty or other fee.
|
|
* b) Create extensions for this code, provided that you make the extensions
|
|
* publicly available and document your modifications clearly.
|
|
* c) Charge for a fee for warranty or support or for accepting liability
|
|
* obligations for your customers.
|
|
*
|
|
* You may NOT:
|
|
* a) Charge for the use of the original code or extensions, including in
|
|
* electronic distribution models, such as ASP (Application Service
|
|
* Provider).
|
|
* b) Charge for the original source code or your extensions other than a
|
|
* nominal fee to cover distribution costs where such distribution
|
|
* involves PHYSICAL media.
|
|
* c) Modify or delete any pre-existing copyright notices, change notices,
|
|
* or License text in the Licensed Software
|
|
* d) Assert any patent claims against the Licensor or Contributors, or
|
|
* which would in any way restrict the ability of any third party to use the
|
|
* Licensed Software.
|
|
*
|
|
* You must:
|
|
* a) Document any modifications you make to this code including the nature of
|
|
* the change, the authors of the change, and the date of the change.
|
|
* b) Make the source code for any extensions you deploy available via an
|
|
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
|
* c) Notify the licensor of the availability of source code to your extensions
|
|
* and include instructions on how to acquire the source code and updates.
|
|
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
|
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
|
*
|
|
* The Original Code is: CommuniCore
|
|
* Olavo Farias
|
|
* 2006-04-7 olavo.farias@gmail.com
|
|
*
|
|
* The Initial Developer of the Original Code is CommuniCore.
|
|
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
|
* All Rights Reserved.
|
|
********************************************************************************/
|
|
|
|
|
|
require_once('modules/EcmDocs/EcmDoc.php');
|
|
require_once('include/formbase.php');
|
|
require_once('modules/EcmDocs/uploadfile.php');
|
|
//require_once('modules/EcmProducts/ProductsStock.php');
|
|
//require_once("modules/EcmSmb/smb.php");
|
|
function addInfoToReminder($parent_id,$parent_module,$name,$description,$role_id,$time="")
|
|
{
|
|
if($time=="")$time=date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")));
|
|
else
|
|
{
|
|
$texp=explode(" ",$time);
|
|
$dtexp=explode("-",$texp[0]);
|
|
$ttexp=explode(":",$texp[1]);
|
|
$time=date("Y-m-d H:i:s",mktime($ttexp[0],$ttexp[1],$ttexp[2],$dtexp[1],$dtexp[2],$dtexp[0]));
|
|
}
|
|
$z="insert into ecmreminders(id,name,date_entered,date_modified,modified_user_id,created_by,description,deleted,assigned_user_id,date_start,status,reminder_time,parent_id,parent_name,role_id) values('".create_guid()."','".$name."','".$time."','".$time."','".$_SESSION['authenticated_user_id']."','".$_SESSION['authenticated_user_id']."','".$desciption."','0','".$_SESSION['authenticated_user_id']."','".$time."','Planned','3600','".$parent_id."','".$parent_module."','".$role_id."')";
|
|
$GLOBALS['db']->query($z);
|
|
}
|
|
$file_id=add_file("filename",$_REQUEST['record'],"ecmdocs","modules/EcmDocs/files/");
|
|
if($_REQUEST['return_module']=="MySettings")$_REQUEST['return_module']="EcmDocuments";
|
|
if($_REQUEST['return_action']=="LoadTabSubpanels")$_REQUEST['return_action']="DetailView";
|
|
$focus = new EcmDoc();
|
|
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name from ecmdocs_group where id='".$_POST['group_id']."'"));
|
|
$group_name=$r['name'];
|
|
|
|
|
|
$file = "modules/Accounts/Account.php";
|
|
if(file_exists($file)) {
|
|
require_once($file);
|
|
$acc = new Account();
|
|
$acc->retrieve($_POST['account_id']);
|
|
$_POST['account_name'] = $acc->name;
|
|
}
|
|
$file = "modules/Contacts/Contact.php";
|
|
if(file_exists($file)) {
|
|
require_once($file);
|
|
$con = new Contact();
|
|
$con->retrieve($_POST['contact_id']);
|
|
$_POST['contact_name'] = $con->full_name;
|
|
}
|
|
|
|
$focus->retrieve($_POST['record']);
|
|
if(!$focus->ACLAccess('Save')){
|
|
ACLController::displayNoAccess(true);
|
|
sugar_cleanup(true);
|
|
}
|
|
if (!empty($_POST['assigned_user_id']) && ($focus->assigned_user_id != $_POST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) {
|
|
$check_notify = TRUE;
|
|
}else{
|
|
$check_notify = FALSE;
|
|
}
|
|
|
|
foreach($focus->column_fields as $field){
|
|
if(isset($_POST[$field])){
|
|
$value = $_POST[$field];
|
|
$focus->$field = $value;
|
|
}
|
|
}
|
|
|
|
foreach($focus->additional_column_fields as $field){
|
|
if(isset($_POST[$field])){
|
|
$value = $_POST[$field];
|
|
$focus->$field = $value;
|
|
}
|
|
}
|
|
|
|
$focus->group_name = $group_name;
|
|
$focus->file_id = $file_id;
|
|
$focus->unformat_all_fields();
|
|
$focus->save($check_notify);
|
|
$return_id = $focus->id;
|
|
$reminder_time=1;
|
|
/*
|
|
if($_REQUEST['account_name']=="")
|
|
{
|
|
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select accounts.id as account_id,accounts.name as account_name from contacts inner join accounts_contacts on contacts.id=accounts_contacts.contact_id inner join accounts on accounts.id=accounts_contacts.account_id where contacts.id='".$_REQUEST['contact_id']."'"));
|
|
$account_name=$r['account_name'];
|
|
$account_id=$r['account_id'];
|
|
$GLOBALS['db']->query("update ecmdocs set account_name='".$account_name."',account_id='".$account_id."' where id='".$return_id."'");
|
|
}
|
|
*/
|
|
|
|
if($_REQUEST['should_remind'] == "1") {
|
|
$time=$timedate->to_db($_REQUEST['reminder_date']." ".$_REQUEST['hour'].":".$_REQUEST['minutes'].":00");
|
|
|
|
//require_once('modules/EcmDocs/getecmdocstoecmreminders.php');
|
|
$rs = $GLOBALS['db']->query("select id from ecmreminders where parent_id='".$return_id."' and status!='Held' and parent_module='EcmDocs'");
|
|
if($rs && is_resource($rs))
|
|
if(mysql_num_rows($rs)==0)addInfoToReminder($return_id,"EcmDocs",$focus->name,$focus->description,"",$time);
|
|
|
|
if($_REQUEST['status']=="Held")$GLOBALS['db']->query("delete from ecmreminders where parent_id='".$return_id."' and parent_module='EcmDocs'");
|
|
$GLOBALS['db']->query("update ecmdocs set reminder_time='".$reminder_time."',date='".date("Y-m-d",strtotime($time))."',reminder_date='".$time."', hour='".date("H",strtotime($time))."', minutes='".date("i",strtotime($time))."' where id='".$return_id."'");
|
|
} else {
|
|
$time=$timedate->to_db($_REQUEST['reminder_date']." ".$_REQUEST['hour'].":".$_REQUEST['minutes'].":00");
|
|
|
|
$GLOBALS['db']->query("update ecmdocs set reminder_time='-1', date='".date("Y-m-d",strtotime($time))."', reminder_date=NULL, hour=NULL, minutes=NULL where id='".$return_id."'");
|
|
}
|
|
|
|
if($_REQUEST['emaildel'] && $_REQUEST['uid'])
|
|
{
|
|
require_once("modules/Emails/Email.php");
|
|
require_once("modules/InboundEmail/InboundEmail.php");
|
|
require_once("include/OutboundEmail/OutboundEmail.php");
|
|
$email = new Email();
|
|
$email->email2init();
|
|
$ie = new InboundEmail();
|
|
$ie->email = $email;
|
|
|
|
$ie->deleteMessageOnMailServer($_REQUEST['uid']);
|
|
$ie->deleteMessageFromCache($_REQUEST['uid']);
|
|
imap_delete($ie->conn, $_REQUEST['uid']);
|
|
$GLOBALS['db']->query("DELETE FROM email_cache WHERE message_id = '".$_REQUEST['uid']."'");
|
|
$GLOBALS['db']->query("DELETE FROM email_cache WHERE imap_uid = '".$_REQUEST['uid']."'");
|
|
|
|
//header("Location: index.php?module=Emails&action=EmailUIAjax&emailUIAction=deleteMessage&mbox=INBOX&ieId=".$_REQUEST['ieId']."&uid=".$_REQUEST['uid']."&return_id=".$return_id);
|
|
}
|
|
if($_REQUEST['backtoemails']==1)header("Location: index.php?module=Emails&action=index");
|
|
else handleRedirect($return_id,'EcmDocs');
|
|
|
|
?>
|