diff --git a/oss/vtiger/trunk/modules/Accounts/Accounts.php b/oss/vtiger/trunk/modules/Accounts/Accounts.php index 6060c44b..ad55ce82 100644 --- a/oss/vtiger/trunk/modules/Accounts/Accounts.php +++ b/oss/vtiger/trunk/modules/Accounts/Accounts.php @@ -73,11 +73,13 @@ class Accounts extends CRMEntity { var $search_fields = Array( 'Account Name'=>Array('vtiger_account'=>'accountname'), 'Billing City'=>Array('vtiger_accountbillads'=>'bill_city'), + 'Assigned To'=>Array('vtiger_crmentity'=>'smownerid'), ); var $search_fields_name = Array( 'Account Name'=>'accountname', 'Billing City'=>'bill_city', + 'Assigned To'=>'assigned_user_id', ); // This is the list of vtiger_fields that are required var $required_fields = array(); @@ -145,6 +147,60 @@ class Accounts extends CRMEntity { } // Mike Crowe Mod -------------------------------------------------------- + /** Returns a list of the associated Campaigns + * @param $id -- campaign id :: Type Integer + * @returns list of campaigns in array format + */ + function get_campaigns($id, $cur_tab_id, $rel_tab_id, $actions=false) { + global $log, $singlepane_view,$currentModule,$current_user; + $log->debug("Entering get_campaigns(".$id.") method ..."); + $this_module = $currentModule; + + $related_module = vtlib_getModuleNameById($rel_tab_id); + require_once("modules/$related_module/$related_module.php"); + $other = new $related_module(); + vtlib_setup_modulevars($related_module, $other); + $singular_modname = vtlib_toSingular($related_module); + + $parenttab = getParentTab(); + + if($singlepane_view == 'true') + $returnset = '&return_module='.$this_module.'&return_action=DetailView&return_id='.$id; + else + $returnset = '&return_module='.$this_module.'&return_action=CallRelatedList&return_id='.$id; + + $button = ''; + + $button .= ''; + + if($actions) { + if(is_string($actions)) $actions = explode(',', strtoupper($actions)); + if(in_array('SELECT', $actions) && isPermitted($related_module,4, '') == 'yes') { + $button .= " "; + } + if(in_array('ADD', $actions) && isPermitted($related_module,1, '') == 'yes') { + $button .= ""; + } + } + + $query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, + vtiger_campaign.campaignid, vtiger_campaign.campaignname, vtiger_campaign.campaigntype, vtiger_campaign.campaignstatus, + vtiger_campaign.expectedrevenue, vtiger_campaign.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, + vtiger_crmentity.modifiedtime from vtiger_campaign + inner join vtiger_campaignaccountrel on vtiger_campaignaccountrel.campaignid=vtiger_campaign.campaignid + inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_campaign.campaignid + left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid + left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid + where vtiger_campaignaccountrel.accountid=".$id." and vtiger_crmentity.deleted=0"; + + $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); + + if($return_value == null) $return_value = Array(); + $return_value['CUSTOM_BUTTON'] = $button; + + $log->debug("Exiting get_campaigns method ..."); + return $return_value; + } /** Returns a list of the associated contacts * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. @@ -371,9 +427,7 @@ class Accounts extends CRMEntity { ON vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_users ON vtiger_users.id=vtiger_crmentity.smownerid - WHERE (vtiger_activity.activitytype = 'Meeting' - OR vtiger_activity.activitytype = 'Call' - OR vtiger_activity.activitytype = 'Task') + WHERE (vtiger_activity.activitytype != 'Emails') AND (vtiger_activity.status = 'Completed' OR vtiger_activity.status = 'Deferred' OR (vtiger_activity.eventstatus = 'Held' @@ -690,34 +744,7 @@ class Accounts extends CRMEntity { ON vtiger_users.id=vtiger_crmentity.smownerid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid - WHERE vtiger_crmentity.deleted = 0 and ( vtiger_troubletickets.parent_id=".$id." or " ; - - $query .= " vtiger_troubletickets.parent_id in(SELECT vtiger_contactdetails.contactid - FROM vtiger_contactdetails - INNER JOIN vtiger_crmentity - ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid - LEFT JOIN vtiger_groups - ON vtiger_groups.groupid = vtiger_crmentity.smownerid - LEFT JOIN vtiger_users - ON vtiger_crmentity.smownerid = vtiger_users.id - WHERE vtiger_crmentity.deleted = 0 - AND vtiger_contactdetails.accountid = ".$id; - - - //Appending the security parameter - global $current_user; - require('user_privileges/user_privileges_'.$current_user->id.'.php'); - require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); - $tab_id=getTabid('Contacts'); - if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) - { - $sec_parameter=getListViewSecurityParameter('Contacts'); - $query .= ' '.$sec_parameter; - - } - - $query .= ") )"; - + WHERE vtiger_crmentity.deleted = 0 and vtiger_troubletickets.parent_id=$id" ; $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); if($return_value == null) $return_value = Array(); @@ -816,7 +843,7 @@ class Accounts extends CRMEntity { ON vtiger_account2.accountid = vtiger_account.parentid ";//vtiger_account2 is added to get the Member of account - + $query .= $this->getNonAdminAccessControlQuery('Accounts',$current_user); $where_auto = " vtiger_crmentity.deleted = 0 "; if($where != "") @@ -824,15 +851,6 @@ class Accounts extends CRMEntity { else $query .= " WHERE ".$where_auto; - require('user_privileges/user_privileges_'.$current_user->id.'.php'); - require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); - //we should add security check when the user has Private Access - if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[6] == 3) - { - //Added security check to get the permitted records only - $query = $query." ".getListViewSecurityParameter("Accounts"); - } - $log->debug("Exiting create_export_query method ..."); return $query; } @@ -865,7 +883,7 @@ class Accounts extends CRMEntity { for($i=0; $i < $numRows;$i++) { $custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel"); - $custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]); + $custom_fields[$i] = preg_replace("/\s+/","",$custom_fields[$i]); $custom_fields[$i] = strtoupper($custom_fields[$i]); } $mergeflds = $custom_fields; @@ -935,6 +953,7 @@ class Accounts extends CRMEntity { "HelpDesk" => array("vtiger_troubletickets"=>array("parent_id","ticketid"),"vtiger_account"=>"accountid"), "Products" => array("vtiger_seproductsrel"=>array("crmid","productid"),"vtiger_account"=>"accountid"), "Documents" => array("vtiger_senotesrel"=>array("crmid","notesid"),"vtiger_account"=>"accountid"), + "Campaigns" => array("vtiger_campaignaccountrel"=>array("accountid","campaignid"),"vtiger_account"=>"accountid"), ); return $rel_tables[$secmodule]; } @@ -1218,7 +1237,10 @@ class Accounts extends CRMEntity { global $log; if(empty($return_module) || empty($return_id)) return; - if($return_module == 'Products') { + if($return_module == 'Campaigns') { + $sql = 'DELETE FROM vtiger_campaignaccountrel WHERE accountid=? AND campaignid=?'; + $this->db->pquery($sql, array($id, $return_id)); + } else if($return_module == 'Products') { $sql = 'DELETE FROM vtiger_seproductsrel WHERE crmid=? AND productid=?'; $this->db->pquery($sql, array($id, $return_id)); } else { @@ -1227,7 +1249,6 @@ class Accounts extends CRMEntity { $this->db->pquery($sql, $params); } } - } -?> +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Accounts/CallRelatedList.php b/oss/vtiger/trunk/modules/Accounts/CallRelatedList.php index 7eb70c34..8d296649 100644 --- a/oss/vtiger/trunk/modules/Accounts/CallRelatedList.php +++ b/oss/vtiger/trunk/modules/Accounts/CallRelatedList.php @@ -62,6 +62,14 @@ if($singlepane_view == 'true' && $_REQUEST['action'] == 'CallRelatedList') { $smarty->assign("UPDATEINFO",updateInfo($focus->id)); if (isset($focus->name)) $smarty->assign("NAME", $focus->name); $related_array=getRelatedLists("Accounts",$focus); + require_once('include/ListView/RelatedListViewSession.php'); + if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) { + $relationId = vtlib_purify($_REQUEST['relation_id']); + RelatedListViewSession::addRelatedModuleToSession($relationId, + vtlib_purify($_REQUEST['selected_header'])); + } + $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession(); + $smarty->assign("SELECTEDHEADERS", $open_related_modules); $smarty->assign("RELATEDLISTS", $related_array); $smarty->assign("ID",$focus->id); $smarty->assign("MODULE",$currentmodule); diff --git a/oss/vtiger/trunk/modules/Accounts/DetailView.php b/oss/vtiger/trunk/modules/Accounts/DetailView.php index 8c2a6f56..1d37900f 100644 --- a/oss/vtiger/trunk/modules/Accounts/DetailView.php +++ b/oss/vtiger/trunk/modules/Accounts/DetailView.php @@ -145,6 +145,13 @@ if($singlepane_view == 'true') { $related_array = getRelatedLists($currentModule,$focus); $smarty->assign("RELATEDLISTS", $related_array); + require_once('include/ListView/RelatedListViewSession.php'); + if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) { + RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']), + vtlib_purify($_REQUEST['selected_header'])); + } + $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession(); + $smarty->assign("SELECTEDHEADERS", $open_related_modules); } $smarty->assign("TODO_PERMISSION",CheckFieldPermission('parent_id','Calendar')); $smarty->assign("EVENT_PERMISSION",CheckFieldPermission('parent_id','Events')); @@ -157,7 +164,7 @@ $focus->markAsViewed($current_user->id); include_once('vtlib/Vtiger/Link.php'); $customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action'])); -$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW'), $customlink_params)); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params)); $smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true)); diff --git a/oss/vtiger/trunk/modules/Accounts/DetailViewAjax.php b/oss/vtiger/trunk/modules/Accounts/DetailViewAjax.php index ab45d84c..e406ce60 100644 --- a/oss/vtiger/trunk/modules/Accounts/DetailViewAjax.php +++ b/oss/vtiger/trunk/modules/Accounts/DetailViewAjax.php @@ -10,11 +10,11 @@ require_once('include/logging.php'); require_once('include/database/PearDatabase.php'); -global $adb; +global $adb,$mod_strings; $local_log =& LoggerManager::getLogger('AccountsAjax'); global $currentModule; -$acntObj = CRMEntity::getInstance($currentModule); +$modObj = CRMEntity::getInstance($currentModule); $ajaxaction = $_REQUEST["ajxaction"]; if($ajaxaction == "DETAILVIEW") @@ -25,20 +25,47 @@ if($ajaxaction == "DETAILVIEW") $fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]); if($crmid != "") { - $acntObj->retrieve_entity_info($crmid,"Accounts"); - $acntObj->column_fields[$fieldname] = $fieldvalue; + $modObj->retrieve_entity_info($crmid,"Accounts"); + $modObj->column_fields[$fieldname] = $fieldvalue; + if($fieldname=='accountname'){ + $value = $fieldvalue; + $query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname =? and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1"; + $params = array($value); + if(isset($crmid) && $crmid !='') { + $query .= " and vtiger_account.accountid != ?"; + array_push($params, $crmid); + } + $result = $adb->pquery($query, $params); + if($adb->num_rows($result) > 0) + { + echo ":#:ERR".$mod_strings['LBL_ACCOUNT_EXIST']; + return false; + } + } + if($fieldname=='accountname'){ + $value = $fieldvalue; + $query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname =? and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1"; + $params = array($value); + if(isset($crmid) && $crmid !='') { + $query .= " and vtiger_account.accountid != ?"; + array_push($params, $crmid); + } + $result = $adb->pquery($query, $params); + if($adb->num_rows($result) > 0) + { + echo ":#:ERR".$mod_strings['LBL_ACCOUNT_EXIST']; + return false; + } + } if($fieldname == 'annual_revenue')//annual revenue converted to dollar value while saving { - $acntObj->column_fields[$fieldname] = getConvertedPrice($fieldvalue); + $modObj->column_fields[$fieldname] = getConvertedPrice($fieldvalue); } - $acntObj->id = $crmid; - $acntObj->mode = "edit"; - $acntObj->save("Accounts"); - if($acntObj->column_fields['notify_owner'] == 1 ) - { - sendNotificationToOwner('Accounts',&$acntObj); - } - if($acntObj->id != "") + $modObj->id = $crmid; + $modObj->mode = "edit"; + $modObj->save("Accounts"); + + if($modObj->id != "") { echo ":#:SUCCESS"; }else @@ -49,5 +76,8 @@ if($ajaxaction == "DETAILVIEW") { echo ":#:FAILURE"; } +}elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){ + require_once 'include/ListView/RelatedListViewContents.php'; } -?> \ No newline at end of file + +?> diff --git a/oss/vtiger/trunk/modules/Accounts/ListView.php b/oss/vtiger/trunk/modules/Accounts/ListView.php index 172c973b..434ca622 100644 --- a/oss/vtiger/trunk/modules/Accounts/ListView.php +++ b/oss/vtiger/trunk/modules/Accounts/ListView.php @@ -91,15 +91,6 @@ $smarty->assign("CV_DELETE_PERMIT",$delete_permit); //<<<<>>>> $smarty->assign("CHANGE_OWNER",getUserslist()); $smarty->assign("CHANGE_GROUP_OWNER",getGroupslist()); -if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') -{ - list($where, $ustring) = split("#@@#",getWhereCondition($currentModule)); - // we have a query - $url_string .="&query=true".$ustring; - $log->info("Here is the where clause for the list view: $where"); - $smarty->assign("SEARCH_URL",$url_string); - -} if($viewid != 0) { $CActionDtls = $oCustomView->getCustomActionDetails($viewid); @@ -170,23 +161,31 @@ $smarty->assign("SINGLE_MOD",'Account'); //Retreive the list from Database //<<<<<<<<>>>>>>>> -if($viewid != "0") -{ - $listquery = getListQuery("Accounts"); - $query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Accounts"); -}else -{ - $query = getListQuery("Accounts"); +global $current_user; +$queryGenerator = new QueryGenerator($currentModule, $current_user); +if ($viewid != "0") { + $queryGenerator->initForCustomViewById($viewid); +} else { + $queryGenerator->initForDefaultCustomView(); } //<<<<<<<>>>>>>>> -if(isset($where) && $where != '') -{ - $query .= ' and '.$where; - $_SESSION['export_where'] = $where; +// Enabling Module Search +$url_string = ''; +if($_REQUEST['query'] == 'true') { + $queryGenerator->addUserSearchConditions($_REQUEST); + $ustring = getSearchURL($_REQUEST); + $url_string .= "&query=true$ustring"; + $smarty->assign('SEARCH_URL', $url_string); +} + +$query = $queryGenerator->getQuery(); +$where = $queryGenerator->getConditionalWhere(); +if(isset($where) && $where != '') { + $_SESSION['export_where'] = $where; +} else { + unset($_SESSION['export_where']); } -else - unset($_SESSION['export_where']); $view_script = " +assign("EDIT_DUPLICATE",""); + if($record_count == 2) { + if(isPermitted($currentModule,"EditView",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[1]) == 'yes' + && isPermitted($currentModule,"Delete",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[1]) == 'yes') + $smarty->assign("EDIT_DUPLICATE","permitted"); + } + else { + if(isPermitted($currentModule,"EditView",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[1]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[2]) == 'yes' + && isPermitted($currentModule,"Delete",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[1]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[2]) == 'yes') + $smarty->assign("EDIT_DUPLICATE","permitted"); + } + + $all_values_array=getRecordValues($exploded_id,$module); + $all_values=$all_values_array[0]; + $js_arr_val=$all_values_array[1]; + $fld_array=$all_values_array[2]; + $js_arr=implode(",",$js_arr_val); + + $imported_records = Array(); + $sql="select bean_id from vtiger_users_last_import where bean_type=? and deleted=0"; + $result = $adb->pquery($sql, array($module)); + $num_rows=$adb->num_rows($result); + $count=0; + for($i=0; $i<$num_rows;$i++) + { + foreach($exploded_id as $value) + if($value == $adb->query_result($result,$i,"bean_id")) + $count++; + array_push($imported_records,$adb->query_result($result,$i,"bean_id")); + } + + if ($record_count == $count) + $no_existing=1; + else + $no_existing=0; + + $smarty->assign("MOD", $mod_strings); + $smarty->assign("APP", $app_strings); + $smarty->assign("RECORD_COUNT",$record_count); + $smarty->assign("THEME", $theme); + $smarty->assign("IMAGE_PATH", $image_path); + $smarty->assign("MODULENAME", $module); + $smarty->assign("PARENT_TAB", $parent_tab); + $smarty->assign("JS_ARRAY", $js_arr); + $smarty->assign("ID_ARRAY", $exploded_id); + $smarty->assign("IDSTRING",$idstring); + $smarty->assign("ALLVALUES", $all_values); + $smarty->assign("FIELD_ARRAY", $fld_array); + $smarty->assign("IMPORTED_RECORDS", $imported_records); + $smarty->assign("NO_EXISTING", $no_existing); + $smarty->display("MergeFields.tpl"); +} + +?> diff --git a/oss/vtiger/trunk/modules/Assets/QuickCreate.php b/oss/vtiger/trunk/modules/Assets/QuickCreate.php new file mode 100644 index 00000000..78fe10f6 --- /dev/null +++ b/oss/vtiger/trunk/modules/Assets/QuickCreate.php @@ -0,0 +1,11 @@ + diff --git a/oss/vtiger/trunk/modules/Assets/Save.php b/oss/vtiger/trunk/modules/Assets/Save.php new file mode 100644 index 00000000..14e736d5 --- /dev/null +++ b/oss/vtiger/trunk/modules/Assets/Save.php @@ -0,0 +1,59 @@ +mode = $mode; +if($record)$focus->id = $record; + +$currencyid=fetchCurrency($current_user->id); +$rate_symbol = getCurrencySymbolandCRate($currencyid); +$rate = $rate_symbol['rate']; + +if($_REQUEST['assigntype'] == 'U') { + $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_user_id']; +} elseif($_REQUEST['assigntype'] == 'T') { + $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_group_id']; +} + +$focus->save($currentModule); +$return_id = $focus->id; + +$search = vtlib_purify($_REQUEST['search_url']); + +$parenttab = getParentTab(); +if($_REQUEST['return_module'] != '') { + $return_module = vtlib_purify($_REQUEST['return_module']); +} else { + $return_module = $currentModule; +} + +if($_REQUEST['return_action'] != '') { + $return_action = vtlib_purify($_REQUEST['return_action']); +} else { + $return_action = "DetailView"; +} + +if($_REQUEST['return_id'] != '') { + $return_id = vtlib_purify($_REQUEST['return_id']); +} + +if(isset($_REQUEST['activity_mode'])) $return_action .= '&activity_mode='.vtlib_purify($_REQUEST['activity_mode']); + +header("Location: index.php?action=$return_action&module=$return_module&record=$return_id&parenttab=$parenttab&start=".vtlib_purify($_REQUEST['pagenumber']).$search); + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Assets/Settings.php b/oss/vtiger/trunk/modules/Assets/Settings.php new file mode 100644 index 00000000..980dd078 --- /dev/null +++ b/oss/vtiger/trunk/modules/Assets/Settings.php @@ -0,0 +1,13 @@ + diff --git a/oss/vtiger/trunk/modules/Assets/TagCloud.php b/oss/vtiger/trunk/modules/Assets/TagCloud.php new file mode 100644 index 00000000..8343cd5b --- /dev/null +++ b/oss/vtiger/trunk/modules/Assets/TagCloud.php @@ -0,0 +1,11 @@ + diff --git a/oss/vtiger/trunk/modules/Assets/UnifiedSearch.php b/oss/vtiger/trunk/modules/Assets/UnifiedSearch.php new file mode 100644 index 00000000..9a37320c --- /dev/null +++ b/oss/vtiger/trunk/modules/Assets/UnifiedSearch.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Assets/UpdateListPrice.php b/oss/vtiger/trunk/modules/Assets/UpdateListPrice.php new file mode 100644 index 00000000..64de814f --- /dev/null +++ b/oss/vtiger/trunk/modules/Assets/UpdateListPrice.php @@ -0,0 +1,24 @@ +debug("Going to update the ListPrice in (modules/Products/UpdateListPrice.php)."); +$record = vtlib_purify($_REQUEST['record']); +$pricebook_id = vtlib_purify($_REQUEST['pricebook_id']); +$product_id = vtlib_purify($_REQUEST['product_id']); +$listprice = vtlib_purify($_REQUEST['list_price']); +$return_action = vtlib_purify($_REQUEST['return_action']); +$return_module = vtlib_purify($_REQUEST['return_module']); + +$query = "update vtiger_pricebookproductrel set listprice=? where pricebookid=? and productid=?"; +$adb->pquery($query, array($listprice, $pricebook_id, $product_id)); +header("Location: index.php?module=$return_module&action=".$return_module."Ajax&file=$return_action&ajax=updatelistprice&record=$record"); +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Assets/index.php b/oss/vtiger/trunk/modules/Assets/index.php new file mode 100644 index 00000000..b7add8d8 --- /dev/null +++ b/oss/vtiger/trunk/modules/Assets/index.php @@ -0,0 +1,15 @@ + diff --git a/oss/vtiger/trunk/modules/Assets/language/en_us.lang.php b/oss/vtiger/trunk/modules/Assets/language/en_us.lang.php new file mode 100644 index 00000000..6046e971 --- /dev/null +++ b/oss/vtiger/trunk/modules/Assets/language/en_us.lang.php @@ -0,0 +1,43 @@ +'Assets', +'SINGLE_Assets'=>'Asset', + +/*blocks for the module*/ +'LBL_ASSET_INFORMATION'=>'Asset Information', +'LBL_CUSTOM_INFORMATION'=>'Custom Information', +'LBL_DESCRIPTION_INFORMATION'=>'Notes', + +/*fields for the module*/ +'Assets'=>'Assets', +'Asset Name' => 'Asset Name', +'Customer Name'=>'Customer Name', +'Product Name'=>'Product Name', +'Serial Number'=>'Serial Number', +'Asset No'=>'Asset No', +'Date Sold'=>'Date Sold', +'Date in Service'=>'Date in Service', +'Status'=>'Status', +'Shipping Method'=>'Shipping Method', +'Shipping Tracking Number'=>'Shipping Tracking Number', +'Tag Number'=>'Tag Number', +'Notes'=>'Notes', +'Invoice Name'=>'Invoice Name', + +/*picklist values*/ +'In Service'=>'In Service', +'Out-of-service'=>'Out-of-service', + + +); +?> diff --git a/oss/vtiger/trunk/modules/Assets/schema.xml b/oss/vtiger/trunk/modules/Assets/schema.xml new file mode 100644 index 00000000..032704de --- /dev/null +++ b/oss/vtiger/trunk/modules/Assets/schema.xml @@ -0,0 +1,32 @@ + + + + + vtiger_assets + +
+ + vtiger_assetscf + +
+
+
diff --git a/oss/vtiger/trunk/modules/Assets/updateRelations.php b/oss/vtiger/trunk/modules/Assets/updateRelations.php new file mode 100644 index 00000000..b1429153 --- /dev/null +++ b/oss/vtiger/trunk/modules/Assets/updateRelations.php @@ -0,0 +1,53 @@ +delete_related_module($currentModule, $forCRMRecord, $destinationModule, $ids); + } +} else { + if(!empty($_REQUEST['idlist'])) { + // Split the string of ids + $ids = explode (";",trim($idlist,";")); + } else if(!empty($_REQUEST['entityid'])){ + $ids = $_REQUEST['entityid']; + } + if(!empty($ids)) { + $focus->save_related_module($currentModule, $forCRMRecord, $destinationModule, $ids); + } +} + +header("Location: index.php?module=$currentModule&record=$forCRMRecord&action=$action&parenttab=$parenttab"); +?> diff --git a/oss/vtiger/trunk/modules/Calendar/Activity.php b/oss/vtiger/trunk/modules/Calendar/Activity.php index eb3e2535..ce8d1dd7 100644 --- a/oss/vtiger/trunk/modules/Calendar/Activity.php +++ b/oss/vtiger/trunk/modules/Calendar/Activity.php @@ -25,6 +25,7 @@ require_once('include/logging.php'); require_once('include/database/PearDatabase.php'); require_once('modules/Calendar/RenderRelatedListUI.php'); require_once('data/CRMEntity.php'); +require_once('modules/Calendar/CalendarCommon.php'); // Task is used to store customer information. class Activity extends CRMEntity { @@ -127,7 +128,22 @@ class Activity extends CRMEntity { { $this->deleteRelation('vtiger_cntactivityrel'); } - + if(isset($this->column_fields['sendnotification'])){ + + $mail_data = Array(); + $mail_data['user_id'] = $this->column_fields['assigned_user_id']; + $mail_data['subject'] = $this->column_fields['subject']; + $mail_data['status'] = (($this->column_fields['activitytype']=='Task')?($this->column_fields['taskstatus']):($this->column_fields['eventstatus'])); + $mail_data['taskpriority'] = $this->column_fields['taskpriority']; + $mail_data['contact_name'] = $this->column_fields['contact_id']; + $mail_data['description'] = $this->column_fields['description']; + $value = getaddEventPopupTime($this->column_fields['time_start'],$this->column_fields['time_end'],'24'); + $start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt']; + $mail_data['st_date_time'] = getDisplayDate($this->column_fields['date_start'])." ".$start_hour; + $mail_data['end_date_time']=getDisplayDate($this->column_fields['due_date']); + getEventNotification($this->column_fields['activitytype'],$this->column_fields['subject'],$mail_data); + + } $recur_type=''; if(($recur_type == "--None--" || $recur_type == '') && $this->mode == "edit") { @@ -167,9 +183,10 @@ class Activity extends CRMEntity { global $adb; - $cbrecord = $this->id; + $cbrecord = $this->id; + unset($_SESSION['next_reminder_time']); if(isset($cbmodule) && isset($cbrecord)) { - $cbdate = $this->column_fields['date_start']; + $cbdate = getValidDBInsertDateValue($this->column_fields['date_start']); $cbtime = $this->column_fields['time_start']; $reminder_query = "SELECT reminderid FROM vtiger_activity_reminder_popup WHERE semodule = ? and recordid = ?"; @@ -204,6 +221,7 @@ class Activity extends CRMEntity { $log->info("in insertIntoReminderTable ".$table_name." module is ".$module); if($_REQUEST['set_reminder'] == 'Yes') { + unset($_SESSION['next_reminder_time']); $log->debug("set reminder is set"); $rem_days = $_REQUEST['remdays']; $log->debug("rem_days is ".$rem_days); @@ -335,6 +353,7 @@ function insertIntoRecurringTable(& $recurObj) $recurring_insert = "insert into vtiger_recurringevents values (?,?,?,?,?,?)"; $rec_params = array($current_id, $this->id, $tdate, $type, $recur_freq, $recurringinfo); $adb->pquery($recurring_insert, $rec_params); + unset($_SESSION['next_reminder_time']); if($_REQUEST['set_reminder'] == 'Yes') { $this->insertIntoReminderTable("vtiger_activity_reminder",$module,$current_id,''); @@ -872,7 +891,7 @@ function insertIntoRecurringTable(& $recurObj) $sql = 'DELETE FROM vtiger_cntactivityrel WHERE contactid = ? AND activityid = ?'; $this->db->pquery($sql, array($return_id, $id)); } elseif($return_module == 'HelpDesk') { - $sql = 'DELETE FROM vtiger_seticketsrel WHERE ticketid = ? AND crmid = ?'; + $sql = 'DELETE FROM vtiger_seactivityrel WHERE crmid = ? AND activityid = ?'; $this->db->pquery($sql, array($return_id, $id)); } else { $sql='DELETE FROM vtiger_seactivityrel WHERE activityid=?'; @@ -948,5 +967,50 @@ function insertIntoRecurringTable(& $recurObj) return $query; } + public function getNonAdminAccessControlQuery($module, $user,$scope='') { + require('user_privileges/user_privileges_'.$user->id.'.php'); + require('user_privileges/sharing_privileges_'.$user->id.'.php'); + $query = ' '; + $tabId = getTabid($module); + if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] + == 1 && $defaultOrgSharingPermission[$tabId] == 3) { + $tableName = 'vt_tmp_u'.$user->id.'_t'.$tabId; + $sharingRuleInfoVariable = $module.'_share_read_permission'; + $sharingRuleInfo = $$sharingRuleInfoVariable; + $sharedTabId = null; + $this->setupTemporaryTable($tableName, $sharedTabId, $user, + $current_user_parent_role_seq, $current_user_groups); + $query = " INNER JOIN $tableName $tableName$scope ON ($tableName$scope.id = ". + "vtiger_crmentity$scope.smownerid and $tableName$scope.shared=0) "; + $sharedIds = getSharedCalendarId($user->id); + if(!empty($sharedIds)){ + $query .= "or ($tableName$scope.id = vtiger_crmentity$scope.smownerid AND ". + "$tableName$scope.shared=1 and vtiger_activity$scope.visibility = 'Public') "; + } + } + return $query; + } + + protected function setupTemporaryTable($tableName, $tabId, $user, $parentRole, $userGroups) { + $module = null; + if (!empty($tabId)) { + $module = getTabname($tabId); + } + $query = $this->getNonAdminAccessQuery($module, $user, $parentRole, $userGroups); + $query = "create temporary table IF NOT EXISTS $tableName(id int(11) primary key, shared ". + "int(1) default 0) ignore ".$query; + $db = PearDatabase::getInstance(); + $result = $db->pquery($query, array()); + if(is_object($result)) { + $query = "create temporary table IF NOT EXISTS $tableName(id int(11) primary key, shared ". + "int(1) default 0) replace select 1, userid as id from vtiger_sharedcalendar where ". + "sharedid = $user->id"; + $result = $db->pquery($query, array()); + if(is_object($result)) { + return true; + } + } + return false; + } } -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/Calendar/ActivityReminderCallbackAjax.php b/oss/vtiger/trunk/modules/Calendar/ActivityReminderCallbackAjax.php index 86457bc0..7e666d5e 100644 --- a/oss/vtiger/trunk/modules/Calendar/ActivityReminderCallbackAjax.php +++ b/oss/vtiger/trunk/modules/Calendar/ActivityReminderCallbackAjax.php @@ -22,38 +22,41 @@ require_once('themes/'.$theme.'/layout_utils.php'); require_once('include/utils/utils.php'); require_once('modules/Calendar/Activity.php'); +$cur_time = time(); +$_SESSION['last_reminder_check_time'] = $cur_time; +$_SESSION['next_reminder_interval'] = 60; +if($_SESSION['next_reminder_time'] == 'None') { + return; +} elseif(isset($_SESSION['next_reminder_interval']) && (($_SESSION['next_reminder_time'] - + $_SESSION['next_reminder_interval']) > $cur_time)) { + echo ""; + return; +} $log = LoggerManager::getLogger('Activity_Reminder'); $smarty = new vtigerCRM_Smarty; if(isPermitted('Calendar','index') == 'yes'){ -$active = $adb->pquery("select * from vtiger_users where id=?",array($current_user->id)); -$active_res = $adb->query_result($active,0,'reminder_interval'); -if($active_res!='None'){ - $reminder_next=$adb->query_result($active,0,"reminder_next_time"); - $lastlogin_time =$adb->query_result($active,0,"date_entered"); - if(empty($reminder_next)) { - $reminder_next = date('Y-m-d H:i'); + $active = $adb->pquery("select * from vtiger_users where id=?",array($current_user->id)); + $active_res = $adb->query_result($active,0,'reminder_interval'); + if($active_res == 'None') { + $_SESSION['next_reminder_time'] = 'None'; } - if(strtotime($lastlogin_time) > strtotime($reminder_next)) { - $reminder_next = $lastlogin_time; - } - $reminder_next_time = strtotime($reminder_next); - $cur_time = mktime(date('H'),date('i'),0,date('m'),date('d'),date('Y')); - - if($reminder_next_time <= $cur_time) - { - $cb_time=$adb->query_result($active,0,"reminder_interval"); - $cb_time = ConvertToMinutes($cb_time); - $cb_mktime = strtotime($reminder_next); - $cbdate1 = date('Y-m-d', strtotime("+$cb_time minutes", $cb_mktime)); - $cbtime1 = date('H:i', strtotime("+$cb_time minutes", $cb_mktime)); - $callback_query = + if($active_res!='None'){ + $interval=$adb->query_result($active,0,"reminder_interval"); + $intervalInMinutes = ConvertToMinutes($interval); + // check for reminders every minute + $time = time(); + $_SESSION['next_reminder_time'] = $time + ($intervalInMinutes * 60); + $date = date('Y-m-d', strtotime("+$intervalInMinutes minutes", $time)); + $time = date('H:i', strtotime("+$intervalInMinutes minutes", $time)); + $callback_query = "SELECT * FROM vtiger_activity_reminder_popup inner join vtiger_crmentity where " . " vtiger_activity_reminder_popup.status = 0 and " . " vtiger_activity_reminder_popup.recordid = vtiger_crmentity.crmid " . " and vtiger_crmentity.smownerid = ".$current_user->id." and vtiger_crmentity.deleted = 0 " . - " and ((DATE_FORMAT(vtiger_activity_reminder_popup.date_start,'%Y-%m-%d') < '" . $cbdate1 . "')" . - " OR ((DATE_FORMAT(vtiger_activity_reminder_popup.date_start,'%Y-%m-%d') = '" . $cbdate1 . "')" . - " AND (TIME_FORMAT(vtiger_activity_reminder_popup.time_start,'%H:%i') <= '" . $cbtime1 . "')))"; + " and ((DATE_FORMAT(vtiger_activity_reminder_popup.date_start,'%Y-%m-%d') < '" . $date . "')" . + " OR ((DATE_FORMAT(vtiger_activity_reminder_popup.date_start,'%Y-%m-%d') = '" . $date . "')" . + " AND (TIME_FORMAT(vtiger_activity_reminder_popup.time_start,'%H:%i') <= '" . $time . "')))"; $result = $adb->query($callback_query); @@ -63,12 +66,12 @@ if($active_res!='None'){ $reminderid = $adb->query_result($result, $index, "reminderid"); $cbrecord = $adb->query_result($result, $index, "recordid"); $cbmodule = $adb->query_result($result, $index, "semodule"); - + $focus = CRMEntity::getInstance($cbmodule); - + if($cbmodule == 'Calendar') { $focus->retrieve_entity_info($cbrecord,$cbmodule); - + $cbsubject = $focus->column_fields['subject']; $cbactivitytype = $focus->column_fields['activitytype']; $cbdate = $focus->column_fields["date_start"]; @@ -79,9 +82,9 @@ if($active_res!='None'){ $cbsubject = $cbsubject[0]; $cbactivitytype = getTranslatedString($cbmodule, $cbmodule); $cbdate = $adb->query_result($result, $index, 'date_start'); - $cbtime = $adb->query_result($result, $index, 'time_start'); + $cbtime = $adb->query_result($result, $index, 'time_start'); } - + if($cbactivitytype=='Task') $cbstatus = $focus->column_fields["taskstatus"]; else @@ -109,20 +112,28 @@ if($active_res!='None'){ $mark_reminder_as_read = "UPDATE vtiger_activity_reminder_popup set status = 1 where reminderid = ?"; $adb->pquery($mark_reminder_as_read, array($reminderid)); + echo ""; } + } else { + $callback_query = + "SELECT * FROM vtiger_activity_reminder_popup inner join vtiger_crmentity where " . + " vtiger_activity_reminder_popup.status = 0 and " . + " vtiger_activity_reminder_popup.recordid = vtiger_crmentity.crmid " . + " and vtiger_crmentity.smownerid = ".$current_user->id." and vtiger_crmentity.deleted = 0 ". + "AND vtiger_activity_reminder_popup.reminderid > 0 ORDER BY date_start DESC , ". + "TIME_FORMAT(vtiger_activity_reminder_popup.time_start,'%H:%i') DESC LIMIT 1"; + $result = $adb->query($callback_query); + $it = new SqlResultIterator($adb, $result); + $nextReminderTime = null; + foreach ($it as $row) { + $nextReminderTime = strtotime($row->date_start.' '.$row->time_start); + } + $_SESSION['next_reminder_time'] = $nextReminderTime - ($intervalInMinutes * 60); } - $reminder_next = date('Y-m-d H:i', strtotime("+$cb_time minutes", $cur_time)); - // NOTE date_entered has CURRENT_TIMESTAMP constraint, so we need to reset when updating the table - $adb->pquery("UPDATE vtiger_users set reminder_next_time=?, date_entered=? where id=?",array($reminder_next, $lastlogin_time, $current_user->id)); - $reminder_interval_reset = (strtotime($reminder_next) - $cur_time) * 1000; - - // NOTE (Overcome Browser's issue): If required comment out the following line if condition below. - // To make popup work fine when interval is set to 1 minute, we need decrement the timeout - // if($reminder_interval_reset / 1000 == 60) $reminder_interval_reset = (40 * 1000); - - echo ""; + echo ""; } } -} ?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Calendar/ActivityReminderSetupCallbackAjax.php b/oss/vtiger/trunk/modules/Calendar/ActivityReminderSetupCallbackAjax.php index 4ec94824..0d24f948 100644 --- a/oss/vtiger/trunk/modules/Calendar/ActivityReminderSetupCallbackAjax.php +++ b/oss/vtiger/trunk/modules/Calendar/ActivityReminderSetupCallbackAjax.php @@ -33,6 +33,7 @@ if($cbaction == 'POSTPONE') { if(isset($cbmodule) && isset($cbrecord)) { $reminderid = $_REQUEST['cbreminderid']; if(!empty($reminderid) ) { + unset($_SESSION['next_reminder_time']); $reminder_query = "UPDATE vtiger_activity_reminder_popup set status = 0 WHERE reminderid = ? AND semodule = ? AND recordid = ?"; $adb->pquery($reminder_query, array($reminderid, $cbmodule, $cbrecord)); echo ":#:SUCCESS"; diff --git a/oss/vtiger/trunk/modules/Calendar/Appointment.php b/oss/vtiger/trunk/modules/Calendar/Appointment.php index 8cd69651..2f815452 100644 --- a/oss/vtiger/trunk/modules/Calendar/Appointment.php +++ b/oss/vtiger/trunk/modules/Calendar/Appointment.php @@ -127,7 +127,8 @@ class Appointment } //Get Recurring events - $q = "SELECT vtiger_activity.*, vtiger_crmentity.*, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name , vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start ,vtiger_recurringevents.recurringtype,vtiger_groups.groupname from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid "; + $q = "SELECT vtiger_activity.*, vtiger_crmentity.*, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name , vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start ,vtiger_recurringevents.recurringtype,vtiger_groups.groupname from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid"; + $q .= getNonAdminAccessControlQuery('Calendar',$current_user); $q.=" where vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype not in ('Emails','Task') AND (recurringdate between ? and ?) "; // User Select Customization @@ -135,12 +136,6 @@ class Appointment // END $params = array($from_datetime->get_formatted_date(), $to_datetime->get_formatted_date()); - - if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3) - { - $sec_parameter=getListViewSecurityParameter('Calendar'); - $q .= $sec_parameter; - } $q .= " ORDER by vtiger_recurringevents.recurringid"; $r = $adb->pquery($q, $params); diff --git a/oss/vtiger/trunk/modules/Calendar/Calendar.js b/oss/vtiger/trunk/modules/Calendar/Calendar.js index 51bc89b5..e8d3fb8d 100644 --- a/oss/vtiger/trunk/modules/Calendar/Calendar.js +++ b/oss/vtiger/trunk/modules/Calendar/Calendar.js @@ -96,4 +96,28 @@ function showActivityView(selectactivity_view) document.frmOpenLstView.submit(); } +function exportCalendar(){ + if(document.getElementsByName('exportCalendar')[0].value == 'iCal'){ + var filename = $('ics_filename').value; + VtigerJS_DialogBox.block(); + + var url = "index.php?module=Calendar&action=iCalExport&filename="+filename; + location.href = url; + VtigerJS_DialogBox.unblock(); + ghide('CalExport') + } +} +function importCalendar(){ + var file = document.getElementById('ics_file').value; + if (file != '') { + if (file.indexOf('.ics') != (file.length - 4)) { + alert(alert_arr.PLS_SELECT_VALID_FILE+".ics") + } + else { + document.ical_import.action.value='iCalImport'; + document.ical_import.module.value='Calendar'; + document.ical_import.submit(); + } + } +} diff --git a/oss/vtiger/trunk/modules/Calendar/CalendarCommon.php b/oss/vtiger/trunk/modules/Calendar/CalendarCommon.php index 8c1097ef..1d84a78b 100644 --- a/oss/vtiger/trunk/modules/Calendar/CalendarCommon.php +++ b/oss/vtiger/trunk/modules/Calendar/CalendarCommon.php @@ -332,13 +332,14 @@ function getAssignedTo($tabid) */ function getActivityDetails($description,$user_id,$from='') { - global $log,$current_user; - global $adb,$mod_strings; - $log->debug("Entering getActivityDetails(".$description.") method ..."); - + global $log,$current_user,$current_language; + global $adb; + require_once 'include/utils/utils.php'; + $mod_strings = return_module_language($current_language, 'Calendar'); + $log->debug("Entering getActivityDetails(".$description.") method ..."); $updated = $mod_strings['LBL_UPDATED']; $created = $mod_strings['LBL_CREATED']; - $reply = (($description['mode'] == 'edit')?"$updated":"$created"); + $reply = (($description['mode'] == 'edit')?"$updated":"$created"); if($description['activity_mode'] == "Events") { $end_date_lable=$mod_strings['End date and time']; @@ -355,17 +356,16 @@ function getActivityDetails($description,$user_id,$from='') else $msg = getTranslatedString($mod_strings['LBL_ACTIVITY_NOTIFICATION']); - $current_username = getUserName($current_user->id); - $status = getTranslatedString($description['status']); - - $list = $name.','; + $current_username = getUserName($current_user->id); + $status = getTranslatedString($description['status'],'Calendar'); + $list = $name.','; $list .= '

'.$msg.' '.$reply.'.
'.$mod_strings['LBL_DETAILS_STRING'].':
'; - $list .= '
      '.$mod_strings["LBL_SUBJECT"].' '.$description['subject']; + $list .= '
      '.$mod_strings["LBL_SUBJECT"].' : '.$description['subject']; $list .= '
      '.$mod_strings["Start date and time"].' : '.$description['st_date_time']; $list .= '
      '.$end_date_lable.' : '.$description['end_date_time']; - $list .= '
      '.$mod_strings["LBL_STATUS"].': '.$status; - $list .= '
      '.$mod_strings["Priority"].': '.getTranslatedString($description['taskpriority']); - $list .= '
      '.$mod_strings["Related To"].': '.getTranslatedString($description['relatedto']); + $list .= '
      '.$mod_strings["LBL_STATUS"].': '.$status; + $list .= '
      '.$mod_strings["Priority"].': '.getTranslatedString($description['taskpriority']); + $list .= '
      '.$mod_strings["Related To"].': '.getTranslatedString($description['relatedto']); if(!empty($description['contact_name'])) { $list .= '
      '.$mod_strings["LBL_CONTACT_LIST"].' '.$description['contact_name']; @@ -378,7 +378,7 @@ function getActivityDetails($description,$user_id,$from='') $list .= '
'.$current_username.'.'; $log->debug("Exiting getActivityDetails method ..."); - return $list; + return $list; } function twoDigit( $no ){ @@ -414,24 +414,15 @@ function getEventNotification($mode,$subject,$desc) require_once("modules/Emails/mail.php"); $subject = $mode.' : '.$subject; $crmentity = new CRMEntity(); - if($desc['assingn_type'] == "U") + if(getUserName($desc['user_id'])) { $to_email = getUserEmailId('id',$desc['user_id']); $description = getActivityDetails($desc,$desc['user_id']); send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description); } - if($desc['assingn_type'] == "T") + else { - $groupid = ''; - $groupname=$desc['group_name']; - // getGroupName API was changed to return array of two elements! - if(is_array($groupname) && !empty($groupname)) { - $groupid = $groupname[1]; - $groupname = $groupname[0]; - } else { - $resultqry=$adb->pquery("select groupid from vtiger_groups where groupname=?", array($groupname)); - $groupid=$adb->query_result($resultqry,0,"groupid"); - } + $groupid = $desc['user_id']; require_once('include/utils/GetGroupUsers.php'); $getGroupObj=new GetGroupUsers(); $getGroupObj->getAllUsersInGroup($groupid); @@ -531,7 +522,7 @@ function getActivityMailInfo($return_id,$status,$activity_type) $mail_data['relatedto'] = $rel_name; $mail_data['contact_name'] = $cont_name; $mail_data['description'] = $description; - $mail_data['assingn_type'] = $assignType; + $mail_data['assign_type'] = $assignType; $mail_data['group_name'] = $grp_name; $value = getaddEventPopupTime($st_time,$end_time,'24'); $start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt']; diff --git a/oss/vtiger/trunk/modules/Calendar/DetailView.php b/oss/vtiger/trunk/modules/Calendar/DetailView.php index 74531d09..0c3de6a6 100644 --- a/oss/vtiger/trunk/modules/Calendar/DetailView.php +++ b/oss/vtiger/trunk/modules/Calendar/DetailView.php @@ -274,7 +274,8 @@ elseif($activity_mode == 'Events') $invited_users[$userid]=$username; } $smarty->assign("INVITEDUSERS",$invited_users); - $related_array = getRelatedLists("Calendar", $focus); + $related_array = getRelatedListsInformation("Calendar", $focus); + $smarty->assign("CONTACTS",$related_array['Contacts']['entries']); $is_fname_permitted = getFieldVisibilityPermission("Contacts", $current_user->id, 'firstname'); @@ -347,7 +348,7 @@ if(PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($ // Gather the custom link information to display include_once('vtlib/Vtiger/Link.php'); $customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action'])); -$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), 'DETAILVIEW', $customlink_params)); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params)); // END $custom_fields_data = getCalendarCustomFields($tabid,'detail_view',$focus->column_fields); diff --git a/oss/vtiger/trunk/modules/Calendar/EditView.php b/oss/vtiger/trunk/modules/Calendar/EditView.php index 671ad994..4328a094 100644 --- a/oss/vtiger/trunk/modules/Calendar/EditView.php +++ b/oss/vtiger/trunk/modules/Calendar/EditView.php @@ -70,7 +70,7 @@ if(isset($_REQUEST['record']) && $_REQUEST['record']!='') { } $smarty->assign("INVITEDUSERS",$invited_users); $smarty->assign("UPDATEINFO",updateInfo($focus->id)); - $related_array = getRelatedLists("Calendar", $focus); + $related_array = getRelatedListsInformation("Calendar", $focus); $cntlist = $related_array['Contacts']['entries']; $is_fname_permitted = getFieldVisibilityPermission("Contacts", $current_user->id, 'firstname'); $cnt_idlist = ''; @@ -86,8 +86,8 @@ if(isset($_REQUEST['record']) && $_REQUEST['record']!='') { $cnt_namelist .= "\n"; } $cnt_idlist .= $key; - $contName = eregi_replace("(]*>)(.*)()", "\\2", $cntvalue[0]); - if ($is_fname_permitted == '0') $contName .= ' '.eregi_replace("(]*>)(.*)()", "\\2", $cntvalue[1]); + $contName = preg_replace("/(]*>)(.*)(<\/a>)/i", "\\2", $cntvalue[0]); + if ($is_fname_permitted == '0') $contName .= ' '.preg_replace("/(]*>)(.*)(<\/a>)/i", "\\2", $cntvalue[1]); $cnt_namelist .= ''; $i++; } diff --git a/oss/vtiger/trunk/modules/Calendar/ListView.php b/oss/vtiger/trunk/modules/Calendar/ListView.php index 2ac99415..7bb2422c 100644 --- a/oss/vtiger/trunk/modules/Calendar/ListView.php +++ b/oss/vtiger/trunk/modules/Calendar/ListView.php @@ -226,7 +226,7 @@ if( $adb->dbType == "pgsql") else $list_result = $adb->pquery($list_query. " LIMIT $limit_start_rec, $list_max_entries_per_page", array()); -$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec); +$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec,$noofrows); $smarty->assign('recordListRange',$recordListRangeMsg); //Retreive the List View Table Header @@ -269,6 +269,12 @@ $smarty->assign("CHECK", $check_button); $_SESSION[$currentModule.'_listquery'] = $list_query; +// Gather the custom link information to display +include_once('vtlib/Vtiger/Link.php'); +$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params)); +// END + if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '') $smarty->display("ListViewEntries.tpl"); else diff --git a/oss/vtiger/trunk/modules/Calendar/OpenListView.php b/oss/vtiger/trunk/modules/Calendar/OpenListView.php index 4910f09d..27d0e301 100644 --- a/oss/vtiger/trunk/modules/Calendar/OpenListView.php +++ b/oss/vtiger/trunk/modules/Calendar/OpenListView.php @@ -45,9 +45,7 @@ function getPendingActivities($mode,$view=''){ $theme_path="themes/".$theme."/"; $image_path=$theme_path."images/"; - require('user_privileges/user_privileges_'.$current_user->id.'.php'); - require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); - + if($_REQUEST['activity_view']==''){ $activity_view='today'; }else{ @@ -64,21 +62,32 @@ function getPendingActivities($mode,$view=''){ } if($mode != 1){ - $list_query = " select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_recurringevents.recurringdate, - vtiger_activity.activityid, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date, - from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 and vtiger_activity.activitytype not in ('Emails') AND ( vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and ( vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus not in ('Held','Not Held') )".$upcoming_condition; - if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3){ - $sec_parameter=getListViewSecurityParameter('Calendar'); - $list_query .= $sec_parameter; - } + $list_query = " select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.". + "setype, vtiger_recurringevents.recurringdate, vtiger_activity.activityid, ". + "vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date,". + "from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=". + "vtiger_activity.activityid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = ". + "vtiger_crmentity.smownerid left outer join vtiger_recurringevents on ". + "vtiger_recurringevents.activityid=vtiger_activity.activityid"; + $list_query .= getNonAdminAccessControlQuery('Calendar',$current_user); + $list_query .= " WHERE vtiger_crmentity.deleted=0 and vtiger_activity.activitytype not in ". + "('Emails') AND ( vtiger_activity.status is NULL OR vtiger_activity.status not in". + "('Completed','Deferred')) and ( vtiger_activity.eventstatus is NULL OR vtiger_activity.". + "eventstatus not in ('Held','Not Held') )".$upcoming_condition; + }else{ - $list_query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_recurringevents.recurringdate, - vtiger_activity.activityid, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date, - from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype not in ('Emails')) AND (vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus not in ('Held','Not Held')) ".$pending_condition; - if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3){ - $sec_parameter=getListViewSecurityParameter('Calendar'); - $list_query .= $sec_parameter; - } + $list_query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity". + "setype, vtiger_recurringevents.recurringdate, vtiger_activity.activityid, vtiger_activity". + ".activitytype, vtiger_activity.date_start, vtiger_activity.due_date, from vtiger_activity". + "inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid ". + "LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid ". + "left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=". + "vtiger_activity.activityid"; + $list_query .= getNonAdminAccessControlQuery('Calendar',$current_user); + $list_query .= "WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.". + "activitytype not in ('Emails')) AND (vtiger_activity.status is NULL OR vtiger_activity.". + "status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR ". + "vtiger_activity.eventstatus not in ('Held','Not Held')) ".$pending_condition; $list_query.= " GROUP BY vtiger_activity.activityid"; $list_query.= " ORDER BY date_start,time_start ASC"; @@ -117,7 +126,7 @@ function getPendingActivities($mode,$view=''){ $entries=array(); foreach($open_activity_list as $event){ - $recur_date=ereg_replace('--','',$event['recurringdate']); + $recur_date=preg_replace('/--/','',$event['recurringdate']); if($recur_date!=""){ $event['date_start']=$event['recurringdate']; } diff --git a/oss/vtiger/trunk/modules/Calendar/RenderRelatedListUI.php b/oss/vtiger/trunk/modules/Calendar/RenderRelatedListUI.php index 7d2d0ccc..2499f82a 100644 --- a/oss/vtiger/trunk/modules/Calendar/RenderRelatedListUI.php +++ b/oss/vtiger/trunk/modules/Calendar/RenderRelatedListUI.php @@ -54,7 +54,7 @@ require_once('include/utils/UserInfoUtil.php'); global $log; $log->debug("Entering time_to_number(".$time_start.") method ..."); $start_time_array = explode(":",$time_start); - if(ereg("^[0]",$start_time_array[0])) + if(preg_match("/^[0]/",$start_time_array[0])) { $time_start_hrs=str_replace('0',"",$start_time_array[0]); } diff --git a/oss/vtiger/trunk/modules/Calendar/RepeatEvents.php b/oss/vtiger/trunk/modules/Calendar/RepeatEvents.php index d41b1587..8badf65e 100644 --- a/oss/vtiger/trunk/modules/Calendar/RepeatEvents.php +++ b/oss/vtiger/trunk/modules/Calendar/RepeatEvents.php @@ -148,7 +148,8 @@ class Calendar_RepeatEvents { /** Create instance before and reuse */ $new_focus = new Activity(); - foreach($repeatIntervals as $interval) { + $numberOfRepeats = count($repeatIntervals); + foreach($repeatIntervals as $index => $interval) { $new_focus_start_timing = self::nexttime($base_focus_start, "+$interval days"); $new_focus_start_timing = self::splittime(self::formattime($new_focus_start_timing)); @@ -157,7 +158,7 @@ class Calendar_RepeatEvents { // Reset the new_focus and prepare for reuse if(isset($new_focus->id)) unset($new_focus->id); - foreach($new_focus->column_fields as $key=>$value) $new_focus->column_fields[$key] = ''; + $new_focus->column_fields = array(); foreach($base_focus->column_fields as $key=>$value) { if(in_array($key, $skip_focus_fields)) { @@ -173,7 +174,10 @@ class Calendar_RepeatEvents { } else { $new_focus->column_fields[$key] = $value; } - } + } + if($numberOfRepeats > 10 && $index > 10) { + unset($new_focus->column_fields['sendnotification']); + } $new_focus->save('Calendar'); } } diff --git a/oss/vtiger/trunk/modules/Calendar/Save.php b/oss/vtiger/trunk/modules/Calendar/Save.php index d9e73830..5114e2e9 100644 --- a/oss/vtiger/trunk/modules/Calendar/Save.php +++ b/oss/vtiger/trunk/modules/Calendar/Save.php @@ -83,11 +83,6 @@ if((isset($_REQUEST['change_status']) && $_REQUEST['change_status']) && ($_REQUE "; echo "";die; } - $mail_data = getActivityMailInfo($return_id,$status,$activity_type); - if($mail_data['sendnotification'] == 1) - { - getEventNotification($activity_type,$mail_data['subject'],$mail_data); - } $invitee_qry = "select * from vtiger_invitees where activityid=?"; $invitee_res = $adb->pquery($invitee_qry, array($return_id)); $count = $adb->num_rows($invitee_res); @@ -196,7 +191,7 @@ function getRequestData($return_id) $mail_data['relatedto'] = $_REQUEST['parent_name']; $mail_data['contact_name'] = $cont_name; $mail_data['description'] = $_REQUEST['description']; - $mail_data['assingn_type'] = $_REQUEST['assigntype']; + $mail_data['assign_type'] = $_REQUEST['assigntype']; $mail_data['group_name'] = getGroupName($_REQUEST['assigned_group_id']); $mail_data['mode'] = $_REQUEST['mode']; $value = getaddEventPopupTime($_REQUEST['time_start'],$_REQUEST['time_end'],'24'); @@ -215,11 +210,12 @@ if(isset($_REQUEST['contactidlist']) && $_REQUEST['contactidlist'] != '') $storearray = explode (";",$_REQUEST['contactidlist']); $del_sql = "delete from vtiger_cntactivityrel where activityid=?"; $adb->pquery($del_sql, array($record)); + $record = $focus->id; foreach($storearray as $id) { if($id != '') { - $record = $focus->id; + $sql = "insert into vtiger_cntactivityrel values (?,?)"; $adb->pquery($sql, array($id, $record)); if(!empty($heldevent_id)) { @@ -229,7 +225,6 @@ if(isset($_REQUEST['contactidlist']) && $_REQUEST['contactidlist'] != '') } } } - //Added code to send mail to the assigned to user about the details of the vtiger_activity if sendnotification = on and assigned to user if($_REQUEST['sendnotification'] == 'on') { @@ -297,10 +292,14 @@ if($_REQUEST['return_viewname'] != '') $parenttab=getParentTab(); -if($_REQUEST['start'] !='') +if(!empty($_REQUEST['start'])) { $page='&start='.vtlib_purify($_REQUEST['start']); +} +if(!empty($_REQUEST['pagenumber'])){ + $page = "&start=".vtlib_purify($_REQUEST['pagenumber']); +} if($_REQUEST['maintab'] == 'Calendar') header("Location: index.php?action=".$return_action."&module=".$return_module."&view=".$view."&hour=".$hour."&day=".$day."&month=".$month."&year=".$year."&record=".$return_id."&viewOption=".$viewOption."&subtab=".$subtab."&parenttab=$parenttab"); else - header("Location: index.php?action=$return_action&module=$return_module$view$hour$day$month$year&record=$return_id$activemode&viewname=$return_viewname$page&parenttab=$parenttab&start=".vtlib_purify($_REQUEST['pagenumber']).$search); -?> \ No newline at end of file + header("Location: index.php?action=$return_action&module=$return_module$view$hour$day$month$year&record=$return_id$activemode&viewname=$return_viewname$page&parenttab=$parenttab$search"); +?> diff --git a/oss/vtiger/trunk/modules/Calendar/TodoSave.php b/oss/vtiger/trunk/modules/Calendar/TodoSave.php index 03282363..8bafec3d 100644 --- a/oss/vtiger/trunk/modules/Calendar/TodoSave.php +++ b/oss/vtiger/trunk/modules/Calendar/TodoSave.php @@ -43,9 +43,12 @@ foreach($focus->column_fields as $fieldname => $val) } $focus->column_fields["subject"] = $_REQUEST["task_subject"]; $focus->column_fields["time_start"] = $_REQUEST["task_time_start"]; - $focus->column_fields["assigned_user_id"] = $_REQUEST["task_assigned_user_id"]; - $_REQUEST["assigned_group_id"] = $_REQUEST['task_assigned_group_id']; - $_REQUEST['assigntype'] = $_REQUEST['task_assigntype']; + if($_REQUEST['task_assigntype'] == 'U') { + $focus->column_fields['assigned_user_id'] = $_REQUEST['task_assigned_user_id']; + } elseif($_REQUEST['task_assigntype'] == 'T') { + $focus->column_fields['assigned_user_id'] = $_REQUEST['task_assigned_group_id']; + } + $focus->column_fields["taskstatus"] = $_REQUEST["taskstatus"]; $focus->column_fields["date_start"] = $_REQUEST["task_date_start"]; $focus->column_fields["due_date"] = $_REQUEST["task_due_date"]; @@ -55,14 +58,8 @@ foreach($focus->column_fields as $fieldname => $val) $focus->column_fields["description"] = $_REQUEST["task_description"]; if(isset($_REQUEST['task_sendnotification']) && $_REQUEST['task_sendnotification'] != null) $focus->column_fields["sendnotification"] = $_REQUEST["task_sendnotification"]; + $focus->save($tab_type); - $focus->save($tab_type); - if($_REQUEST["task_sendnotification"]=='on') - { - $mail_contents = getRequestedToData(); - getEventNotification($_REQUEST['activity_mode'],$_REQUEST['task_subject'],$mail_contents); - - } function getRequestedToData() { $mail_data = Array(); @@ -74,7 +71,7 @@ function getRequestedToData() $mail_data['relatedto'] = $_REQUEST['task_parent_name']; $mail_data['contact_name'] = $_REQUEST['task_contact_name']; $mail_data['description'] = $_REQUEST['task_description']; - $mail_data['assingn_type'] = $_REQUEST['task_assigntype']; + $mail_data['assign_type'] = $_REQUEST['task_assigntype']; $mail_data['group_name'] = getGroupName($_REQUEST['task_assigned_group_id']); $mail_data['mode'] = $_REQUEST['task_mode']; $value = getaddEventPopupTime($_REQUEST['task_time_start'],$_REQUEST['task_time_end'],'24'); @@ -85,4 +82,4 @@ function getRequestedToData() } header("Location: index.php?action=index&module=Calendar&view=".vtlib_purify($_REQUEST['view'])."&hour=".vtlib_purify($_REQUEST['hour'])."&day=".vtlib_purify($_REQUEST['day'])."&month=".vtlib_purify($_REQUEST['month'])."&year=".vtlib_purify($_REQUEST['year'])."&viewOption=".vtlib_purify($_REQUEST['viewOption'])."&subtab=todo&parenttab=".getParentTab()); -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/Calendar/calendarLayout.php b/oss/vtiger/trunk/modules/Calendar/calendarLayout.php index 658df3d5..80c35023 100644 --- a/oss/vtiger/trunk/modules/Calendar/calendarLayout.php +++ b/oss/vtiger/trunk/modules/Calendar/calendarLayout.php @@ -1105,7 +1105,7 @@ function getdayEventLayer(& $cal,$slice,$rows) $color = $act[$i]->color; $image = vtiger_imageurl($act[$i]->image_name, $theme); if($act[$i]->recurring) - $recurring = ''; + $recurring = ''; else $recurring = ' '; $height = $rowspan * 75; @@ -1207,7 +1207,7 @@ function getweekEventLayer(& $cal,$slice) $image = vtiger_imageurl($act[$i]->image_name, $theme); $idShared = "normal"; if($act[$i]->shared) $idShared = "shared"; if($act[$i]->recurring) - $recurring = ''; + $recurring = ''; else $recurring = ' '; $color = $act[$i]->color; @@ -1360,24 +1360,10 @@ function getEventList(& $calendar,$start_date,$end_date,$info='') $cal_log->debug("Entering getEventList() method..."); //modified query to fix the ticket #5014 & #5180 - $and = "AND ((((vtiger_activity.date_start between ? AND ?) - OR (vtiger_activity.date_start < ? AND vtiger_activity.due_date > ?) - OR (vtiger_activity.due_date between ? AND ?)) + $and = "AND (((vtiger_activity.date_start >= ? AND vtiger_activity.due_date <= ?) AND (vtiger_recurringevents.activityid is NULL)) OR (vtiger_recurringevents.recurringdate BETWEEN ? AND ?))"; - $count_qry = "SELECT count(*) as count FROM vtiger_activity - INNER JOIN vtiger_crmentity - ON vtiger_crmentity.crmid = vtiger_activity.activityid - LEFT JOIN vtiger_groups - ON vtiger_groups.groupid = vtiger_crmentity.smownerid - LEFT JOIN vtiger_users - ON vtiger_users.id = vtiger_crmentity.smownerid - LEFT OUTER JOIN vtiger_recurringevents - ON vtiger_recurringevents.activityid = vtiger_activity.activityid - WHERE vtiger_crmentity.deleted = 0 - AND (vtiger_activity.activitytype not in ('Emails','Task')) $and "; - $query = "SELECT vtiger_groups.groupname, vtiger_users.user_name,vtiger_crmentity.smownerid, vtiger_crmentity.crmid, vtiger_activity.* FROM vtiger_activity INNER JOIN vtiger_crmentity @@ -1390,7 +1376,8 @@ function getEventList(& $calendar,$start_date,$end_date,$info='') ON vtiger_recurringevents.activityid = vtiger_activity.activityid WHERE vtiger_crmentity.deleted = 0 AND (vtiger_activity.activitytype not in ('Emails','Task')) $and "; - $list_query = $query." AND vtiger_crmentity.smownerid = " . $current_user->id; + + $list_query = $query." AND vtiger_crmentity.smownerid = " . $current_user->id; // User Select Customization: Changes should made also in (Appointment::readAppointment) $query_filter_prefix = calendarview_getSelectedUserFilterQuerySuffix(); @@ -1398,7 +1385,7 @@ function getEventList(& $calendar,$start_date,$end_date,$info='') $count_query .= $query_filter_prefix; // END - $params = $info_params = array($start_date, $end_date, $start_date, $end_date, $start_date, $end_date, $start_date, $end_date); + $params = $info_params = array($start_date, $end_date, $start_date, $end_date); if($info != '') { $groupids = explode(",", fetchUserGroupids($current_user->id)); // Explode can be removed, once implode is removed from fetchUserGroupids @@ -1432,40 +1419,50 @@ function getEventList(& $calendar,$start_date,$end_date,$info='') { $sec_parameter=getCalendarViewSecurityParameter(); $query .= $sec_parameter; - $list_query .= $sec_parameter; - $count_qry .= $sec_parameter; } if(isset($_REQUEST['type']) && $_REQUEST['type'] == 'search') { $search_where = calendar_search_where($_REQUEST['field_name'],$_REQUEST['search_option'],$_REQUEST['search_text']); - $group_cond .= $search_where; - $count_qry .= $search_where; - } + $group_cond .= $search_where; + } $group_cond .= " GROUP BY vtiger_activity.activityid ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC"; - $count_qry .= ' GROUP BY vtiger_activity.activityid '; - $count_res = $adb->pquery($count_qry, $params); - $total_rec_count = $adb->num_rows($count_res); - if(isset($_REQUEST['start']) && $_REQUEST['start'] != '') - $start = vtlib_purify($_REQUEST['start']); - else - $start = 1; - $navigation_array = getNavigationValues($start, $total_rec_count, $list_max_entries_per_page); - $start_rec = $navigation_array['start']; + + //Ticket 6476 + if(PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true){ + $count_result = $adb->pquery( mkCountQuery( $query),$params); + $noofrows = $adb->query_result($count_result,0,"count"); + }else{ + $noofrows = null; + } + global $currentModule; + $queryMode = (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true'); + //$viewid is used as a key for cache query and other info so pass the dates as viewid + $viewid = $start_date.$end_date; + $start = ListViewSession::getRequestCurrentPage($currentModule, $adb->convert2sql($query, + $params), $viewid, $queryMode); + + $navigation_array = VT_getSimpleNavigationValues($start,$list_max_entries_per_page,$noofrows); + + //end + + $start_rec = ($start-1) * $list_max_entries_per_page; $end_rec = $navigation_array['end_val']; - if($start_rec <= 1) + //print_r($navigation_array);die(); + //echo $end_rec.'val'; + + $list_query = $adb->convert2Sql($query, $params); + $_SESSION['Calendar_listquery'] = $list_query; + + if($start_rec < 0) $start_rec = 0; - else - $start_rec = $start_rec-1; $query .= $group_cond." limit $start_rec,$list_max_entries_per_page"; - $list_query .= $group_cond; if( $adb->dbType == "pgsql"){ - $query = fixPostgresQuery( $query, $log, 0); - $list_query = fixPostgresQuery( $list_query, $log, 0); + $query = fixPostgresQuery($query, $log, 0); } - $list_query = $adb->convert2Sql($list_query, $params); - $_SESSION['Calendar_listquery'] = $list_query; - + + + $result = $adb->pquery($query, $params); $rows = $adb->num_rows($result); $c = 0; @@ -1597,20 +1594,8 @@ function getTodoList(& $calendar,$start_date,$end_date,$info='') $cal_log->debug("Entering getTodoList() method..."); require('user_privileges/user_privileges_'.$current_user->id.'.php'); require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); - $count_qry = "SELECT count(*) as count FROM vtiger_activity - INNER JOIN vtiger_crmentity - ON vtiger_crmentity.crmid = vtiger_activity.activityid - LEFT JOIN vtiger_cntactivityrel - ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid - LEFT JOIN vtiger_groups - ON vtiger_groups.groupid = vtiger_crmentity.smownerid - LEFT JOIN vtiger_users - ON vtiger_users.id = vtiger_crmentity.smownerid - WHERE vtiger_crmentity.deleted = 0 - AND vtiger_activity.activitytype = 'Task' - AND (vtiger_activity.date_start BETWEEN ? AND ?) AND vtiger_crmentity.smownerid = " . $current_user->id; - - $query = "SELECT vtiger_groups.groupname, vtiger_users.user_name, vtiger_crmentity.crmid, vtiger_cntactivityrel.contactid, + + $query = "SELECT vtiger_groups.groupname, vtiger_users.user_name, vtiger_crmentity.crmid, vtiger_cntactivityrel.contactid, vtiger_activity.* FROM vtiger_activity INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_activity.activityid @@ -1619,13 +1604,12 @@ function getTodoList(& $calendar,$start_date,$end_date,$info='') LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_users - ON vtiger_users.id = vtiger_crmentity.smownerid - WHERE vtiger_crmentity.deleted = 0 - AND vtiger_activity.activitytype = 'Task' - AND (vtiger_activity.date_start BETWEEN ? AND ?) AND vtiger_crmentity.smownerid = " . $current_user->id; - - $list_query = $query; + ON vtiger_users.id = vtiger_crmentity.smownerid"; + $query .= getNonAdminAccessControlQuery('Calendar',$current_user); + $query .= "WHERE vtiger_crmentity.deleted = 0 AND vtiger_activity.activitytype = 'Task'". + " AND (vtiger_activity.date_start BETWEEN ? AND ?)"; + $list_query = $query." AND vtiger_crmentity.smownerid = " . $current_user->id; // User Select Customization /*$only_for_user = calendarview_getSelectedUserId(); if($only_for_user != 'ALL') { @@ -1669,39 +1653,38 @@ function getTodoList(& $calendar,$start_date,$end_date,$info='') return Array('totaltodo'=>$total,'pendingtodo'=>$pending_rows); } - if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[9] == 3) - { - $sec_parameter=getListViewSecurityParameter('Calendar'); - $query .= $sec_parameter; - $list_query .= $sec_parameter; - $count_qry .= $sec_parameter; - } $group_cond = ''; - $count_res = $adb->pquery($count_qry, $params); - $total_rec_count = $adb->query_result($count_res,0,'count'); $group_cond .= " ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC"; - if(isset($_REQUEST['start']) && $_REQUEST['start'] != '') + if(isset($_REQUEST['start']) && $_REQUEST['start'] != '') $start = vtlib_purify($_REQUEST['start']); else $start = 1; - $navigation_array = getNavigationValues($start, $total_rec_count, $list_max_entries_per_page); - - $start_rec = $navigation_array['start']; + +//T6477 changes + if(PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true){ + $count_res = $adb->pquery(mkCountQuery($query), $params); + $total_rec_count = $adb->query_result($count_res,0,'count'); + }else{ + $total_rec_count = null; + } + + $navigation_array = VT_getSimpleNavigationValues($start,$list_max_entries_per_page,$total_rec_count); + + $start_rec = ($start-1) * $list_max_entries_per_page; $end_rec = $navigation_array['end_val']; - if($start_rec <= 1) + + $list_query = $adb->convert2Sql($query, $params); + $_SESSION['Calendar_listquery'] = $list_query; + + if($start_rec < 0) $start_rec = 0; - else - $start_rec = $start_rec-1; + + //ends $query .= $group_cond." limit $start_rec,$list_max_entries_per_page"; - $list_query .= $group_cond; - + if( $adb->dbType == "pgsql"){ $query = fixPostgresQuery( $query, $log, 0); - $list_query = fixPostgresQuery( $list_query, $log, 0); } - - $list_query = $adb->convert2Sql($list_query, $params); - $_SESSION['Calendar_listquery'] = $list_query; $result = $adb->pquery($query, $params); $rows = $adb->num_rows($result); @@ -1892,7 +1875,9 @@ function constructEventListView(& $cal,$entry_list,$navigation_array='') $list_view .=""; $header_rows = count($header); - $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Calendar","index"); + + $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Calendar","index"); + if($navigationOutput != '') { $list_view .= ""; } @@ -2102,7 +2087,7 @@ function constructTodoListView($todo_list,$cal,$subtab,$navigation_array='') { $list_view .=""; } - $list_view .=" + $list_view .="
"; @@ -1946,7 +1931,7 @@ function constructEventListView(& $cal,$entry_list,$navigation_array='') //checking permission for Create/Edit Operation if(isPermitted("Calendar","EditView") == "yes") { - $list_view .="".$app_strings['LBL_YOU_CAN_CREATE']." ".$app_strings['LBL_AN']." ".$app_strings['Event']." ".$app_strings['LBL_NOW'].".
+ $list_view .="
".$app_strings['LBL_YOU_CAN_CREATE']." ".$app_strings['LBL_AN']." ".$app_strings['Event']." ".$app_strings['LBL_NOW'].". ".$app_strings['LBL_CLICK_THE_LINK'].":
  -".$app_strings['LBL_CREATE']." ".$app_strings['LBL_AN']." ".$app_strings['Event']."
 ".getTodoInfo($cal,'listcnt')." ".getTodoInfo($cal,'listcnt')."   
@@ -2110,7 +2095,9 @@ function constructTodoListView($todo_list,$cal,$subtab,$navigation_array='')
"; $header_rows = count($header); - $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Calendar","index"); + $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Calendar","index"); + + if($navigationOutput != '') { $list_view .= ""); @@ -266,13 +261,16 @@ if(isPermitted("Contacts","Merge") == 'yes') if(!empty($viewid)) $url_string .="&viewname=".$viewid; -$listview_header = getListViewHeader($focus,"Contacts",$url_string,$sorder,$order_by,"",$oCustomView); +$controller = new ListViewController($adb, $current_user, $queryGenerator); +$listview_header = $controller->getListViewHeader($focus,$currentModule,$url_string,$sorder, + $order_by); $smarty->assign("LISTHEADER", $listview_header); -$listview_header_search=getSearchListHeaderValues($focus,"Contacts",$url_string,$sorder,$order_by,"",$oCustomView); +$listview_header_search = $controller->getBasicSearchFieldInfoList(); $smarty->assign("SEARCHLISTHEADER", $listview_header_search); -$listview_entries = getListViewEntries($focus,"Contacts",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView); +$listview_entries = $controller->getListViewEntries($focus,$currentModule,$list_result, + $navigation_array); $smarty->assign("LISTENTITY", $listview_entries); $smarty->assign("SELECT_SCRIPT", $view_script); @@ -286,7 +284,7 @@ $smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries),";") $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Contacts","index",$viewid); $alphabetical = AlphabeticalSearch($currentModule,'index','lastname','true','basic',"","","","",$viewid); -$fieldnames = getAdvSearchfields($currentModule); +$fieldnames = $controller->getAdvancedSearchOptionString(); $criteria = getcriteria_options(); $smarty->assign("CRITERIA", $criteria); $smarty->assign("FIELDNAMES", $fieldnames); @@ -300,6 +298,12 @@ $smarty->assign("CHECK", $check_button); $_SESSION[$currentModule.'_listquery'] = $list_query; +// Gather the custom link information to display +include_once('vtlib/Vtiger/Link.php'); +$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params)); +// END + if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '') $smarty->display("ListViewEntries.tpl"); else diff --git a/oss/vtiger/trunk/modules/Contacts/Merge.php b/oss/vtiger/trunk/modules/Contacts/Merge.php index 17cac46a..d85f5583 100644 --- a/oss/vtiger/trunk/modules/Contacts/Merge.php +++ b/oss/vtiger/trunk/modules/Contacts/Merge.php @@ -218,7 +218,7 @@ while($columnValues = $adb->fetch_array($result)) $actual_values[$x] = $value; $actual_values[$x] = str_replace('"'," ",$actual_values[$x]); //if value contains any line feed or carriage return replace the value with ".value." - if (preg_match ("/(\r\n)/", $actual_values[$x])) + if (preg_match ("/(\r?\n)/", $actual_values[$x])) { $actual_values[$x] = '"'.$actual_values[$x].'"'; } diff --git a/oss/vtiger/trunk/modules/Contacts/Save.php b/oss/vtiger/trunk/modules/Contacts/Save.php index d5104a97..a19577dd 100644 --- a/oss/vtiger/trunk/modules/Contacts/Save.php +++ b/oss/vtiger/trunk/modules/Contacts/Save.php @@ -125,18 +125,25 @@ if($image_error=="false") if(isset($_REQUEST['activity_mode']) && $_REQUEST['activity_mode'] != '') $activitymode = vtlib_purify($_REQUEST['activity_mode']); $local_log->debug("Saved record with id of ".$return_id); - if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] == "Campaigns") { if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") { + $campContStatusResult = $adb->pquery("select campaignrelstatusid from vtiger_campaigncontrel where campaignid=? AND contactid=?",array($_REQUEST['return_id'], $focus->id)); + $contactStatus = $adb->query_result($campContStatusResult,0,'campaignrelstatusid'); $sql = "delete from vtiger_campaigncontrel where contactid = ?"; $adb->pquery($sql, array($focus->id)); - $sql = "insert into vtiger_campaigncontrel values (?,?)"; - $adb->pquery($sql, array($_REQUEST['return_id'], $focus->id)); + if(isset($contactStatus) && $contactStatus!=''){ + $sql = "insert into vtiger_campaigncontrel values (?,?,?)"; + $adb->pquery($sql, array($_REQUEST['return_id'], $focus->id,$contactStatus)); + } + else + { + $sql = "insert into vtiger_campaigncontrel values (?,?,1)"; + $adb->pquery($sql, array($_REQUEST['return_id'], $focus->id)); + } } } - //BEGIN -- Code for Create Customer Portal Users password and Send Mail if($_REQUEST['portal'] == '' && $_REQUEST['mode'] == 'edit') { @@ -212,12 +219,9 @@ if($image_error=="false") if($_REQUEST['return_viewname'] != '')$return_viewname=vtlib_purify($_REQUEST['return_viewname']); $parenttab = getParentTab(); - - //Send notification mail to the assigned to owner about the contact creation - if($focus->column_fields['notify_owner'] == 1 || $focus->column_fields['notify_owner'] == 'on') - $status = sendNotificationToOwner('Contacts',$focus); + header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&activity_mode=$activitymode&viewname=$return_viewname&start=".vtlib_purify($_REQUEST['pagenumber'])); } -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/Contacts/language/en_us.lang.php b/oss/vtiger/trunk/modules/Contacts/language/en_us.lang.php index 61b21493..ac90dd61 100644 --- a/oss/vtiger/trunk/modules/Contacts/language/en_us.lang.php +++ b/oss/vtiger/trunk/modules/Contacts/language/en_us.lang.php @@ -246,4 +246,4 @@ $mod_strings = Array( ); -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/Contacts/updateRelations.php b/oss/vtiger/trunk/modules/Contacts/updateRelations.php index ea8cd200..c526ba9b 100644 --- a/oss/vtiger/trunk/modules/Contacts/updateRelations.php +++ b/oss/vtiger/trunk/modules/Contacts/updateRelations.php @@ -41,7 +41,7 @@ foreach($storearray as $id) if($dest_mod == 'Products') $adb->pquery("insert into vtiger_seproductsrel values (?,?,?)", array($forCRMRecord, $id, 'Contacts')); elseif($dest_mod == 'Campaigns') - $adb->pquery("insert into vtiger_campaigncontrel values(?,?)", array($id, $forCRMRecord)); + $adb->pquery("insert into vtiger_campaigncontrel values(?,?,1)", array($id, $forCRMRecord)); elseif($dest_mod == 'Documents') $adb->pquery("insert into vtiger_senotesrel values(?,?)", array($forCRMRecord,$id)); else { @@ -52,4 +52,4 @@ foreach($storearray as $id) header("Location: index.php?action=$action&module=$currentModule&record=".$forCRMRecord."&parenttab=".$parenttab); -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/CustomView/CustomView.php b/oss/vtiger/trunk/modules/CustomView/CustomView.php index 45af420b..5bfb7379 100644 --- a/oss/vtiger/trunk/modules/CustomView/CustomView.php +++ b/oss/vtiger/trunk/modules/CustomView/CustomView.php @@ -14,6 +14,7 @@ global $theme; $theme_path="themes/".$theme."/"; $image_path=$theme_path."images/"; require_once('include/utils/utils.php'); +require_once 'include/Webservices/Utils.php'; global $adv_filter_options; @@ -54,6 +55,8 @@ class CustomView extends CRMEntity{ // Information as defined for this instance in the database table. protected $_status = false; protected $_userid = false; + protected $meta; + protected $moduleMetaInfo; /** This function sets the currentuser id to the class variable smownerid, * modulename to the class variable customviewmodule @@ -67,8 +70,26 @@ class CustomView extends CRMEntity{ $this->escapemodule[] = $module."_"; $this->escapemodule[] = "_"; $this->smownerid = $current_user->id; + $this->moduleMetaInfo = array(); + if($module != "" && $module != 'Calendar') { + $this->meta = $this->getMeta($module, $current_user); + } } + /** + * + * @param String:ModuleName $module + * @return EntityMeta + */ + public function getMeta($module, $user) { + $db = PearDatabase::getInstance(); + if (empty($this->moduleMetaInfo[$module])) { + $handler = vtws_getModuleHandlerFromName($module, $user); + $meta = $handler->getMeta(); + $this->moduleMetaInfo[$module] = $meta; + } + return $this->moduleMetaInfo[$module]; + } /** To get the customViewId of the specified module * @param $module -- The module Name:: Type String @@ -78,7 +99,7 @@ class CustomView extends CRMEntity{ { global $adb,$current_user; $now_action = vtlib_purify($_REQUEST['action']); - if(isset($_REQUEST['viewname']) == false) { + if(empty($_REQUEST['viewname'])) { if (isset($_SESSION['lvs'][$module]["viewname"]) && $_SESSION['lvs'][$module]["viewname"]!='') { $viewid = $_SESSION['lvs'][$module]["viewname"]; } @@ -206,6 +227,7 @@ class CustomView extends CRMEntity{ $ssql .= " and (vtiger_customview.status=0 or vtiger_customview.userid = ? or vtiger_customview.status = 3 or vtiger_customview.userid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%'))"; array_push($sparams, $current_user->id); } + $ssql .= " ORDER BY viewname"; $result = $adb->pquery($ssql, $sparams); while($cvrow=$adb->fetch_array($result)) { @@ -278,12 +300,14 @@ class CustomView extends CRMEntity{ global $adb,$mod_strings,$app_strings; $block_ids = explode(",", $block); $tabid = getTabid($module); + global $current_user; + require('user_privileges/user_privileges_'.$current_user->id.'.php'); + if (empty($this->meta) && $module != 'Calendar') { + $this->meta = $this->getMeta($module, $current_user); + } if($tabid == 9) $tabid ="9,16"; - global $current_user; - require('user_privileges/user_privileges_'.$current_user->id.'.php'); - - $display_type = " vtiger_field.displaytype in (1,2,3)"; + $display_type = " vtiger_field.displaytype in (1,2,3)"; if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { @@ -342,7 +366,9 @@ class CustomView extends CRMEntity{ if($module == 'Quotes' && $block == 51) $module_columnlist['vtiger_crmentity:crmid::Quotes_Quote_No:I'] = $app_strings['Quote No']; - + if ($module != 'Calendar') { + $moduleFieldList = $this->meta->getModuleFields(); + } for($i=0; $i<$noofrows; $i++) { $fieldtablename = $adb->query_result($result,$i,"tablename"); @@ -352,8 +378,15 @@ class CustomView extends CRMEntity{ $fieldtype = explode("~",$fieldtype); $fieldtypeofdata = $fieldtype[0]; $fieldlabel = $adb->query_result($result,$i,"fieldlabel"); - //Here we Changing the displaytype of the field. So that its criteria will be displayed Correctly in Custom view Advance Filter. - $fieldtypeofdata=ChangeTypeOfData_Filter($fieldtablename,$fieldcolname,$fieldtypeofdata); + $field = $moduleFieldList[$fieldname]; + if(!empty($field) && $field->getFieldDataType() == 'reference') { + $fieldtypeofdata = 'V'; + } else { + //Here we Changing the displaytype of the field. So that its criteria will be + //displayed Correctly in Custom view Advance Filter. + $fieldtypeofdata=ChangeTypeOfData_Filter($fieldtablename,$fieldcolname, + $fieldtypeofdata); + } if($fieldlabel == "Related To") { $fieldlabel = "Related to"; @@ -366,14 +399,8 @@ class CustomView extends CRMEntity{ } $fieldlabel1 = str_replace(" ","_",$fieldlabel); - if($fieldname == 'account_id' && $fieldtablename != 'vtiger_account')//Potential,Contacts,Invoice,SalesOrder & Quotes records sort by Account Name . But for account member of we have to avoid this - $optionvalue = "vtiger_account:accountname:accountname:".$module."_".$fieldlabel1.":".$fieldtypeofdata; - else if($fieldname == 'contact_id' && $module != "Contacts")//Calendar,Documents,PurchaseOrder,SalesOrder,Quotes,and Invoice records sort by Contact Name - $optionvalue = "vtiger_contactdetails:lastname:lastname:".$module."_".$fieldlabel1.":".$fieldtypeofdata; - else if($fieldname == 'product_id' && ($module != 'Products' && $module != 'HelpDesk' && $module !="Faq"))//Campaign records sort by Product Name. - $optionvalue = "vtiger_products:productname:productname:".$module."_".$fieldlabel1.":".$fieldtypeofdata; - else - $optionvalue = $fieldtablename.":".$fieldcolname.":".$fieldname.":".$module."_".$fieldlabel1.":".$fieldtypeofdata; + $optionvalue = $fieldtablename.":".$fieldcolname.":".$fieldname.":".$module."_". + $fieldlabel1.":".$fieldtypeofdata; //added to escape attachments fields in customview as we have multiple attachments $fieldlabel = getTranslatedString($fieldlabel); //added to support i18n issue if($module != 'HelpDesk' || $fieldname !='filename') @@ -473,7 +500,7 @@ class CustomView extends CRMEntity{ { $sql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid "; $sql.= " where vtiger_field.tabid=? and vtiger_field.block in (". generateQuestionMarks($blockids) .") - and (vtiger_field.uitype in (5,6,23) or vtiger_field.displaytype=2) "; + and vtiger_field.uitype in (5,6,23,70)"; $sql.= " and vtiger_field.presence in (0,2) order by vtiger_field.sequence"; $params = array($tabid, $blockids); } @@ -481,7 +508,7 @@ class CustomView extends CRMEntity{ { $profileList = getCurrentUserProfileList(); $sql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid 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 "; - $sql.= " where vtiger_field.tabid=? and vtiger_field.block in (". generateQuestionMarks($blockids) .") and (vtiger_field.uitype in (5,6,23) or vtiger_field.displaytype=2)"; + $sql.= " where vtiger_field.tabid=? and vtiger_field.block in (". generateQuestionMarks($blockids) .") and vtiger_field.uitype in (5,6,23,70)"; $sql.= " and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_field.presence in (0,2)"; $params = array($tabid, $blockids); @@ -1067,6 +1094,17 @@ class CustomView extends CRMEntity{ elseif($this->customviewmodule == "Documents" && $columns[1]=='folderid'){ $advfiltersql[] = "vtiger_attachmentsfolder.foldername".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]),$datatype); } + elseif($this->customviewmodule == "Assets"){ + if($columns[1]=='account' ){ + $advfiltersql[] = "vtiger_account.accountname".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]),$datatype); + } + if($columns[1]=='product'){ + $advfiltersql[] = "vtiger_products.productname".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]),$datatype); + } + if($columns[1]=='invoiceid'){ + $advfiltersql[] = "vtiger_invoice.subject".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]),$datatype); + } + } else { $advfiltersql[] = $this->getRealValues($columns[0],$columns[1],$advfltrow["comparator"],trim($advfltrow["value"]),$datatype); @@ -1926,7 +1964,7 @@ class CustomView extends CRMEntity{ elseif($status == CV_STATUS_PUBLIC) { $log->debug("Entering when status=3"); - if($action == 'ListView' || $action == $module."Ajax" || $action == 'index') + if($action == 'ListView' || $action == $module."Ajax" || $action == 'index' || $action == 'DetailView') { $permission = "yes"; } @@ -2016,4 +2054,4 @@ class CustomView extends CRMEntity{ } } -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/CustomView/ListViewTop.php b/oss/vtiger/trunk/modules/CustomView/ListViewTop.php index 8e739d88..64799617 100644 --- a/oss/vtiger/trunk/modules/CustomView/ListViewTop.php +++ b/oss/vtiger/trunk/modules/CustomView/ListViewTop.php @@ -72,16 +72,12 @@ function getKeyMetrics($maxval,$calCnt) $log->info("Metrics :: Successfully got MetricList to be displayed"); if(isset($metriclists)) { - foreach ($metriclists as $key => $metriclist) - { - $listquery = getListQuery($metriclist['module']); - if($metriclist['module'] == 'Calendar') - $listquery .= " AND vtiger_activity.activitytype != 'Emails' "; - $oCustomView = new CustomView($metriclist['module']); - $metricsql = $oCustomView->getMetricsCvListQuery($metriclist['id'],$listquery,$metriclist['module']); - if($metriclist['module'] == "Calendar" and !$adb->isPostgres()) - $metricsql.=" group by vtiger_activity.activityid "; - + global $current_user; + foreach ($metriclists as $key => $metriclist) { + $queryGenerator = new QueryGenerator($metriclist['module'], $current_user); + $queryGenerator->initForCustomViewById($metriclist['id']); + $metricsql = $queryGenerator->getQuery(); + $metricsql = mkCountQuery($metricsql); $metricresult = $adb->query($metricsql); if($metricresult) { diff --git a/oss/vtiger/trunk/modules/CustomView/PopulateCustomView.php b/oss/vtiger/trunk/modules/CustomView/PopulateCustomView.php index 0556ff37..e0025708 100644 --- a/oss/vtiger/trunk/modules/CustomView/PopulateCustomView.php +++ b/oss/vtiger/trunk/modules/CustomView/PopulateCustomView.php @@ -206,7 +206,7 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V', 'vtiger_contactdetails:firstname:firstname:Contacts_First_Name:V', 'vtiger_contactdetails:lastname:lastname:Contacts_Last_Name:V', 'vtiger_contactdetails:title:title:Contacts_Title:V', - 'vtiger_account:accountname:accountname:Contacts_Account_Name:V', + 'vtiger_contactdetails:accountid:account_id:Contacts_Account_Name:I', 'vtiger_contactdetails:email:email:Contacts_Email:E', 'vtiger_contactdetails:phone:phone:Contacts_Office_Phone:V', 'vtiger_crmentity:smownerid:assigned_user_id:Contacts_Assigned_To:V'), @@ -222,7 +222,7 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V', Array('vtiger_contactdetails:firstname:firstname:Contacts_First_Name:V', 'vtiger_contactdetails:lastname:lastname:Contacts_Last_Name:V', 'vtiger_contactdetails:title:title:Contacts_Title:V', - 'vtiger_account:accountname:accountname:Contacts_Account_Name:V', + 'vtiger_contactdetails:accountid:account_id:Contacts_Account_Name:I', 'vtiger_contactdetails:email:email:Contacts_Email:E', 'vtiger_contactsubdetails:otherphone:otherphone:Contacts_Phone:V', 'vtiger_crmentity:smownerid:assigned_user_id:Contacts_Assigned_To:V'), @@ -272,20 +272,20 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V', 'vtiger_quotes:subject:subject:Quotes_Subject:V', 'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V', 'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I', - 'vtiger_account:accountname:accountname:Quotes_Account_Name:V', + 'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I', 'vtiger_quotes:total:hdnGrandTotal:Quotes_Total:I', 'vtiger_crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'), Array('vtiger_quotes:subject:subject:Quotes_Subject:V', 'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V', 'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I', - 'vtiger_account:accountname:accountname:Quotes_Account_Name:V', + 'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I', 'vtiger_quotes:validtill:validtill:Quotes_Valid_Till:D', 'vtiger_crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'), Array('vtiger_quotes:subject:subject:Quotes_Subject:V', 'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I', - 'vtiger_account:accountname:accountname:Quotes_Account_Name:V', + 'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I', 'vtiger_quotes:validtill:validtill:Quotes_Valid_Till:D', 'vtiger_crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'), @@ -336,8 +336,8 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V', Array('vtiger_salesorder:salesorder_no:salesorder_no:SalesOrder_SalesOrder_No:V', 'vtiger_salesorder:subject:subject:SalesOrder_Subject:V', - 'vtiger_account:accountname:accountname:SalesOrder_Account_Name:V', - 'vtiger_quotes:quoteid:quote_id:SalesOrder_Quote_Name:I', + 'vtiger_salesorder:accountid:account_id:SalesOrder_Account_Name:I', + 'vtiger_salesorder:quoteid:quote_id:SalesOrder_Quote_Name:I', 'vtiger_salesorder:total:hdnGrandTotal:SalesOrder_Total:V', 'vtiger_crmentity:smownerid:assigned_user_id:SalesOrder_Assigned_To:V'), @@ -400,7 +400,7 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V', Array( 'vtiger_invoice:invoice_no:invoice_no:Invoice_Invoice_No:V', 'vtiger_invoice:subject:subject:Invoice_Subject:V', - 'vtiger_account:accountname:accountname:Invoice_Account_Name:V', + 'vtiger_invoice:accountid:account_id:Invoice_Account_Name:I', 'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I', 'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V', 'vtiger_crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V', @@ -408,14 +408,14 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V', Array( 'vtiger_invoice:invoice_no:invoice_no:Invoice_Invoice_No:V', 'vtiger_invoice:subject:subject:Invoice_Subject:V', - 'vtiger_account:accountname:accountname:Invoice_Account_Name:V', + 'vtiger_invoice:accountid:account_id:Invoice_Account_Name:I', 'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I', 'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V', 'vtiger_invoiceshipads:ship_street:ship_street:Invoice_Shipping_Address:V', 'vtiger_crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V'), Array( 'vtiger_salesorder:subject:subject:SalesOrder_Subject:V', - 'vtiger_account:accountname:accountname:SalesOrder_Account_Name:V', + 'vtiger_salesorder:accountid:account_id:SalesOrder_Account_Name:I', 'vtiger_salesorder:sostatus:sostatus:SalesOrder_Status:V', 'vtiger_crmentity:smownerid:assigned_user_id:SalesOrder_Assigned_To:V', 'vtiger_soshipads:ship_street:ship_street:SalesOrder_Shipping_Address:V', diff --git a/oss/vtiger/trunk/modules/CustomView/Save.php b/oss/vtiger/trunk/modules/CustomView/Save.php index d01e8699..e6b407ee 100644 --- a/oss/vtiger/trunk/modules/CustomView/Save.php +++ b/oss/vtiger/trunk/modules/CustomView/Save.php @@ -81,19 +81,19 @@ if($cvmodule != "") { //<<<<<<>>>>>>>> for ($i=0;$ipquery($query,array()); + $tabseq = $adb->query_result($res,0,'max_tabseq'); + $i = ++$tabseq; foreach($portalmodules as $modules) { ++$i; $tabid = getTabid($modules); @@ -63,4 +67,4 @@ class CustomerPortal { } } } -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/CustomerPortal/schema.xml b/oss/vtiger/trunk/modules/CustomerPortal/schema.xml index 913b1a17..07fd58fe 100644 --- a/oss/vtiger/trunk/modules/CustomerPortal/schema.xml +++ b/oss/vtiger/trunk/modules/CustomerPortal/schema.xml @@ -1,34 +1,13 @@ -
"; @@ -2193,4 +2180,4 @@ function getCalendarViewSecurityParameter() $sec_query .= ")"; return $sec_query; } -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_components.php b/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_components.php new file mode 100644 index 00000000..3e6e7fcd --- /dev/null +++ b/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_components.php @@ -0,0 +1,628 @@ +construct(); + } + + function construct() { + // Initialize the components array + if(empty($this->components)) { + $this->components = array(); + foreach($this->valid_components as $name) { + $this->components[$name] = array(); + } + } + } + + function get_name() { + return $this->name; + } + + function add_property($name, $value = NULL, $parameters = NULL) { + + // Uppercase first of all + $name = strtoupper($name); + // Are we trying to add a valid property? + $xname = false; + if(!isset($this->valid_properties[$name])) { + // If not, is it an x-name as per RFC 2445? + if(!rfc2445_is_xname($name)) { + return false; + } + // Since this is an xname, all components are supposed to allow this property + $xname = true; + } + + // Create a property object of the correct class + if($xname) { + $property = new iCalendar_property_x; + $property->set_name($name); + } + else { + $classname = 'iCalendar_property_'.strtolower(str_replace('-', '_', $name)); + $property = new $classname; + } + // If $value is NULL, then this property must define a default value. + if($value === NULL) { + $value = $property->default_value(); + if($value === NULL) { + return false; + } + } + + // Set this property's parent component to ourselves, because some + // properties behave differently according to what component they apply to. + $property->set_parent_component($this->name); + + // Set parameters before value; this helps with some properties which + // accept a VALUE parameter, and thus change their default value type. + + // The parameters must be valid according to property specifications + if(!empty($parameters)) { + foreach($parameters as $paramname => $paramvalue) { + if(!$property->set_parameter($paramname, $paramvalue)) { + return false; + } + } + + // Some parameters interact among themselves (e.g. ENCODING and VALUE) + // so make sure that after the dust settles, these invariants hold true + if(!$property->invariant_holds()) { + return false; + } + } + + // $value MUST be valid according to the property data type + if(!$property->set_value($value)) { + return false; + } + + // If this property is restricted to only once, blindly overwrite value + if(!$xname && $this->valid_properties[$name] & RFC2445_ONCE) { + $this->properties[$name] = array($property); + } + + // Otherwise add it to the instance array for this property + else { + $this->properties[$name][] = $property; + } + + // Finally: after all these, does the component invariant hold? + if(!$this->invariant_holds()) { + // If not, completely undo the property addition + array_pop($this->properties[$name]); + if(empty($this->properties[$name])) { + unset($this->properties[$name]); + } + return false; + } + + return true; + + } + + function add_component($component) { + + // With the detailed interface, you can add only components with this function + if(!is_object($component) || !is_subclass_of($component, 'iCalendar_component')) { + return false; + } + + $name = $component->get_name(); + + // Only valid components as specified by this component are allowed + if(!in_array($name, $this->valid_components)) { + return false; + } + + // Add it + $this->components[$name][] = $component; + + return true; + } + + function get_property_list($name) { + } + + function invariant_holds() { + return true; + } + + function is_valid() { + // If we have any child components, check that they are all valid + if(!empty($this->components)) { + foreach($this->components as $component => $instances) { + foreach($instances as $number => $instance) { + if(!$instance->is_valid()) { + return false; + } + } + } + } + // Finally, check the valid property list for any mandatory properties + // that have not been set and do not have a default value + foreach($this->valid_properties as $property => $propdata) { + if(($propdata & RFC2445_REQUIRED) && empty($this->properties[$property])) { + $classname = 'iCalendar_property_'.strtolower(str_replace('-', '_', $property)); + $object = new $classname; + if($object->default_value() === NULL) { + return false; + } + unset($object); + } + } + + return true; + } + + function serialize() { + // Check for validity of the object + if(!$this->is_valid()) { + return false; + } + + // Maybe the object is valid, but there are some required properties that + // have not been given explicit values. In that case, set them to defaults. + foreach($this->valid_properties as $property => $propdata) { + if(($propdata & RFC2445_REQUIRED) && empty($this->properties[$property])) { + $this->add_property($property); + } + } + + // Start tag + $string = rfc2445_fold('BEGIN:'.$this->name) . RFC2445_CRLF; + // List of properties + if(!empty($this->properties)) { + foreach($this->properties as $name => $properties) { + foreach($properties as $property) { + $string .= $property->serialize(); + } + } + } + // List of components + if(!empty($this->components)) { + foreach($this->components as $name => $components) { + foreach($components as $component) { + $string .= $component->serialize(); + } + } + } + + // End tag + $string .= rfc2445_fold('END:'.$this->name) . RFC2445_CRLF; + + return $string; + } + + function assign_values($activity) { + foreach($this->mapping_arr as $key=>$components){ + if(!is_array($components['component']) && empty($components['function'])){ + $this->add_property($key,$activity[$components['component']]); + } else if(is_array($components['component']) && empty($components['function'])){ + $component = ''; + foreach($components['component'] as $comp){ + if(!empty($component)) $component .= ','; + $component .= $activity[$comp]; + } + $this->add_property($key,$component); + } else if(!empty($components['function'])){ + $this->$components['function']($activity); + } + } + return true; + } + + function generateArray($ical_activity){ + global $current_user; + $activity = array(); + $activitytype = $ical_activity['TYPE']; + if($activitytype=='VEVENT'){ + $modtype = 'Events'; + } else { + $modtype = 'Calendar'; + } + foreach($this->mapping_arr as $key=>$comp){ + $type = $comp['type']; + $component = $comp['component']; + if(!is_array($component)){ + if($type!='user'){ + if(isset($this->field_mapping_arr[$component])){ + if(getFieldVisibilityPermission($modtype,$current_user->id,$this->field_mapping_arr[$component])=='0') + $activity[$this->field_mapping_arr[$component]] = $ical_activity[$key]; + else + $activity[$this->field_mapping_arr[$component]] = ''; + } else { + if(getFieldVisibilityPermission($modtype,$current_user->id,$component)=='0') + $activity[$component] = $ical_activity[$key]; + else + $activity[$component] = ''; + } + } + } else { + $temp = $ical_activity[$key]; + $count = 0; + if($type == 'string'){ + $values = explode('\\,',$temp); + } else if($type == 'datetime'){ + $values = $this->strtodatetime($temp); + } + foreach($component as $index){ + if(!isset($activity[$index])){ + if(isset($this->field_mapping_arr[$index])){ + if(getFieldVisibilityPermission($modtype,$current_user->id,$this->field_mapping_arr[$index])=='0') + $activity[$this->field_mapping_arr[$index]] = $values[$count]; + else + $activity[$this->field_mapping_arr[$index]] = ''; + } else { + if(getFieldVisibilityPermission($modtype,$current_user->id,$index)=='0') + $activity[$index] = $values[$count]; + else + $activity[$index] = ''; + } + } + $count++; + } + unset($values); + } + } + if($activitytype=='VEVENT'){ + $activity['activitytype'] = 'Meeting'; + if(!empty($ical_activity['VALARM'])){ + $temp = str_replace("PT",'',$ical_activity['VALARM']['TRIGGER']); + $duration_type = $temp[strlen($temp)-1]; + $duration = intval($temp); + if($duration_type=='H'){ + $reminder_time = $duration*60; + } else if($duration_type=='M'){ + $reminder_time = $duration; + } + $activity['reminder_time'] = $reminder_time; + } + } else { + $activity['activitytype'] = 'Task'; + } + return $activity; + } + + function strtodatetime($date){ + $date = preg_replace('/[A-Za-z_]*/', '', $date); + $year = substr($date,0,4); + $month = substr($date,4,2); + $day = substr($date,6,2); + $hours = substr($date,8,2); + $minutes = substr($date,10,2); + $seconds = substr($date,12,2); + $datetime[] = $year."-".$month."-".$day; + $datetime[] = $hours.":".$minutes.":".$seconds; + return $datetime; + } +} + +class iCalendar extends iCalendar_component { + var $name = 'VCALENDAR'; + + function construct() { + $this->valid_properties = array( + 'CALSCALE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'METHOD' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'PRODID' => RFC2445_REQUIRED | RFC2445_ONCE, + 'VERSION' => RFC2445_REQUIRED | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + + $this->valid_components = array( + 'VEVENT', 'VTODO', 'VTIMEZONE' + // TODO: add support for the other component types + //, 'VJOURNAL', 'VFREEBUSY', 'VALARM' + ); + parent::construct(); + } + +} + +class iCalendar_event extends iCalendar_component { + + var $name = 'VEVENT'; + var $properties; + var $mapping_arr = array( + 'CLASS' => array('component'=>'visibility','type'=>'string'), + 'DESCRIPTION' => array('component'=>'description','type'=>'string'), + 'DTSTART' => array('component'=>array('date_start','time_start'),'function'=>'iCalendar_event_dtstart','type'=>'datetime'), + 'DTEND' => array('component'=>array('due_date','time_end'),'function'=>'iCalendar_event_dtend','type'=>'datetime'), + 'DTSTAMP' => array('component'=>array('date_start','time_start'),'function'=>'iCalendar_event_dtstamp','type'=>'datetime'), + 'LOCATION' => array('component'=>'location','type'=>'string'), + 'STATUS' => array('component'=>'eventstatus','type'=>'string'), + 'SUMMARY' => array('component'=>'subject','type'=>'string'), + 'PRIORITY' => array('component'=>'priority','type'=>'string'), + 'ATTENDEE' => array('component'=>'activityid','function'=>'iCalendar_event_attendee','type'=>'user'), + 'RESOURCES' => array('component'=>array('location','eventstatus'),'type'=>'string'), + ); + var $field_mapping_arr = array( + 'priority'=>'taskpriority' + ); + + function construct() { + + $this->valid_components = array('VALARM'); + + $this->valid_properties = array( + 'CLASS' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'CREATED' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE, + // Standard ambiguous here: in 4.6.1 it says that DTSTAMP in optional, + // while in 4.8.7.2 it says it's REQUIRED. Go with REQUIRED. + 'DTSTAMP' => RFC2445_REQUIRED | RFC2445_ONCE, + // Standard ambiguous here: in 4.6.1 it says that DTSTART in optional, + // while in 4.8.2.4 it says it's REQUIRED. Go with REQUIRED. + 'DTSTART' => RFC2445_REQUIRED | RFC2445_ONCE, + 'GEO' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LAST-MODIFIED' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LOCATION' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'ORGANIZER' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'PRIORITY' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'SEQUENCE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'STATUS' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'SUMMARY' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'TRANSP' => RFC2445_OPTIONAL | RFC2445_ONCE, + // Standard ambiguous here: in 4.6.1 it says that UID in optional, + // while in 4.8.4.7 it says it's REQUIRED. Go with REQUIRED. + 'UID' => RFC2445_REQUIRED | RFC2445_ONCE, + 'URL' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'RECURRENCE-ID' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DTEND' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DURATION' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'ATTACH' => RFC2445_OPTIONAL, + 'ATTENDEE' => RFC2445_OPTIONAL, + 'CATEGORIES' => RFC2445_OPTIONAL, + 'COMMENT' => RFC2445_OPTIONAL, + 'CONTACT' => RFC2445_OPTIONAL, + 'EXDATE' => RFC2445_OPTIONAL, + 'EXRULE' => RFC2445_OPTIONAL, + 'REQUEST-STATUS' => RFC2445_OPTIONAL, + 'RELATED-TO' => RFC2445_OPTIONAL, + 'RESOURCES' => RFC2445_OPTIONAL, + 'RDATE' => RFC2445_OPTIONAL, + 'RRULE' => RFC2445_OPTIONAL, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + + parent::construct(); + } + + function invariant_holds() { + // DTEND and DURATION must not appear together + if(isset($this->properties['DTEND']) && isset($this->properties['DURATION'])) { + return false; + } + + + if(isset($this->properties['DTEND']) && isset($this->properties['DTSTART'])) { + // DTEND must be later than DTSTART + // The standard is not clear on how to hande different value types though + // TODO: handle this correctly even if the value types are different + if($this->properties['DTEND'][0]->value <= $this->properties['DTSTART'][0]->value) { + return false; + } + + // DTEND and DTSTART must have the same value type + if($this->properties['DTEND'][0]->val_type != $this->properties['DTSTART'][0]->val_type) { + return false; + } + + } + return true; + } + + function iCalendar_event_dtstamp($activity){ + $components = gmdate('Ymd', strtotime($activity['date_start']." ".$activity['time_start']))."T".gmdate('His', strtotime($activity['date_start']." ".$activity['time_start']))."Z"; + $this->add_property("DTSTAMP",$components); + return true; + } + + function iCalendar_event_dtstart($activity){ + $time = str_replace(':','',$activity['time_start']); + if(strlen($time)<6){ + while((6-strlen($time)) > 0 ){ + $time .= '0'; + } + } + $components = str_replace('-', '', $activity['date_start']).'T'. $time . 'Z'; + $this->add_property("DTSTART",$components); + return true; + } + + function iCalendar_event_dtend($activity){ + $time = str_replace(':','',$activity['time_end']); + if(strlen($time)<6){ + while((6-strlen($time)) > 0 ){ + $time .= '0'; + } + } + $components = str_replace('-', '', $activity['due_date']).'T'. $time . 'Z'; + $this->add_property("DTEND",$components); + return true; + } + + function iCalendar_event_attendee($activity){ + global $adb; + $users_res = $adb->pquery("SELECT inviteeid FROM vtiger_invitees WHERE activityid=?", array($activity['id'])); + if($adb->num_rows($users_res)>0){ + for($i=0;$i<$adb->num_rows($users_res);$i++){ + $inviteeid = $adb->query_result($users_res,$i,'inviteeid'); + $username = getUserFullName($inviteeid); + $user_email = getUserEmail($inviteeid); + $attendee = 'mailto:'.$user_email; + $this->add_property('ATTENDEE',$attendee); + } + } + return true; + } + +} + +class iCalendar_todo extends iCalendar_component { + var $name = 'VTODO'; + var $properties; + var $mapping_arr = array( + 'DESCRIPTION' => array('component'=>'description','type'=>'string'), + 'DTSTAMP' => array('component'=>array('date_start','time_start'),'function'=>'iCalendar_event_dtstamp','type'=>'datetime'), + 'DTSTART' => array('component'=>array('date_start','time_start'),'function'=>'iCalendar_event_dtstart','type'=>'datetime'), + 'DUE' => array('component'=>array('due_date'),'function'=>'iCalendar_event_dtend','type'=>'datetime'), + 'STATUS' => array('component'=>'status','type'=>'string'), + 'SUMMARY' => array('component'=>'subject','type'=>'string'), + 'PRIORITY' => array('component'=>'priority','type'=>'string'), + 'RESOURCES' => array('component'=>array('status'),'type'=>'string'), + ); + var $field_mapping_arr = array( + 'status'=>'taskstatus', + 'priority'=>'taskpriority' + ); + + function construct() { + + $this->valid_components = array(); + $this->valid_properties = array( + 'CLASS' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'COMPLETED' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'CREATED' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DTSTAMP' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DTSTART' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'GEO' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LAST-MODIFIED' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LOCATION' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'ORGANIZER' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'PERCENT' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'PRIORITY' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'RECURID' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'SEQUENCE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'STATUS' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'SUMMARY' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'UID' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'URL' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DUE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DURATION' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'ATTACH' => RFC2445_OPTIONAL, + 'ATTENDEE' => RFC2445_OPTIONAL, + 'CATEGORIES' => RFC2445_OPTIONAL, + 'COMMENT' => RFC2445_OPTIONAL, + 'CONTACT' => RFC2445_OPTIONAL, + 'EXDATE' => RFC2445_OPTIONAL, + 'EXRULE' => RFC2445_OPTIONAL, + 'RSTATUS' => RFC2445_OPTIONAL, + 'RELATED' => RFC2445_OPTIONAL, + 'RESOURCES' => RFC2445_OPTIONAL, + 'RDATE' => RFC2445_OPTIONAL, + 'RRULE' => RFC2445_OPTIONAL, + 'XPROP' => RFC2445_OPTIONAL + ); + + parent::construct(); + // TODO: + // either 'due' or 'duration' may appear in a 'eventprop', but 'due' + // and 'duration' MUST NOT occur in the same 'eventprop' + } + function iCalendar_event_dtstamp($activity){ + $components = gmdate('Ymd', strtotime($activity['date_start']." ".$activity['time_start']))."T".gmdate('His', strtotime($activity['date_start']." ".$activity['time_start']))."Z"; + $this->add_property("DTSTAMP",$components); + return true; + } + + function iCalendar_event_dtstart($activity){ + $time = str_replace(':','',$activity['time_start']); + if(strlen($time)<6){ + while((6-strlen($time)) > 0 ){ + $time .= '0'; + } + } + $components = str_replace('-', '', $activity['date_start']).'T'. $time . 'Z'; + $this->add_property("DTSTART",$components); + return true; + } + + function iCalendar_event_dtend($activity){ + $components = str_replace('-', '', $activity['due_date']).'T000000Z'; + $this->add_property("DUE",$components); + return true; + } +} + +class iCalendar_journal extends iCalendar_component { + // TODO: implement +} + +class iCalendar_freebusy extends iCalendar_component { + // TODO: implement +} + +class iCalendar_alarm extends iCalendar_component { + var $name='VALARM'; + var $properties; + var $mapping_arr = array( + 'TRIGGER' => array('component'=>'reminder_time', 'function'=>'iCalendar_event_trigger'), + ); + + function construct() { + + $this->valid_components = array(); + $this->valid_properties = array( + 'TRIGGER' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'ACTION' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'X-WR-ALARMUID' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + + parent::construct(); + } + + function iCalendar_event_trigger($activity){ + $reminder_time = $activity['reminder_time']; + if($reminder_time>60){ + $reminder_time = round($reminder_time/60); + $reminder = $reminder_time.'H'; + }else { + $reminder = $reminder_time.'M'; + } + $this->add_property('ACTION', 'DISPLAY'); + $this->add_property('TRIGGER', 'PT'.$reminder); + $this->add_property('DESCRIPTION', 'Reminder'); + return true; + } +} + +class iCalendar_timezone extends iCalendar_component { + var $name = 'VTIMEZONE'; + var $properties; + + function construct() { + $this->valid_components = array(); + $this->valid_properties = array( + 'TZID' => RFC2445_REQUIRED | RFC2445_ONCE, + 'LAST-MODIFIED' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'TZURL' => RFC2445_OPTIONAL | RFC2445_ONCE, + // TODO: the next two are components of their own! + 'STANDARDC' => RFC2445_OPTIONAL, + 'DAYLIGHTC' => RFC2445_OPTIONAL, + 'TZOFFSETFROM' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'TZOFFSETTO' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'X-PROP' => RFC2445_OPTIONAL + ); + + parent::construct(); + } + +} + +// REMINDER: DTEND must be later than DTSTART for all components which support both +// REMINDER: DUE must be later than DTSTART for all components which support both + +?> diff --git a/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_parameters.php b/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_parameters.php new file mode 100644 index 00000000..1b029c9c --- /dev/null +++ b/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_parameters.php @@ -0,0 +1,227 @@ + array('PLAIN', 'RICHTEXT', 'ENRICHED', 'TAB-SEPARATED-VALUES', 'HTML', 'SGML', + 'VND.LATEX-Z', 'VND.FMI.FLEXSTOR'), + 'MULTIPART' => array('MIXED', 'ALTERNATIVE', 'DIGEST', 'PARALLEL', 'APPLEDOUBLE', 'HEADER-SET', + 'FORM-DATA', 'RELATED', 'REPORT', 'VOICE-MESSAGE', 'SIGNED', 'ENCRYPTED', + 'BYTERANGES'), + 'MESSAGE' => array('RFC822', 'PARTIAL', 'EXTERNAL-BODY', 'NEWS', 'HTTP'), + 'APPLICATION' => array('OCTET-STREAM', 'POSTSCRIPT', 'ODA', 'ATOMICMAIL', 'ANDREW-INSET', 'SLATE', + 'WITA', 'DEC-DX', 'DCA-RFT', 'ACTIVEMESSAGE', 'RTF', 'APPLEFILE', + 'MAC-BINHEX40', 'NEWS-MESSAGE-ID', 'NEWS-TRANSMISSION', 'WORDPERFECT5.1', + 'PDF', 'ZIP', 'MACWRITEII', 'MSWORD', 'REMOTE-PRINTING', 'MATHEMATICA', + 'CYBERCASH', 'COMMONGROUND', 'IGES', 'RISCOS', 'ESHOP', 'X400-BP', 'SGML', + 'CALS-1840', 'PGP-ENCRYPTED', 'PGP-SIGNATURE', 'PGP-KEYS', 'VND.FRAMEMAKER', + 'VND.MIF', 'VND.MS-EXCEL', 'VND.MS-POWERPOINT', 'VND.MS-PROJECT', + 'VND.MS-WORKS', 'VND.MS-TNEF', 'VND.SVD', 'VND.MUSIC-NIFF', 'VND.MS-ARTGALRY', + 'VND.TRUEDOC', 'VND.KOAN', 'VND.STREET-STREAM', 'VND.FDF', + 'SET-PAYMENT-INITIATION', 'SET-PAYMENT', 'SET-REGISTRATION-INITIATION', + 'SET-REGISTRATION', 'VND.SEEMAIL', 'VND.BUSINESSOBJECTS', + 'VND.MERIDIAN-SLINGSHOT', 'VND.XARA', 'SGML-OPEN-CATALOG', 'VND.RAPID', + 'VND.ENLIVEN', 'VND.JAPANNET-REGISTRATION-WAKEUP', + 'VND.JAPANNET-VERIFICATION-WAKEUP', 'VND.JAPANNET-PAYMENT-WAKEUP', + 'VND.JAPANNET-DIRECTORY-SERVICE', 'VND.INTERTRUST.DIGIBOX', 'VND.INTERTRUST.NNCP'), + 'IMAGE' => array('JPEG', 'GIF', 'IEF', 'G3FAX', 'TIFF', 'CGM', 'NAPLPS', 'VND.DWG', 'VND.SVF', + 'VND.DXF', 'PNG', 'VND.FPX', 'VND.NET-FPX'), + 'AUDIO' => array('BASIC', '32KADPCM', 'VND.QCELP'), + 'VIDEO' => array('MPEG', 'QUICKTIME', 'VND.VIVO', 'VND.MOTOROLA.VIDEO', 'VND.MOTOROLA.VIDEOP') + ); + $value = strtoupper($value); + if(rfc2445_is_xname($value)) { + return true; + } + @list($type, $subtype) = explode('/', $value); + if(empty($type) || empty($subtype)) { + return false; + } + if(!isset($fmttypes[$type]) || !in_array($subtype, $fmttypes[$type])) { + return false; + } + return true; + break; + + case 'LANGUAGE': + $value = strtoupper($value); + $parts = explode('-', $value); + foreach($parts as $part) { + if(empty($part)) { + return false; + } + if(strspn($part, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') != strlen($part)) { + return false; + } + } + return true; + break; + + case 'PARTSTAT': + $value = strtoupper($value); + switch($parent_property->parent_component) { + case 'VEVENT': + return ($value == 'NEEDS-ACTION' || $value == 'ACCEPTED' || $value == 'DECLINED' || $value == 'TENTATIVE' + || $value == 'DELEGATED' || rfc2445_is_xname($value)); + break; + case 'VTODO': + return ($value == 'NEEDS-ACTION' || $value == 'ACCEPTED' || $value == 'DECLINED' || $value == 'TENTATIVE' + || $value == 'DELEGATED' || $value == 'COMPLETED' || $value == 'IN-PROCESS' || rfc2445_is_xname($value)); + break; + case 'VJOURNAL': + return ($value == 'NEEDS-ACTION' || $value == 'ACCEPTED' || $value == 'DECLINED' || rfc2445_is_xname($value)); + break; + } + return false; + break; + + case 'RANGE': + $value = strtoupper($value); + return ($value == 'THISANDPRIOR' || $value == 'THISANDFUTURE'); + break; + + case 'RELATED': + $value = strtoupper($value); + return ($value == 'START' || $value == 'END'); + break; + + case 'RELTYPE': + $value = strtoupper($value); + return ($value == 'PARENT' || $value == 'CHILD' || $value == 'SIBLING' || rfc2445_is_xname($value)); + break; + + case 'ROLE': + $value = strtoupper($value); + return ($value == 'CHAIR' || $value == 'REQ-PARTICIPANT' || $value == 'OPT-PARTICIPANT' || $value == 'NON-PARTICIPANT' || rfc2445_is_xname($value)); + break; + + case 'RSVP': + $value = strtoupper($value); + return ($value == 'TRUE' || $value == 'FALSE'); + break; + + case 'TZID': + if(empty($value)) { + return false; + } + return (strcspn($value, '";:,') == strlen($value)); + break; + + case 'VALUE': + $value = strtoupper($value); + return ($value == 'BINARY' || $value == 'BOOLEAN' || $value == 'CAL-ADDRESS' || $value == 'DATE' || + $value == 'DATE-TIME' || $value == 'DURATION' || $value == 'FLOAT' || $value == 'INTEGER' || + $value == 'PERIOD' || $value == 'RECUR' || $value == 'TEXT' || $value == 'TIME' || + $value == 'URI' || $value == 'UTC-OFFSET' || rfc2445_is_xname($value)); + break; + } + } + + function do_value_formatting($parameter, $value) { + switch($parameter) { + // Parameters of type CAL-ADDRESS or URI MUST be double-quoted + case 'ALTREP': + case 'DIR': + case 'DELEGATED-FROM': + case 'DELEGATED-TO': + case 'MEMBER': + case 'SENT-BY': + return '"'.$value.'"'; + break; + + // Textual parameter types must be double quoted if they contain COLON, SEMICOLON + // or COMMA. Quoting always sounds easier and standards-conformant though. + case 'CN': + return '"'.$value.'"'; + break; + + // Parameters with enumerated legal values, just make them all caps + case 'CUTYPE': + case 'ENCODING': + case 'FBTYPE': + case 'FMTTYPE': + case 'LANGUAGE': + case 'PARTSTAT': + case 'RANGE': + case 'RELATED': + case 'RELTYPE': + case 'ROLE': + case 'RSVP': + case 'VALUE': + return strtoupper($value); + break; + + // Parameters we shouldn't be messing with + case 'TZID': + return $value; + break; + } + } + + function undo_value_formatting($parameter, $value) { + } + +} + +?> diff --git a/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_properties.php b/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_properties.php new file mode 100644 index 00000000..2c373e0a --- /dev/null +++ b/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_properties.php @@ -0,0 +1,1367 @@ +construct(); + } + + function construct() { + $this->parameters = array(); + } + + // If some property needs extra care with its parameters, override this + // IMPORTANT: the parameter name MUST BE CAPITALIZED! + function is_valid_parameter($parameter, $value) { + + if(is_array($value)) { + if(!iCalendar_parameter::multiple_values_allowed($parameter)) { + return false; + } + foreach($value as $item) { + if(!iCalendar_parameter::is_valid_value($this, $parameter, $item)) { + return false; + } + } + return true; + } + + return iCalendar_parameter::is_valid_value($this, $parameter, $value); + } + + function invariant_holds() { + return true; + } + + // If some property is very picky about its values, it should do the work itself + // Only data type validation is done here + function is_valid_value($value) { + if(is_array($value)) { + if(!$this->val_multi) { + return false; + } + else { + foreach($value as $oneval) { + if(!rfc2445_is_valid_value($oneval, $this->val_type)) { + return false; + } + } + } + return true; + } + return rfc2445_is_valid_value($value, $this->val_type); + } + + function default_value() { + return $this->val_default; + } + + function set_parent_component($componentname) { + if(class_exists('iCalendar_'.strtolower(substr($componentname, 1)))) { + $this->parent_component = strtoupper($componentname); + return true; + } + + return false; + } + + function set_value($value) { + if($this->is_valid_value($value)) { + // This transparently formats any value type according to the iCalendar specs + if(is_array($value)) { + foreach($value as $key => $item) { + $value[$key] = rfc2445_do_value_formatting($item, $this->val_type); + } + $this->value = implode(',', $value); + } + else { + $this->value = rfc2445_do_value_formatting($value, $this->val_type); + } + + return true; + } + return false; + } + + function get_value() { + // First of all, assume that we have multiple values + $valarray = explode('\\,', $this->value); + + // Undo transparent formatting + $replace_function = create_function('$a', 'return rfc2445_undo_value_formatting($a, '.$this->val_type.');'); + $valarray = array_map($replace_function, $valarray); + + // Now, if this property cannot have multiple values, don't return as an array + if(!$this->val_multi) { + return $valarray[0]; + } + + // Otherwise return an array even if it has one element, for uniformity + return $valarray; + + } + + function set_parameter($name, $value) { + + // Uppercase + $name = strtoupper($name); + + // Are we trying to add a valid parameter? + $xname = false; + if(!isset($this->valid_parameters[$name])) { + // If not, is it an x-name as per RFC 2445? + if(!rfc2445_is_xname($name)) { + return false; + } + // No more checks -- all components are supposed to allow x-name parameters + $xname = true; + } + + if(!$this->is_valid_parameter($name, $value)) { + return false; + } + + if(is_array($value)) { + foreach($value as $key => $element) { + $value[$key] = iCalendar_parameter::do_value_formatting($name, $element); + } + } + else { + $value = iCalendar_parameter::do_value_formatting($name, $value); + } + + $this->parameters[$name] = $value; + + // Special case: if we just changed the VALUE parameter, reflect this + // in the object's status so that it only accepts correct type values + if($name == 'VALUE') { + // TODO: what if this invalidates an already-set value? + $this->val_type = constant('RFC2445_TYPE_'.str_replace('-', '_', $value)); + } + + return true; + + } + + function get_parameter($name) { + + // Uppercase + $name = strtoupper($name); + + if(isset($this->parameters[$name])) { + // If there are any double quotes in the value, invisibly strip them + if(is_array($this->parameters[$name])) { + foreach($this->parameters[$name] as $key => $value) { + if(substr($value, 0, 1) == '"') { + $this->parameters[$name][$key] = substr($value, 1, strlen($value) - 2); + } + } + return $this->parameters[$name]; + } + + else { + if(substr($this->parameters[$name], 0, 1) == '"') { + return substr($this->parameters[$name], 1, strlen($this->parameters[$name]) - 2); + } + } + } + + return NULL; + } + + function serialize() { + $string = $this->name; + + if(!empty($this->parameters)) { + foreach($this->parameters as $name => $value) { + $string .= ';'.$name.'='; + if(is_array($value)) { + $string .= implode(',', $value); + } + else { + $string .= $value; + } + } + } + + $string .= ':'.$this->value; + + return rfc2445_fold($string) . RFC2445_CRLF; + } +} + +// 4.7 Calendar Properties +// ----------------------- + +class iCalendar_property_calscale extends iCalendar_property { + + var $name = 'CALSCALE'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + // This is case-sensitive + return ($value === 'GREGORIAN'); + } +} + +class iCalendar_property_method extends iCalendar_property { + + var $name = 'METHOD'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + // This is case-sensitive + // Methods from RFC 2446 + $methods == array('PUBLISH', 'REQUEST', 'REPLY', 'ADD', 'CANCEL', 'REFRESH', 'COUNTER', 'DECLINECOUNTER'); + return in_array($value, $methods); + } +} + +class iCalendar_property_prodid extends iCalendar_property { + + var $name = 'PRODID'; + var $val_type = RFC2445_TYPE_TEXT; + var $val_default = NULL; + + function construct() { + $this->val_default = '-//John Papaioannou/NONSGML Bennu '._BENNU_VERSION.'//EN'; + + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_version extends iCalendar_property { + + var $name = 'VERSION'; + var $val_type = RFC2445_TYPE_TEXT; + var $val_default = '2.0'; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + return($value === '2.0' || $value === 2.0); + } + +} + +// 4.8.1 Descriptive Component Properties +// -------------------------------------- + +class iCalendar_property_attach extends iCalendar_property { + + var $name = 'ATTACH'; + var $val_type = RFC2445_TYPE_URI; + + function construct() { + $this->valid_parameters = array( + 'FMTTYPE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'ENCODING' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function invariant_holds() { + if(isset($this->parameters['ENCODING']) && !isset($this->parameters['VALUE'])) { + return false; + } + if(isset($this->parameters['VALUE']) && !isset($this->parameters['ENCODING'])) { + return false; + } + + return true; + } + + function is_valid_parameter($parameter, $value) { + + $parameter = strtoupper($parameter); + + if(!parent::is_valid_parameter($parameter, $value)) { + return false; + } + + if($parameter === 'ENCODING' && strtoupper($value) != 'BASE64') { + return false; + } + + if($parameter === 'VALUE' && strtoupper($value) != 'BINARY') { + return false; + } + + return true; + } +} + +class iCalendar_property_categories extends iCalendar_property { + + var $name = 'CATEGORIES'; + var $val_type = RFC2445_TYPE_TEXT; + var $val_multi = true; + + function construct() { + $this->valid_parameters = array( + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_class extends iCalendar_property { + + var $name = 'CLASS'; + var $val_type = RFC2445_TYPE_TEXT; + var $val_default = 'PUBLIC'; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + function is_valid_value($value) { + $value = strtoupper($value); + // If this is not an xname, it is case-sensitive + return ($value === 'PUBLIC' || $value === 'PRIVATE' || $value === 'CONFIDENTIAL' || rfc2445_is_xname(strtoupper($value))); + } +} + +class iCalendar_property_comment extends iCalendar_property { + + var $name = 'COMMENT'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + 'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_description extends iCalendar_property { + + var $name = 'DESCRIPTION'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + 'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_geo extends iCalendar_property { + + var $name = 'GEO'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + 'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + // This MUST be two floats separated by a semicolon + if(!is_string($value)) { + return false; + } + + $floats = explode(';', $value); + if(count($floats) != 2) { + return false; + } + + return rfc2445_is_valid_value($floats[0], RFC2445_TYPE_FLOAT) && rfc2445_is_valid_value($floats[1], RFC2445_TYPE_FLOAT); + } + + function set_value($value) { + // Must override this, otherwise the semicolon separating + // the two floats would get auto-quoted, which is illegal + if($this->is_valid_value($value)) { + $this->value = $value; + return true; + } + + return false; + } + +} + +class iCalendar_property_location extends iCalendar_property { + + var $name = 'LOCATION'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + 'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_percent_complete extends iCalendar_property { + + var $name = 'PERCENT-COMPLETE'; + var $val_type = RFC2445_TYPE_INTEGER; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + // Only integers between 0 and 100 inclusive allowed + if(!parent::is_valid_value($value)) { + return false; + } + $value = intval($value); + return ($value >= 0 && $value <= 100); + } + +} + +class iCalendar_property_priority extends iCalendar_property { + + var $name = 'PRIORITY'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + // Only integers between 0 and 9 inclusive allowed + if(!parent::is_valid_value($value)) { + return false; + } + return true; + //$value = intval($value); + //return ($value >= 0 && $value <= 9); + } +} + +class iCalendar_property_resources extends iCalendar_property { + + var $name = 'RESOURCES'; + var $val_type = RFC2445_TYPE_TEXT; + var $val_multi = true; + + function construct() { + $this->valid_parameters = array( + 'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_status extends iCalendar_property { + + var $name = 'STATUS'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + +/* function is_valid_value($value) { + // This is case-sensitive + switch ($this->parent_component) { + case 'VEVENT': + $allowed = array('TENTATIVE', 'CONFIRMED', 'CANCELLED'); + break; + case 'VTODO': + $allowed = array('NEEDS-ACTION', 'COMPLETED', 'IN-PROCESS', 'CANCELLED'); + break; + case 'VJOURNAL': + $allowed = array('DRAFT', 'FINAL', 'CANCELLED'); + break; + } + return in_array($value, $allowed); + + } +*/ +} + +class iCalendar_property_summary extends iCalendar_property { + + var $name = 'SUMMARY'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + 'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +// 4.8.2 Date and Time Component Properties +// ---------------------------------------- + +class iCalendar_property_completed extends iCalendar_property { + + var $name = 'COMPLETED'; + var $val_type = RFC2445_TYPE_DATE_TIME; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + if(!parent::is_valid_value($value)) { + return false; + } + // Time MUST be in UTC format + return(substr($value, -1) == 'Z'); + } +} + +class iCalendar_property_dtend extends iCalendar_property { + + var $name = 'DTEND'; + var $val_type = RFC2445_TYPE_DATE_TIME; + + function construct() { + $this->valid_parameters = array( + 'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + if(!parent::is_valid_value($value)) { + return false; + } + + // If present in a FREEBUSY component, must be in UTC format + if($this->parent_component == 'VFREEBUSY' && substr($value, -1) != 'Z') { + return false; + } + + return true; + + } + + function is_valid_parameter($parameter, $value) { + + $parameter = strtoupper($parameter); + + if(!parent::is_valid_parameter($parameter, $value)) { + return false; + } + if($parameter == 'VALUE' && !($value == 'DATE' || $value == 'DATE-TIME')) { + return false; + } + + return true; + } +} + +class iCalendar_property_due extends iCalendar_property { + + var $name = 'DUE'; + var $val_type = RFC2445_TYPE_DATE_TIME; + + function construct() { + $this->valid_parameters = array( + 'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + if(!parent::is_valid_value($value)) { + return false; + } + + // If present in a FREEBUSY component, must be in UTC format + if($this->parent_component == 'VFREEBUSY' && substr($value, -1) != 'Z') { + return false; + } + + return true; + + } + + function is_valid_parameter($parameter, $value) { + + $parameter = strtoupper($parameter); + + if(!parent::is_valid_parameter($parameter, $value)) { + return false; + } + if($parameter == 'VALUE' && !($value == 'DATE' || $value == 'DATE-TIME')) { + return false; + } + + return true; + } +} + +class iCalendar_property_dtstart extends iCalendar_property { + + var $name = 'DTSTART'; + var $val_type = RFC2445_TYPE_DATE_TIME; + + function construct() { + $this->valid_parameters = array( + 'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + // TODO: unimplemented stuff when parent is a VTIMEZONE component + + function is_valid_value($value) { + if(!parent::is_valid_value($value)) { + return false; + } + // If present in a FREEBUSY component, must be in UTC format + if($this->parent_component == 'VFREEBUSY' && substr($value, -1) != 'Z') { + return false; + } + + return true; + } + + function is_valid_parameter($parameter, $value) { + $parameter = strtoupper($parameter); + + if(!parent::is_valid_parameter($parameter, $value)) { + return false; + } + if($parameter == 'VALUE' && !($value == 'DATE' || $value == 'DATE-TIME')) { + return false; + } + + return true; + } +} + +class iCalendar_property_duration extends iCalendar_property { + + var $name = 'DURATION'; + var $val_type = RFC2445_TYPE_DURATION; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + if(!parent::is_valid_value($value)) { + return false; + } + + // Value must be positive + return ($value{0} != '-'); + } +} + +class iCalendar_property_freebusy extends iCalendar_property { + + var $name = 'FREEBUSY'; + var $val_type = RFC2445_TYPE_PERIOD; + var $val_multi = true; + + function construct() { + $this->valid_parameters = array( + 'FBTYPE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + if(!parent::is_valid_value($value)) { + return false; + } + + $pos = strpos($value, '/'); // We know there's only one / in there + if($value{$pos - 1} != 'Z') { + // Start time MUST be in UTC + return false; + } + if($value{$pos + 1} != 'P' && $substr($value, -1) != 'Z') { + // If the second part is not a period, it MUST be in UTC + return false; + } + + return true; + } + + // TODO: these properties SHOULD be shorted in ascending order (by start time and end time as tiebreak) +} + +class iCalendar_property_transp extends iCalendar_property { + + var $name = 'TRANSP'; + var $val_type = RFC2445_TYPE_TEXT; + var $val_default = 'OPAQUE'; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + return ($value === 'TRANSPARENT' || $value === 'OPAQUE'); + } +} + +// TODO: 4.8.3 timezone component properties + + +// 4.8.4 Relationship Component Properties +// --------------------------------------- + +class iCalendar_property_attendee extends iCalendar_property { + + var $name = 'ATTENDEE'; + var $val_type = RFC2445_TYPE_CAL_ADDRESS; + + // TODO: MUST NOT be specified when the calendar object has METHOD=PUBLISH + // TODO: standard has lots of detail here, make triple sure that we eventually conform + + function construct() { + $this->valid_parameters = array( + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'CN' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'ROLE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'PARTSTAT' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'RSVP' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'CUTYPE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'MEMBER' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DELEGATED-TO' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DELEGATED-FROM' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'SENT-BY' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DIR' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function set_parent_component($componentname) { + if(!parent::set_parent_component($componentname)) { + return false; + } + + if($this->parent_component == 'VFREEBUSY' || $this->parent_component == 'VALARM') { + // Most parameters become invalid in this case, the full allowed set is now: + $this->valid_parameters = array( + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + return false; + } + +} + +class iCalendar_property_contact extends iCalendar_property { + + var $name = 'CONTACT'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + 'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_organizer extends iCalendar_property { + + var $name = 'ORGANIZER'; + var $val_type = RFC2445_TYPE_CAL_ADDRESS; + + function construct() { + $this->valid_parameters = array( + 'CN' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'DIR' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'SENT-BY' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + // TODO: +/* + Conformance: This property MUST be specified in an iCalendar object + that specifies a group scheduled calendar entity. This property MUST + be specified in an iCalendar object that specifies the publication of + a calendar user's busy time. This property MUST NOT be specified in + an iCalendar object that specifies only a time zone definition or + that defines calendar entities that are not group scheduled entities, + but are entities only on a single user's calendar. +*/ + +} + +class iCalendar_property_recurrence_id extends iCalendar_property { + + // TODO: can only be specified when defining recurring components in the calendar +/* + Conformance: This property can be specified in an iCalendar object + containing a recurring calendar component. + + Description: The full range of calendar components specified by a + recurrence set is referenced by referring to just the "UID" property + value corresponding to the calendar component. The "RECURRENCE-ID" + property allows the reference to an individual instance within the + recurrence set. +*/ + + var $name = 'RECURRENCE-ID'; + var $val_type = RFC2445_TYPE_DATE_TIME; + + function construct() { + $this->valid_parameters = array( + 'RANGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_parameter($parameter, $value) { + + $parameter = strtoupper($parameter); + + if(!parent::is_valid_parameter($parameter, $value)) { + return false; + } + if($parameter == 'VALUE' && !($value == 'DATE' || $value == 'DATE-TIME')) { + return false; + } + + return true; + } + +} + +class iCalendar_property_related_to extends iCalendar_property { + + var $name = 'RELATED-TO'; + var $val_type = RFC2445_TYPE_TEXT; + + // TODO: the value of this property must reference another component's UID + + function construct() { + $this->valid_parameters = array( + 'RELTYPE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_url extends iCalendar_property { + + var $name = 'URL'; + var $val_type = RFC2445_TYPE_URI; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_uid extends iCalendar_property { + + var $name = 'UID'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + + // The exception to the rule: this is not a static value, so we + // generate it on-the-fly here. Guaranteed to be different for + // each instance of this property, too. Nice. + $this->val_default = rfc2445_guid(); + } +} + +// 4.8.5 Recurrence Component Properties +// ------------------------------------- + +class iCalendar_property_exdate extends iCalendar_property { + + var $name = 'EXDATE'; + var $val_type = RFC2445_TYPE_DATE_TIME; + var $val_multi = true; + + function construct() { + $this->valid_parameters = array( + 'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_parameter($parameter, $value) { + + $parameter = strtoupper($parameter); + + if(!parent::is_valid_parameter($parameter, $value)) { + return false; + } + if($parameter == 'VALUE' && !($value == 'DATE' || $value == 'DATE-TIME')) { + return false; + } + + return true; + } + +} + +class iCalendar_property_exrule extends iCalendar_property { + + var $name = 'EXRULE'; + var $val_type = RFC2445_TYPE_RECUR; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_rdate extends iCalendar_property { + + var $name = 'RDATE'; + var $val_type = RFC2445_TYPE_DATE_TIME; + var $val_multi = true; + + function construct() { + $this->valid_parameters = array( + 'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE, + 'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_parameter($parameter, $value) { + + $parameter = strtoupper($parameter); + + if(!parent::is_valid_parameter($parameter, $value)) { + return false; + } + if($parameter == 'VALUE' && !($value == 'DATE' || $value == 'DATE-TIME' || $value == 'PERIOD')) { + return false; + } + + return true; + } + +} + +class iCalendar_property_rrule extends iCalendar_property { + + var $name = 'RRULE'; + var $val_type = RFC2445_TYPE_RECUR; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +// TODO: 4.8.6 Alarm Component Properties + +// 4.8.7 Change Management Component Properties +// -------------------------------------------- + +class iCalendar_property_created extends iCalendar_property { + + var $name = 'CREATED'; + var $val_type = RFC2445_TYPE_DATE_TIME; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + if(!parent::is_valid_value($value)) { + return false; + } + // Time MUST be in UTC format + return(substr($value, -1) == 'Z'); + } +} + +class iCalendar_property_dtstamp extends iCalendar_property { + + var $name = 'DTSTAMP'; + var $val_type = RFC2445_TYPE_DATE_TIME; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + if(!parent::is_valid_value($value)) { + return false; + } + // Time MUST be in UTC format + return(substr($value, -1) == 'Z'); + } +} + +class iCalendar_property_last_modified extends iCalendar_property { + var $name = 'LAST-MODIFIED'; + var $val_type = RFC2445_TYPE_DATE_TIME; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + if(!parent::is_valid_value($value)) { + return false; + } + // Time MUST be in UTC format + return(substr($value, -1) == 'Z'); + } +} + +class iCalendar_property_sequence extends iCalendar_property { + + var $name = 'SEQUENCE'; + var $val_type = RFC2445_TYPE_INTEGER; + var $val_default = 0; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + if(!parent::is_valid_value($value)) { + return false; + } + $value = intval($value); + return ($value >= 0); + } +} + +// 4.8.8 Miscellaneous Component Properties +// ---------------------------------------- + +class iCalendar_property_x extends iCalendar_property { + + var $name = RFC2445_XNAME; + var $val_type = NULL; + + function construct() { + $this->valid_parameters = array( + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function set_name($name) { + + $name = strtoupper($name); + + if(rfc2445_is_xname($name)) { + $this->name = $name; + return true; + } + + return false; + } +} + +class iCalendar_property_request_status extends iCalendar_property { + + // IMPORTANT NOTE: This property value includes TEXT fields + // separated by semicolons. Unfortunately, auto-value-formatting + // cannot be used in this case. As an exception, the value passed + // to this property MUST be already escaped. + + var $name = 'REQUEST-STATUS'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + 'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } + + function is_valid_value($value) { + if(!is_string($value) || empty($value)) { + return false; + } + + $len = strlen($value); + $parts = array(); + $from = 0; + $escch = false; + + for($i = 0; $i < $len; ++$i) { + if($value{$i} == ';' && !$escch) { + // Token completed + $parts[] = substr($value, $from, $i - $from); + $from = $i + 1; + continue; + } + $escch = ($value{$i} == '\\'); + } + // Add one last token with the remaining text; if the value + // ended with a ';' it was illegal, so check that this token + // is not the empty string. + $parts[] = substr($value, $from); + + $count = count($parts); + + // May have 2 or 3 tokens (last one is optional) + if($count != 2 && $count != 3) { + return false; + } + + // REMEMBER: if ANY part is empty, we have an illegal value + + // First token must be hierarchical numeric status (3 levels max) + if(strlen($parts[0]) == 0) { + return false; + } + + if($parts[0]{0} < '1' || $parts[0]{0} > '4') { + return false; + } + + $len = strlen($parts[0]); + + // Max 3 levels, and can't end with a period + if($len > 5 || $parts[0]{$len - 1} == '.') { + return false; + } + + for($i = 1; $i < $len; ++$i) { + if(($i & 1) == 1 && $parts[0]{$i} != '.') { + // Even-indexed chars must be periods + return false; + } + else if(($i & 1) == 0 && ($parts[0]{$i} < '0' || $parts[0]{$i} > '9')) { + // Odd-indexed chars must be numbers + return false; + } + } + + // Second and third tokens must be TEXT, and already escaped, so + // they are not allowed to have UNESCAPED semicolons, commas, slashes, + // or any newlines at all + + for($i = 1; $i < $count; ++$i) { + if(strpos($parts[$i], "\n") !== false) { + return false; + } + + $len = strlen($parts[$i]); + if($len == 0) { + // Cannot be empty + return false; + } + + $parts[$i] .= '#'; // This guard token saves some conditionals in the loop + + for($j = 0; $j < $len; ++$j) { + $thischar = $parts[$i]{$j}; + $nextchar = $parts[$i]{$j + 1}; + if($thischar == '\\') { + // Next char must now be one of ";,\nN" + if($nextchar != ';' && $nextchar != ',' && $nextchar != '\\' && + $nextchar != 'n' && $nextchar != 'N') { + return false; + } + + // OK, this escaped sequence is correct, bypass next char + ++$j; + continue; + } + if($thischar == ';' || $thischar == ',' || $thischar == '\\') { + // This wasn't escaped as it should + return false; + } + } + } + + return true; + } + + function set_value($value) { + // Must override this, otherwise the value would be quoted again + if($this->is_valid_value($value)) { + $this->value = $value; + return true; + } + + return false; + } + +} + +class iCalendar_property_trigger extends iCalendar_property { + + var $name = 'TRIGGER'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_action extends iCalendar_property { + + var $name = 'ACTION'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + 'DISPLAY' => RFC2445_OPTIONAL | RFC2445_ONCE, + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_x_wr_alarmuid extends iCalendar_property { + + var $name = 'X_WR_ALARMUID'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_tzoffsetto extends iCalendar_property { + + var $name = 'TZOFFSETTO'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_daylightc extends iCalendar_property { + + var $name = 'DAYLIGHTC'; + var $val_type = RFC2445_TYPE_INTEGER; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_standardc extends iCalendar_property { + + var $name = 'STANDARDC'; + var $val_type = RFC2445_TYPE_INTEGER; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} + +class iCalendar_property_tzid extends iCalendar_property { + + var $name = 'TZID'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_REQUIRED + ); + } +} + +####################### +/* +class iCalendar_property_class extends iCalendar_property { + + var $name = 'CLASS'; + var $val_type = RFC2445_TYPE_TEXT; + + function construct() { + $this->valid_parameters = array( + RFC2445_XNAME => RFC2445_OPTIONAL + ); + } +} +*/ + +?> diff --git a/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_rfc2445.php b/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_rfc2445.php new file mode 100644 index 00000000..a1625d71 --- /dev/null +++ b/oss/vtiger/trunk/modules/Calendar/iCal/iCalendar_rfc2445.php @@ -0,0 +1,807 @@ + RFC2445_FOLDED_LINE_LENGTH) { + $retval .= substr($string, 0, RFC2445_FOLDED_LINE_LENGTH - 1) . RFC2445_CRLF . ' '; + $string = substr($string, RFC2445_FOLDED_LINE_LENGTH - 1); + } + + $retval .= $string; + + return $retval; + +} + +function rfc2445_unfold($string) { + for($i = 0; $i < strlen(RFC2445_WSP); ++$i) { + $string = str_replace(RFC2445_CRLF.substr(RFC2445_WSP, $i, 1), '', $string); + } + + return $string; +} + +function rfc2445_is_xname($name) { + + // If it's less than 3 chars, it cannot be legal + if(strlen($name) < 3) { + return false; + } + + // If it contains an illegal char anywhere, reject it + if(strspn($name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-') != strlen($name)) { + return false; + } + + // To be legal, it must still start with "X-" + return substr($name, 0, 2) === 'X-'; +} + +function rfc2445_is_valid_value($value, $type) { + + // This branch should only be taken with xname values + if($type === NULL) { + return true; + } + + switch($type) { + case RFC2445_TYPE_CAL_ADDRESS: + case RFC2445_TYPE_URI: + if(!is_string($value)) { + return false; + } + $valid_schemes = array('ftp', 'http', 'ldap', 'gopher', 'mailto', 'news', 'nntp', 'telnet', 'wais', 'file', 'prospero'); + + $pos = strpos($value, ':'); + if(!$pos) { + return false; + } + + $scheme = strtolower(substr($value, 0, $pos)); + $remain = substr($value, $pos + 1); + + if(!in_array($scheme, $valid_schemes)) { + return false; + } + + if($scheme === 'mailto') { + $regexp = '/^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$/'; + } + else { + $regexp = '/^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$/'; + } + + return preg_match($regexp, $remain); + break; + + case RFC2445_TYPE_BINARY: + if(!is_string($value)) { + return false; + } + + $len = strlen($value); + + if($len % 4 != 0) { + return false; + } + + for($i = 0; $i < $len; ++$i) { + $ch = $value{$i}; + if(!($ch >= 'a' && $ch <= 'z' || $ch >= 'A' && $ch <= 'Z' || $ch >= '0' && $ch <= '9' || $ch == '-' || $ch == '+')) { + if($ch == '=' && $len - $i <= 2) { + continue; + } + return false; + } + } + return true; + break; + + case RFC2445_TYPE_BOOLEAN: + if(is_bool($value)) { + return true; + } + if(is_string($value)) { + $value = strtoupper($value); + return ($value == 'TRUE' || $value == 'FALSE'); + } + return false; + break; + + case RFC2445_TYPE_DATE: + if(is_int($value)) { + if($value < 0) { + return false; + } + $value = "$value"; + } + else if(!is_string($value)) { + return false; + } + + if(strlen($value) != 8) { + return false; + } + + $y = intval(substr($value, 0, 4)); + $m = intval(substr($value, 4, 2)); + $d = intval(substr($value, 6, 2)); + + return checkdate($m, $d, $y); + break; + + case RFC2445_TYPE_DATE_TIME: + if(!is_string($value) || strlen($value) < 15) { + return false; + } + + return($value{8} == 'T' && + rfc2445_is_valid_value(substr($value, 0, 8), RFC2445_TYPE_DATE) && + rfc2445_is_valid_value(substr($value, 9), RFC2445_TYPE_TIME)); + break; + + case RFC2445_TYPE_DURATION: + if(!is_string($value)) { + return false; + } + + $len = strlen($value); + + if($len < 3) { + // Minimum conformant length: "P1W" + return false; + } + + if($value{0} == '+' || $value{0} == '-') { + $value = substr($value, 1); + --$len; // Don't forget to update this! + } + + if($value{0} != 'P') { + return false; + } + + // OK, now break it up + $num = ''; + $allowed = 'WDT'; + + for($i = 1; $i < $len; ++$i) { + $ch = $value{$i}; + if($ch >= '0' && $ch <= '9') { + $num .= $ch; + continue; + } + if(strpos($allowed, $ch) === false) { + // Non-numeric character which shouldn't be here + return false; + } + if($num === '' && $ch != 'T') { + // Allowed non-numeric character, but no digits came before it + return false; + } + + // OK, $ch now holds a character which tells us what $num is + switch($ch) { + case 'W': + // If duration in weeks is specified, this must end the string + return ($i == $len - 1); + break; + + case 'D': + // Days specified, now if anything comes after it must be a 'T' + $allowed = 'T'; + break; + + case 'T': + // Starting to specify time, H M S are now valid delimiters + $allowed = 'HMS'; + break; + + case 'H': + $allowed = 'M'; + break; + + case 'M': + $allowed = 'S'; + break; + + case 'S': + return ($i == $len - 1); + break; + } + + // If we 're going to continue, reset $num + $num = ''; + + } + + // $num is kept for this reason: if we 're here, we ran out of chars + // therefore $num must be empty for the period to be legal + return ($num === '' && $ch != 'T'); + + break; + + case RFC2445_TYPE_FLOAT: + if(is_float($value)) { + return true; + } + if(!is_string($value) || $value === '') { + return false; + } + + $dot = false; + $int = false; + $len = strlen($value); + for($i = 0; $i < $len; ++$i) { + switch($value{$i}) { + case '-': case '+': + // A sign can only be seen at position 0 and cannot be the only char + if($i != 0 || $len == 1) { + return false; + } + break; + case '.': + // A second dot is an error + // Make sure we had at least one int before the dot + if($dot || !$int) { + return false; + } + $dot = true; + // Make also sure that the float doesn't end with a dot + if($i == $len - 1) { + return false; + } + break; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + $int = true; + break; + default: + // Any other char is a no-no + return false; + break; + } + } + return true; + break; + + case RFC2445_TYPE_INTEGER: + if(is_int($value)) { + return true; + } + if(!is_string($value) || $value === '') { + return false; + } + + if($value{0} == '+' || $value{0} == '-') { + if(strlen($value) == 1) { + return false; + } + $value = substr($value, 1); + } + + if(strspn($value, '0123456789') != strlen($value)) { + return false; + } + + return ($value >= -2147483648 && $value <= 2147483647); + break; + + case RFC2445_TYPE_PERIOD: + if(!is_string($value) || empty($value)) { + return false; + } + + $parts = explode('/', $value); + if(count($parts) != 2) { + return false; + } + + if(!rfc2445_is_valid_value($parts[0], RFC2445_TYPE_DATE_TIME)) { + return false; + } + + // Two legal cases for the second part: + if(rfc2445_is_valid_value($parts[1], RFC2445_TYPE_DATE_TIME)) { + // It has to be after the start time, so + return ($parts[1] > $parts[0]); + } + else if(rfc2445_is_valid_value($parts[1], RFC2445_TYPE_DURATION)) { + // The period MUST NOT be negative + return ($parts[1]{0} != '-'); + } + + // It seems to be illegal + return false; + break; + + case RFC2445_TYPE_RECUR: + if(!is_string($value)) { + return false; + } + + $parts = explode(';', strtoupper($value)); + + // First of all, we need at least a FREQ and a UNTIL or COUNT part, so... + if(count($parts) < 2) { + return false; + } + + // Let's get that into a more easily comprehensible format + $vars = array(); + foreach($parts as $part) { + + $pieces = explode('=', $part); + // There must be exactly 2 pieces, e.g. FREQ=WEEKLY + if(count($pieces) != 2) { + return false; + } + + // It's illegal for a variable to appear twice + if(isset($vars[$pieces[0]])) { + return false; + } + + // Sounds good + $vars[$pieces[0]] = $pieces[1]; + } + + // OK... now to test everything else + + // FREQ must be the first thing appearing + reset($vars); + if(key($vars) != 'FREQ') { + return false; + } + + // It's illegal to have both UNTIL and COUNT appear + if(isset($vars['UNTIL']) && isset($vars['COUNT'])) { + return false; + } + + // Special case: BYWEEKNO is only valid for FREQ=YEARLY + if(isset($vars['BYWEEKNO']) && $vars['FREQ'] != 'YEARLY') { + return false; + } + + // Special case: BYSETPOS is only valid if another BY option is specified + if(isset($vars['BYSETPOS'])) { + $options = array('BYSECOND', 'BYMINUTE', 'BYHOUR', 'BYDAY', 'BYMONTHDAY', 'BYYEARDAY', 'BYWEEKNO', 'BYMONTH'); + $defined = array_keys($vars); + $common = array_intersect($options, $defined); + if(empty($common)) { + return false; + } + } + + // OK, now simply check if each element has a valid value, + // unsetting them on the way. If at the end the array still + // has some elements, they are illegal. + + if($vars['FREQ'] != 'SECONDLY' && $vars['FREQ'] != 'MINUTELY' && $vars['FREQ'] != 'HOURLY' && + $vars['FREQ'] != 'DAILY' && $vars['FREQ'] != 'WEEKLY' && + $vars['FREQ'] != 'MONTHLY' && $vars['FREQ'] != 'YEARLY') { + return false; + } + unset($vars['FREQ']); + + // Set this, we may need it later + $weekdays = explode(',', RFC2445_WEEKDAYS); + + if(isset($vars['UNTIL'])) { + if(rfc2445_is_valid_value($vars['UNTIL'], RFC2445_TYPE_DATE_TIME)) { + // The time MUST be in UTC format + if(!(substr($vars['UNTIL'], -1) == 'Z')) { + return false; + } + } + else if(!rfc2445_is_valid_value($vars['UNTIL'], RFC2445_TYPE_DATE_TIME)) { + return false; + } + } + unset($vars['UNTIL']); + + + if(isset($vars['COUNT'])) { + if(empty($vars['COUNT'])) { + // This also catches the string '0', which makes no sense + return false; + } + if(strspn($vars['COUNT'], '0123456789') != strlen($vars['COUNT'])) { + return false; + } + } + unset($vars['COUNT']); + + + if(isset($vars['INTERVAL'])) { + if(empty($vars['INTERVAL'])) { + // This also catches the string '0', which makes no sense + return false; + } + if(strspn($vars['INTERVAL'], '0123456789') != strlen($vars['INTERVAL'])) { + return false; + } + } + unset($vars['INTERVAL']); + + + if(isset($vars['BYSECOND'])) { + if($vars['BYSECOND'] == '') { + return false; + } + // Comma also allowed + if(strspn($vars['BYSECOND'], '0123456789,') != strlen($vars['BYSECOND'])) { + return false; + } + $secs = explode(',', $vars['BYSECOND']); + foreach($secs as $sec) { + if($sec == '' || $sec < 0 || $sec > 59) { + return false; + } + } + } + unset($vars['BYSECOND']); + + + if(isset($vars['BYMINUTE'])) { + if($vars['BYMINUTE'] == '') { + return false; + } + // Comma also allowed + if(strspn($vars['BYMINUTE'], '0123456789,') != strlen($vars['BYMINUTE'])) { + return false; + } + $mins = explode(',', $vars['BYMINUTE']); + foreach($mins as $min) { + if($min == '' || $min < 0 || $min > 59) { + return false; + } + } + } + unset($vars['BYMINUTE']); + + + if(isset($vars['BYHOUR'])) { + if($vars['BYHOUR'] == '') { + return false; + } + // Comma also allowed + if(strspn($vars['BYHOUR'], '0123456789,') != strlen($vars['BYHOUR'])) { + return false; + } + $hours = explode(',', $vars['BYHOUR']); + foreach($hours as $hour) { + if($hour == '' || $hour < 0 || $hour > 23) { + return false; + } + } + } + unset($vars['BYHOUR']); + + + if(isset($vars['BYDAY'])) { + if(empty($vars['BYDAY'])) { + return false; + } + + // First off, split up all values we may have + $days = explode(',', $vars['BYDAY']); + + foreach($days as $day) { + $daypart = substr($day, -2); + if(!in_array($daypart, $weekdays)) { + return false; + } + + if(strlen($day) > 2) { + $intpart = substr($day, 0, strlen($day) - 2); + if(!rfc2445_is_valid_value($intpart, RFC2445_TYPE_INTEGER)) { + return false; + } + if(intval($intpart) == 0) { + return false; + } + } + } + } + unset($vars['BYDAY']); + + + if(isset($vars['BYMONTHDAY'])) { + if(empty($vars['BYMONTHDAY'])) { + return false; + } + $mdays = explode(',', $vars['BYMONTHDAY']); + foreach($mdays as $mday) { + if(!rfc2445_is_valid_value($mday, RFC2445_TYPE_INTEGER)) { + return false; + } + $mday = abs(intval($mday)); + if($mday == 0 || $mday > 31) { + return false; + } + } + } + unset($vars['BYMONTHDAY']); + + + if(isset($vars['BYYEARDAY'])) { + if(empty($vars['BYYEARDAY'])) { + return false; + } + $ydays = explode(',', $vars['BYYEARDAY']); + foreach($ydays as $yday) { + if(!rfc2445_is_valid_value($yday, RFC2445_TYPE_INTEGER)) { + return false; + } + $yday = abs(intval($yday)); + if($yday == 0 || $yday > 366) { + return false; + } + } + } + unset($vars['BYYEARDAY']); + + + if(isset($vars['BYWEEKNO'])) { + if(empty($vars['BYWEEKNO'])) { + return false; + } + $weeknos = explode(',', $vars['BYWEEKNO']); + foreach($weeknos as $weekno) { + if(!rfc2445_is_valid_value($weekno, RFC2445_TYPE_INTEGER)) { + return false; + } + $weekno = abs(intval($weekno)); + if($weekno == 0 || $weekno > 53) { + return false; + } + } + } + unset($vars['BYWEEKNO']); + + + if(isset($vars['BYMONTH'])) { + if(empty($vars['BYMONTH'])) { + return false; + } + // Comma also allowed + if(strspn($vars['BYMONTH'], '0123456789,') != strlen($vars['BYMONTH'])) { + return false; + } + $months = explode(',', $vars['BYMONTH']); + foreach($months as $month) { + if($month == '' || $month < 1 || $month > 12) { + return false; + } + } + } + unset($vars['BYMONTH']); + + + if(isset($vars['BYSETPOS'])) { + if(empty($vars['BYSETPOS'])) { + return false; + } + $sets = explode(',', $vars['BYSETPOS']); + foreach($sets as $set) { + if(!rfc2445_is_valid_value($set, RFC2445_TYPE_INTEGER)) { + return false; + } + $set = abs(intval($set)); + if($set == 0 || $set > 366) { + return false; + } + } + } + unset($vars['BYSETPOS']); + + + if(isset($vars['WKST'])) { + if(!in_array($vars['WKST'], $weekdays)) { + return false; + } + } + unset($vars['WKST']); + + + // Any remaining vars must be x-names + if(empty($vars)) { + return true; + } + + foreach($vars as $name => $var) { + if(!rfc2445_is_xname($name)) { + return false; + } + } + + // At last, all is OK! + return true; + + break; + + case RFC2445_TYPE_TEXT: + return true; + break; + + case RFC2445_TYPE_TIME: + if(is_int($value)) { + if($value < 0) { + return false; + } + $value = "$value"; + } + else if(!is_string($value)) { + return false; + } + + if(strlen($value) == 7) { + if(strtoupper(substr($value, -1)) != 'Z') { + return false; + } + $value = substr($value, 0, 6); + } + if(strlen($value) != 6) { + return false; + } + + $h = intval(substr($value, 0, 2)); + $m = intval(substr($value, 2, 2)); + $s = intval(substr($value, 4, 2)); + + return ($h <= 23 && $m <= 59 && $s <= 60); + break; + + case RFC2445_TYPE_UTC_OFFSET: + if(is_int($value)) { + if($value >= 0) { + $value = "+$value"; + } + else { + $value = "$value"; + } + } + else if(!is_string($value)) { + return false; + } + + if(strlen($value) == 7) { + $s = intval(substr($value, 5, 2)); + $value = substr($value, 0, 5); + } + if(strlen($value) != 5 || $value == "-0000") { + return false; + } + + if($value{0} != '+' && $value{0} != '-') { + return false; + } + + $h = intval(substr($value, 1, 2)); + $m = intval(substr($value, 3, 2)); + + return ($h <= 23 && $m <= 59 && $s <= 59); + break; + } + + // TODO: remove this assertion + trigger_error('bad code path', E_USER_WARNING); + var_dump($type); + return false; +} + +function rfc2445_do_value_formatting($value, $type) { + // Note: this does not only do formatting; it also does conversion to string! + switch($type) { + case RFC2445_TYPE_CAL_ADDRESS: + case RFC2445_TYPE_URI: + // Enclose in double quotes + $value = '"'.$value.'"'; + break; + case RFC2445_TYPE_TEXT: + // Escape entities + $value = strtr($value, array("\n" => '\\n', '\\' => '\\\\', ',' => '\\,', ';' => '\\;')); + break; + } + return $value; +} + +function rfc2445_undo_value_formatting($value, $type) { + switch($type) { + case RFC2445_TYPE_CAL_ADDRESS: + case RFC2445_TYPE_URI: + // Trim beginning and end double quote + $value = substr($value, 1, strlen($value) - 2); + break; + case RFC2445_TYPE_TEXT: + // Unescape entities + $value = strtr($value, array('\\n' => "\n", '\\N' => "\n", '\\\\' => '\\', '\\,' => ',', '\\;' => ';')); + break; + } + return $value; +} + +// This is cheating: GUIDs have nothing to do with RFC 2445 + +function rfc2445_guid() { + // Implemented as per the Network Working Group draft on UUIDs and GUIDs + + // These two octets get special treatment + $time_hi_and_version = sprintf('%02x', (1 << 6) + mt_rand(0, 15)); // 0100 plus 4 random bits + $clock_seq_hi_and_reserved = sprintf('%02x', (1 << 7) + mt_rand(0, 63)); // 10 plus 6 random bits + + // Need another 14 random octects + $pool = ''; + for($i = 0; $i < 7; ++$i) { + $pool .= sprintf('%04x', mt_rand(0, 65535)); + } + + // time_low = 4 octets + $random = substr($pool, 0, 8).'-'; + + // time_mid = 2 octets + $random .= substr($pool, 8, 4).'-'; + + // time_high_and_version = 2 octets + $random .= $time_hi_and_version.substr($pool, 12, 2).'-'; + + // clock_seq_high_and_reserved = 1 octet + $random .= $clock_seq_hi_and_reserved; + + // clock_seq_low = 1 octet + $random .= substr($pool, 13, 2).'-'; + + // node = 6 octets + $random .= substr($pool, 14, 12); + + return $random; +} + +?> diff --git a/oss/vtiger/trunk/modules/Calendar/iCal/ical-parser-class.php b/oss/vtiger/trunk/modules/Calendar/iCal/ical-parser-class.php new file mode 100644 index 00000000..ed4d3c32 --- /dev/null +++ b/oss/vtiger/trunk/modules/Calendar/iCal/ical-parser-class.php @@ -0,0 +1,91 @@ +folders = 'cache/import/'; + } + + function iCalReader($filename,$root_directory='') { + $iCaltoArray = $this->iCalDecoder($filename,$root_directory); + return $iCaltoArray; + } + + function iCalDecoder($file,$root_directory) { + $ical = file_get_contents($root_directory.$this->folders.$file); + preg_match_all('/BEGIN:VEVENT.*?END:VEVENT/si', $ical, $eventresult, PREG_PATTERN_ORDER); + preg_match_all('/BEGIN:VTODO.*?END:VTODO/si', $ical, $todoresult, PREG_PATTERN_ORDER); + for ($i = 0; $i < count($eventresult[0]); $i++) { + $tmpbyline = explode("\r\n", $eventresult[0][$i]); + $begin = false; + $key=NULL; + foreach ($tmpbyline as $item) { + $tmpholderarray = explode(":",$item,2); + + if (count($tmpholderarray) >1) { + if($tmpholderarray[0]=='BEGIN'){ + if($begin==false){ + $begin = true; + $majorarray['TYPE']=$tmpholderarray[1]; + } else { + $majorarray[$tmpholderarray[1]]=array(); + $key = $tmpholderarray[1]; + } + } else if($tmpholderarray[0]=='END'){ + if(!empty($key)){ + $key = NULL; + } + } else { + if(!empty($key)){ + $majorarray[$key][$tmpholderarray[0]] = $tmpholderarray[1]; + } else { + $majorarray[$tmpholderarray[0]] = $tmpholderarray[1]; + } + } + } + + } + $icalarray[] = $majorarray; + unset($majorarray); + } + + for ($i = 0; $i < count($todoresult[0]); $i++) { + $tmpbyline = explode("\r\n", $todoresult[0][$i]); + $begin = false; + $key=NULL; + foreach ($tmpbyline as $item) { + $tmpholderarray = explode(":",$item); + + if (count($tmpholderarray) >1) { + if($tmpholderarray[0]=='BEGIN'){ + if($begin==false){ + $begin = true; + $majorarray['TYPE']=$tmpholderarray[1]; + } else { + $majorarray[$tmpholderarray[1]]=array(); + $key = $tmpholderarray[1]; + } + } else if($tmpholderarray[0]=='END'){ + if(!empty($key)){ + $key = NULL; + } + } else { + if(!empty($key)){ + $majorarray[$key][$tmpholderarray[0]] = $tmpholderarray[1]; + } else { + $majorarray[$tmpholderarray[0]] = $tmpholderarray[1]; + } + } + } + + } + $icalarray[] = $majorarray; + unset($majorarray); + } + return $icalarray; + } +} + +?> diff --git a/oss/vtiger/trunk/modules/Calendar/iCalExport.php b/oss/vtiger/trunk/modules/Calendar/iCalExport.php new file mode 100644 index 00000000..6886deb4 --- /dev/null +++ b/oss/vtiger/trunk/modules/Calendar/iCalExport.php @@ -0,0 +1,113 @@ +id . + " and vtiger_activity.activitytype NOT IN ('Emails')"; + +$calendar_results = $adb->query($ical_query); + +// Send the right content type and filename +header ("Content-type: text/calendar"); +header('Content-Disposition: attachment; '."filename={$filename}.ics"); + +$todo_fields = getColumnFields('Calendar'); +$event_fields = getColumnFields('Events'); +$event = $todo = array(); +$keys_to_replace = array( + 'events'=>array('taskpriority'), + 'todo'=>array('taskpriority','taskstatus') +); +$keyvals_to_replace = array( + 'events'=>array('taskpriority'=>'priority'), + 'todo'=>array('taskpriority'=>'priority','taskstatus'=>'status') +); +foreach($todo_fields as $key=>$val){ + if(getFieldVisibilityPermission('Calendar',$current_user->id,$key)==0){ + if(!in_array($key,$keys_to_replace['todo'])){ + $todo[$key] = 'yes'; + } else { + $todo[$keyvals_to_replace['todo'][$key]] = 'yes'; + } + } +} +foreach($event_fields as $key=>$val){ + if(getFieldVisibilityPermission('Events',$current_user->id,$key)==0){ + if(!in_array($key,$keys_to_replace['events'])){ + $event[$key] = 'yes'; + } else { + $event[$keyvals_to_replace['events'][$key]] = 'yes'; + } + } +} + +$tz = new iCalendar_timezone; +if(!empty($default_timezone)){ + $tzid = split('/',$default_timezone); +} else { + $default_timezone = date_default_timezone_get(); + $tzid = split('/',$default_timezone); +} + +if(!empty($tzid[1])){ + $tz->add_property('TZID', $tzid[1]); +} else { + $tz->add_property('TZID', $tzid[0]); +} +$tz->add_property('TZOFFSETTO', date('O')); +if(date('I')==1){ + $tz->add_property('DAYLIGHTC', date('I')); +} else { + $tz->add_property('STANDARDC', date('I')); +} + +$myical = new iCalendar; + +$myical->add_component($tz); + +while (!$calendar_results->EOF) { + $this_event = $calendar_results->fields; + $id = $this_event['activityid']; + $type = $this_event['activitytype']; + if($type!='Task'){ + $temp = $event; + foreach($temp as $key=>$val){ + $temp[$key] = $this_event[$key]; + } + $temp['id'] = $id; + $ev = new iCalendar_event; + $ev->assign_values($temp); + + $al = new iCalendar_alarm; + $al->assign_values($temp); + $ev->add_component($al); + } else { + $temp = $todo; + foreach($temp as $key=>$val){ + $temp[$key] = $this_event[$key]; + } + $ev = new iCalendar_todo; + $ev->assign_values($temp); + } + + $myical->add_component($ev); + $calendar_results->MoveNext(); +} +// Print the actual calendar +echo $myical->serialize(); + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Calendar/iCalImport.php b/oss/vtiger/trunk/modules/Calendar/iCalImport.php new file mode 100644 index 00000000..01440132 --- /dev/null +++ b/oss/vtiger/trunk/modules/Calendar/iCalImport.php @@ -0,0 +1,146 @@ +mark_deleted_by_user_id($current_user->id); + $file_details = $_FILES['ics_file']; + $binFile = 'vtiger_import'.date('YmdHis'); + $file = $import_dir.''.$binFile; + $filetmp_name = $file_details['tmp_name']; + $upload_status = move_uploaded_file($filetmp_name,$file); + + $skip_fields = array( + 'Events'=>array('duration_hours'), + 'Calendar'=>array('eventstatus') + ); + $required_fields = array(); + + $modules = array('Events','Calendar'); + foreach($modules as $module){ + $calendar = CRMEntity::getInstance('Calendar'); + $calendar->initRequiredFields($module); + $val = array_keys($calendar->required_fields); + $required_fields[$module] = array_diff($val,$skip_fields[$module]); + } + + $ical = new iCal(); + $ical_activities = $ical->iCalReader($binFile); + + $count['Events'] = $count['Calendar'] = $skip_count['Events'] = $skip_count['Calendar'] = 0; + for($i=0;$icolumn_fields = $activity->generateArray($ical_activities[$i]); + $calendar->column_fields['assigned_user_id'] = $current_user->id; + foreach($required_fields[$module] as $key){ + if(empty($calendar->column_fields[$key])){ + $skip_count[$module]++; + break; + } + } + $calendar->save('Calendar'); + $last_import = new UsersLastImport(); + $last_import->assigned_user_id = $current_user->id; + $last_import->bean_type = 'Calendar'; + $last_import->bean_id = $calendar->id; + $last_import->save(); + if(!empty($ical_activities[$i]['VALARM'])){ + $calendar->activity_reminder($calendar->id,$calendar->column_fields['reminder_time'],0,'',''); + } + } + unlink($file); + $smarty->assign("IMAGE_PATH", $last_imported); + $smarty = new vtigerCRM_Smarty; + + $smarty->assign("MOD", $mod_strings); + $smarty->assign("APP", $app_strings); + $smarty->assign("IMP", $import_mod_strings); + $smarty->assign("THEME", $theme); + $smarty->assign("IMAGE_PATH", $image_path); + $parent_tab = vtlib_purify($_SESSION['import_parenttab']); + if(empty($parent_Tab)){ + $parent_tab = getParentTab(); + } + $smarty->assign("MODULE", vtlib_purify($_REQUEST['module'])); + $smarty->assign("SINGLE_MOD", vtlib_purify($_REQUEST['module'])); + $smarty->assign("CATEGORY", $parent_tab); + //@session_unregister("import_parenttab"); + $smarty->display("Buttons_List1.tpl"); + + $imported_events = $count['Events'] - $skip_count['Events']; + $imported_tasks = $count['Calendar'] - $skip_count['Calendar']; + $message= "".$mod_strings['LBL_SUCCESS']."" + ."

