更新到 5.2 正式版后第一次 SVN 提交。

[email protected]


git-svn-id: https://svn.code.sf.net/p/hawebs/svn@570 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
YuCheng Hu
2010-11-14 14:46:58 +00:00
parent 549a9dad8c
commit 951f0e4023
708 changed files with 167299 additions and 235367 deletions
@@ -150,7 +150,18 @@ class ListViewController {
$idList[] = $id;
}
}
$this->ownerNameList[$fieldName] = getOwnerNameList($idList);
if(count($idList) > 0) {
if(!is_array($this->ownerNameList[$fieldName])) {
$this->ownerNameList[$fieldName] = getOwnerNameList($idList);
} else {
//array_merge API loses key information so need to merge the arrays
// manually.
$newOwnerList = getOwnerNameList($idList);
foreach ($newOwnerList as $id => $name) {
$this->ownerNameList[$fieldName][$id] = $name;
}
}
}
}
}
@@ -294,6 +305,7 @@ class ListViewController {
$value = "<font color='red'>".getTranslatedString('LBL_NOT_ACCESSIBLE',
$module)."</font>";
} else {
$value = getTranslatedString($value,$module);
$value = textlength_check($value);
}
}elseif($field->getFieldDataType() == 'date' ||
@@ -667,4 +679,4 @@ class ListViewController {
}
}
?>
?>
@@ -197,6 +197,15 @@ class ListViewSession {
}
return $start;
}
function setSessionQuery($currentModule,$query,$viewid){
if(isset($_SESSION[$currentModule.'_listquery'])){
if($_SESSION[$currentModule.'_listquery'] != $query){
unset($_SESSION[$currentModule.'_DetailView_Navigation'.$viewid]);
}
}
$_SESSION[$currentModule.'_listquery'] = $query;
}
}
?>
@@ -782,10 +782,32 @@ class QueryGenerator {
list($fieldName,$typeOfData) = split("::::",str_replace('\'','',
stripslashes($input[$fieldInfo])));
$moduleFields = $this->meta->getModuleFields();
$field = $moduleFields[$fieldName];
$type = $field->getFieldDataType();
$operator = str_replace('\'','',stripslashes($input[$condition]));
$searchValue = $input[$value];
$searchValue = function_exists(iconv) ? @iconv("UTF-8",$default_charset,
$searchValue) : $searchValue;
if($type == 'picklist') {
global $mod_strings;
// Get all the keys for the for the Picklist value
$mod_keys = array_keys($mod_strings, $searchValue);
if(sizeof($mod_keys) >= 1) {
// Iterate on the keys, to get the first key which doesn't start with LBL_ (assuming it is not used in PickList)
foreach($mod_keys as $mod_idx=>$mod_key) {
$stridx = strpos($mod_key, 'LBL_');
// Use strict type comparision, refer strpos for more details
if ($stridx !== 0) {
$searchValue = $mod_key;
break;
}
}
}
}
$this->addCondition($fieldName, $searchValue, $operator);
if($i+1<$noOfConditions) {
$this->addConditionGlue($matchType);
@@ -841,6 +863,23 @@ class QueryGenerator {
if(!$this->isStringType($type)) {
$value=trim($stringConvert);
}
if($type == 'picklist') {
global $mod_strings;
// Get all the keys for the for the Picklist value
$mod_keys = array_keys($mod_strings, $value);
if(sizeof($mod_keys) >= 1) {
// Iterate on the keys, to get the first key which doesn't start with LBL_ (assuming it is not used in PickList)
foreach($mod_keys as $mod_idx=>$mod_key) {
$stridx = strpos($mod_key, 'LBL_');
// Use strict type comparision, refer strpos for more details
if ($stridx !== 0) {
$value = $mod_key;
break;
}
}
}
}
}
if(!empty($input['operator'])) {
$operator = $input['operator'];
@@ -20,12 +20,11 @@ function vtws_convertlead($leadId,$assignedTo,$accountName,$avoidPotential,$pote
if(((boolean)$avoidPotential) !== true){
try{
if(empty($potential)){
throw new WebServiceException(WebServiceCustomErrorCode::$INVALID_POTENTIAL_FOR_CONVERT_LEAD,
throw new WebServiceException(WebServiceErrorCode::$INVALID_POTENTIAL_FOR_CONVERT_LEAD,
"Invalid lead information given for potential");
}
$potential = Zend_Json::decode($potential);
}catch(Zend_Json_Exception $e){
throw new WebServiceException(WebServiceCustomErrorCode::$INVALID_POTENTIAL_FOR_CONVERT_LEAD,
throw new WebServiceException(WebServiceErrorCode::$INVALID_POTENTIAL_FOR_CONVERT_LEAD,
"Potentail information given is not in valid JSON format");
}
}
@@ -54,7 +53,7 @@ function vtws_convertlead($leadId,$assignedTo,$accountName,$avoidPotential,$pote
}
$rowCount = $adb->num_rows($result);
if($rowCount > 0){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_ALREADY_CONVERTED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_ALREADY_CONVERTED,
"Lead is already converted");
}
@@ -79,18 +78,18 @@ function vtws_convertlead($leadId,$assignedTo,$accountName,$avoidPotential,$pote
$status = vtws_getRelatedNotesAttachments($leadIdComponents[1],$crmId);
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move related Documents to the Account");
}
//Retrieve the lead related products and relate them with this new account
$status = vtws_saveLeadRelatedProducts($leadIdComponents[1], $crmId, "Accounts");
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move related Products to the Account");
}
$status = vtws_saveLeadRelations($leadIdComponents[1], $crmId, "Accounts");
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move Records to the Account");
}
}else{
@@ -159,18 +158,18 @@ function vtws_convertlead($leadId,$assignedTo,$accountName,$avoidPotential,$pote
$accountIdComponents = vtws_getIdComponents($account['id']);
$status = vtws_getRelatedNotesAttachments($leadIdComponents[1],$accountIdComponents[1]);
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move related Documents to the Account");
}
//Retrieve the lead related products and relate them with this new account
$status = vtws_saveLeadRelatedProducts($leadIdComponents[1], $accountIdComponents[1], "Accounts");
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move related Products to the Account");
}
$status = vtws_saveLeadRelations($leadIdComponents[1], $accountIdComponents[1], "Accounts");
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move Records to the Account");
}
}
@@ -245,29 +244,29 @@ function vtws_convertlead($leadId,$assignedTo,$accountName,$avoidPotential,$pote
//To convert relates Activites and Email.
$status = vtws_getRelatedActivities($leadIdComponents[1],$accountId,$contactIdComponents[1]);
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move Related Activities to the Contact");
}
$status = vtws_getRelatedNotesAttachments($leadIdComponents[1],$contactIdComponents[1]);
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move related Documents to the Contact");
}
//Retrieve the lead related products and relate them with this new contact
$status = vtws_saveLeadRelatedProducts($leadIdComponents[1], $contactIdComponents[1], "Contacts");
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move related Products to the Contact");
}
$status = vtws_saveLeadRelations($leadIdComponents[1], $contactIdComponents[1], "Contacts");
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move Records to the Contact");
}
//Retrieve the lead related Campaigns and relate them with this new contact --Minnie
$status = vtws_saveLeadRelatedCampaigns($leadIdComponents[1], $contactIdComponents[1]);
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move Related Campaigns to the Contact");
}
}
@@ -318,19 +317,19 @@ function vtws_convertlead($leadId,$assignedTo,$accountName,$avoidPotential,$pote
$sql ="insert into vtiger_contpotentialrel values(?,?)";
$result = $adb->pquery($sql, array($contactId, $potentialIdComponents[1]));
if($result === false){
throw new WebServiceException(WebServiceCustomErrorCode::$FAILED_TO_CREATE_RELATION,
throw new WebServiceException(WebServiceErrorCode::$FAILED_TO_CREATE_RELATION,
"Failed to related Contact with the Potential");
}
}
//Retrieve the lead related products and relate them with this new potential
$status = vtws_saveLeadRelatedProducts($leadIdComponents[1], $potentialIdComponents[1], "Potentials");
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move related Products to the Potential");
}
$status = vtws_saveLeadRelations($leadIdComponents[1], $potentialIdComponents[1], "Potentials");
if($status === false){
throw new WebServiceException(WebServiceCustomErrorCode::$LEAD_RELATED_UPDATE_FAILED,
throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED,
"Failed to move Records to the Potential");
}
$potentialId = $potentialIdComponents[1];
@@ -341,7 +340,7 @@ function vtws_convertlead($leadId,$assignedTo,$accountName,$avoidPotential,$pote
$sql = "UPDATE vtiger_leaddetails SET converted = 1 where leadid=?";
$result = $adb->pquery($sql, array($leadIdComponents[1]));
if($result === false){
throw new WebServiceException(WebServiceCustomErrorCode::$FAILED_TO_MARK_CONVERTED,
throw new WebServiceException(WebServiceErrorCode::$FAILED_TO_MARK_CONVERTED,
"Failed mark lead converted");
}
//updating the campaign-lead relation --Minnie
@@ -367,4 +366,4 @@ function vtws_convertlead($leadId,$assignedTo,$accountName,$avoidPotential,$pote
return $result;
}
?>
?>
@@ -85,10 +85,15 @@
$_REQUEST['remmin'] = $minutes;
$_REQUEST['remhrs'] = $hours;
$_REQUEST['remdays'] = $days;
}
else{
} else {
$_REQUEST['set_reminder'] = "No";
}
} elseif(strtolower($meta->getEntityName()) == "calendar") {
if(empty($row['sendnotification']) || strtolower($row['sendnotificaiton'])=='no'
|| $row['sendnotificaiton'] == '0' || $row['sendnotificaiton'] == 'false'
|| strtolower($row['sendnotificaiton']) == 'n') {
unset($row['sendnotification']);
}
}
$references = $meta->getReferenceFieldDetails();
foreach($references as $field=>$typeList){
@@ -128,6 +128,7 @@
function handleType($type,$value){
$result;
$value = stripslashes($value);
$type = strtolower($type);
if($this->inParamProcess[$type]){
$result = call_user_func($this->inParamProcess[$type],$value);
}else{
@@ -1,54 +1,54 @@
<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
class VTWS_PreserveGlobal{
private static $globalData = array();
static function preserveGlobal($name,$value){
//$name store the name of the global.
global $$name;
if(!is_array(VTWS_PreserveGlobal::$globalData[$name])){
VTWS_PreserveGlobal::$globalData[$name] = array();
VTWS_PreserveGlobal::$globalData[$name]['exists'] = true;
VTWS_PreserveGlobal::$globalData[$name]['value'] = $$name;
}
$$name = $value;
return $$name;
}
static function restore($name){
//$name store the name of the global.
global $$name;
if(VTWS_PreserveGlobal::$globalData[$name]['exists'] === true){
$$name = VTWS_PreserveGlobal::$globalData[$name]['value'];
return $$name;
}
}
static function getGlobal($name){
global $$name;
return VTWS_PreserveGlobal::preserveGlobal($name,$$name);
}
static function flush(){
foreach (VTWS_PreserveGlobal::$globalData as $name => $detail) {
//$name store the name of the global.
global $$name;
$$name = VTWS_PreserveGlobal::$globalData[$name]['value'];
return $$name;
}
}
}
?>
<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
class VTWS_PreserveGlobal{
private static $globalData = array();
static function preserveGlobal($name,$value){
//$name store the name of the global.
global $$name;
if(!is_array(VTWS_PreserveGlobal::$globalData[$name])){
VTWS_PreserveGlobal::$globalData[$name] = array();
VTWS_PreserveGlobal::$globalData[$name][] = $$name;
}
$$name = $value;
return $$name;
}
static function restore($name){
//$name store the name of the global.
global $$name;
if(is_array(VTWS_PreserveGlobal::$globalData[$name]) && count(VTWS_PreserveGlobal::$globalData[$name]) > 0){
$$name = array_pop(VTWS_PreserveGlobal::$globalData[$name]);
}
$$name;
}
static function getGlobal($name){
global $$name;
return VTWS_PreserveGlobal::preserveGlobal($name,$$name);
}
static function flush(){
foreach (VTWS_PreserveGlobal::$globalData as $name => $detail) {
//$name store the name of the global.
global $$name;
if(is_array(VTWS_PreserveGlobal::$globalData[$name]) && count(VTWS_PreserveGlobal::$globalData[$name]) > 0) {
$$name = array_pop(VTWS_PreserveGlobal::$globalData[$name]);
}
}
}
}
?>
@@ -0,0 +1,82 @@
<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
function vtws_revise($element,$user){
global $log,$adb;
$idList = vtws_getIdComponents($element['id']);
$webserviceObject = VtigerWebserviceObject::fromId($adb,$idList[0]);
$handlerPath = $webserviceObject->getHandlerPath();
$handlerClass = $webserviceObject->getHandlerClass();
require_once $handlerPath;
$handler = new $handlerClass($webserviceObject,$user,$adb,$log);
$meta = $handler->getMeta();
$entityName = $meta->getObjectEntityName($element['id']);
$types = vtws_listtypes($user);
if(!in_array($entityName,$types['types'])){
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED,"Permission to perform the operation is denied");
}
if($entityName !== $webserviceObject->getEntityName()){
throw new WebServiceException(WebServiceErrorCode::$INVALIDID,"Id specified is incorrect");
}
if(!$meta->hasPermission(EntityMeta::$UPDATE,$element['id'])){
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED,"Permission to read given object is denied");
}
if(!$meta->exists($idList[1])){
throw new WebServiceException(WebServiceErrorCode::$RECORDNOTFOUND,"Record you are trying to access is not found");
}
if($meta->hasWriteAccess()!==true){
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED,"Permission to write is denied");
}
$referenceFields = $meta->getReferenceFieldDetails();
foreach($referenceFields as $fieldName=>$details){
if(isset($element[$fieldName]) && strlen($element[$fieldName]) > 0){
$ids = vtws_getIdComponents($element[$fieldName]);
$elemTypeId = $ids[0];
$elemId = $ids[1];
$referenceObject = VtigerWebserviceObject::fromId($adb,$elemTypeId);
if(!in_array($referenceObject->getEntityName(),$details)){
throw new WebServiceException(WebServiceErrorCode::$REFERENCEINVALID,
"Invalid reference specified for $fieldName");
}
if(!in_array($referenceObject->getEntityName(),$types['types'])){
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED,
"Permission to access reference type is denied ".$referenceObject->getEntityName());
}
}else if($element[$fieldName] !== NULL){
unset($element[$fieldName]);
}
}
$ownerFields = $meta->getOwnerFields();
if(is_array($ownerFields) && sizeof($ownerFields) >0){
foreach($ownerFields as $ownerField){
if(isset($element[$ownerField]) && $element[$ownerField]!==null &&
!$meta->hasAssignPrivilege($element[$ownerField])){
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Cannot assign record to the given user");
}
}
}
$entity = $handler->revise($element);
VTWS_PreserveGlobal::flush();
return $entity;
}
?>
@@ -171,7 +171,8 @@ function vtws_getEntityNameFields($moduleName){
function vtws_getModuleNameList(){
global $adb;
$sql = "select name from vtiger_tab where presence=0 and isentitytype=1 order by tabsequence";
$sql = "select name from vtiger_tab where isentitytype=1 and name not in ('Rss','Webmails',".
"'Recyclebin','Events') order by tabsequence";
$res = $adb->pquery($sql, array());
$mod_array = Array();
while($row = $adb->fetchByAssoc($res)){
@@ -1,13 +1,4 @@
<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
/* Driver template for the PHP_VTQL_ParserrGenerator parser generator. (PHP port of LEMON)
*/
@@ -183,7 +174,7 @@ function buildSelectStmt($sqlDump){
$fieldcol = $meta->getFieldColumnMapping();
$columnTable = $meta->getColumnTableMapping();
$this->query = 'SELECT ';
if(is_string($this->out['column_list']) && strcmp($sqlDump['column_list'],'*')===0){
if(in_array('*', $sqlDump['column_list'])){
$i=0;
foreach($fieldcol as $field=>$col){
if($i===0){
@@ -193,7 +184,7 @@ function buildSelectStmt($sqlDump){
$this->query = $this->query.','.$columnTable[$col].'.'.$col;
}
}
}else if(is_string($this->out['column_list']) && strcmp($sqlDump['column_list'],'count(*)')===0){
}else if(in_array('count(*)', $sqlDump['column_list'])){
$this->query = $this->query." COUNT(*)";
}else{
$i=0;
@@ -212,6 +203,7 @@ function buildSelectStmt($sqlDump){
$this->query = $this->query.' FROM '.$sqlDump['tableName'].$sqlDump['defaultJoinConditions'];
$deletedQuery = $meta->getEntityDeletedQuery();
$accessControlQuery = $meta->getEntityAccessControlQuery();
$this->query = $this->query.' '.$accessControlQuery;
if($sqlDump['where_condition']){
if((sizeof($sqlDump['where_condition']['column_names']) ==
sizeof($sqlDump['where_condition']['column_values'])) &&
@@ -272,7 +264,7 @@ function buildSelectStmt($sqlDump){
$this->query = $this->query.")";
$nextToken = ' AND ';
}else{
if(!empty($deletedQuery) || !empty($accessControlQuery)){
if(!empty($deletedQuery)){
$nextToken = " WHERE ";
}
}
@@ -287,7 +279,6 @@ function buildSelectStmt($sqlDump){
}
$this->query = $this->query.' '.$deletedQuery;
$this->query = $this->query.' '.$accessControlQuery;
if($sqlDump['orderby']){
$i=0;
@@ -1184,20 +1175,20 @@ $this->out['column_list'][] = $this->yystack[$this->yyidx + 0]->minor;
#line 1181 "e:\workspace\nonadmin\pkg\vtiger\extensions\Webservices\VTQL_parser.php"
#line 22 "e:\workspace\nonadmin\pkg\vtiger\extensions\Webservices\VTQL_parser.y"
function yy_r3(){
$this->out['column_list'] = $this->yystack[$this->yyidx + 0]->minor;
$this->out['column_list'][] = $this->yystack[$this->yyidx + 0]->minor;
}
#line 1186 "e:\workspace\nonadmin\pkg\vtiger\extensions\Webservices\VTQL_parser.php"
#line 25 "e:\workspace\nonadmin\pkg\vtiger\extensions\Webservices\VTQL_parser.y"
function yy_r4(){
$this->out['column_list'] = 'count(*)';
$this->out['column_list'][] = 'count(*)';
}
#line 1191 "e:\workspace\nonadmin\pkg\vtiger\extensions\Webservices\VTQL_parser.php"
#line 30 "e:\workspace\nonadmin\pkg\vtiger\extensions\Webservices\VTQL_parser.y"
function yy_r7(){
if(is_array($this->out["column_list"])){
if(!in_array("*", $this->out["column_list"]) && !in_array("count(*)", array_map(strtolower, $this->out["column_list"]))){
if(!in_array("id",$this->out["column_list"])){
$this->out["column_list"][] = "id";
}
}
}
$moduleName = $this->yystack[$this->yyidx + 0]->minor;
if(!$moduleName){
@@ -1339,9 +1330,9 @@ $this->out['meta'] = $objectMeta;
$meta = $this->out['meta'];
$fieldcol = $meta->getFieldColumnMapping();
$columns = array();
if(is_string($this->out['column_list']) && strcmp($this->out['column_list'],'*')===0){
if(in_array('*', $this->out['column_list'])){
$columns = array_values($fieldcol);
}else if(is_string($this->out['column_list']) && strcmp($this->out['column_list'],'count(*)')!==0){
}elseif( !in_array('count(*)', array_map(strtolower, $this->out['column_list']))){
foreach($this->out['column_list'] as $ind=>$field){
$columns[] = $fieldcol[$field];
}
@@ -1352,7 +1343,7 @@ $columns[] = $fieldcol[$field];
}
}
$tables = $this->getTables($this->out, $columns);
if(sizeof($tables)===0){
if(!in_array($objectMeta->getEntityBaseTable(), $tables)){
$tables[] = $objectMeta->getEntityBaseTable();
}
$defaultTableList = $objectMeta->getEntityDefaultTableList();
@@ -13,6 +13,8 @@ class VtigerActorOperation extends WebserviceEntityOperation {
protected $entityTableName;
protected $moduleFields;
protected $isEntity = false;
protected $element;
protected $id;
public function __construct($webserviceObject,$user,$adb,$log){
parent::__construct($webserviceObject,$user,$adb,$log);
@@ -22,6 +24,8 @@ class VtigerActorOperation extends WebserviceEntityOperation {
}
$this->meta = new VtigerCRMActorMeta($this->entityTableName,$webserviceObject,$adb,$user);
$this->moduleFields = null;
$this->element = null;
$this->id = null;
}
protected function getActorTables(){
@@ -55,94 +59,166 @@ class VtigerActorOperation extends WebserviceEntityOperation {
}
$meta = $this->getMeta();
$sql = "update $tableName"."_seq set id=(select max(".$meta->getIdColumn().")
from $tableName)";
$this->pearDB->pquery($sql,array());
if(strcasecmp($elementType,'Groups') !== 0 && strcasecmp($elementType,'Users') !== 0) {
$sql = "update $tableName"."_seq set id=(select max(".$meta->getIdColumn().")
from $tableName)";
$this->pearDB->pquery($sql,array());
}
$id = $this->pearDB->getUniqueId($tableName);
return $id;
}
public function __create($elementType,$element){
require_once 'include/utils/utils.php';
$db = PearDatabase::getInstance();
$this->id=$this->getNextId($elementType, $element);
$element[$this->meta->getObectIndexColumn()] = $this->id;
//Insert into group vtiger_table
$query = "insert into {$this->entityTableName}(".implode(',',array_keys($element)).
") values(".generateQuestionMarks(array_keys($element)).")";
$result = null;
$transactionSuccessful = vtws_runQueryAsTransaction($query, array_values($element),
$result);
return $transactionSuccessful;
}
public function create($elementType,$element){
$element = DataTransform::sanitizeForInsert($element,$this->meta);
$id = $this->getNextId($elementType,$element);
$element = $this->restrictFields($element);
$element[$this->meta->getObectIndexColumn()] = $id;
//Insert into group vtiger_table
$query = "insert into {$this->entityTableName}(".implode(',',array_keys($element)).") values(".
generateQuestionMarks(array_keys($element)).")";
$result = null;
$transactionSuccessful = vtws_runQueryAsTransaction($query, array_values($element),$result);
if(!$transactionSuccessful){
$success = $this->__create($elementType,$element);
if(!$success){
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
"Database error while performing required operation create");
}
return $this->retrieve(vtws_getId($this->meta->getEntityId(),$id));
return $this->retrieve(vtws_getId($this->meta->getEntityId(),$this->id));
}
protected function restrictFields($element){
protected function restrictFields($element, $selectedOnly = false){
$fields = $this->getModuleFields();
$newElement = array();
foreach ($fields as $field) {
if(isset($element[$field['name']])){
$newElement[$field['name']] = $element[$field['name']];
}else if($field['name'] != 'id'){
}else if($field['name'] != 'id' && $selectedOnly == false){
$newElement[$field['name']] = '';
}
}
return $newElement;
}
public function retrieve($id){
$ids = vtws_getIdComponents($id);
$elemid = $ids[1];
public function __retrieve($id){
$query = "select * from {$this->entityTableName} where {$this->meta->getObectIndexColumn()}=?";
$transactionSuccessful = vtws_runQueryAsTransaction($query,array($elemid),$result);
$transactionSuccessful = vtws_runQueryAsTransaction($query,array($id),$result);
if(!$transactionSuccessful){
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
"Database error while performing required operation");
}
$adb = $this->pearDB;
$db = $this->pearDB;
if($result){
$rowCount = $adb->num_rows($result);
$rowCount = $db->num_rows($result);
if($rowCount >0){
$element = $adb->query_result_rowdata($result,0);
$this->element = $db->query_result_rowdata($result,0);
return true;
}
}
return false;
}
public function retrieve($id){
$ids = vtws_getIdComponents($id);
$elemId = $ids[1];
$success = $this->__retrieve($elemId);
if(!$success){
throw new WebServiceException(WebServiceErrorCode::$RECORDNOTFOUND,
"Record not found");
}
$element = $this->getElement();
return DataTransform::filterAndSanitize($element,$this->meta);
}
public function __update($element,$id){
$columnStr = 'set '.implode('=?,',array_keys($element)).' =? ';
$query = 'update '.$this->entityTableName.' '.$columnStr.'where '.
$this->meta->getObectIndexColumn().'=?';
$params = array_values($element);
array_push($params,$id);
$result = null;
$transactionSuccessful = vtws_runQueryAsTransaction($query,$params,$result);
return $transactionSuccessful;
}
public function update($element){
$ids = vtws_getIdComponents($element["id"]);
$element = DataTransform::sanitizeForInsert($element,$this->meta);
$element = $this->restrictFields($element);
$columnStr = 'set '.implode('=?,',array_keys($element)).' =? ';
$query = 'update '.$this->entityTableName.' '.$columnStr.'where '.$this->meta->getObectIndexColumn().'=?';
$params = array_values($element);
array_push($params,$ids[1]);
$result = null;
$transactionSuccessful = vtws_runQueryAsTransaction($query,$params,$result);
if(!$transactionSuccessful){
$success = $this->__update($element,$ids[1]);
if(!$success){
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
"Database error while performing required operation");
}
return $this->retrieve(vtws_getId($ids[0],$ids[1]));
return $this->retrieve(vtws_getId($this->meta->getEntityId(),$ids[1]));
}
public function __revise($element,$id){
$columnStr = 'set '.implode('=?,',array_keys($element)).' =? ';
$query = 'update '.$this->entityTableName.' '.$columnStr.'where '.
$this->meta->getObectIndexColumn().'=?';
$params = array_values($element);
array_push($params,$id);
$result = null;
$transactionSuccessful = vtws_runQueryAsTransaction($query,$params,$result);
return $transactionSuccessful;
}
public function revise($element){
$ids = vtws_getIdComponents($element["id"]);
$element = DataTransform::sanitizeForInsert($element,$this->meta);
$element = $this->restrictFields($element, true);
$success = $this->__retrieve($ids[1]);
if(!$success){
throw new WebServiceException(WebServiceErrorCode::$RECORDNOTFOUND,
"Record not found");
}
$allDetails = $this->getElement();
foreach ($allDetails as $index=>$value) {
if(!isset($element)){
$element[$index] = $value;
}
}
$success = $this->__revise($element,$ids[1]);
if(!$success){
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
"Database error while performing required operation");
}
return $this->retrieve(vtws_getId($this->meta->getEntityId(),$ids[1]));
}
public function __delete($elemId){
$result = null;
$query = 'delete from '.$this->entityTableName.' where '.
$this->meta->getObectIndexColumn().'=?';
$transactionSuccessful = vtws_runQueryAsTransaction($query,array($elemId),$result);
return $transactionSuccessful;
}
public function delete($id){
$ids = vtws_getIdComponents($id);
$elemId = $ids[1];
$result = null;
$query = 'delete from '.$this->entityTableName.' where '.$this->meta->getObectIndexColumn().'=?';
$transactionSuccessful = vtws_runQueryAsTransaction($query,array($elemId),$result);
if(!$transactionSuccessful){
$success = $this->__delete($elemId);
if(!$success){
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
"Database error while performing required operation");
}
@@ -235,5 +311,10 @@ class VtigerActorOperation extends WebserviceEntityOperation {
return $output;
}
protected function getElement(){
return $this->element;
}
}
?>
@@ -83,6 +83,7 @@ class VtigerCRMActorMeta extends EntityMeta {
$field['tabid'] = null;
$field['fieldid'] = null;
$field['masseditable'] = 0;
$field['presence'] = '0';
return $field;
}
@@ -136,6 +136,27 @@ class VtigerCRMObject{
return !$error;
}
public function revise($element){
global $adb;
$error = false;
$error = $this->read($this->getObjectId());
if($error == false){
return $error;
}
foreach($element as $k=>$v){
$this->instance->column_fields[$k] = $v;
}
$adb->startTransaction();
$this->instance->mode = "edit";
$this->instance->Save($this->getTabName());
$error = $adb->hasFailedTransaction();
$adb->completeTransaction();
return !$error;
}
public function delete($id){
global $adb;
$error = false;
@@ -339,8 +339,7 @@ class VtigerCRMObjectMeta extends EntityMeta {
$this->retrieveMetaForBlock($blockArray);
$this->meta = true;
VTWS_PreserveGlobal::restore('theme');
VTWS_PreserveGlobal::flush();
}
private function retrieveUserHierarchy(){
@@ -358,8 +357,8 @@ class VtigerCRMObjectMeta extends EntityMeta {
$tabid = $this->getTabId();
require('user_privileges/user_privileges_'.$this->user->id.'.php');
if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0){
$sql = "select * from vtiger_field where tabid =? and block in (".generateQuestionMarks($block).") and displaytype in (1,2,3,4) and vtiger_field.presence in (0,2) group by columnname";
$params = array($tabid, $block);
$sql = "select * from vtiger_field where tabid =? and block in (".generateQuestionMarks($block).") and displaytype in (1,2,3,4)";
$params = array($tabid, $block);
}else{
$profileList = getCurrentUserProfileList();
@@ -73,6 +73,27 @@ class VtigerModuleOperation extends WebserviceEntityOperation {
return DataTransform::filterAndSanitize($crmObject->getFields(),$this->meta);
}
public function revise($element){
$ids = vtws_getIdComponents($element["id"]);
$element = DataTransform::sanitizeForInsert($element,$this->meta);
$crmObject = new VtigerCRMObject($this->tabId, true);
$crmObject->setObjectId($ids[1]);
$error = $crmObject->revise($element);
if(!$error){
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,"Database error while performing required operation");
}
$id = $crmObject->getObjectId();
$error = $crmObject->read($id);
if(!$error){
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,"Database error while performing required operation");
}
return DataTransform::filterAndSanitize($crmObject->getFields(),$this->meta);
}
public function delete($id){
$ids = vtws_getIdComponents($id);
$elemid = $ids[1];
@@ -139,6 +160,9 @@ class VtigerModuleOperation extends WebserviceEntityOperation {
$fields = array();
$moduleFields = $this->meta->getModuleFields();
foreach ($moduleFields as $fieldName=>$webserviceField) {
if(((int)$webserviceField->getPresence()) == 1) {
continue;
}
array_push($fields,$this->getDescribeFieldArray($webserviceField));
}
array_push($fields,$this->getIdField($this->meta->getObectIndexColumn()));
@@ -41,6 +41,11 @@ abstract class WebserviceEntityOperation{
"Operation Update is not supported for this entity");
}
public function revise($element){
throw new WebServiceException(WebServiceErrorCode::$OPERATIONNOTSUPPORTED,
"Operation Update is not supported for this entity");
}
public function delete($id){
throw new WebServiceException(WebServiceErrorCode::$OPERATIONNOTSUPPORTED,
"Operation delete is not supported for this entity");
@@ -24,6 +24,7 @@ class WebserviceField{
private $mandatory;
private $massEditable;
private $tabid;
private $presence;
/**
*
* @var PearDatabase
@@ -40,7 +41,7 @@ class WebserviceField{
private $genericUIType = 10;
private function WebserviceField($adb,$row){
private function __construct($adb,$row){
$this->uitype = $row['uitype'];
$this->blockId = $row['block'];
$this->tableName = $row['tablename'];
@@ -50,6 +51,7 @@ class WebserviceField{
$this->displayType = $row['displaytype'];
$this->massEditable = ($row['masseditable'] === 1)? true: false;
$typeOfData = $row['typeofdata'];
$this->presence = $row['presence'];
$this->typeOfData = $typeOfData;
$typeOfData = explode("~",$typeOfData);
$this->mandatory = ($typeOfData[1] == 'M')? true: false;
@@ -291,6 +293,11 @@ class WebserviceField{
return null;
}
}
function getPresence() {
return $this->presence;
}
}
?>
@@ -1,71 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckcontextmenugroup.js
* FCKContextMenuGroup Class: represents a group of items in the context
* menu. Generaly a group of items is directly dependent of the same rules.
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
var FCKContextMenuGroup = function( addSeparator, contextMenu, firstItemCommand, firstItemLabel, hasIcon )
{
this.IsVisible = true ;
// Array with all available context menu items of this group.
this.Items = new Array() ;
if ( addSeparator )
this.Add( new FCKContextMenuSeparator() ) ;
if ( contextMenu && firstItemCommand && firstItemLabel )
this.Add( new FCKContextMenuItem( contextMenu, firstItemCommand, firstItemLabel, hasIcon ) ) ;
// This OPTIONAL function checks if the group must be shown.
this.ValidationFunction = null ;
}
// Adds an item to the group's items collecion.
FCKContextMenuGroup.prototype.Add = function( contextMenuItem )
{
this.Items[ this.Items.length ] = contextMenuItem ;
}
// Creates the <TR> elements that represent the item in a table (usually the rendered context menu).
FCKContextMenuGroup.prototype.CreateTableRows = function( table )
{
for ( var i = 0 ; i < this.Items.length ; i++ )
{
this.Items[i].CreateTableRow( table ) ;
}
}
FCKContextMenuGroup.prototype.SetVisible = function( isVisible )
{
for ( var i = 0 ; i < this.Items.length ; i++ )
{
this.Items[i].SetVisible( isVisible ) ;
}
this.IsVisible = isVisible ;
}
FCKContextMenuGroup.prototype.RefreshState = function()
{
if ( ! this.IsVisible ) return ;
for ( var i = 0 ; i < this.Items.length ; i++ )
{
this.Items[i].RefreshState() ;
}
}
@@ -1,103 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckcontextmenuitem.js
* FCKContextMenuItem Class: represents a item in the context menu.
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
var FCKContextMenuItem = function( contextMenu, commandName, label, hasIcon )
{
this.ContextMenu = contextMenu ;
this.Command = FCKCommands.GetCommand( commandName ) ;
this.Label = label ? label : commandName ;
this.HasIcon = hasIcon ? true : false ;
}
function FCKContextMenuItem_OnMouseOver()
{
if ( this.className != 'CM_Disabled' )
this.className = 'CM_Over' ;
}
function FCKContextMenuItem_OnMouseOut()
{
if ( this.className != 'CM_Disabled' )
this.className = 'CM_Option' ;
}
function FCKContextMenuItem_OnClick()
{
if ( this.className != 'CM_Disabled' )
{
this.FCKContextMenuItem.ContextMenu.Hide() ;
this.FCKContextMenuItem.Command.Execute() ;
}
return false ;
}
FCKContextMenuItem.prototype.CreateTableRow = function( targetTable )
{
// Creates the <TR> element.
this._Row = targetTable.insertRow(-1) ;
this._Row.className = 'CM_Disabled' ;
this._Row.FCKContextMenuItem = this ;
this._Row.onmouseover = FCKContextMenuItem_OnMouseOver ;
this._Row.onmouseout = FCKContextMenuItem_OnMouseOut ;
this._Row.onclick = FCKContextMenuItem_OnClick ;
var oCell = this._Row.insertCell(-1) ;
oCell.className = 'CM_Icon' ;
if ( this.HasIcon ) oCell.innerHTML = '<img alt="" src="' + FCKConfig.SkinPath + 'toolbar/' + this.Command.Name.toLowerCase() + '.gif" width="21" height="20">' ;
oCell = this._Row.insertCell(-1) ;
oCell.className = 'CM_Label' ;
oCell.noWrap = true ;
oCell.innerHTML = this.Label ;
}
FCKContextMenuItem.prototype.SetVisible = function( isVisible )
{
this._Row.style.display = isVisible ? '' : 'none' ;
}
FCKContextMenuItem.prototype.RefreshState = function()
{
switch ( this.Command.GetState() )
{
case FCK_TRISTATE_ON :
case FCK_TRISTATE_OFF :
this._Row.className = 'CM_Option' ;
break ;
default :
this._Row.className = 'CM_Disabled' ;
break ;
}
}
/*
Sample output.
-----------------------------------------
<tr class="CM_Disabled">
<td class="CM_Icon"><img alt="" src="icons/cut.gif" width="21" height="20"></td>
<td class="CM_Label">Cut</td>
</tr>
-----------------------------------------
<tr class="CM_Option" onmouseover="OnOver(this);" onmouseout="OnOut(this);">
<td class="CM_Icon"></td>
<td class="CM_Label">Do Something</td>
</tr>
*/
@@ -1,57 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckcontextmenuseparator.js
* FCKContextMenuSeparator Class: represents a separator in the toolbar.
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
var FCKContextMenuSeparator = function()
{
}
FCKContextMenuSeparator.prototype.CreateTableRow = function( targetTable )
{
// Creates the <TR> element.
this._Row = targetTable.insertRow(-1) ;
this._Row.className = 'CM_Separator' ;
var oCell = this._Row.insertCell(-1) ;
oCell.className = 'CM_Icon' ;
var oDoc = targetTable.ownerDocument || targetTable.document ;
oCell = this._Row.insertCell(-1) ;
oCell.className = 'CM_Label' ;
oCell.appendChild( oDoc.createElement( 'DIV' ) ).className = 'CM_Separator_Line' ;
}
FCKContextMenuSeparator.prototype.SetVisible = function( isVisible )
{
this._Row.style.display = isVisible ? '' : 'none' ;
}
FCKContextMenuSeparator.prototype.RefreshState = function()
{
// Do nothing... its state doesn't change.
}
/*
Sample output.
-----------------------------------------
<tr class="CM_Separator">
<td class="CM_Icon"></td>
<td class="CM_Label"><div></div></td>
</tr>
*/
@@ -1,50 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckevents.js
* FCKEvents Class: used to handle events is a advanced way.
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
var FCKEvents ;
if ( !( FCKEvents = NS.FCKEvents ) )
{
FCKEvents = NS.FCKEvents = function( eventsOwner )
{
this.Owner = eventsOwner ;
this.RegisteredEvents = new Object() ;
}
FCKEvents.prototype.AttachEvent = function( eventName, functionPointer )
{
if ( ! this.RegisteredEvents[ eventName ] ) this.RegisteredEvents[ eventName ] = new Array() ;
this.RegisteredEvents[ eventName ][ this.RegisteredEvents[ eventName ].length ] = functionPointer ;
}
FCKEvents.prototype.FireEvent = function( eventName, params )
{
var bReturnValue = true ;
var oCalls = this.RegisteredEvents[ eventName ] ;
if ( oCalls )
{
for ( var i = 0 ; i < oCalls.length ; i++ )
bReturnValue = ( oCalls[ i ]( this.Owner, params ) && bReturnValue ) ;
}
return bReturnValue ;
}
}
@@ -1,173 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckpanel_gecko.js
* FCKPanel Class: Creates and manages floating panels in Gecko Browsers.
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
var FCKPanel = function( parentWindow )
{
this.IsRTL = false ;
this.IsContextMenu = false ;
this._IsOpened = false ;
if ( parentWindow )
this._Window = parentWindow ;
else
{
this._Window = window ;
while ( this._Window != window.top )
{
// Try/Catch must be used to avoit an error when using a frameset
// on a different domain:
// "Permission denied to get property HTMLDocument.Body".
try
{
if ( this._Window.parent.document.body.tagName == 'FRAMESET' )
break ;
} catch (e) { break ; }
this._Window = this._Window.parent ;
}
}
var oIFrame = this._IFrame = this._Window.document.createElement('iframe') ;
oIFrame.frameBorder = '0';
oIFrame.scrolling = 'no' ;
oIFrame.style.position = 'absolute';
oIFrame.width = oIFrame.height = 0 ;
oIFrame.style.zIndex = FCKConfig.FloatingPanelsZIndex ;
this._Window.document.body.appendChild( oIFrame ) ;
this.Document = oIFrame.contentWindow.document ;
// Initialize the IFRAME document body.
this.Document.open() ;
this.Document.write( '<html><head></head><body><\/body><\/html>' ) ;
this.Document.close() ;
// Remove the default margins.
this.Document.body.style.margin = this.Document.body.style.padding = '0px' ;
this._IFrame.contentWindow.onblur = this.Hide ;
oIFrame.contentWindow.Panel = this ;
// Create the main DIV that is used as the panel base.
this.PanelDiv = this.Document.body.appendChild( this.Document.createElement('DIV') ) ;
this.PanelDiv.className = 'FCK_Panel' ;
this.EnableContextMenu( false ) ;
this.SetDirection( FCKLang.Dir ) ;
}
FCKPanel.prototype.EnableContextMenu = function( enabled )
{
this.Document.oncontextmenu = enabled ? null : FCKTools.CancelEvent ;
}
FCKPanel.prototype.AppendStyleSheet = function( styleSheet )
{
FCKTools.AppendStyleSheet( this.Document, styleSheet ) ;
}
FCKPanel.prototype.SetDirection = function( dir )
{
this.IsRTL = ( dir == 'rtl' ) ;
this.Document.dir = dir ;
// The "float" property must be set so Firefox calculates the size correcly.
this.PanelDiv.style.cssFloat = ( dir == 'rtl' ? 'right' : 'left' ) ;
}
FCKPanel.prototype.Load = function()
{
// This is a IE only need.
}
FCKPanel.prototype.Show = function( x, y, relElement, width, height )
{
this.PanelDiv.style.width = width ? width + 'px' : '' ;
this.PanelDiv.style.height = height ? height + 'px' : '' ;
if ( !width ) this._IFrame.width = 1 ;
if ( !height ) this._IFrame.height = 1 ;
var oPos = FCKTools.GetElementPosition( relElement, this._Window ) ;
x += oPos.X ;
y += oPos.Y ;
if ( this.IsRTL )
{
if ( this.IsContextMenu )
x = x - this.PanelDiv.offsetWidth + 1 ;
else if ( relElement )
x = x + ( relElement.offsetWidth - this.PanelDiv.offsetWidth ) ;
}
else
{
if ( ( x + this.PanelDiv.offsetWidth ) > this._Window.document.body.clientWidth )
x -= x + this.PanelDiv.offsetWidth - this._Window.document.body.clientWidth ;
}
if ( x < 0 )
x = 0 ;
// Set the context menu DIV in the specified location.
this._IFrame.style.left = x + 'px' ;
this._IFrame.style.top = y + 'px' ;
var iWidth = this.PanelDiv.offsetWidth ;
var iHeight = this.PanelDiv.offsetHeight ;
this._IFrame.width = iWidth ;
this._IFrame.height = iHeight ;
// Move the focus to the IFRAME so we catch the "onblur".
this._IFrame.contentWindow.focus() ;
this._IsOpened = true ;
}
FCKPanel.prototype.Hide = function()
{
var oPanel = this.Panel ? this.Panel : this ;
if ( !oPanel._IsOpened )
return ;
// It is better to set the sizes to 0, otherwise Firefox would have
// rendering problems.
oPanel._IFrame.width = oPanel._IFrame.height = 0 ;
if ( oPanel._OnHide )
oPanel._OnHide( oPanel ) ;
oPanel._IsOpened = false ;
}
FCKPanel.prototype.CheckIsOpened = function()
{
return this._IsOpened ;
}
FCKPanel.prototype.AttachToOnHideEvent = function( targetFunction )
{
this._OnHide = targetFunction ;
}
@@ -1,127 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckpanel_ie.js
* FCKPanel Class: Creates and manages floating panels in IE Browsers.
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
var FCKPanel = function( parentWindow )
{
this.IsRTL = false ;
this.IsContextMenu = false ;
this._IsOpened = false ;
this._Window = parentWindow ? parentWindow : window ;
// Create the Popup that will hold the panel.
this._Popup = this._Window.createPopup() ;
this.Document = this._Popup.document ;
// Create the main DIV that is used as the panel base.
this.PanelDiv = this.Document.body.appendChild( this.Document.createElement('DIV') ) ;
this.PanelDiv.className = 'FCK_Panel' ;
this.EnableContextMenu( false ) ;
this.SetDirection( FCKLang.Dir ) ;
}
FCKPanel.prototype.EnableContextMenu = function( enabled )
{
this.Document.oncontextmenu = enabled ? null : FCKTools.CancelEvent ;
}
FCKPanel.prototype.AppendStyleSheet = function( styleSheet )
{
FCKTools.AppendStyleSheet( this.Document, styleSheet ) ;
}
FCKPanel.prototype.SetDirection = function( dir )
{
this.IsRTL = ( dir == 'rtl' ) ;
this.Document.dir = dir ;
}
FCKPanel.prototype.Load = function( x, y, relElement )
{
// The offsetWidth and offsetHeight properties are not available if the
// element is not visible. So we must "show" the popup with no size to
// be able to use that values in the second call.
this._Popup.show( x, y, 0, 0, relElement ) ;
}
FCKPanel.prototype.Show = function( x, y, relElement, width, height )
{
this.Load( x, y, relElement ) ;
// The following lines must be place after the above "show", otherwise it
// doesn't has the desired effect.
this.PanelDiv.style.width = width ? width + 'px' : '' ;
this.PanelDiv.style.height = height ? height + 'px' : '' ;
if ( this.IsRTL )
{
if ( this.IsContextMenu )
x = x - this.PanelDiv.offsetWidth + 1 ;
else if ( relElement )
x = x + ( relElement.offsetWidth - this.PanelDiv.offsetWidth ) ;
}
// Second call: Show the Popup at the specified location, with the correct size.
this._Popup.show( x, y, this.PanelDiv.offsetWidth, this.PanelDiv.offsetHeight, relElement ) ;
if ( this._OnHide )
{
if ( FCKPanel_ActivePopupInfo.Timer )
CheckPopupOnHide() ;
FCKPanel_ActivePopupInfo.Timer = window.setInterval( CheckPopupOnHide, 200 ) ;
FCKPanel_ActivePopupInfo.Panel = this ;
}
this._IsOpened = true ;
}
FCKPanel.prototype.Hide = function()
{
this._Popup.hide() ;
}
FCKPanel.prototype.CheckIsOpened = function()
{
return this._Popup.isOpen ;
}
FCKPanel.prototype.AttachToOnHideEvent = function( targetFunction )
{
this._OnHide = targetFunction ;
}
var FCKPanel_ActivePopupInfo = new Object() ;
function CheckPopupOnHide()
{
var oPanel = FCKPanel_ActivePopupInfo.Panel ;
if ( oPanel && !oPanel._Popup.isOpen )
{
window.clearInterval( FCKPanel_ActivePopupInfo.Timer ) ;
if ( oPanel._OnHide )
oPanel._OnHide( oPanel ) ;
FCKPanel_ActivePopupInfo.Timer = null ;
FCKPanel_ActivePopupInfo.Panel = null ;
}
}
@@ -1,56 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckplugin.js
* FCKPlugin Class: Represents a single plugin.
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
// Certifies that the "PluginsPath" configuration ends with a slash.
if ( !FCKConfig.PluginsPath.endsWith('/') )
FCKConfig.PluginsPath += '/' ;
var FCKPlugin = function( name, availableLangs, basePath )
{
this.Name = name ;
this.BasePath = basePath ? basePath : FCKConfig.PluginsPath ;
this.Path = this.BasePath + name + '/' ;
if ( !availableLangs || availableLangs.length == 0 )
this.AvailableLangs = new Array() ;
else
this.AvailableLangs = availableLangs.split(',') ;
}
FCKPlugin.prototype.Load = function()
{
// Load the language file, if defined.
if ( this.AvailableLangs.length > 0 )
{
var sLang ;
// Check if the plugin has the language file for the active language.
if ( this.AvailableLangs.indexOf( FCKLanguageManager.ActiveLanguage.Code ) >= 0 )
sLang = FCKLanguageManager.ActiveLanguage.Code ;
else
// Load the default language file (first one) if the current one is not available.
sLang = this.AvailableLangs[0] ;
// Add the main plugin script.
FCKScriptLoader.AddScript( this.Path + 'lang/' + sLang + '.js' ) ;
}
// Add the main plugin script.
FCKScriptLoader.AddScript( this.Path + 'fckplugin.js' ) ;
}
File diff suppressed because it is too large Load Diff
@@ -1,55 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckstyledef.js
* FCKStyleDef Class: represents a single stylke definition.
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
var FCKStyleDef = function( name, element )
{
this.Name = name ;
this.Element = element.toUpperCase() ;
this.IsObjectElement = FCKRegexLib.ObjectElements.test( this.Element ) ;
this.Attributes = new Object() ;
}
FCKStyleDef.prototype.AddAttribute = function( name, value )
{
this.Attributes[ name ] = value ;
}
FCKStyleDef.prototype.GetOpenerTag = function()
{
var s = '<' + this.Element ;
for ( var a in this.Attributes )
s += ' ' + a + '="' + this.Attributes[a] + '"' ;
return s + '>' ;
}
FCKStyleDef.prototype.GetCloserTag = function()
{
return '</' + this.Element + '>' ;
}
FCKStyleDef.prototype.RemoveFromSelection = function()
{
if ( FCKSelection.GetType() == 'Control' )
this._RemoveMe( FCKSelection.GetSelectedElement() ) ;
else
this._RemoveMe( FCKSelection.GetParentElement() ) ;
}
@@ -1,107 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckstyledef_gecko.js
* FCKStyleDef Class: represents a single stylke definition. (Gecko specific)
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
FCKStyleDef.prototype.ApplyToSelection = function()
{
if ( FCKSelection.GetType() == 'Text' && !this.IsObjectElement )
{
var oSelection = FCK.EditorWindow.getSelection() ;
// Create the main element.
var e = FCK.EditorDocument.createElement( this.Element ) ;
for ( var i = 0 ; i < oSelection.rangeCount ; i++ )
{
e.appendChild( oSelection.getRangeAt(i).extractContents() ) ;
}
// Set the attributes.
this._AddAttributes( e ) ;
// Remove the duplicated elements.
this._RemoveDuplicates( e ) ;
var oRange = oSelection.getRangeAt(0) ;
oRange.insertNode( e ) ;
}
else
{
var oControl = FCKSelection.GetSelectedElement() ;
if ( oControl.tagName == this.Element )
this._AddAttributes( oControl ) ;
}
}
FCKStyleDef.prototype._AddAttributes = function( targetElement )
{
for ( var a in this.Attributes )
targetElement.setAttribute( a, this.Attributes[a], 0 ) ;
}
FCKStyleDef.prototype._RemoveDuplicates = function( parent )
{
for ( var i = 0 ; i < parent.childNodes.length ; i++ )
{
var oChild = parent.childNodes[i] ;
if ( oChild.nodeType != 1 )
continue ;
this._RemoveDuplicates( oChild ) ;
if ( this.IsEqual( oChild ) )
FCKTools.RemoveOuterTags( oChild ) ;
}
}
FCKStyleDef.prototype.IsEqual = function( e )
{
if ( e.tagName != this.Element )
return false ;
for ( var a in this.Attributes )
{
if ( e.getAttribute( a ) != this.Attributes[a] )
return false ;
}
return true ;
}
FCKStyleDef.prototype._RemoveMe = function( elementToCheck )
{
if ( ! elementToCheck )
return ;
var oParent = elementToCheck.parentNode ;
if ( elementToCheck.nodeType == 1 && this.IsEqual( elementToCheck ) )
{
if ( this.IsObjectElement )
{
for ( var a in this.Attributes )
elementToCheck.removeAttribute( a, 0 ) ;
return ;
}
else
FCKTools.RemoveOuterTags( elementToCheck ) ;
}
this._RemoveMe( oParent ) ;
}
@@ -1,136 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckstyledef_ie.js
* FCKStyleDef Class: represents a single stylke definition. (IE specific)
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
FCKStyleDef.prototype.ApplyToSelection = function()
{
var oSelection = FCK.EditorDocument.selection ;
if ( oSelection.type == 'Text' )
{
var oRange = oSelection.createRange() ;
// Create the main element.
var e = document.createElement( this.Element ) ;
e.innerHTML = oRange.htmlText ;
// Set the attributes.
this._AddAttributes( e ) ;
// Remove the duplicated elements.
this._RemoveDuplicates( e ) ;
// Replace the selection with the resulting HTML.
oRange.pasteHTML( e.outerHTML ) ;
}
else if ( oSelection.type == 'Control' )
{
var oControl = FCKSelection.GetSelectedElement() ;
if ( oControl.tagName == this.Element )
this._AddAttributes( oControl ) ;
}
}
FCKStyleDef.prototype._AddAttributes = function( targetElement )
{
for ( var a in this.Attributes )
{
switch ( a.toLowerCase() )
{
case 'style' :
targetElement.style.cssText = this.Attributes[a] ;
break ;
case 'class' :
targetElement.setAttribute( 'className', this.Attributes[a], 0 ) ;
break ;
default :
targetElement.setAttribute( a, this.Attributes[a], 0 ) ;
}
}
}
FCKStyleDef.prototype._RemoveDuplicates = function( parent )
{
for ( var i = 0 ; i < parent.children.length ; i++ )
{
var oChild = parent.children[i] ;
this._RemoveDuplicates( oChild ) ;
if ( this.IsEqual( oChild ) )
FCKTools.RemoveOuterTags( oChild ) ;
}
}
FCKStyleDef.prototype.IsEqual = function( e )
{
if ( e.tagName != this.Element )
return false ;
for ( var a in this.Attributes )
{
switch ( a.toLowerCase() )
{
case 'style' :
if ( e.style.cssText.toLowerCase() != this.Attributes[a].toLowerCase() )
return false ;
break ;
case 'class' :
if ( e.getAttribute( 'className', 0 ) != this.Attributes[a] )
return false ;
break ;
default :
if ( e.getAttribute( a, 0 ) != this.Attributes[a] )
return false ;
}
}
return true ;
}
FCKStyleDef.prototype._RemoveMe = function( elementToCheck )
{
if ( ! elementToCheck )
return ;
var oParent = elementToCheck.parentElement ;
if ( this.IsEqual( elementToCheck ) )
{
if ( this.IsObjectElement )
{
for ( var a in this.Attributes )
{
switch ( a.toLowerCase() )
{
case 'class' :
elementToCheck.removeAttribute( 'className', 0 ) ;
break ;
default :
elementToCheck.removeAttribute( a, 0 ) ;
}
}
return ;
}
else
FCKTools.RemoveOuterTags( elementToCheck ) ;
}
this._RemoveMe( oParent ) ;
}
@@ -1,84 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckstylesloader.js
* FCKStylesLoader Class: this class define objects that are responsible
* for loading the styles defined in the XML file.
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
var FCKStylesLoader = function()
{
this.Styles = new Object() ;
this.StyleGroups = new Object() ;
this.Loaded = false ;
this.HasObjectElements = false ;
}
FCKStylesLoader.prototype.Load = function( stylesXmlUrl )
{
// Load the XML file into a FCKXml object.
var oXml = new FCKXml() ;
oXml.LoadUrl( stylesXmlUrl ) ;
// Get the "Style" nodes defined in the XML file.
var aStyleNodes = oXml.SelectNodes( 'Styles/Style' ) ;
// Add each style to our "Styles" collection.
for ( var i = 0 ; i < aStyleNodes.length ; i++ )
{
var sElement = aStyleNodes[i].attributes.getNamedItem('element').value.toUpperCase() ;
// Create the style definition object.
var oStyleDef = new FCKStyleDef( aStyleNodes[i].attributes.getNamedItem('name').value, sElement ) ;
if ( oStyleDef.IsObjectElement )
this.HasObjectElements = true ;
// Get the attributes defined for the style (if any).
var aAttNodes = oXml.SelectNodes( 'Attribute', aStyleNodes[i] ) ;
// Add the attributes to the style definition object.
for ( var j = 0 ; j < aAttNodes.length ; j++ )
{
var sAttName = aAttNodes[j].attributes.getNamedItem('name').value ;
var sAttValue = aAttNodes[j].attributes.getNamedItem('value').value ;
// IE changes the "style" attribute value when applied to an element
// so we must get the final resulting value (for comparision issues).
if ( sAttName.toLowerCase() == 'style' )
{
var oTempE = document.createElement( 'SPAN' ) ;
oTempE.style.cssText = sAttValue ;
sAttValue = oTempE.style.cssText ;
}
oStyleDef.AddAttribute( sAttName, sAttValue ) ;
}
// Add the style to the "Styles" collection using it's name as the key.
this.Styles[ oStyleDef.Name ] = oStyleDef ;
// Add the style to the "StyleGroups" collection.
var aGroup = this.StyleGroups[sElement] ;
if ( aGroup == null )
{
this.StyleGroups[sElement] = new Array() ;
aGroup = this.StyleGroups[sElement] ;
}
aGroup[aGroup.length] = oStyleDef ;
}
this.Loaded = true ;
}
@@ -1,61 +0,0 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fcktoolbar.js
* FCKToolbar Class: represents a toolbar. A toolbar is not the complete
* toolbar set visible, but just a strip on it... a group of items.
*
* File Authors:
* Frederico Caldeira Knabben ([email protected])
*/
var FCKToolbar = function()
{
this.Items = new Array() ;
var e = this.DOMTable = document.createElement( 'table' ) ;
e.className = 'TB_Toolbar' ;
// Sets the toolbar direction. IE uses "styleFloat" and Gecko uses "cssFloat".
e.style.styleFloat = e.style.cssFloat = FCKLang.Dir == 'rtl' ? 'right' : 'left' ;
e.cellPadding = 0 ;
e.cellSpacing = 0 ;
e.border = 0 ;
this.DOMRow = e.insertRow(-1) ;
var oCell = this.DOMRow.insertCell(-1) ;
oCell.className = 'TB_Start' ;
oCell.innerHTML = '<img src="' + FCKConfig.SkinPath + 'images/toolbar.start.gif" width="7" height="21" style="VISIBILITY: hidden" onload="this.style.visibility = \'\';">' ;
FCKToolbarSet.DOMElement.appendChild( e ) ;
}
FCKToolbar.prototype.AddItem = function( toolbarItem )
{
this.Items[ this.Items.length ] = toolbarItem ;
toolbarItem.CreateInstance( this ) ;
}
FCKToolbar.prototype.AddSeparator = function()
{
var oCell = this.DOMRow.insertCell(-1) ;
oCell.innerHTML = '<img src="' + FCKConfig.SkinPath + 'images/toolbar.separator.gif" width="5" height="21" style="VISIBILITY: hidden" onload="this.style.visibility = \'\';">' ;
}
FCKToolbar.prototype.AddTerminator = function()
{
var oCell = this.DOMRow.insertCell(-1) ;
oCell.className = 'TB_End' ;
oCell.innerHTML = '<img src="' + FCKConfig.SkinPath + 'images/toolbar.end.gif" width="12" height="21" style="VISIBILITY: hidden" onload="this.style.visibility = \'\';">' ;
}

Some files were not shown because too many files have changed in this diff Show More