" .$mod_strings['LBL_SUCCESS_EVENTS_1']." $imported_events" + ."

" .$mod_strings['LBL_SKIPPED_EVENTS_1'].$skip_count['Events'] + ."

" .$mod_strings['LBL_SUCCESS_CALENDAR_1']." $imported_tasks" + ."

" .$mod_strings['LBL_SKIPPED_CALENDAR_1'].$skip_count['Calendar'] + ."

"; + + $smarty->assign("MESSAGE", $message); + $smarty->assign("RETURN_MODULE", $currentModule); + $smarty->assign("RETURN_ACTION", 'ListView'); + $smarty->assign("MODULE", $currentModule); + $smarty->assign("MODULENAME", $currentModule); + $smarty->display("iCalImport.tpl"); + +} else { + $smarty->assign("IMAGE_PATH", $last_imported); + $smarty = new vtigerCRM_Smarty; + + $smarty->assign("MOD", $mod_strings); + $smarty->assign("APP", $app_strings); + $smarty->assign("IMP", $import_mod_strings); + $smarty->assign("THEME", $theme); + $smarty->assign("IMAGE_PATH", $image_path); + $parent_tab = vtlib_purify($_SESSION['import_parenttab']); + if(empty($parent_Tab)){ + $parent_tab = getParentTab(); + } + $smarty->assign("MODULE", vtlib_purify($_REQUEST['module'])); + $smarty->assign("SINGLE_MOD", vtlib_purify($_REQUEST['module'])); + $smarty->assign("CATEGORY", $parent_tab); + //@session_unregister("import_parenttab"); + $smarty->display("Buttons_List1.tpl"); + + $last_import = new UsersLastImport(); + $ret_value = $last_import->undo($current_user->id); + + if(!empty($ret_value)){ + $message= "".$mod_strings['LBL_SUCCESS']."" + ."

" .$mod_strings['LBL_LAST_IMPORT_UNDONE']." "; + } else { + $message= "".$mod_strings['LBL_FAILURE']."" + ."

" .$mod_strings['LBL_NO_IMPORT_TO_UNDO']." "; + } + + $smarty->assign("MESSAGE", $message); + $smarty->assign("UNDO", 'yes'); + $smarty->assign("RETURN_MODULE", $currentModule); + $smarty->assign("RETURN_ACTION", 'ListView'); + $smarty->assign("MODULE", $currentModule); + $smarty->assign("MODULENAME", $currentModule); + $smarty->display("iCalImport.tpl"); +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Calendar/language/en_us.lang.php b/oss/vtiger/trunk/modules/Calendar/language/en_us.lang.php index 3b5cf4c5..891c51aa 100644 --- a/oss/vtiger/trunk/modules/Calendar/language/en_us.lang.php +++ b/oss/vtiger/trunk/modules/Calendar/language/en_us.lang.php @@ -436,7 +436,17 @@ $mod_strings = Array( 'LBL_SET_DATE'=>'Set Date', 'LBL_MINE' =>'Mine', - +'LBL_SUCCESS_CALENDAR_1' => 'No. of Tasks Successfully Imported : ', +'LBL_SKIPPED_CALENDAR_1' => 'No. of Tasks Skipped as they were missing one or more required fields : ', +'LBL_SUCCESS_EVENTS_1' => 'No. of Events Successfully Imported : ', +'LBL_SKIPPED_EVENTS_1' => 'No. of Events Skipped as they were missing one or more required fields : ', +'LBL_FINISHED'=>'Finished', +'LBL_UNDO_LAST_IMPORT'=>'Undo Last Import', +'LBL_LAST_IMPORT'=>'Last Imported', +'LBL_LAST_IMPORT_UNDONE'=>'Your Last Import Was Undone', +'LBL_SUCCESS'=>'Success!', +'LBL_NO_IMPORT_TO_UNDO'=>'There was no import to undo.', +'LBL_FAILURE'=>'Failed!', ); -?> +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Calendar/script.js b/oss/vtiger/trunk/modules/Calendar/script.js index c90ceb8f..9a7bd799 100644 --- a/oss/vtiger/trunk/modules/Calendar/script.js +++ b/oss/vtiger/trunk/modules/Calendar/script.js @@ -742,15 +742,16 @@ function cal_navigation(type,urlstring,start) $("status").style.display="inline"; if(type == 'event') { - var OptionData = $('view_Option').options[$('view_Option').selectedIndex].value; - new Ajax.Request( + var users = document.getElementsByName('onlyforuser'); + var onlyforusers = users[0].value; + var OptionData = $('view_Option').options[$('view_Option').selectedIndex].value; + new Ajax.Request( 'index.php', {queue: {position: 'end', scope: 'command'}, method: 'post', - postBody: 'module=Calendar&action=CalendarAjax&file=ActivityAjax&ajax=true&n_type=nav&viewOption='+OptionData+url+start+'&subtab='+type, + postBody: 'module=Calendar&action=CalendarAjax&file=ActivityAjax&ajax=true&n_type=nav&viewOption='+OptionData+url+start+'&subtab='+type+'&onlyforuser='+encodeURIComponent(onlyforusers), onComplete: function(response) { - //alert(response.responseText); - if(OptionData == 'listview') + if(OptionData == 'listview') { result = response.responseText.split('####'); $("total_activities").innerHTML = result[1]; diff --git a/oss/vtiger/trunk/modules/Campaigns/CallRelatedList.php b/oss/vtiger/trunk/modules/Campaigns/CallRelatedList.php index b9633ed4..a20a12c6 100644 --- a/oss/vtiger/trunk/modules/Campaigns/CallRelatedList.php +++ b/oss/vtiger/trunk/modules/Campaigns/CallRelatedList.php @@ -68,6 +68,15 @@ if($singlepane_view == 'true' && $_REQUEST['action'] == 'CallRelatedList') { } // END $smarty->assign("RELATEDLISTS", $related_array); + + require_once('include/ListView/RelatedListViewSession.php'); + if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) { + $relationId = vtlib_purify($_REQUEST['relation_id']); + RelatedListViewSession::addRelatedModuleToSession($relationId, + vtlib_purify($_REQUEST['selected_header'])); + } + $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession(); + $smarty->assign("SELECTEDHEADERS", $open_related_modules); require_once('modules/CustomView/CustomView.php'); diff --git a/oss/vtiger/trunk/modules/Campaigns/Campaigns.php b/oss/vtiger/trunk/modules/Campaigns/Campaigns.php index 26f2367f..72300fbe 100644 --- a/oss/vtiger/trunk/modules/Campaigns/Campaigns.php +++ b/oss/vtiger/trunk/modules/Campaigns/Campaigns.php @@ -129,6 +129,100 @@ class Campaigns extends CRMEntity { } // Mike Crowe Mod -------------------------------------------------------- + /** + * Function to get Campaign related Accouts + * @param integer $id - campaignid + * returns related Accounts record in array format + */ + function get_accounts($id, $cur_tab_id, $rel_tab_id, $actions = false) { + global $log, $singlepane_view,$currentModule; + $log->debug("Entering get_accounts(".$id.") method ..."); + $this_module = $currentModule; + + $related_module = vtlib_getModuleNameById($rel_tab_id); + require_once("modules/$related_module/$related_module.php"); + $other = new $related_module(); + + $is_CampaignStatusAllowed = false; + global $current_user; + if(getFieldVisibilityPermission('Accounts', $current_user->id, 'campaignrelstatus') == '0') { + $other->list_fields['Status'] = array('vtiger_campaignrelstatus'=>'campaignrelstatus'); + $other->list_fields_name['Status'] = 'campaignrelstatus'; + $other->sortby_fields[] = 'campaignrelstatus'; + $is_CampaignStatusAllowed = true; + } + + vtlib_setup_modulevars($related_module, $other); + $singular_modname = vtlib_toSingular($related_module); + + $parenttab = getParentTab(); + + if($singlepane_view == 'true') + $returnset = '&return_module='.$this_module.'&return_action=DetailView&return_id='.$id; + else + $returnset = '&return_module='.$this_module.'&return_action=CallRelatedList&return_id='.$id; + + $button = ''; + + // Send mail button for selected Accounts + $button .= ""; + $button .= '    '; + /* To get Accounts CustomView -START */ + require_once('modules/CustomView/CustomView.php'); + $ahtml = ""; + /* To get Accounts CustomView -END */ + + $button .= $ahtml.""; + $button .= '    '; + + if($actions) + { + if(is_string($actions)) + $actions = explode(',', strtoupper($actions)); + if(in_array('SELECT', $actions) && isPermitted($related_module,4, '') == 'yes') + { + $button .= " "; + } + if(in_array('ADD', $actions) && isPermitted($related_module,1, '') == 'yes') + { + $button .= " "; + } + } + + $query = "SELECT vtiger_account.*, + CASE when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, + vtiger_crmentity.*, vtiger_crmentity.modifiedtime, vtiger_campaignrelstatus.*, vtiger_accountbillads.* + FROM vtiger_account + INNER JOIN vtiger_campaignaccountrel ON vtiger_campaignaccountrel.accountid = vtiger_account.accountid + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_account.accountid + LEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid + LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id + LEFT JOIN vtiger_accountbillads ON vtiger_accountbillads.accountaddressid = vtiger_account.accountid + LEFT JOIN vtiger_campaignrelstatus ON vtiger_campaignrelstatus.campaignrelstatusid = vtiger_campaignaccountrel.campaignrelstatusid + WHERE vtiger_campaignaccountrel.campaignid = ".$id." AND vtiger_crmentity.deleted=0"; + + $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); + + if($return_value == null) + $return_value = Array(); + else if($is_CampaignStatusAllowed) { + $statusPos = count($return_value['header']) - 2; // Last column is for Actions, exclude that. Also the index starts from 0, so reduce one more count. + $return_value = $this->add_status_popup($return_value, $statusPos, 'Accounts'); + } + + $return_value['CUSTOM_BUTTON'] = $button; + + $log->debug("Exiting get_accounts method ..."); + return $return_value; + } + /** * Function to get Campaign related Contacts * @param integer $id - campaignid @@ -142,7 +236,17 @@ class Campaigns extends CRMEntity { $related_module = vtlib_getModuleNameById($rel_tab_id); require_once("modules/$related_module/$related_module.php"); $other = new $related_module(); - vtlib_setup_modulevars($related_module, $other); + + $is_CampaignStatusAllowed = false; + global $current_user; + if(getFieldVisibilityPermission('Contacts', $current_user->id, 'campaignrelstatus') == '0') { + $other->list_fields['Status'] = array('vtiger_campaignrelstatus'=>'campaignrelstatus'); + $other->list_fields_name['Status'] = 'campaignrelstatus'; + $other->sortby_fields[] = 'campaignrelstatus'; + $is_CampaignStatusAllowed = true; + } + + vtlib_setup_modulevars($related_module, $other); $singular_modname = vtlib_toSingular($related_module); $parenttab = getParentTab(); @@ -160,7 +264,7 @@ class Campaigns extends CRMEntity { /* To get Leads CustomView -START */ require_once('modules/CustomView/CustomView.php'); - $lhtml = ""; $oCustomView = new CustomView($related_module); $viewid = $oCustomView->getViewId($related_module); $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid, false); @@ -184,21 +288,28 @@ class Campaigns extends CRMEntity { } $query = "SELECT vtiger_contactdetails.accountid, vtiger_account.accountname, - CASE when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name , - vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, - vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, - vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime - FROM vtiger_contactdetails - INNER JOIN vtiger_campaigncontrel ON vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid - INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid - LEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid - LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id - LEFT JOIN vtiger_account ON vtiger_account.accountid = vtiger_contactdetails.accountid - WHERE vtiger_campaigncontrel.campaignid = ".$id." AND vtiger_crmentity.deleted=0"; + CASE when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name , + vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, + vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, + vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_campaignrelstatus.* + FROM vtiger_contactdetails + INNER JOIN vtiger_campaigncontrel ON vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid + LEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid + LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id + LEFT JOIN vtiger_account ON vtiger_account.accountid = vtiger_contactdetails.accountid + LEFT JOIN vtiger_campaignrelstatus ON vtiger_campaignrelstatus.campaignrelstatusid = vtiger_campaigncontrel.campaignrelstatusid + WHERE vtiger_campaigncontrel.campaignid = ".$id." AND vtiger_crmentity.deleted=0"; $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); - if($return_value == null) $return_value = Array(); + if($return_value == null) + $return_value = Array(); + else if($is_CampaignStatusAllowed) { + $statusPos = count($return_value['header']) - 2; // Last column is for Actions, exclude that. Also the index starts from 0, so reduce one more count. + $return_value = $this->add_status_popup($return_value, $statusPos, 'Contacts'); + } + $return_value['CUSTOM_BUTTON'] = $button; $log->debug("Exiting get_contacts method ..."); @@ -218,7 +329,17 @@ class Campaigns extends CRMEntity { $related_module = vtlib_getModuleNameById($rel_tab_id); require_once("modules/$related_module/$related_module.php"); $other = new $related_module(); - vtlib_setup_modulevars($related_module, $other); + + $is_CampaignStatusAllowed = false; + global $current_user; + if(getFieldVisibilityPermission('Leads', $current_user->id, 'campaignrelstatus') == '0') { + $other->list_fields['Status'] = array('vtiger_campaignrelstatus'=>'campaignrelstatus'); + $other->list_fields_name['Status'] = 'campaignrelstatus'; + $other->sortby_fields[] = 'campaignrelstatus'; + $is_CampaignStatusAllowed = true; + } + + vtlib_setup_modulevars($related_module, $other); $singular_modname = vtlib_toSingular($related_module); $parenttab = getParentTab(); @@ -236,7 +357,7 @@ class Campaigns extends CRMEntity { /* To get Leads CustomView -START */ require_once('modules/CustomView/CustomView.php'); - $lhtml = ""; $oCustomView = new CustomView($related_module); $viewid = $oCustomView->getViewId($related_module); $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid, false); @@ -260,19 +381,27 @@ class Campaigns extends CRMEntity { } $query = "SELECT vtiger_leaddetails.*, vtiger_crmentity.crmid,vtiger_leadaddress.phone,vtiger_leadsubdetails.website, - CASE when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, - vtiger_crmentity.smownerid FROM vtiger_leaddetails - INNER JOIN vtiger_campaignleadrel ON vtiger_campaignleadrel.leadid=vtiger_leaddetails.leadid - INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid - INNER JOIN vtiger_leadsubdetails ON vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid - INNER JOIN vtiger_leadaddress ON vtiger_leadaddress.leadaddressid = vtiger_leadsubdetails.leadsubscriptionid - LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id - LEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid - WHERE vtiger_crmentity.deleted=0 AND vtiger_campaignleadrel.campaignid = ".$id; + CASE when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, + vtiger_crmentity.smownerid, vtiger_campaignrelstatus.* + FROM vtiger_leaddetails + INNER JOIN vtiger_campaignleadrel ON vtiger_campaignleadrel.leadid=vtiger_leaddetails.leadid + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid + INNER JOIN vtiger_leadsubdetails ON vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid + INNER JOIN vtiger_leadaddress ON vtiger_leadaddress.leadaddressid = vtiger_leadsubdetails.leadsubscriptionid + LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id + LEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid + LEFT JOIN vtiger_campaignrelstatus ON vtiger_campaignrelstatus.campaignrelstatusid = vtiger_campaignleadrel.campaignrelstatusid + WHERE vtiger_crmentity.deleted=0 AND vtiger_campaignleadrel.campaignid = ".$id; $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); - if($return_value == null) $return_value = Array(); + if($return_value == null) + $return_value = Array(); + else if($is_CampaignStatusAllowed) { + $statusPos = count($return_value['header']) - 2; // Last column is for Actions, exclude that. Also the index starts from 0, so reduce one more count. + $return_value = $this->add_status_popup($return_value, $statusPos, 'Leads'); + } + $return_value['CUSTOM_BUTTON'] = $button; $log->debug("Exiting get_leads method ..."); @@ -410,7 +539,40 @@ class Campaigns extends CRMEntity { return $return_value; } - + /* + * Function populate the status columns' HTML + * @param - $related_list return value from GetRelatedList + * @param - $status_column index of the status column in the list. + * returns true on success + */ + function add_status_popup($related_list, $status_column = 7, $related_module) + { + global $adb; + + if(!$this->campaignrelstatus) + { + $result = $adb->query('SELECT * FROM vtiger_campaignrelstatus;'); + while($row = $adb->fetchByAssoc($result)) + { + $this->campaignrelstatus[$row['campaignrelstatus']] = $row; + } + } + foreach($related_list['entries'] as $key => &$entry) + { + $popupitemshtml = ''; + foreach($this->campaignrelstatus as $campaingrelstatus) + { + $camprelstatus = getTranslatedString($campaingrelstatus[campaignrelstatus],'Campaigns'); + $popupitemshtml .= "id."', '$key', '$campaingrelstatus[campaignrelstatusid]', '".addslashes($camprelstatus)."');\">$camprelstatus
"; + } + $popuphtml = '
'.$popupitemshtml.'
'; + + $entry[$status_column] = "[+] ".$entry[$status_column]."".$popuphtml; + } + + return $related_list; + } + /* * Function to get the secondary query part of a report * @param - $module primary module name @@ -437,6 +599,7 @@ class Campaigns extends CRMEntity { $rel_tables = array ( "Contacts" => array("vtiger_campaigncontrel"=>array("campaignid","contactid"),"vtiger_campaign"=>"campaignid"), "Leads" => array("vtiger_campaignleadrel"=>array("campaignid","leadid"),"vtiger_campaign"=>"campaignid"), + "Accounts" => array("vtiger_campaignaccountrel"=>array("campaignid","accountid"),"vtiger_campaign"=>"campaignid"), "Potentials" => array("vtiger_potential"=>array("campaignid","potentialid"),"vtiger_campaign"=>"campaignid"), "Calendar" => array("vtiger_seactivityrel"=>array("crmid","activityid"),"vtiger_campaign"=>"campaignid"), "Products" => array("vtiger_campaign"=>array("campaignid","product_id")), @@ -455,6 +618,9 @@ class Campaigns extends CRMEntity { } elseif($return_module == 'Contacts') { $sql = 'DELETE FROM vtiger_campaigncontrel WHERE campaignid=? AND contactid=?'; $this->db->pquery($sql, array($id, $return_id)); + } elseif($return_module == 'Accounts') { + $sql = 'DELETE FROM vtiger_campaignaccountrel WHERE campaignid=? AND accountid=?'; + $this->db->pquery($sql, array($id, $return_id)); } else { $sql = 'DELETE FROM vtiger_crmentityrel WHERE (crmid=? AND relmodule=? AND relcrmid=?) OR (relcrmid=? AND module=? AND crmid=?)'; $params = array($id, $return_module, $return_id, $id, $return_module, $return_id); @@ -463,4 +629,4 @@ class Campaigns extends CRMEntity { } } -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/Campaigns/DetailView.php b/oss/vtiger/trunk/modules/Campaigns/DetailView.php index cd82717d..7e4424ce 100644 --- a/oss/vtiger/trunk/modules/Campaigns/DetailView.php +++ b/oss/vtiger/trunk/modules/Campaigns/DetailView.php @@ -81,6 +81,13 @@ if($singlepane_view == 'true') { $related_array = getRelatedLists($currentModule,$focus); $smarty->assign("RELATEDLISTS", $related_array); + require_once('include/ListView/RelatedListViewSession.php'); + if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) { + RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']), + vtlib_purify($_REQUEST['selected_header'])); + } + $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession(); + $smarty->assign("SELECTEDHEADERS", $open_related_modules); } $smarty->assign("SinglePane_View", $singlepane_view); @@ -98,6 +105,12 @@ if(PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($ $focus->markAsViewed($current_user->id); // END +// Gather the custom link information to display +include_once('vtlib/Vtiger/Link.php'); +$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action'])); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params)); +// END + $smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true)); $smarty->display("DetailView.tpl"); diff --git a/oss/vtiger/trunk/modules/Campaigns/DetailViewAjax.php b/oss/vtiger/trunk/modules/Campaigns/DetailViewAjax.php index 31f31673..081bf9c9 100644 --- a/oss/vtiger/trunk/modules/Campaigns/DetailViewAjax.php +++ b/oss/vtiger/trunk/modules/Campaigns/DetailViewAjax.php @@ -41,5 +41,7 @@ if($ajaxaction == "DETAILVIEW") { echo ":#:FAILURE"; } +} elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){ + require_once 'include/ListView/RelatedListViewContents.php'; } ?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Campaigns/ListView.php b/oss/vtiger/trunk/modules/Campaigns/ListView.php index c5d65dab..1662c76f 100644 --- a/oss/vtiger/trunk/modules/Campaigns/ListView.php +++ b/oss/vtiger/trunk/modules/Campaigns/ListView.php @@ -58,17 +58,6 @@ $_SESSION['CAMPAIGN_ORDER_BY'] = $order_by; $_SESSION['CAMPAIGN_SORT_ORDER'] = $sorder; //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>> - - -if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') -{ - list($where, $ustring) = split("#@@#",getWhereCondition($currentModule)); - // we have a query - $url_string .="&query=true".$ustring; - $log->info("Here is the where clause for the list view: $where"); - $smarty->assign("SEARCH_URL",$url_string); -} - //<<<>>>>>> $oCustomView = new CustomView("Campaigns"); $viewid = $oCustomView->getViewId($currentModule); @@ -142,22 +131,25 @@ $smarty->assign("SINGLE_MOD",'Campaign'); //Retreive the list from Database //<<<<<<<<>>>>>>>> -if($viewid != "0") -{ - $listquery = getListQuery("Campaigns"); - $list_query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Campaigns"); -} -else -{ - $list_query = getListQuery("Campaigns"); +global $current_user; +$queryGenerator = new QueryGenerator($currentModule, $current_user); +if ($viewid != "0") { + $queryGenerator->initForCustomViewById($viewid); +} else { + $queryGenerator->initForDefaultCustomView(); } //<<<<<<<>>>>>>>> -if(isset($where) && $where != '') -{ - $list_query .= ' and '.$where; +// Enabling Module Search +$url_string = ''; +if($_REQUEST['query'] == 'true') { + $queryGenerator->addUserSearchConditions($_REQUEST); + $ustring = getSearchURL($_REQUEST); + $url_string .= "&query=true$ustring"; + $smarty->assign('SEARCH_URL', $url_string); } +$list_query = $queryGenerator->getQuery(); //sort by "assignedto" and default sort by "ticketid"(DESC) if(isset($order_by) && $order_by != '') { @@ -208,13 +200,13 @@ if( $adb->dbType == "pgsql") else $list_result = $adb->pquery($list_query. " LIMIT $limit_start_rec, $list_max_entries_per_page", array()); -$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec); +$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec,$noofrows); $smarty->assign('recordListRange',$recordListRangeMsg); //mass merge for word templates -- *Raj*17/11 while($row = $adb->fetch_array($list_result)) { - $ids[] = $row["crmid"]; + $ids[] = $row[$focus->table_index]; } if(isset($ids)) { @@ -225,13 +217,16 @@ if(isset($ids)) if($viewid !='') $url_string .="&viewname=".$viewid; -$listview_header = getListViewHeader($focus,"Campaigns",$url_string,$sorder,$order_by,"",$oCustomView); +$controller = new ListViewController($adb, $current_user, $queryGenerator); +$listview_header = $controller->getListViewHeader($focus,$currentModule,$url_string,$sorder, + $order_by); $smarty->assign("LISTHEADER", $listview_header); -$listview_header_search = getSearchListHeaderValues($focus,"Campaigns",$url_string,$sorder,$order_by,"",$oCustomView); +$listview_header_search = $controller->getBasicSearchFieldInfoList(); $smarty->assign("SEARCHLISTHEADER",$listview_header_search); -$listview_entries = getListViewEntries($focus,"Campaigns",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView); +$listview_entries = $controller->getListViewEntries($focus,$currentModule,$list_result, + $navigation_array); $smarty->assign("LISTENTITY", $listview_entries); $smarty->assign("SELECT_SCRIPT", $view_script); @@ -242,7 +237,7 @@ $smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries),";") $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Campaigns","index",$viewid); $alphabetical = AlphabeticalSearch($currentModule,'index','campaignname','true','basic',"","","","",$viewid); -$fieldnames = getAdvSearchfields($module); +$fieldnames = $controller->getAdvancedSearchOptionString(); $criteria = getcriteria_options(); $smarty->assign("CRITERIA", $criteria); $smarty->assign("FIELDNAMES", $fieldnames); @@ -255,6 +250,12 @@ $smarty->assign("CHECK", $check_button); $_SESSION[$currentModule.'_listquery'] = $list_query; +// Gather the custom link information to display +include_once('vtlib/Vtiger/Link.php'); +$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params)); +// END + if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '') $smarty->display("ListViewEntries.tpl"); else diff --git a/oss/vtiger/trunk/modules/Campaigns/LoadList.php b/oss/vtiger/trunk/modules/Campaigns/LoadList.php index 9a18b28c..1c518605 100644 --- a/oss/vtiger/trunk/modules/Campaigns/LoadList.php +++ b/oss/vtiger/trunk/modules/Campaigns/LoadList.php @@ -12,7 +12,7 @@ require_once('modules/CustomView/CustomView.php'); require_once('user_privileges/default_module_view.php'); -global $singlepane_view; +global $singlepane_view, $adb; $cvObj = new CustomView(vtlib_purify($_REQUEST["list_type"])); $listquery = getListQuery(vtlib_purify($_REQUEST["list_type"])); @@ -26,13 +26,19 @@ elseif($_REQUEST["list_type"] == "Contacts"){ $reltable = "vtiger_campaigncontrel"; $relid = "contactid"; } - -while($row=$adb->fetch_array($rs)) { - $sql = "delete from $reltable where $relid = ? and campaignid = ?"; - $adb->pquery($sql, array($row["crmid"], $_REQUEST['return_id'])); - $adb->pquery("INSERT INTO ".$reltable." VALUES(?,?)", array($_REQUEST["return_id"], $row["crmid"])); +elseif($_REQUEST["list_type"] == "Accounts"){ + $reltable = "vtiger_campaignaccountrel"; + $relid = "accountid"; } -header("Location: index.php?module=Campaigns&action=CampaignsAjax&file=CallRelatedList&ajax=true&record=".vtlib_purify($_REQUEST['return_id'])); +while($row=$adb->fetch_array($rs)) { + $sql = "SELECT $relid FROM $reltable WHERE $relid = ? AND campaignid = ?"; + $result = $adb->pquery($sql, array($row['crmid'], $_REQUEST['return_id'])); + if ($adb->num_rows($result) > 0) continue; + $adb->pquery("INSERT INTO $reltable(campaignid, $relid,campaignrelstatusid) VALUES(?,?,1)", array($_REQUEST["return_id"], $row["crmid"])); +} -?> \ No newline at end of file +header("Location: index.php?module=Campaigns&action=CampaignsAjax&file=CallRelatedList&ajax=true&". + "record=".vtlib_purify($_REQUEST['return_id'])); + +?> diff --git a/oss/vtiger/trunk/modules/Campaigns/language/en_us.lang.php b/oss/vtiger/trunk/modules/Campaigns/language/en_us.lang.php index 349b78e9..cbf740b7 100644 --- a/oss/vtiger/trunk/modules/Campaigns/language/en_us.lang.php +++ b/oss/vtiger/trunk/modules/Campaigns/language/en_us.lang.php @@ -84,6 +84,11 @@ $mod_strings = Array( //Module Sequence Numbering 'Campaign No'=>'Campaign No', +// status fields +'--None--'=>'--None--', +'Contacted - Successful' => 'Contacted - Successful', +'Contacted - Unsuccessful' => 'Contacted - Unsuccessful', +'Contacted - Never Contact Again' => 'Contacted - Never Contact Again' // END ); diff --git a/oss/vtiger/trunk/modules/Campaigns/language/zh_cn.lang.php b/oss/vtiger/trunk/modules/Campaigns/language/zh_cn.lang.php index 812fe194..0848f1d1 100644 --- a/oss/vtiger/trunk/modules/Campaigns/language/zh_cn.lang.php +++ b/oss/vtiger/trunk/modules/Campaigns/language/zh_cn.lang.php @@ -21,7 +21,7 @@ *--------------------------------------------- */ $mod_strings=Array( -//Addedinrelease5.0 +// Added in release 5.0 'LBL_CAMPAIGN_INFORMATION'=>'活动信息', 'LBL_CUSTOM_INFORMATION'=>'自订信息', 'LBL_DESCRIPTION_INFORMATION'=>'说明信息', diff --git a/oss/vtiger/trunk/modules/Campaigns/updateRelations.php b/oss/vtiger/trunk/modules/Campaigns/updateRelations.php index 1f9f4cf3..05a805f1 100644 --- a/oss/vtiger/trunk/modules/Campaigns/updateRelations.php +++ b/oss/vtiger/trunk/modules/Campaigns/updateRelations.php @@ -30,6 +30,10 @@ elseif($update_mod == 'Contacts') { $rel_table = 'vtiger_campaigncontrel'; } +elseif($update_mod == 'Accounts') +{ + $rel_table = 'vtiger_campaignaccountrel'; +} $storearray = array(); if(!empty($_REQUEST['idlist'])) { @@ -43,9 +47,9 @@ foreach($storearray as $id) { if($id != '') { - if ($update_mod == 'Leads' || $update_mod == 'Contacts') { - $sql = "insert into $rel_table values(?,?)"; - $adb->pquery($sql, array($forCRMRecord, $id)); + if ($update_mod == 'Leads' || $update_mod == 'Contacts' || $update_mod == 'Accounts') { + $sql = "insert into $rel_table values(?,?,1)"; + $adb->pquery($sql, array($forCRMRecord, $id)); } else { $focus->save_related_module($currentModule, $forCRMRecord, $update_mod, $id); } @@ -54,4 +58,4 @@ foreach($storearray as $id) header("Location: index.php?action=$action&module=$currentModule&record=".$forCRMRecord."&parenttab=".$parenttab); -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/Campaigns/updateRelationsAjax.php b/oss/vtiger/trunk/modules/Campaigns/updateRelationsAjax.php new file mode 100644 index 00000000..02cfc5b7 --- /dev/null +++ b/oss/vtiger/trunk/modules/Campaigns/updateRelationsAjax.php @@ -0,0 +1,52 @@ +pquery($sql, $params)) +{ + echo ":#:SUCCESS"; +} +else +{ + echo ":#:FAILURE"; +} + +exit; + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Contacts/CallRelatedList.php b/oss/vtiger/trunk/modules/Contacts/CallRelatedList.php index 8c8b9ef6..545c1d7a 100644 --- a/oss/vtiger/trunk/modules/Contacts/CallRelatedList.php +++ b/oss/vtiger/trunk/modules/Contacts/CallRelatedList.php @@ -85,6 +85,15 @@ if($singlepane_view == 'true' && $_REQUEST['action'] == 'CallRelatedList') { // END $related_array = getRelatedLists($currentModule,$focus); + require_once('include/ListView/RelatedListViewSession.php'); + if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) { + $relationId = vtlib_purify($_REQUEST['relation_id']); + RelatedListViewSession::addRelatedModuleToSession($relationId, + vtlib_purify($_REQUEST['selected_header'])); + } + $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession(); + $smarty->assign("SELECTEDHEADERS", $open_related_modules); + $smarty->assign("RELATEDLISTS", $related_array); $smarty->assign("MODULE",$currentmodule); $smarty->assign("SINGLE_MOD",$app_strings['Contact']); diff --git a/oss/vtiger/trunk/modules/Contacts/Contacts.php b/oss/vtiger/trunk/modules/Contacts/Contacts.php index 2ef35b2f..1994f6a3 100644 --- a/oss/vtiger/trunk/modules/Contacts/Contacts.php +++ b/oss/vtiger/trunk/modules/Contacts/Contacts.php @@ -110,12 +110,14 @@ class Contacts extends CRMEntity { 'Name' => Array('contactdetails'=>'lastname'), 'Title' => Array('contactdetails'=>'title'), 'Account Name'=>Array('contactdetails'=>'account_id'), + 'Assigned To'=>Array('crmentity'=>'smownerid'), ); var $search_fields_name = Array( 'Name' => 'lastname', 'Title' => 'title', 'Account Name'=>'account_id', + 'Assigned To'=>'assigned_user_id' ); // This is the list of vtiger_fields that are required @@ -489,7 +491,7 @@ class Contacts extends CRMEntity { left join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid - where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task') + where (vtiger_activity.activitytype != 'Emails') and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != '')) and vtiger_cntactivityrel.contactid=".$id." and vtiger_crmentity.deleted = 0"; @@ -956,6 +958,7 @@ class Contacts extends CRMEntity { ON vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_contactdetails vtiger_contactdetails2 ON vtiger_contactdetails2.contactid = vtiger_contactdetails.reportsto"; + $query .= getNonAdminAccessControlQuery('Contacts',$current_user); $where_auto = " vtiger_crmentity.deleted = 0 "; if($where != "") @@ -963,18 +966,7 @@ class Contacts extends CRMEntity { else $query .= " WHERE ".$where_auto; - - - require('user_privileges/user_privileges_'.$current_user->id.'.php'); - require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); - //we should add security check when the user has Private Access - if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[4] == 3) - { - //Added security check to get the permitted records only - $query = $query." ".getListViewSecurityParameter("Contacts"); - } - - $log->info("Export Query Constructed Successfully"); + $log->info("Export Query Constructed Successfully"); $log->debug("Exiting create_export_query method ..."); return $query; } @@ -1008,7 +1000,7 @@ function getColumnNames() for($i=0; $i < $numRows;$i++) { $custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel"); - $custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]); + $custom_fields[$i] = preg_replace("/\s+/","",$custom_fields[$i]); $custom_fields[$i] = strtoupper($custom_fields[$i]); } $mergeflds = $custom_fields; @@ -1043,20 +1035,19 @@ function get_searchbyemailid($username,$emailaddress) inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid - LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid - where vtiger_crmentity.deleted=0"; - if(trim($emailaddress) != '') - $query .= " and ((vtiger_contactdetails.email like '". formatForSqlLike($emailaddress) ."') or vtiger_contactdetails.lastname REGEXP REPLACE('".$emailaddress."',' ','|') or vtiger_contactdetails.firstname REGEXP REPLACE('".$emailaddress."',' ','|')) and vtiger_contactdetails.email != ''"; - else - $query .= " and (vtiger_contactdetails.email like '". formatForSqlLike($emailaddress) ."' and vtiger_contactdetails.email != '')"; - - $tab_id = getTabid("Contacts"); - if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) - { - $sec_parameter=getListViewSecurityParameter("Contacts"); - $query .= $sec_parameter; - + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid"; + $query .= getNonAdminAccessControlQuery('Contacts',$current_user); + $query .= "where vtiger_crmentity.deleted=0"; + if(trim($emailaddress) != '') { + $query .= " and ((vtiger_contactdetails.email like '". formatForSqlLike($emailaddress) . + "') or vtiger_contactdetails.lastname REGEXP REPLACE('".$emailaddress. + "',' ','|') or vtiger_contactdetails.firstname REGEXP REPLACE('".$emailaddress. + "',' ','|')) and vtiger_contactdetails.email != ''"; + } else { + $query .= " and (vtiger_contactdetails.email like '". formatForSqlLike($emailaddress) . + "' and vtiger_contactdetails.email != '')"; } + $log->debug("Exiting get_searchbyemailid method ..."); return $this->plugin_process_list_query($query); } @@ -1118,6 +1109,8 @@ function get_contactsforol($user_name) left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid left join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid + left join vtiger_campaigncontrel on vtiger_contactdetails.contactid = vtiger_campaigncontrel.contactid + left join vtiger_campaignrelstatus on vtiger_campaignrelstatus.campaignrelstatusid = vtiger_campaigncontrel.campaignrelstatusid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 and vtiger_users.user_name='".$user_name."'"; $log->debug("Exiting get_contactsforol method ..."); @@ -1374,7 +1367,6 @@ function get_contactsforol($user_name) } //End - } ?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Contacts/DetailView.php b/oss/vtiger/trunk/modules/Contacts/DetailView.php index 92b25e3d..f7fbf14d 100644 --- a/oss/vtiger/trunk/modules/Contacts/DetailView.php +++ b/oss/vtiger/trunk/modules/Contacts/DetailView.php @@ -158,6 +158,13 @@ if($singlepane_view == 'true') { $related_array = getRelatedLists($currentModule,$focus); $smarty->assign("RELATEDLISTS", $related_array); + require_once('include/ListView/RelatedListViewSession.php'); + if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) { + RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']), + vtlib_purify($_REQUEST['selected_header'])); + } + $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession(); + $smarty->assign("SELECTEDHEADERS", $open_related_modules); } $smarty->assign("TODO_PERMISSION",CheckFieldPermission('parent_id','Calendar')); $smarty->assign("CONTACT_PERMISSION",CheckFieldPermission('contact_id','Calendar')); @@ -175,7 +182,7 @@ $focus->markAsViewed($current_user->id); include_once('vtlib/Vtiger/Link.php'); $customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action'])); -$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW'), $customlink_params)); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params)); $smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true)); diff --git a/oss/vtiger/trunk/modules/Contacts/DetailViewAjax.php b/oss/vtiger/trunk/modules/Contacts/DetailViewAjax.php index fe844e35..684a286f 100644 --- a/oss/vtiger/trunk/modules/Contacts/DetailViewAjax.php +++ b/oss/vtiger/trunk/modules/Contacts/DetailViewAjax.php @@ -14,7 +14,7 @@ global $adb; $local_log =& LoggerManager::getLogger('ContactsAjax'); global $currentModule; -$cntObj = CRMEntity::getInstance($currentModule); +$modObj = CRMEntity::getInstance($currentModule); $ajaxaction = $_REQUEST["ajxaction"]; if($ajaxaction == "DETAILVIEW") @@ -25,19 +25,15 @@ if($ajaxaction == "DETAILVIEW") $fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]); if($crmid != "") { - $cntObj->retrieve_entity_info($crmid,"Contacts"); - $cntObj->column_fields[$fieldname] = $fieldvalue; - $cntObj->id = $crmid; - $cntObj->mode = "edit"; - $cntObj->save("Contacts"); - if($cntObj->column_fields['notify_owner'] == 1 ) - { - sendNotificationToOwner('Contacts',&$cntObj); - } - $email_res = $adb->pquery("select email from vtiger_contactdetails where contactid=?", array($cntObj->id)); + $modObj->retrieve_entity_info($crmid,"Contacts"); + $modObj->column_fields[$fieldname] = $fieldvalue; + $modObj->id = $crmid; + $modObj->mode = "edit"; + $modObj->save("Contacts"); + $email_res = $adb->pquery("select email from vtiger_contactdetails where contactid=?", array($modObj->id)); $email = $adb->query_result($email_res,0,'email'); - $check_available = $adb->pquery("select * from vtiger_portalinfo where id=?", array($cntObj->id)); + $check_available = $adb->pquery("select * from vtiger_portalinfo where id=?", array($modObj->id)); $update = ''; if($fieldname =='email') { @@ -48,7 +44,7 @@ if($ajaxaction == "DETAILVIEW") $sql = "update vtiger_portalinfo set user_name=?,isactive=? where id=?"; $adb->pquery($sql, array($fieldvalue, $active, $crmid)); $email = $fieldvalue; - $result = $adb->pquery("select user_password from vtiger_portalinfo where id=?", array($cntObj->id)); + $result = $adb->pquery("select user_password from vtiger_portalinfo where id=?", array($modObj->id)); $password = $adb->query_result($result,0,'user_password'); $update = true; } @@ -63,7 +59,7 @@ if($ajaxaction == "DETAILVIEW") { $password = makeRandomPassword(); $sql = "insert into vtiger_portalinfo (id,user_name,user_password,type,isactive) values(?,?,?,?,?)"; - $params = array($cntObj->id, $email, $password, 'C', 1); + $params = array($modObj->id, $email, $password, 'C', 1); $adb->pquery($sql, $params); $insert = true; @@ -71,10 +67,10 @@ if($ajaxaction == "DETAILVIEW") elseif($confirm == 0 && $fieldvalue == 1) { $sql = "update vtiger_portalinfo set user_name=?, isactive=1 where id=?"; - $params = array($email, $cntObj->id); + $params = array($email, $modObj->id); $adb->pquery($sql, $params); - $result = $adb->pquery("select user_password from vtiger_portalinfo where id=?", array($cntObj->id)); + $result = $adb->pquery("select user_password from vtiger_portalinfo where id=?", array($modObj->id)); $password = $adb->query_result($result,0,'user_password'); $update = true; @@ -82,22 +78,19 @@ if($ajaxaction == "DETAILVIEW") elseif($confirm == 1 && $fieldvalue == 0) { $sql = "update vtiger_portalinfo set isactive=0 where id=?"; - $adb->pquery($sql, array($cntObj->id)); + $adb->pquery($sql, array($modObj->id)); } } } require_once("modules/Emails/mail.php"); global $current_user; $data_array = Array(); - $data_array['first_name'] = $cntObj->column_fields['firstname']; - $data_array['last_name'] = $cntObj->column_fields['lastname']; + $data_array['first_name'] = $modObj->column_fields['firstname']; + $data_array['last_name'] = $modObj->column_fields['lastname']; $data_array['email'] = $email; $data_array['portal_url'] = "".$mod_strings['Please Login Here'].""; $contents = getmail_contents_portalUser($data_array,$password); - if($insert == true || $update == true) - send_mail('Contacts',$cntObj->column_fields['email'],$current_user->user_name,'',$mod_strings['Customer Portal Login Details'],$contents); - - if($cntObj->id != "") + if($modObj->id != "") { echo ":#:SUCCESS"; }else @@ -108,5 +101,7 @@ if($ajaxaction == "DETAILVIEW") { echo ":#:FAILURE"; } +} elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){ + require_once 'include/ListView/RelatedListViewContents.php'; } -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/Contacts/ListView.php b/oss/vtiger/trunk/modules/Contacts/ListView.php index ca3c3715..a888d953 100644 --- a/oss/vtiger/trunk/modules/Contacts/ListView.php +++ b/oss/vtiger/trunk/modules/Contacts/ListView.php @@ -68,19 +68,6 @@ $_SESSION['CONTACTS_ORDER_BY'] = $order_by; $_SESSION['CONTACTS_SORT_ORDER'] = $sorder; //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>> -if (!isset($where)) $where = ""; - -$url_string = ''; // assigning http url string - -if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') -{ - list($where, $ustring) = split("#@@#",getWhereCondition($currentModule)); - // we have a query - $url_string .="&query=true".$ustring; - $log->info("Here is the where clause for the list view: $where"); - $smarty->assign("SEARCH_URL",$url_string); -} - //<<<>>>>>> $oCustomView = new CustomView("Contacts"); $viewid = $oCustomView->getViewId($currentModule); @@ -149,24 +136,33 @@ if($viewnamedesc['viewname'] == 'All') //Retreive the list from Database //<<<<<<<<>>>>>>>> -if($viewid != "0") -{ - $listquery = getListQuery("Contacts"); - $list_query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Contacts"); -}else -{ - $list_query = getListQuery("Contacts"); +global $current_user; +$queryGenerator = new QueryGenerator($currentModule, $current_user); +if ($viewid != "0") { + $queryGenerator->initForCustomViewById($viewid); +} else { + $queryGenerator->initForDefaultCustomView(); } //<<<<<<<>>>>>>>> -if(isset($where) && $where != '') -{ - $list_query .= " AND ".$where; - $_SESSION['export_where'] = $where; -} -else - unset($_SESSION['export_where']); +if (!isset($where)) $where = ""; +$url_string = ''; // assigning http url string +if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') { + $queryGenerator->addUserSearchConditions($_REQUEST); + $ustring = getSearchURL($_REQUEST); + // we have a query + $url_string .="&query=true".$ustring; + $smarty->assign("SEARCH_URL",$url_string); + +} +$list_query = $queryGenerator->getQuery(); +$where = $queryGenerator->getConditionalWhere(); +if(isset($where) && $where != '') { + $_SESSION['export_where'] = $where; +} else { + unset($_SESSION['export_where']); +} if(isset($order_by) && $order_by != '') { @@ -222,13 +218,13 @@ if( $adb->dbType == "pgsql") else $list_result = $adb->pquery($list_query. " LIMIT $limit_start_rec, $list_max_entries_per_page", array()); -$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec); +$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec,$noofrows); $smarty->assign('recordListRange',$recordListRangeMsg); //mass merge for word templates -- *Raj*17/11 while($row = $adb->fetch_array($list_result)) { - $ids[] = $row["crmid"]; + $ids[] = $row[$focus->table_index]; } if(isset($ids)) { @@ -252,8 +248,7 @@ if(isPermitted("Contacts","Merge") == 'yes') } else { - global $current_user; - require("user_privileges/user_privileges_".$current_user->id.".php"); + require("user_privileges/user_privileges_".$current_user->id.".php"); if($is_admin == true) { $smarty->assign("MERGEBUTTON","
". $app_strings['LBL_CREATE_MERGE_TEMPLATE']."
- vtiger_customerportal_tabs - -
vtiger_customerportal_fields -
- - vtiger_customerportal_prefs - -
- - vtiger_customerportal_prefs - + `tabid` int(19) NOT NULL, + `fieldid` int(19) default NULL, + `visible` int(1) default NULL + ) ENGINE=InnoDB DEFAULT CHARSET=utf8]]>
diff --git a/oss/vtiger/trunk/modules/Dashboard/Entity_charts.php b/oss/vtiger/trunk/modules/Dashboard/Entity_charts.php index b8f47c51..faff1768 100644 --- a/oss/vtiger/trunk/modules/Dashboard/Entity_charts.php +++ b/oss/vtiger/trunk/modules/Dashboard/Entity_charts.php @@ -354,7 +354,7 @@ function module_Chart($user_id,$date_start="2000-01-01",$end_date="2017-01-01",$ } if($graph_for =="smownerid") { - $name_val=get_assigned_user_name($mod_name); + $name_val=getOwnerName($mod_name); if($name_val!="") { $mod_name=$name_val; @@ -421,24 +421,30 @@ function module_Chart($user_id,$date_start="2000-01-01",$end_date="2017-01-01",$ $search_str=$name_val; } } - if($graph_for =="contactid") + if($graph_for =="parent_id" || $graph_for =="related_to") { - $query = "SELECT contact_no, lastname, firstname FROM vtiger_contactdetails WHERE contactid=?"; - $result = $adb->pquery($query, array($mod_name)); - $name_val = $adb->query_result($result,0,"lastname"); - if($name_val!="") - { - if(getFieldVisibilityPermission('Contacts', $current_user->id,'firstname') == '0') - { - $first_name = ''; - $first_name = $adb->query_result($result,0,"firstname"); - if($first_name != '') - $name_val .= " ".$first_name; + $seType = getSalesEntityType($mod_name); + if($seType == 'Contacts') { + $query = "SELECT lastname, firstname FROM vtiger_contactdetails + WHERE contactid=?"; + $result = $adb->pquery($query, array($mod_name)); + $name_val = $adb->query_result($result,0,"lastname"); + if($name_val!="") { + if(getFieldVisibilityPermission('Contacts', $current_user->id, + 'firstname') == '0') { + $first_name = $adb->query_result($result,0,"firstname"); + if($first_name != '') { + $name_val .= " ".$first_name; + } + } } - - $mod_name=$name_val; - $search_str=$adb->query_result($result, 0, "contact_no"); - } + } else { + $query = "SELECT accountname FROM vtiger_account WHERE accountid=?"; + $result = $adb->pquery($query, array($mod_name)); + $name_val = $adb->query_result($result,0,"accountname"); + } + $mod_name=$name_val; + $search_str=$name_val; } //Passing name to graph $mod_name = str_replace(":", ":", $mod_name); @@ -458,9 +464,17 @@ function module_Chart($user_id,$date_start="2000-01-01",$end_date="2017-01-01",$ } //added to get valid url in dashbord for tickets by team - if($graph_for == "ticketgroupname" || $graph_for == "groupname") $graph_for = "smownerid"; - - if($graph_for == "accountid") $graph_for = "account_id"; + if($graph_for == "smownerid"){ + $searchField = "assigned_user_id"; + } elseif($graph_for == 'category') { + $searchField = 'ticketcategories'; + } elseif($graph_for == 'priority') { + $searchField = 'ticketpriorities'; + } elseif($graph_for == "accountid") { + $searchField = "account_id"; + } else{ + $searchField = $graph_for; + } $cvid = getCvIdOfAll($module); if($module == "Home") { @@ -468,15 +482,13 @@ function module_Chart($user_id,$date_start="2000-01-01",$end_date="2017-01-01",$ $link_val="index.php?module=".$mod_name."&action=ListView&from_homepagedb=true&type=dbrd&query=true&owner=".$current_user->user_name."&viewname=".$cvid; } else if($module == "Contacts" || ($module=="Products" && ($graph_for == "quoteid" || $graph_for == "invoiceid" || $graph_for == "purchaseorderid"))) - $link_val="index.php?module=".$module."&action=ListView&from_dashboard=true&type=dbrd&query=true&".$graph_for."=".$id_name."&viewname=".$cvid; + $link_val="index.php?module=".$module."&action=ListView&from_dashboard=true&type=dbrd&query=true&".$searchField."=".$id_name."&viewname=".$cvid; else { $esc_search_str = urlencode($search_str); //$esc_search_str = htmlentities($search_str, ENT_QUOTES, $default_charset); - $link_val="index.php?module=".$module."&action=index&from_dashboard=true&search_text=".$esc_search_str."&search_field=".$graph_for."&searchtype=BasicSearch&query=true&type=entchar&viewname=".$cvid; + $link_val="index.php?module=".$module."&action=index&from_dashboard=true&search_text=".$esc_search_str."&search_field=".$searchField."&searchtype=BasicSearch&query=true&type=entchar&operator=e&viewname=".$cvid; } - if($graph_for == "account_id") $graph_for = "accountid"; - //Adding the links to the graph $link_val = str_replace(':', ':', $link_val); if($i==0) diff --git a/oss/vtiger/trunk/modules/Dashboard/display_charts.php b/oss/vtiger/trunk/modules/Dashboard/display_charts.php index 74f94aab..c2a2b1b3 100644 --- a/oss/vtiger/trunk/modules/Dashboard/display_charts.php +++ b/oss/vtiger/trunk/modules/Dashboard/display_charts.php @@ -76,7 +76,8 @@ $helpdesk_query=" select vtiger_troubletickets.status AS ticketstatus, vtiger_gr //Query for Contacts by Campaign -$cont_Q = "select crmid from vtiger_contactdetails inner join vtiger_campaigncontrel on vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_crmentity.deleted=0 ".dashboard_check("Contacts"); +$contByCampaign = "select crmid from vtiger_contactdetails inner join vtiger_campaigncontrel on vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_crmentity.deleted=0 "; +$cont_Q = getDashboardQuery($contByCampaign,"Contacts"); $result = $adb->pquery($cont_Q, array()); $num_conts = $adb->num_rows($result); @@ -146,7 +147,7 @@ $graph_array = Array( $graph_title= $mod_strings['leadsource']; $module="Leads"; $where=""; - $query=$leads_query." ".dashboard_check($module); + $query=getDashboardQuery($leads_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } @@ -157,7 +158,7 @@ $graph_array = Array( $graph_title= $mod_strings['leadstatus']; $module="Leads"; $where=""; - $query=$leads_query." ".dashboard_check($module); + $query=getDashboardQuery($leads_query,$module); if(!$is_admin) $query .= ' and vtiger_leaddetails.leadsource '.picklist_check($module,$graph_by); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); @@ -169,7 +170,7 @@ $graph_array = Array( $graph_title=$mod_strings['leadindustry']; $module="Leads"; $where=""; - $query=$leads_query." ".dashboard_check($module); + $query=getDashboardQuery($leads_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Sales by Lead Source @@ -179,38 +180,38 @@ $graph_array = Array( $graph_title=$mod_strings['salesbyleadsource']; $module="Potentials"; $where=" and vtiger_potential.sales_stage like '%Closed Won%' "; - $query=$potential_query." ".dashboard_check($module); + $query=getDashboardQuery($potential_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Sales by Account - elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyaccount") && (getFieldVisibilityPermission('Potentials',$user_id,'account_id') == "0")) + elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyaccount") && (getFieldVisibilityPermission('Potentials',$user_id,'related_to') == "0")) { - $graph_by="accountid"; + $graph_by="related_to"; $graph_title=$mod_strings['salesbyaccount']; $module="Potentials"; $where=" and vtiger_potential.sales_stage like '%Closed Won%' "; - $query=$potential_query." ".dashboard_check($module); + $query=getDashboardQuery($potential_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Sales by User elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyuser")) { - $graph_by="smownerid"; - $graph_title=$mod_strings['salesbyuser']; - $module="Potentials"; - $where=" and vtiger_potential.sales_stage like '%Closed Won%' and (vtiger_crmentity.smownerid != NULL || vtiger_crmentity.smownerid != ' ')"; - $query=$potential_query." ".dashboard_check($module); - return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); + $graph_by="smownerid"; + $graph_title=$mod_strings['salesbyuser']; + $module="Potentials"; + $where=" and vtiger_potential.sales_stage like '%Closed Won%' and (vtiger_groups.groupname is NULL)"; + $query=getDashboardQuery($potential_query,$module); + return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Sales by team elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyteam")) { - $graph_by="groupname"; - $graph_title=$mod_strings['salesbyteam']; - $module="Potentials"; - $where=" and vtiger_potential.sales_stage like '%Closed Won%' and (vtiger_groups.groupname != NULL || vtiger_groups.groupname != '')"; - $query=$potential_query." ".dashboard_check($module); - return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); + $graph_by="smownerid"; + $graph_title=$mod_strings['salesbyteam']; + $module="Potentials"; + $where=" and vtiger_potential.sales_stage like '%Closed Won%' and (vtiger_groups.groupname != NULL || vtiger_groups.groupname != '')"; + $query=getDashboardQuery($potential_query,$module); + return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Charts for Account by Industry elseif ($profileTabsPermission[getTabid("Accounts")] == 0 && ($type == "accountindustry") && (getFieldVisibilityPermission('Accounts',$user_id,'industry') == "0")) @@ -219,7 +220,7 @@ $graph_array = Array( $graph_title=$mod_strings['accountindustry']; $module="Accounts"; $where=""; - $query=$account_query." ".dashboard_check($module); + $query=getDashboardQuery($account_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Charts for Products by Category @@ -229,7 +230,7 @@ $graph_array = Array( $graph_title=$mod_strings['productcategory']; $module="Products"; $where=""; - $query=$product_category." ".dashboard_check($module); + $query=getDashboardQuery($product_category, $module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Charts for Products by Quantity in stock @@ -239,7 +240,7 @@ $graph_array = Array( $graph_title=$mod_strings['productbyqtyinstock']; $module="Products"; $where=""; - $query=$products_query." ".dashboard_check($module); + $query=getDashboardQuery($products_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Charts for Products by PO @@ -249,7 +250,7 @@ $graph_array = Array( $graph_title=$mod_strings['productbypo']; $module="Products"; $where=""; - $query=$probyPO." ".dashboard_check($module); + $query=getDashboardQuery($probyPO,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Charts for Products by Quotes @@ -259,7 +260,7 @@ $graph_array = Array( $graph_title=$mod_strings['productbyquotes']; $module="Products"; $where=""; - $query=$probyQ." ".dashboard_check($module); + $query=getDashboardQuery($probyQ, $module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Charts for Products by Invoice @@ -269,7 +270,7 @@ $graph_array = Array( $graph_title=$mod_strings['productbyinvoice']; $module="Products"; $where=""; - $query=$probyInv." ".dashboard_check($module); + $query=getDashboardQuery($probyInv, $module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } @@ -280,7 +281,7 @@ $graph_array = Array( $graph_title=$mod_strings['sobyaccounts']; $module="SalesOrder"; $where=""; - $query=$so_query." ".dashboard_check($module); + $query=getDashboardQuery($so_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Sales Order by Status @@ -290,7 +291,7 @@ $graph_array = Array( $graph_title=$mod_strings['sobystatus']; $module="SalesOrder"; $where=""; - $query=$so_query." ".dashboard_check($module); + $query=getDashboardQuery($so_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Purchase Order by Status @@ -300,7 +301,7 @@ $graph_array = Array( $graph_title=$mod_strings['pobystatus']; $module="PurchaseOrder"; $where=""; - $query=$po_query." ".dashboard_check($module); + $query=getDashboardQuery($po_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Quotes by Accounts @@ -310,7 +311,7 @@ $graph_array = Array( $graph_title= $mod_strings['quotesbyaccounts']; $module="Quotes"; $where=""; - $query=$quotes_query." ".dashboard_check($module); + $query=getDashboardQuery($quotes_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Quotes by Stage @@ -320,7 +321,7 @@ $graph_array = Array( $graph_title=$mod_strings['quotesbystage']; $module="Quotes"; $where=""; - $query=$quotes_query." ".dashboard_check($module); + $query=getDashboardQuery($quotes_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Invoice by Accounts @@ -330,7 +331,7 @@ $graph_array = Array( $graph_title=$mod_strings['invoicebyacnts']; $module="Invoice"; $where=""; - $query=$invoice_query." ".dashboard_check($module); + $query=getDashboardQuery($invoice_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Invoices by status @@ -340,7 +341,7 @@ $graph_array = Array( $graph_title=$mod_strings['invoicebystatus']; $module="Invoice"; $where=""; - $query=$invoice_query." ".dashboard_check($module); + $query=getDashboardQuery($invoice_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Tickets by Status @@ -350,7 +351,7 @@ $graph_array = Array( $graph_title=$mod_strings['ticketsbystatus']; $module="HelpDesk"; $where=""; - $query=$helpdesk_query." ".dashboard_check($module); + $query=getDashboardQuery($helpdesk_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Tickets by Priority @@ -360,7 +361,7 @@ $graph_array = Array( $graph_title=$mod_strings['ticketsbypriority']; $module="HelpDesk"; $where=""; - $query=$helpdesk_query." ".dashboard_check($module); + $query=getDashboardQuery($helpdesk_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Tickets by Category @@ -370,7 +371,7 @@ $graph_array = Array( $graph_title=$mod_strings['ticketsbycategory']; $module="HelpDesk"; $where=""; - $query=$helpdesk_query." ".dashboard_check($module); + $query=getDashboardQuery($helpdesk_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Tickets by User @@ -379,18 +380,18 @@ $graph_array = Array( $graph_by="smownerid"; $graph_title=$mod_strings['ticketsbyuser']; $module="HelpDesk"; - $where=" and (vtiger_crmentity.smownerid != NULL || vtiger_crmentity.smownerid != ' ')"; - $query=$helpdesk_query." ".dashboard_check($module); + $where=" and (vtiger_groups.groupname is NULL)"; + $query=getDashboardQuery($helpdesk_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Tickets by Team elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyteam")) { - $graph_by="ticketgroupname"; + $graph_by="smownerid"; $graph_title=$mod_strings['ticketsbyteam']; $module="HelpDesk"; $where=" and (vtiger_groups.groupname != NULL || vtiger_groups.groupname != ' ')"; - $query=$helpdesk_query." ".dashboard_check($module); + $query=getDashboardQuery($helpdesk_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Tickets by Product @@ -400,7 +401,7 @@ $graph_array = Array( $graph_title=$mod_strings['ticketsbyproduct']; $module="HelpDesk"; $where=""; - $query=$helpdesk_query." ".dashboard_check($module); + $query=getDashboardQuery($helpdesk_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Campaigns by Contact @@ -410,27 +411,27 @@ $graph_array = Array( $graph_title=$mod_strings['contactbycampaign']; $module="Contacts"; $where=""; - $query=$campaign_query." ".dashboard_check($module); + $query=getDashboardQuery($campaign_query,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Tickets by Account elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyaccount") && (getFieldVisibilityPermission('HelpDesk',$user_id,'parent_id') == "0")) { - $graph_by="accountid"; + $graph_by="parent_id"; $graph_title=$mod_strings['ticketsbyaccount']; $module="HelpDesk"; $where=""; - $query=$tickets_by_account." ".dashboard_check($module); + $query=getDashboardQuery($tickets_by_account,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } //Tickets by Contact elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbycontact") && (getFieldVisibilityPermission('HelpDesk',$user_id,'parent_id') == "0")) { - $graph_by="contactid"; + $graph_by="parent_id"; $graph_title=$mod_strings['ticketsbycontact']; $module="HelpDesk"; $where=""; - $query=$tickets_by_contact." ".dashboard_check($module); + $query=getDashboardQuery($tickets_by_contact,$module); return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage"); } else @@ -450,7 +451,7 @@ $graph_array = Array( $graph_title= $mod_strings['leadsource']; $module="Leads"; $where=""; - $query=$leads_query." ".dashboard_check($module); + $query=getDashboardQuery($leads_query,$module); //$html .= get_graph_by_type($graph_by,$graph_title,$module,$where,$query); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } @@ -461,7 +462,7 @@ $graph_array = Array( $graph_title= $mod_strings['leadstatus']; $module="Leads"; $where=""; - $query=$leads_query." ".dashboard_check($module); + $query=getDashboardQuery($leads_query,$module); if(!$is_admin) $query .= ' and vtiger_leaddetails.leadstatus '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -473,7 +474,7 @@ $graph_array = Array( $graph_title=$mod_strings['leadindustry']; $module="Leads"; $where=""; - $query=$leads_query." ".dashboard_check($module); + $query=getDashboardQuery($leads_query,$module); if(!$is_admin) $query .= ' and vtiger_leaddetails.industry '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -485,19 +486,19 @@ $graph_array = Array( $graph_title=$mod_strings['salesbyleadsource']; $module="Potentials"; $where=" and vtiger_potential.sales_stage like 'Closed Won' "; - $query=$potential_query." ".dashboard_check($module); + $query=getDashboardQuery($potential_query,$module); if(!$is_admin) $query .= ' and vtiger_potential.leadsource '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Sales by Account - elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyaccount") && (getFieldVisibilityPermission('Potentials',$user_id,'account_id') == "0")) + elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyaccount") && (getFieldVisibilityPermission('Potentials',$user_id,'related_to') == "0")) { - $graph_by="accountid"; + $graph_by="related_to"; $graph_title=$mod_strings['salesbyaccount']; $module="Potentials"; $where=" and vtiger_potential.sales_stage like 'Closed Won' "; - $query=$potential_query." ".dashboard_check($module); + $query=getDashboardQuery($potential_query,$module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Sales by User @@ -506,18 +507,18 @@ $graph_array = Array( $graph_by="smownerid"; $graph_title=$mod_strings['salesbyuser']; $module="Potentials"; - $where=" and vtiger_potential.sales_stage like 'Closed Won' and (vtiger_crmentity.smownerid != NULL || vtiger_crmentity.smownerid != ' ')"; - $query=$potential_query." ".dashboard_check($module); + $where=" and vtiger_potential.sales_stage like 'Closed Won' and (vtiger_groups.groupname is NULL)"; + $query=getDashboardQuery($potential_query,$module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Sales by team elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyteam")) { - $graph_by="groupname"; + $graph_by="smownerid"; $graph_title=$mod_strings['salesbyteam']; $module="Potentials"; $where=" and vtiger_potential.sales_stage like 'Closed Won' and (vtiger_groups.groupname != NULL || vtiger_groups.groupname != '')"; - $query=$potential_query." ".dashboard_check($module); + $query=getDashboardQuery($potential_query,$module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Charts for Account by Industry @@ -527,7 +528,7 @@ $graph_array = Array( $graph_title=$mod_strings['accountindustry']; $module="Accounts"; $where=""; - $query=$account_query." ".dashboard_check($module); + $query=getDashboardQuery($account_query,$module); if(!$is_admin) $query .= ' and vtiger_account.industry '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -539,7 +540,7 @@ $graph_array = Array( $graph_title=$mod_strings['productcategory']; $module="Products"; $where=""; - $query=$product_category." ".dashboard_check($module); + $query=getDashboardQuery($product_category,$module); if(!$is_admin) $query .= ' and vtiger_products.productcategory '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -551,7 +552,7 @@ $graph_array = Array( $graph_title=$mod_strings['productbyqtyinstock']; $module="Products"; $where=""; - $query=$products_query." ".dashboard_check($module); + $query=getDashboardQuery($products_query,$module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Charts for Products by PO @@ -561,7 +562,7 @@ $graph_array = Array( $graph_title=$mod_strings['productbypo']; $module="Products"; $where=""; - $query=$probyPO." ".dashboard_check("PurchaseOrder"); + $query=getDashboardQuery($probyPO,"PurchaseOrder"); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Charts for Products by Quotes @@ -571,7 +572,7 @@ $graph_array = Array( $graph_title=$mod_strings['productbyquotes']; $module="Products"; $where=""; - $query=$probyQ." ".dashboard_check("Quotes"); + $query=getDashboardQuery($probyQ,"Quotes"); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Charts for Products by Invoice @@ -581,7 +582,7 @@ $graph_array = Array( $graph_title=$mod_strings['productbyinvoice']; $module="Products"; $where=""; - $query=$probyInv." ".dashboard_check("Invoice"); + $query=getDashboardQuery($probyInv,"Invoice"); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } @@ -592,7 +593,7 @@ $graph_array = Array( $graph_title=$mod_strings['sobyaccounts']; $module="SalesOrder"; $where=""; - $query=$so_query." ".dashboard_check($module); + $query=getDashboardQuery($so_query,$module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Sales Order by Status @@ -602,7 +603,7 @@ $graph_array = Array( $graph_title=$mod_strings['sobystatus']; $module="SalesOrder"; $where=""; - $query=$so_query." ".dashboard_check($module); + $query=getDashboardQuery($so_query,$module); if(!$is_admin) $query .= ' and vtiger_salesorder.sostatus '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -614,7 +615,7 @@ $graph_array = Array( $graph_title=$mod_strings['pobystatus']; $module="PurchaseOrder"; $where=""; - $query=$po_query." ".dashboard_check($module); + $query=getDashboardQuery($po_query,$module); if(!$is_admin) $query .= ' and vtiger_purchaseorder.postatus '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -626,7 +627,7 @@ $graph_array = Array( $graph_title= $mod_strings['quotesbyaccounts']; $module="Quotes"; $where=""; - $query=$quotes_query." ".dashboard_check($module); + $query=getDashboardQuery($quotes_query,$module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Quotes by Stage @@ -636,7 +637,7 @@ $graph_array = Array( $graph_title=$mod_strings['quotesbystage']; $module="Quotes"; $where=""; - $query=$quotes_query." ".dashboard_check($module); + $query=getDashboardQuery($quotes_query,$module); if(!$is_admin) $query .= ' and vtiger_quotes.quotestage '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -648,7 +649,7 @@ $graph_array = Array( $graph_title=$mod_strings['invoicebyacnts']; $module="Invoice"; $where=""; - $query=$invoice_query." ".dashboard_check($module); + $query=getDashboardQuery($invoice_query,$module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Invoices by status @@ -658,7 +659,7 @@ $graph_array = Array( $graph_title=$mod_strings['invoicebystatus']; $module="Invoice"; $where=""; - $query=$invoice_query." ".dashboard_check($module); + $query=getDashboardQuery($invoice_query,$module); if(!$is_admin) $query .= ' and vtiger_invoice.invoicestatus '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -670,7 +671,7 @@ $graph_array = Array( $graph_title=$mod_strings['ticketsbystatus']; $module="HelpDesk"; $where=""; - $query=$helpdesk_query." ".dashboard_check($module); + $query=getDashboardQuery($helpdesk_query,$module); if(!$is_admin) $query .= ' and vtiger_troubletickets.status '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -682,7 +683,7 @@ $graph_array = Array( $graph_title=$mod_strings['ticketsbypriority']; $module="HelpDesk"; $where=""; - $query=$helpdesk_query." ".dashboard_check($module); + $query=getDashboardQuery($helpdesk_query,$module); if(!$is_admin) $query .= ' and vtiger_troubletickets.priority '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -694,7 +695,7 @@ $graph_array = Array( $graph_title=$mod_strings['ticketsbycategory']; $module="HelpDesk"; $where=""; - $query=$helpdesk_query." ".dashboard_check($module); + $query=getDashboardQuery($helpdesk_query,$module); if(!$is_admin) $query .= ' and vtiger_troubletickets.category '.picklist_check($module,$graph_by); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); @@ -705,18 +706,18 @@ $graph_array = Array( $graph_by="smownerid"; $graph_title=$mod_strings['ticketsbyuser']; $module="HelpDesk"; - $where=" and (vtiger_crmentity.smownerid != NULL || vtiger_crmentity.smownerid != ' ')"; - $query=$helpdesk_query." ".dashboard_check($module); + $where=" and (vtiger_groups.groupname is NULL)"; + $query=getDashboardQuery($helpdesk_query,$module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Tickets by Team elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyteam")) { - $graph_by="ticketgroupname"; + $graph_by="smownerid"; $graph_title=$mod_strings['ticketsbyteam']; $module="HelpDesk"; $where=" and (vtiger_groups.groupname != NULL || vtiger_groups.groupname != ' ')"; - $query=$helpdesk_query." ".dashboard_check($module); + $query=getDashboardQuery($helpdesk_query,$module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Tickets by Product @@ -726,7 +727,7 @@ $graph_array = Array( $graph_title=$mod_strings['ticketsbyproduct']; $module="HelpDesk"; $where=""; - $query=$helpdesk_query." ".dashboard_check($module); + $query=getDashboardQuery($helpdesk_query,$module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Campaigns by Contact @@ -736,27 +737,27 @@ $graph_array = Array( $graph_title=$mod_strings['contactbycampaign']; $module="Contacts"; $where=""; - $query=$campaign_query." ".dashboard_check("Campaigns"); + $query=getDashboardQuery($campaign_query,"Campaigns"); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Tickets by Account elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyaccount") && (getFieldVisibilityPermission('HelpDesk',$user_id,'parent_id') == "0")) { - $graph_by="accountid"; + $graph_by="parent_id"; $graph_title=$mod_strings['ticketsbyaccount']; $module="HelpDesk"; $where=""; - $query=$tickets_by_account." ".dashboard_check($module); + $query=getDashboardQuery($tickets_by_account, $module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } //Tickets by Contact elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbycontact") && (getFieldVisibilityPermission('HelpDesk',$user_id,'parent_id') == "0")) { - $graph_by="contactid"; + $graph_by="parent_id"; $graph_title=$mod_strings['ticketsbycontact']; $module="HelpDesk"; $where=""; - $query=$tickets_by_contact." ".dashboard_check($module); + $query=getDashboardQuery($tickets_by_contact, $module); echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query); } else @@ -773,18 +774,13 @@ $graph_array = Array( *Returns an string value */ -function dashboard_check($module) -{ +function getDashboardQuery($query, $module) { global $current_user; - $sec_parameter = ''; - $tab_id = getTabid($module); - require('user_privileges/user_privileges_'.$current_user->id.'.php'); - require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); - if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) - { - $sec_parameter=getListViewSecurityParameter($module); + $secQuery = getNonAdminAccessControlQuery($module, $current_user); + if(strlen($secQuery) > 1) { + $query = appendFromClauseToQuery($query, $secQuery); } - return $sec_parameter; + return $query; } /**This function generates the security parameters for a given user base picklist values diff --git a/oss/vtiger/trunk/modules/Dashboard/homestuff.php b/oss/vtiger/trunk/modules/Dashboard/homestuff.php index a48637d4..8a8ff3e9 100644 --- a/oss/vtiger/trunk/modules/Dashboard/homestuff.php +++ b/oss/vtiger/trunk/modules/Dashboard/homestuff.php @@ -87,4 +87,4 @@ function dashboardDisplayCall($type,$Chart_Type,$from_page) } } -?> +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Dashboard/horizontal_bargraph.php b/oss/vtiger/trunk/modules/Dashboard/horizontal_bargraph.php index 2fd4ded0..14ba624f 100644 --- a/oss/vtiger/trunk/modules/Dashboard/horizontal_bargraph.php +++ b/oss/vtiger/trunk/modules/Dashboard/horizontal_bargraph.php @@ -117,8 +117,6 @@ function horizontal_graph($referdata,$refer_code,$width,$height,$left,$right,$to $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white')); elseif($theme == 'softed') $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white')); - elseif($theme == 'hawebs') - $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white')); else $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'black', 'white')); diff --git a/oss/vtiger/trunk/modules/Dashboard/vertical_bargraph.php b/oss/vtiger/trunk/modules/Dashboard/vertical_bargraph.php index 305c4c12..f854174c 100644 --- a/oss/vtiger/trunk/modules/Dashboard/vertical_bargraph.php +++ b/oss/vtiger/trunk/modules/Dashboard/vertical_bargraph.php @@ -43,7 +43,7 @@ function vertical_graph($referdata,$refer_code,$width,$height,$left,$right,$top, else $name=$datax[$i]; $pos = substr_count($name," "); - $alts[]=htmlentities($name,ENT_QUOTES,'UTF-8')."=%d"; + $alts[]=htmlentities($name)."=%d"; //If the datax value of a string is greater, adding '\n' to it so that it'll cme inh 2nd line if(strlen($name)>=15) $name=substr($name, 0, 15); @@ -117,8 +117,6 @@ function vertical_graph($referdata,$refer_code,$width,$height,$left,$right,$top, $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, 'blue', 'white')); elseif($theme == 'softed') $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, 'blue', 'white')); - elseif($theme == 'hawebs') - $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white')); else $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, 'black', 'white')); diff --git a/oss/vtiger/trunk/modules/Documents/DetailView.php b/oss/vtiger/trunk/modules/Documents/DetailView.php index 33814eac..319910f0 100644 --- a/oss/vtiger/trunk/modules/Documents/DetailView.php +++ b/oss/vtiger/trunk/modules/Documents/DetailView.php @@ -85,7 +85,7 @@ foreach($allblocks as $blocks) { foreach($blocks as $block_entries) { - if($block_entries['File Name']['value'] != '' || isset($block_entries['File Name']['value'])) + if(!empty($block_entries[getTranslatedString('File Name',$currentModule)]['value'])) $flag = 1; } } @@ -168,6 +168,12 @@ if(PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($ $focus->markAsViewed($current_user->id); // END +// Gather the custom link information to display +include_once('vtlib/Vtiger/Link.php'); +$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action'])); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params)); +// END + $smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true)); $smarty->display("DetailView.tpl"); diff --git a/oss/vtiger/trunk/modules/Documents/DetailViewAjax.php b/oss/vtiger/trunk/modules/Documents/DetailViewAjax.php index d9e93b58..7e9f41d7 100644 --- a/oss/vtiger/trunk/modules/Documents/DetailViewAjax.php +++ b/oss/vtiger/trunk/modules/Documents/DetailViewAjax.php @@ -41,5 +41,7 @@ if($ajaxaction == "DETAILVIEW") { echo ":#:FAILURE"; } +} elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){ + require_once 'include/ListView/RelatedListViewContents.php'; } ?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Documents/Documents.php b/oss/vtiger/trunk/modules/Documents/Documents.php index 024e294a..0a5fd08b 100644 --- a/oss/vtiger/trunk/modules/Documents/Documents.php +++ b/oss/vtiger/trunk/modules/Documents/Documents.php @@ -233,24 +233,13 @@ class Documents extends CRMEntity { LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id " . " LEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid=vtiger_groups.groupid " ; - - $where_auto=" vtiger_crmentity.deleted=0"; - if($where != "") - $query .= " WHERE ($where) AND ".$where_auto; - else - $query .= " WHERE ".$where_auto; + $query .= getNonAdminAccessControlQuery('Documents',$current_user); + $where_auto=" vtiger_crmentity.deleted=0"; + if($where != "") + $query .= " WHERE ($where) AND ".$where_auto; + else + $query .= " WHERE ".$where_auto; - require('user_privileges/user_privileges_'.$current_user->id.'.php'); - require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); - //we should add security check when the user has Private Access - $tabid = getTabid("Documents"); - if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tabid] == 3) - { - //Added security check to get the permitted records only - $query = $query." ".getListViewSecurityParameter("Documents"); - } - - $log->debug("Exiting create_export_query method ..."); return $query; } diff --git a/oss/vtiger/trunk/modules/Documents/EditView.php b/oss/vtiger/trunk/modules/Documents/EditView.php index b483e3ef..72451f2a 100644 --- a/oss/vtiger/trunk/modules/Documents/EditView.php +++ b/oss/vtiger/trunk/modules/Documents/EditView.php @@ -119,10 +119,11 @@ $smarty->assign("MOD", $mod_strings); $smarty->assign("APP", $app_strings); $smarty->assign("MODULE",$currentModule); $smarty->assign("SINGLE_MOD",'Document'); -//Display the FCKEditor or not? -- configure $FCKEDITOR_DISPLAY in config.php +//Display the RTE or not? -- configure $USE_RTE in config.php +$USE_RTE = vt_hasRTE(); if(getFieldVisibilityPermission('Documents',$current_user->id,'notecontent') != '0') - $FCKEDITOR_DISPLAY = false; -$smarty->assign("FCKEDITOR_DISPLAY",$FCKEDITOR_DISPLAY); + $USE_RTE = false; +$smarty->assign("USE_RTE",$USE_RTE); if (isset($focus->name)) $smarty->assign("NAME", $focus->name); diff --git a/oss/vtiger/trunk/modules/Documents/ListView.php b/oss/vtiger/trunk/modules/Documents/ListView.php index 82c6a708..64ef4220 100644 --- a/oss/vtiger/trunk/modules/Documents/ListView.php +++ b/oss/vtiger/trunk/modules/Documents/ListView.php @@ -65,16 +65,6 @@ $_SESSION['NOTES_ORDER_BY'] = $order_by; $_SESSION['NOTES_SORT_ORDER'] = $sorder; //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>> - -if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') -{ - list($where, $ustring) = split("#@@#",getWhereCondition($currentModule)); - // we have a query - $url_string .="&query=true".$ustring; - $log->info("Here is the where clause for the list view: $where"); - $smarty->assign("SEARCH_URL",$url_string); - -} if(isPermitted('Documents','Delete','') == 'yes') { $smarty->assign("MASS_DELETE","yes"); @@ -111,25 +101,33 @@ $smarty->assign("CATEGORY",$category); //Retreive the list from Database //<<<<<<<<>>>>>>>> -if($viewid != 0) -{ - $listquery = getListQuery("Documents"); - $query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Documents"); -}else -{ - $query = getListQuery("Documents"); +global $current_user; +$queryGenerator = new QueryGenerator($currentModule, $current_user); +if ($viewid != "0") { + $queryGenerator->initForCustomViewById($viewid); +} else { + $queryGenerator->initForDefaultCustomView(); } //<<<<<<<>>>>>>>> $hide_empty_folders = 'no'; -if(isset($where) && $where != '') -{ - $query .= ' and '.$where; - $_SESSION['export_where'] = $where; +// Enabling Module Search +$url_string = ''; +if($_REQUEST['query'] == 'true') { + $queryGenerator->addUserSearchConditions($_REQUEST); + $ustring = getSearchURL($_REQUEST); + $url_string .= "&query=true$ustring"; + $smarty->assign('SEARCH_URL', $url_string); +} + +$query = $queryGenerator->getQuery(); +$where = $queryGenerator->getConditionalWhere(); +if(isset($where) && $where != '') { + $_SESSION['export_where'] = $where; +} else { + unset($_SESSION['export_where']); } -else - unset($_SESSION['export_where']); $focus->query = $query; @@ -159,9 +157,11 @@ if($viewid ==0) if($viewid !='') $url_string .="&viewname=".$viewid; -$listview_header = getListViewHeader($focus,"Documents",$url_string,$sorder,$order_by,"",$oCustomView); +$controller = new ListViewController($adb, $current_user, $queryGenerator); +$listview_header = $controller->getListViewHeader($focus,$currentModule,$url_string,$sorder, + $order_by); $smarty->assign("LISTHEADER", $listview_header); -$listview_header_search = getSearchListHeaderValues($focus,"Documents",$url_string,$sorder,$order_by,"",$oCustomView); +$listview_header_search = $controller->getBasicSearchFieldInfoList(); $smarty->assign("SEARCHLISTHEADER",$listview_header_search); $smarty->assign("SELECT_SCRIPT", $view_script); @@ -262,10 +262,12 @@ if($foldercount > 0 ) $folder_details['foldername']=$adb->query_result($result,$i,"foldername"); $foldername = $folder_details['foldername']; $folder_details['description']=$adb->query_result($result,$i,"description"); - $folder_files = getListViewEntries($focus,"Documents",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView); + $folder_files = $controller->getListViewEntries($focus,$currentModule,$list_result, + $navigation_array); $folder_details['entries']= $folder_files; $folder_details['navigation'] = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Documents",$folder_id,$viewid); - $folder_details['recordListRange'] = getRecordRangeMessage($list_result, $limit_start_rec); + $folder_details['recordListRange'] = getRecordRangeMessage($list_result, $limit_start_rec, + $num_records); if ($displayFolder == true) { $folders[$foldername] = $folder_details; } else{ @@ -290,20 +292,27 @@ $smarty->assign("SELECTEDIDS", vtlib_purify($_REQUEST['selobjs'])); $smarty->assign("ALLSELECTEDIDS", vtlib_purify($_REQUEST['allselobjs'])); $alphabetical = AlphabeticalSearch($currentModule,'index','notes_title','true','basic',"","","","",$viewid); -$fieldnames = getAdvSearchfields($module); +$fieldnames = $controller->getAdvancedSearchOptionString(); $criteria = getcriteria_options(); $smarty->assign("CRITERIA", $criteria); $smarty->assign("FIELDNAMES", $fieldnames); $smarty->assign("ALPHABETICAL", $alphabetical); $smarty->assign("NAVIGATION", $navigationOutput); $smarty->assign("RECORD_COUNTS", $record_string); -if($current_user->id == 1) - $smarty->assign("IS_ADMIN","on"); + +$smarty->assign("IS_ADMIN",$current_user->is_admin); + $check_button = Button_Check($module); $smarty->assign("CHECK", $check_button); $_SESSION[$currentModule.'_listquery'] = $list_query; +// Gather the custom link information to display +include_once('vtlib/Vtiger/Link.php'); +$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params)); +// END + if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '' || $_REQUEST['mode'] == 'ajax') $smarty->display("DocumentsListViewEntries.tpl"); else diff --git a/oss/vtiger/trunk/modules/Documents/language/en_us.lang.php b/oss/vtiger/trunk/modules/Documents/language/en_us.lang.php index be697932..289df952 100644 --- a/oss/vtiger/trunk/modules/Documents/language/en_us.lang.php +++ b/oss/vtiger/trunk/modules/Documents/language/en_us.lang.php @@ -133,6 +133,10 @@ $mod_strings = Array( 'LBL_MAXIMUM_20'=>'Maximum 20', 'LBL_MAXIMUM_50'=>'Maximum 50', + +// Added after 5.1.0 GA +'Folder Name'=>'Folder Name', +'Document No'=>'Document No', ); ?> diff --git a/oss/vtiger/trunk/modules/Documents/language/zh_cn.lang.php b/oss/vtiger/trunk/modules/Documents/language/zh_cn.lang.php index be697932..a1accdc2 100644 --- a/oss/vtiger/trunk/modules/Documents/language/zh_cn.lang.php +++ b/oss/vtiger/trunk/modules/Documents/language/zh_cn.lang.php @@ -21,118 +21,122 @@ ********************************************************************************/ $mod_strings = Array( -'LBL_MODULE_NAME'=>'Documents', -'LBL_MODULE_TITLE'=>'Documents: Home', -'LBL_SEARCH_FORM_TITLE'=>'Document Search', -'LBL_LIST_FORM_TITLE'=>'Document List', -'LBL_NEW_FORM_TITLE'=>'New Document', +'LBL_MODULE_NAME'=>'文档', +'LBL_MODULE_TITLE'=>'文档: 首页', +'LBL_SEARCH_FORM_TITLE'=>'文档查找', +'LBL_LIST_FORM_TITLE'=>'文档列表', +'LBL_NEW_FORM_TITLE'=>'新建文档', -'LBL_LIST_SUBJECT'=>'Subject', -'LBL_LIST_CONTACT_NAME'=>'Contact Name', -'LBL_LIST_RELATED_TO'=>'Related To', -'LBL_LIST_DATE_MODIFIED'=>'Last Modified', +'LBL_LIST_SUBJECT'=>'主题', +'LBL_LIST_CONTACT_NAME'=>'联系人', +'LBL_LIST_RELATED_TO'=>'指定给', +'LBL_LIST_DATE_MODIFIED'=>'最后修改日期', -'LBL_NOTE'=>'Document:', -'LBL_NOTE_SUBJECT'=>'Document Subject:', -'LBL_CONTACT_NAME'=>'Contact Name:', -'LBL_PHONE'=>'Phone:', -'LBL_SUBJECT'=>'Subject:', -'LBL_CLOSE'=>'Close:', -'LBL_RELATED_TO'=>'Related To:', -'LBL_EMAIL_ADDRESS'=>'Email Address:', +'LBL_NOTE'=>'文档:', +'LBL_NOTE_SUBJECT'=>'文档主题:', +'LBL_CONTACT_NAME'=>'联系人:', +'LBL_PHONE'=>'电话:', +'LBL_SUBJECT'=>'主题:', +'LBL_CLOSE'=>'关闭:', +'LBL_RELATED_TO'=>'指定给:', +'LBL_EMAIL_ADDRESS'=>'电子邮件地址:', 'LBL_COLON'=>':', 'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.", -'LBL_LIST_FILENAME'=>"File Name", +'LBL_LIST_FILENAME'=>"文件名", // Added for Note(3.2-patch 3) -'LBL_FILENAME'=>'Attachment:', -'LBL_NOTE_INFORMATION'=>'Basic Information', -'File Information'=>'File Information', +'LBL_FILENAME'=>'附件:', +'LBL_NOTE_INFORMATION'=>'基本信息', +'File Information'=>'文件信息', // Added for 4GA -'LBL_TOOL_FORM_TITLE'=>'Documents Tools', +'LBL_TOOL_FORM_TITLE'=>'文档工具', // Added for 4GA -'Contact Name'=>'Contact Name', -'Related To'=>'Related to', -'Subject'=>'Subject', -'Created Time'=>'Created Time', -'Modified Time'=>'Modified Time', -'Document'=>'Document', +'Contact Name'=>'联系人', +'Related To'=>'指定给', +'Subject'=>'主题', +'Created Time'=>'创建日期', +'Modified Time'=>'修改时间', +'Document'=>'文档', 'Note'=>'Notes', //Added for 4.2 Release -- CustomView -'Related to'=>'Related to', -'Last Modified'=>'Last Modified', -'File'=>'File', -'LBL_ALL'=>'All', -'Title'=>'Title', +'Related to'=>'指定给', +'Last Modified'=>'最后修改日期', +'File'=>'文件', +'LBL_ALL'=>'所有', +'Title'=>'标题', //Added after 504 for Downloads Module -'LBL_FILE_INFORMATION'=>'File Information', -'LBL_FILE_NAME'=>'File Name', -'LBL_FILE_TYPE'=>'File Type', -'LBL_FILE_SIZE'=>'Size', -'filelocationtype'=>'Download Type', -'fileversion'=>'Version', -'filestatus'=>'Active', -'filedownloadcount'=>'Download Count', -'os'=>'Platform', -'LBL_FOLDER_NAME'=>'Folder Name', -'LBL_DOWNLOAD_TYPE'=>'Download Type', -'LBL_INTERNAL'=>'Internal', -'LBL_EXTERNAL'=>'External', -'LBL_EXTERNAL_FILE_NAME'=>'File Name', -'LBL_FILE_LOCATION'=>'File Location', -'LBL_PD'=>'Platform Dependent', -'LBL_PIND'=>'Platform Independent', -'ChoosePlatform'=>'Choose Platform', -'LBL_ACTIVE'=>'Active', -'LBL_INACTIVE'=>'Inactive', -'LBL_UPLOAD_BUTTON'=>'Upload', -'architecture'=>'Architecture', -'LBL_DOWNLOAD_FILE'=>'Download file', -'LBL_CHECK_INTEGRITY'=>'Check file integrity', -'LBL_EMAIL_FILE'=>'Email file as attachment', -'LBL_CLICK_HERE'=>'Click here', -'LBL_TO_ADD_FOLDER'=>'to add a new folder.', -'LBL_DELETE_FOLDER'=>'Delete Folder', -'LBL_FOLDER_DESC'=>'Description', -'LBL_ADD_NEW_FOLDER'=>'Add Folder', -'LBL_DELETE_DOCUMENTS'=>'Delete Document(s)', -'LBL_MOVE_TO'=>'Move to', -'File Name'=>'File Name', -'File Type'=>'File Type', -'File Size'=>'Size', -'LBL_INTERNAL'=>'Internal', +'LBL_FILE_INFORMATION'=>'文件信息', +'LBL_FILE_NAME'=>'文件名', +'LBL_FILE_TYPE'=>'文件类型', +'LBL_FILE_SIZE'=>'大小', +'filelocationtype'=>'下载类型', +'fileversion'=>'版本', +'filestatus'=>'归档', +'filedownloadcount'=>'下载量', +'os'=>'适用平台', +'LBL_FOLDER_NAME'=>'文件夹名', +'LBL_DOWNLOAD_TYPE'=>'下载类型', +'LBL_INTERNAL'=>'内部链接', +'LBL_EXTERNAL'=>'外部链接', +'LBL_EXTERNAL_FILE_NAME'=>'文件名', +'LBL_FILE_LOCATION'=>'文件位置', +'LBL_PD'=>'平台相关', +'LBL_PIND'=>'平台无关', +'ChoosePlatform'=>'选择平台', +'LBL_ACTIVE'=>'活动', +'LBL_INACTIVE'=>'非活动', +'LBL_UPLOAD_BUTTON'=>'上传', +'architecture'=>'归档', +'LBL_DOWNLOAD_FILE'=>'下载文件', +'LBL_CHECK_INTEGRITY'=>'检查文件完整性', +'LBL_EMAIL_FILE'=>'作为电子邮件附件发送这个文件', +'LBL_CLICK_HERE'=>'单击这里', +'LBL_TO_ADD_FOLDER'=>'新建一个目录.', +'LBL_DELETE_FOLDER'=>'删除目录', +'LBL_FOLDER_DESC'=>'描述', +'LBL_ADD_NEW_FOLDER'=>'添加目录', +'LBL_DELETE_DOCUMENTS'=>'删除文档', +'LBL_MOVE_TO'=>'移动到', +'File Name'=>'文件名', +'File Type'=>'文件类型', +'File Size'=>'大小', +'LBL_INTERNAL'=>'内部', 'LBL_URL'=>'URL', -'LBL_EXTERNAL'=>'External', -'LBL_EXTERNAL_LNK'=>'External Link', -'LBL_ACTIVE'=>'Active', -'LBL_INACTIVE'=>'Inactive', -'LBL_PLATFORM_INDEPENDENT'=>'Platform Independent', -'LNK_DOWNLOAD'=>'download', -'LBL_MOVE_DOCUMENTS'=>'Move Document(s)', -'LBL_MOVE'=>'Move', -'Download Type'=>'Download Type', -'Version'=>'Version', -'Active'=>'Active', -'Download Count'=>'Download Count', -'Platform'=>'Platform', -'Assigned To'=>'Assigned To', +'LBL_EXTERNAL'=>'外部', +'LBL_EXTERNAL_LNK'=>'外部链接', +'LBL_ACTIVE'=>'活动', +'LBL_INACTIVE'=>'非活动', +'LBL_PLATFORM_INDEPENDENT'=>'平台无关', +'LNK_DOWNLOAD'=>'下载', +'LBL_MOVE_DOCUMENTS'=>'移动文档', +'LBL_MOVE'=>'移动', +'Download Type'=>'下载类型', +'Version'=>'版本', +'Active'=>'归档', +'Download Count'=>'下载量', +'Platform'=>'平台', +'Assigned To'=>'指定给', // Module Sequence Numbering -'Note No' => 'Document No', +'Note No' => '文档序列号', // END // Documents module -'LBL_EMPTY_FOLDERS' => 'Empty Folders', -'LBL_VIEW_EMPTY_FOLDERS' => 'View Empty Folders', -'LBL_NO_DOCUMENTS' => 'No Documents', -'LBL_DESCRIPTION' => 'Description', -'FILE_HAS_NO_DATA'=>'The selected file has no data or a invalid file', +'LBL_EMPTY_FOLDERS' => '空目录', +'LBL_VIEW_EMPTY_FOLDERS' => '查看空目录', +'LBL_NO_DOCUMENTS' => '没有文档', +'LBL_DESCRIPTION' => '描述', +'FILE_HAS_NO_DATA'=>'选择的文件没有数据或者不是有效的文件', -'LBL_MAXIMUM_20'=>'Maximum 20', -'LBL_MAXIMUM_50'=>'Maximum 50', +'LBL_MAXIMUM_20'=>'最大 20', +'LBL_MAXIMUM_50'=>'最大 50', + +// Added after 5.1.0 GA +'Folder Name'=>'文件夹名', +'Document No'=>'文档序列号', ); ?> diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEmailRecipientsTemplate.inc b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEmailRecipientsTemplate.inc new file mode 100644 index 00000000..f3322175 --- /dev/null +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEmailRecipientsTemplate.inc @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEntityCache.inc b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEntityCache.inc index 3da6b136..98cd5e4f 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEntityCache.inc +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEntityCache.inc @@ -86,4 +86,4 @@ class VTEntityCache{ return $this->cache[$id]; } } -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEventHandler.inc b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEventHandler.inc index 613071ce..a450ccfb 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEventHandler.inc +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTEventHandler.inc @@ -32,9 +32,6 @@ require_once('VTWorkflowUtils.php'); * VTEventHandler */ class VTWorkflowEventHandler extends VTEventHandler{ - - - /** * Push tasks to the task queue if the conditions are true * @param $entityData A VTEntityData object representing the entity. @@ -66,11 +63,19 @@ require_once('VTWorkflowUtils.php'); break; } case VTWorkflowManager::$ONCE:{ + $entity_id = vtws_getIdComponents($entityData->getId()); + $entity_id = $entity_id[1]; $result = $adb->pquery("SELECT * FROM com_vtiger_workflow_activatedonce - WHERE entity_id=? and workflow_id=?", array($entityData->getId(), $workflow->id)); - if($adb->num_rows($result)===0){ - $adb->pquery("INSERT INTO com_vtiger_workflow_activatedonce (entity_id, workflow_id) - VALUES (?,?)", array($entityData->getId(), $workflow->id)); + WHERE entity_id=? and workflow_id=?", array($entity_id, $workflow->id)); + + //Changes + $result2=$adb->pquery("SELECT * FROM com_vtiger_workflowtasks + INNER JOIN com_vtiger_workflowtask_queue + ON com_vtiger_workflowtasks.task_id= com_vtiger_workflowtask_queue.task_id + WHERE workflow_id=? AND entity_id=?", + array($workflow->id,$entity_id)); + + if($adb->num_rows($result)===0 && $adb->num_rows($result2)===0){ $doEvaluate = true; }else{ $doEvaluate = false; @@ -81,16 +86,27 @@ require_once('VTWorkflowUtils.php'); $doEvaluate = true; break; } + case VTWorkflowManager::$ON_MODIFY:{ + $doEvaluate = !($isNew); + break; + } default:{ throw new Exception("Should never come here! Execution Condition:".$workflow->executionCondition); } } if($doEvaluate && $workflow->evaluate($entityCache, $entityData->getId())){ + if(VTWorkflowManager::$ONCE == $workflow->executionCondition) { + $entity_id = vtws_getIdComponents($entityData->getId()); + $entity_id = $entity_id[1]; + $adb->pquery("INSERT INTO com_vtiger_workflow_activatedonce (entity_id, workflow_id) + VALUES (?,?)", array($entity_id, $workflow->id)); + } + $tasks = $tm->getTasksForWorkflow($workflow->id); - foreach($tasks as $task){ + foreach($tasks as $task){ if($task->active) { - $trigger = $task->trigger; + $trigger = $task->trigger; if($trigger != null){ $delay = strtotime($data[$trigger['field']])+$trigger['days']*86400; }else{ @@ -99,7 +115,7 @@ require_once('VTWorkflowUtils.php'); if($task->executeImmediately==true){ $task->doTask($entityData); }else{ - $taskQueue->queueTask($task->id, $entityData->getId(), $delay); + $taskQueue->queueTask($task->id,$entityData->getId(), $delay); } } } diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTSimpleTemplate.inc b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTSimpleTemplate.inc index b628724d..7998d6f4 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTSimpleTemplate.inc +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTSimpleTemplate.inc @@ -20,31 +20,77 @@ class VTSimpleTemplate{ } private function matchHandler($match){ - preg_match('/\((\w+) : \((\w+)\) (\w+)\)/', $match[1], $matches); + preg_match('/\((\w+) : \(([_\w]+)\) (\w+)\)/', $match[1], $matches); if(count($matches)==0){ $fieldname = $match[1]; $data = $this->parent->getData(); - $result = $data[$fieldname]; + if($this->useValue($data, $fieldname)){ + $result = $data[$fieldname]; + }else{ + $result =''; + } }else{ list($full, $referenceField, $referenceModule, $fieldname) = $matches; - $referenceId = $this->parent->get($referenceField); - if($referenceId==null){ - $result=""; + if($referenceModule === '__VtigerMeta__'){ + $result = $this->getMetaValue($fieldname); }else{ - $entity = $this->cache->forId($referenceId); - if($entity->getModuleName()==$referenceModule){ - $data = $entity->getData(); - $result = $data[$fieldname]; + $referenceId = $this->parent->get($referenceField); + if($referenceId==null){ + $result=""; }else{ - $result = ""; + $entity = $this->cache->forId($referenceId); + if($referenceModule==="Users" && $entity->getModuleName()=="Groups"){ + list($groupEntityId, $groupId) = vtws_getIdComponents($referenceId); + + require_once('include/utils/GetGroupUsers.php'); + $ggu = new GetGroupUsers(); + $ggu->getAllUsersInGroup($groupId); + + $users = $ggu->group_users; + $parts = Array(); + foreach($users as $userId){ + $refId = vtws_getWebserviceEntityId("Users", $userId); + $entity = $this->cache->forId($refId); + $data = $entity->getData(); + if($this->useValue($data, $fieldname)){ + $parts[] = $data[$fieldname]; + } + } + $result = implode(",", $parts); + }if($entity->getModuleName()===$referenceModule){ + $data = $entity->getData(); + if($this->useValue($data, $fieldname)){ + $result = $data[$fieldname]; + }else{ + $result = ''; + } + }else{ + $result = ''; + } } } } - return $result; + if(!empty($result)){ + $result .= ','; + } + return $result; + + } + + protected function useValue($data, $fieldname) { + return !empty($data[$fieldname]); + } + + function parseTemplate(){ + return preg_replace_callback('/\\$(\w+|\((\w+) : \(([_\w]+)\) (\w+)\))\s*,?/', array($this,"matchHandler"), $this->template); } - function parseTemplate(){ - return preg_replace_callback('/\\$(\w+|\((\w+) : \((\w+)\) (\w+)\))/', array($this,"matchHandler"), $this->template); + function getMetaValue($fieldname){ + switch($fieldname){ + case 'date': return getNewDisplayDate(); + case 'time': return date('h-i-s'); + default: ''; + } } } -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTTaskManager.inc b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTTaskManager.inc index eaa248b3..67532916 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTTaskManager.inc +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTTaskManager.inc @@ -110,8 +110,13 @@ function getTaskTypes(){ - return array("VTEmailTask", "VTEntityMethodTask", "VTCreateTodoTask", - "VTCreateEventTask"); + $taskTypes = array("VTEmailTask", "VTEntityMethodTask", "VTCreateTodoTask","VTCreateEventTask"); + // Make SMSTask available if module is active + // TODO Generic way of handling this could be helpful + if(getTabid('SMSNotifier') && vtlib_isModuleActive('SMSNotifier')) { + $taskTypes [] = 'VTSMSTask'; + } + return $taskTypes; } private function getTasksForResult($result){ @@ -123,7 +128,7 @@ $this->requireTask(self::taskName($text)); $tasks[] = unserialize($text); - } + } return $tasks; } @@ -137,8 +142,6 @@ require_once("tasks/".$taskType.".inc"); } - - } abstract class VTTask{ @@ -147,4 +150,4 @@ } //require 'modules/Workflow/tasks/VTEmailTask.inc'; -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTWorkflowManager.inc b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTWorkflowManager.inc index 2a4d23a9..10293821 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTWorkflowManager.inc +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTWorkflowManager.inc @@ -11,10 +11,11 @@ class VTWorkflowManager{ - static $ON_FIRST_SAVE=1; - static $ONCE=2; - static $ON_EVERY_SAVE=3; - + static $ON_FIRST_SAVE = 1; + static $ONCE = 2; + static $ON_EVERY_SAVE = 3; + static $ON_MODIFY = 4; + function __construct($adb){ $this->adb = $adb; @@ -42,16 +43,34 @@ function getWorkflows(){ $adb=$this->adb; - $result = $adb->query("select workflow_id, module_name, summary, test, execution_condition + + $result=$adb->getColumnNames("com_vtiger_workflows"); + if(in_array("defaultworkflow",$result)){ + $result = $adb->query("select workflow_id, module_name, summary, test, execution_condition,defaultworkflow + from com_vtiger_workflows "); + }else{ + + $result = $adb->query("select workflow_id, module_name, summary, test, execution_condition from com_vtiger_workflows"); + } return $this->getWorkflowsForResult($result); } function getWorkflowsForModule($moduleName){ $adb=$this->adb; - $result = $adb->pquery("select workflow_id, module_name, summary, test, execution_condition + + + //my changes + $result=$adb->getColumnNames("com_vtiger_workflows"); + if(in_array(defaultworkflow,$result)){ + $result = $adb->pquery("select workflow_id, module_name, summary, test, execution_condition,defaultworkflow from com_vtiger_workflows where module_name=?",array($moduleName)); + } + else{ + $result = $adb->pquery("select workflow_id, module_name, summary, test, execution_condition + from com_vtiger_workflows where module_name=?",array($moduleName)); + } return $this->getWorkflowsForResult($result); } @@ -66,6 +85,10 @@ $workflow->description = $row->summary; $workflow->test = $row->test; $workflow->executionCondition = $row->execution_condition; + + if($row->defaultworkflow){ + $workflow->defaultworkflow=$row->defaultworkflow; + } $workflows[]=$workflow; } return $workflows; @@ -176,12 +199,12 @@ function executionConditionAsLabel($label=null){ if($label==null){ - $arr = array('ON_FIRST_SAVE', 'ONCE', 'ON_EVERY_SAVE'); + $arr = array('ON_FIRST_SAVE', 'ONCE', 'ON_EVERY_SAVE','ON_MODIFY'); return $arr[$this->executionCondition-1]; }else{ - $arr = array('ON_FIRST_SAVE'=>1, 'ONCE'=>2, 'ON_EVERY_SAVE'=>3); + $arr = array('ON_FIRST_SAVE'=>1, 'ONCE'=>2, 'ON_EVERY_SAVE'=>3, 'ON_MODIFY'=>4); $this->executionCondition = $arr[$label]; } } } -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTWorkflowUtils.php b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTWorkflowUtils.php index f6449fc9..789a2941 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/VTWorkflowUtils.php +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/VTWorkflowUtils.php @@ -67,8 +67,8 @@ class VTWorkflowUtils{ function toWSModuleName($entityData){ $moduleName = $entityData->getModuleName(); if($moduleName == 'Activity'){ - $arr = array('Task' => 'Calendar', 'Email' => 'Emails'); - $moduleName = $arr[$entityData->get('activitytype')]; + $arr = array('Task' => 'Calendar', 'Emails' => 'Emails'); + $moduleName = $arr[getActivityType($entityData->getId())]; if($moduleName == null){ $moduleName = 'Events'; } @@ -112,6 +112,21 @@ class VTWorkflowUtils{ return false; } } + + function vtGetModules($adb){ + $modules_not_supported = array('Documents','Calendar','Emails','Faq','Events','PBXManager','Users'); + $sql="select distinct vtiger_field.tabid, name + from vtiger_field + inner join vtiger_tab + on vtiger_field.tabid=vtiger_tab.tabid + where vtiger_tab.name not in(".generateQuestionMarks($modules_not_supported).") and vtiger_tab.isentitytype=1 and vtiger_tab.presence = 0 "; + $it = new SqlResultIterator($adb, $adb->pquery($sql,array($modules_not_supported))); + $modules = array(); + foreach($it as $row){ + $modules[] = $row->name; + } + return $modules; + } + } - -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/edittask.php b/oss/vtiger/trunk/modules/com_vtiger_workflow/edittask.php index 754b310f..8ccfb4ed 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/edittask.php +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/edittask.php @@ -95,12 +95,17 @@ require_once("VTWorkflowUtils.php"); $smarty->assign('trigger', array('days'=>$days, 'direction'=>$direction, 'field'=>$trigger['field'])); } - - + $curr_date="(general : (__VtigerMeta__) date)"; + $curr_time='(general : (__VtigerMeta__) time)'; + + $smarty->assign("DATE",$curr_date); + $smarty->assign("TIME",$curr_time); $smarty->assign("MOD", array_merge( - return_module_language($current_language,'Settings'), - return_module_language($current_language, $module->name))); + return_module_language($current_language,'Settings'), + return_module_language($current_language, 'Calendar'), + return_module_language($current_language, $module->name))); $smarty->assign("APP", $app_strings); + $smarty->assign("dateFormat", parse_calendardate($app_strings['NTC_DATE_FORMAT'])); $smarty->assign("IMAGE_PATH",$image_path); $smarty->assign("THEME", $theme); $smarty->assign("MODULE_NAME", $module->label); @@ -108,8 +113,7 @@ require_once("VTWorkflowUtils.php"); $smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_TASK_TITLE']); $smarty->assign("module", $module); - $smarty->display("{$module->name}/EditTask.tpl"); } vtTaskEdit($adb, $_REQUEST, $current_language, $app_strings); -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/editworkflow.php b/oss/vtiger/trunk/modules/com_vtiger_workflow/editworkflow.php index 639a0098..f4bf71de 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/editworkflow.php +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/editworkflow.php @@ -59,6 +59,7 @@ function vtWorkflowEdit($adb, $request, $requestUrl, $current_language, $app_str $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_WORKFLOW']); return; } + $workflow->test = addslashes($workflow->test); $tm = new VTTaskManager($adb); $tasks = $tm->getTasksForWorkflow($workflow->id); $smarty->assign("tasks", $tasks); @@ -83,4 +84,4 @@ function vtWorkflowEdit($adb, $request, $requestUrl, $current_language, $app_str $smarty->display("{$module->name}/EditWorkflow.tpl"); } vtWorkflowEdit($adb, $_REQUEST, $_SERVER["REQUEST_URI"], $current_language, $app_strings); -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/language/en_us.lang.php b/oss/vtiger/trunk/modules/com_vtiger_workflow/language/en_us.lang.php index 6a5f28f5..17afdde6 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/language/en_us.lang.php +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/language/en_us.lang.php @@ -1,30 +1,18 @@ 'Send Email', 'VTEntityMethodTask' => 'Invoke Custom Function', 'VTCreateTodoTask' => 'Create Todo', 'VTCreateEventTask' => 'Create Event', +'VTSMSTask' => 'SMS Task', 'LBL_EDIT_TASK'=>'Edit Task', 'LBL_EDIT_TASK_TITLE'=>'Edit an existing task or create a new one', 'LBL_EDIT_WORKFLOW'=>'Edit Workflow', @@ -34,7 +22,6 @@ $mod_strings = array( 'LBL_NEW_TEMPLATE'=>'Save as Template', 'LBL_CREATE_WORKFLOW_FOR'=>'Create a workflow for', 'LBL_FOR_MODULE'=>'For Module', -'LBL_FROM_TEMPLATE'=>'From Template', 'LBL_CHOOSE_A_TEMPLATE'=>'Choose a template', 'LBL_VALIDATION_MISSING_MANDATORY_FIELDS'=>'There are empty mandatory fields.', 'LBL_VALIDATION_INVALID_DATE_RANGE'=>'Start date/time is greater than the end date/time', @@ -49,7 +36,9 @@ $mod_strings = array( 'LBL_SELECT_OPTION_DOTDOTDOT'=>'Select Option...', 'LBL_WORKFLOW_NOTE_CRON_CONFIG'=>'NOTE: You should have Workflow cron script configured.', 'LBL_NO_TEMPLATES'=>'No Templates', +'LBL_SELECT'=>'Select', +'LBL_MESSAGE'=>'Message', ); -?> \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/resources/edittaskscript.js b/oss/vtiger/trunk/modules/com_vtiger_workflow/resources/edittaskscript.js index e41c15a0..4a2e7016 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/resources/edittaskscript.js +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/resources/edittaskscript.js @@ -25,7 +25,7 @@ function edittaskscript($){ }); $('.box_cel').click(function(){ - element.attr('value', parseInt($(this).text())); + element.attr('value', parseInt($(this).text(), 10)); }); } diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/resources/emailtaskscript.js b/oss/vtiger/trunk/modules/com_vtiger_workflow/resources/emailtaskscript.js index d16ee655..829f363c 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/resources/emailtaskscript.js +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/resources/emailtaskscript.js @@ -213,9 +213,9 @@ function VTEmailTask($){ $('#task-fieldnames-busyicon').hide(); $('#task-fieldnames').show(); $('#task-fieldnames').change(function(){ - var textarea = $('#save_content').get(0); - var value = '$'+$(this).attr('value'); - insertAtCursor(textarea, value); + var textarea = CKEDITOR.instances.save_content; + var value = '$'+jQuery(this).attr('value'); + textarea.insertHtml(value); }); fillSelectBox('task-emailfields', modules, moduleName, @@ -227,6 +227,46 @@ function VTEmailTask($){ var value = '$'+$(this).attr('value'); input.attr("value", input.attr("value")+','+value); }); + var selptype = document.getElementById('task-emailfields'); + var selecc = document.getElementById('task-emailfieldscc'); + for (ops=0;ops \ No newline at end of file +?> diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/savetask.php b/oss/vtiger/trunk/modules/com_vtiger_workflow/savetask.php index 1824f9b7..232aa32c 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/savetask.php +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/savetask.php @@ -51,6 +51,9 @@ require_once("VTWorkflowApplication.inc"); $fieldNames = $task->getFieldNames(); foreach($fieldNames as $fieldName){ $task->$fieldName = $request[$fieldName]; + if ($fieldName == 'calendar_repeat_limit_date') { + $task->$fieldName = getDBInsertDateValue($request[$fieldName]); + } } $tm->saveTask($task); diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTCreateEventTask.inc b/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTCreateEventTask.inc index 0e01a70c..bc050993 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTCreateEventTask.inc +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTCreateEventTask.inc @@ -13,7 +13,7 @@ require_once("include/Webservices/VtigerCRMObjectMeta.php"); require_once("include/Webservices/DataTransform.php"); require_once("include/Webservices/WebServiceError.php"); require_once 'include/Webservices/ModuleTypes.php'; -require_once('include/Webservices/Create.php'); +require_once('include/Webservices/Create.php'); require_once 'include/Webservices/DescribeObject.php'; require_once 'include/Webservices/WebserviceField.php'; require_once 'include/Webservices/EntityMeta.php'; @@ -28,7 +28,10 @@ class VTCreateEventTask extends VTTask{ return array('eventType', 'eventName', 'description', 'sendNotification', 'startTime', 'startDays', 'startDirection', 'startDatefield', 'endTime','endDays', 'endDirection', 'endDatefield', - 'status', 'priority'); + 'status', 'priority','recurringcheck','repeat_frequency', + 'recurringtype','calendar_repeat_limit_date', + 'mon_flag','tue_flag','wed_flag','thu_flag','fri_flag','sat_flag','sun_flag', + 'repeatMonth','repeatMonth_date','repeatMonth_daytype','repeatMonth_day'); } function getAdmin(){ @@ -65,9 +68,27 @@ class VTCreateEventTask extends VTTask{ 'due_date'=>$endDate, 'visibility'=>'all', 'taskstatus'=>'', - 'duration_hours'=>'' + 'duration_hours'=>'0' ); + $_REQUEST['date_start'] = getDisplayDate($startDate); + $_REQUEST['due_date'] = getDisplayDate($endDate); + $_REQUEST['recurringcheck']=$this->recurringcheck; + $_REQUEST['repeat_frequency']=$this->repeat_frequency; + $_REQUEST['recurringtype']=$this->recurringtype; + $_REQUEST['calendar_repeat_limit_date']=getDisplayDate($this->calendar_repeat_limit_date); + $_REQUEST['mon_flag']=$this->mon_flag; + $_REQUEST['tue_flag']=$this->tue_flag; + $_REQUEST['wed_flag']=$this->wed_flag; + $_REQUEST['thu_flag']=$this->thu_flag; + $_REQUEST['fri_flag']=$this->fri_flag; + $_REQUEST['sat_flag']=$this->sat_flag; + $_REQUEST['sun_flag']=$this->sun_flag; + $_REQUEST['repeatMonth']=$this->repeatMonth; + $_REQUEST['repeatMonth_date']=$this->repeatMonth_date; + $_REQUEST['repeatMonth_daytype']=$this->repeatMonth_daytype; + $_REQUEST['repeatMonth_day']=$this->repeatMonth_day; + $moduleName = $entityData->getModuleName(); $adminUser = $this->getAdmin(); $id = $entityData->getId(); @@ -88,7 +109,16 @@ class VTCreateEventTask extends VTTask{ } } - vtws_create('Events', $fields, $adminUser); + $event = vtws_create('Events', $fields, $adminUser); + list($typeId, $id) = vtws_getIdComponents($event['id']); + $event = CRMEntity::getInstance('Events'); + $event->id = $id; + $startDate = $entityData->get($this->startDatefield); + if($this->recurringcheck && !empty($startDate) && + ($this->calendar_repeat_limit_date)) { + include_once 'modules/Calendar/RepeatEvents.php'; + Calendar_RepeatEvents::repeat($event); + } global $current_user; $current_user = $this->originalUser; } @@ -113,4 +143,4 @@ class VTCreateEventTask extends VTTask{ return str_pad($hours, 2, '0', STR_PAD_LEFT).':'.str_pad($arr[2], 2, '0', STR_PAD_LEFT); } } -?> +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.inc b/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.inc index e52fbadc..82c04e28 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.inc +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.inc @@ -43,6 +43,10 @@ class VTCreateTodoTask extends VTTask{ } $baseDate = $entityData->get($this->datefield); + $time = explode(' ',$baseDate); + if(count($time) < 2) { + $time[] = date('H:i'); + } preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDate, $match); $baseDate = strtotime($match[0]); $date = strftime('%Y-%m-%d', $baseDate+$this->days*24*60*60*($this->directions=='Before'?-1:1)); @@ -53,7 +57,7 @@ class VTCreateTodoTask extends VTTask{ 'taskpriority'=>$this->priority, 'taskstatus'=>$this->status, 'assigned_user_id'=>$userId, - 'time_start'=>self::conv12to24hour($this->time), + 'time_start'=>$time[1], 'sendnotification'=>$this->sendNotification!=''?1:0, 'date_start'=>$date, 'due_date'=>$date, diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTEmailTask.inc b/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTEmailTask.inc index a47e13e0..b675e48f 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTEmailTask.inc +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTEmailTask.inc @@ -8,37 +8,45 @@ * All Rights Reserved. ************************************************************************************/ require_once('modules/com_vtiger_workflow/VTEntityCache.inc'); -require_once('modules/com_vtiger_workflow/VTWorkflowUtils.php'); -require_once('modules/com_vtiger_workflow/VTSimpleTemplate.inc'); +require_once('modules/com_vtiger_workflow/VTWorkflowUtils.php'); +require_once('modules/com_vtiger_workflow/VTEmailRecipientsTemplate.inc'); require_once('modules/Emails/mail.php'); -class VTEmailTask extends VTTask{ - // Sending email takes more time, this should be handled via queue all the time. +class VTEmailTask extends VTTask{ + // Sending email takes more time, this should be handled via queue all the time. public $executeImmediately = false; public function getFieldNames(){ - return array("subject", "content", "recepient"); + return array("subject", "content", "recepient", 'emailcc', 'emailbcc'); } public function doTask($entity){ global $adb, $current_user; $util = new VTWorkflowUtils(); $result = $adb->query("select user_name, email1, email2 from vtiger_users where id=1"); - $from_email = $adb->query_result($result,0,'email1'); + $from_email = $adb->query_result($result,0,'email1'); $from_name = $adb->query_result($result,0,'user_name'); $admin = $util->adminUser(); - $module = $entity->getModuleName(); + $module = $entity->getModuleName(); $entityCache = new VTEntityCache($admin); - $et = new VTSimpleTemplate($this->recepient); + $et = new VTEmailRecipientsTemplate($this->recepient); $to_email = $et->render($entityCache, $entity->getId()); - + $ecct = new VTEmailRecipientsTemplate($this->emailcc); + $cc = $ecct->render($entityCache, $entity->getId()); + $ebcct = new VTEmailRecipientsTemplate($this->emailbcc); + $bcc = $ebcct->render($entityCache, $entity->getId()); + if(strlen(trim($to_email, " \t\n,")) == 0 && strlen(trim($cc, " \t\n,")) == 0 && + strlen(trim($bcc, " \t\n,")) == 0) { + return ; + } + $st = new VTSimpleTemplate($this->subject); $subject = $st->render($entityCache, $entity->getId()); $ct = new VTSimpleTemplate($this->content); - $content = $ct->render($entityCache, $entity->getId()); - send_mail($module,$to_email,$from_name,$from_email,$subject,$content); + $content = $ct->render($entityCache, $entity->getId()); + send_mail($module,$to_email,$from_name,$from_email,$subject,$content, $cc, $bcc); $util->revertUser(); } diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTSMSTask.inc b/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTSMSTask.inc new file mode 100644 index 00000000..d3bc0721 --- /dev/null +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/tasks/VTSMSTask.inc @@ -0,0 +1,12 @@ + diff --git a/oss/vtiger/trunk/modules/com_vtiger_workflow/workflowlist.php b/oss/vtiger/trunk/modules/com_vtiger_workflow/workflowlist.php index 9dd4e99b..275b0cee 100644 --- a/oss/vtiger/trunk/modules/com_vtiger_workflow/workflowlist.php +++ b/oss/vtiger/trunk/modules/com_vtiger_workflow/workflowlist.php @@ -47,10 +47,10 @@ function vtDisplayWorkflowList($adb, $request, $requestUrl, $app_strings, $curre $smarty = new vtigerCRM_Smarty(); $wfs = new VTWorkflowManager($adb); - $smarty->assign("moduleNames", vtGetModules($adb)); + $smarty->assign("moduleNames", $util->vtGetModules($adb)); $smarty->assign("returnUrl", $requestUrl); - $listModule = $request["list_module"]; + $listModule =$request['list_module']; $smarty->assign("listModule", $listModule); if($listModule==null || strtolower($listModule)=="all"){ $smarty->assign("workflows", $wfs->getWorkflows());