diff --git a/include/Webservices/VtigerCRMObjectMeta.php b/include/Webservices/VtigerCRMObjectMeta.php index 584206ec491e34d4db1f3744d24d6e2c91a303f4..0d35e2b5d0e8a2057c72c0176ce8c40f43252c79 100644 --- a/include/Webservices/VtigerCRMObjectMeta.php +++ b/include/Webservices/VtigerCRMObjectMeta.php @@ -408,7 +408,7 @@ class VtigerCRMObjectMeta extends EntityMeta { ON vtiger_def_org_field.fieldid = vtiger_field.fieldid WHERE vtiger_field.tabid =? AND vtiger_profile2field.visible = 0 AND vtiger_profile2field.profileid IN (". generateQuestionMarks($profileList) .") - AND vtiger_def_org_field.visible = 0 and vtiger_field.block in (".generateQuestionMarks($block).") and vtiger_field.displaytype in (1,2,3,4,5) and vtiger_field.presence in (0,2) group by columnname"; + AND vtiger_def_org_field.visible = 0 and vtiger_field.block in (".generateQuestionMarks($block).") and vtiger_field.displaytype in (1,2,3,4,5,6) and vtiger_field.presence in (0,2) group by columnname"; $params = array($tabid, $profileList, $block); } else { $sql = "SELECT vtiger_field.*, vtiger_profile2field.readonly @@ -419,7 +419,7 @@ class VtigerCRMObjectMeta extends EntityMeta { ON vtiger_def_org_field.fieldid = vtiger_field.fieldid WHERE vtiger_field.tabid=? AND vtiger_profile2field.visible = 0 - AND vtiger_def_org_field.visible = 0 and vtiger_field.block in (".generateQuestionMarks($block).") and vtiger_field.displaytype in (1,2,3,4,5) and vtiger_field.presence in (0,2) group by columnname"; + AND vtiger_def_org_field.visible = 0 and vtiger_field.block in (".generateQuestionMarks($block).") and vtiger_field.displaytype in (1,2,3,4,5,6) and vtiger_field.presence in (0,2) group by columnname"; $params = array($tabid, $block); } } diff --git a/layouts/v7/modules/CustomView/EditView.tpl b/layouts/v7/modules/CustomView/EditView.tpl index 7989206bc688909cf1e788d6d4fc01dc88d66d01..101171e9f6b0cfbe693f769204369d20356ee695 100644 --- a/layouts/v7/modules/CustomView/EditView.tpl +++ b/layouts/v7/modules/CustomView/EditView.tpl @@ -37,7 +37,7 @@ <label>{vtranslate('LBL_VIEW_NAME',$MODULE)} <span class="redColor">*</span> </label> <div class="row"> <div class="col-lg-5"> - <input class="form-control" type="text" id="viewname" name="viewname" value="{$CUSTOMVIEW_MODEL->get('viewname')}" data-rule-required="true"> + <input class="form-control" type="text" id="viewname" name="viewname" value="{$CUSTOMVIEW_MODEL->get('viewname')}" data-rule-required="true" data-record-id="{$RECORD_ID}" data-rule-maxsize="100" data-rule-check-filter-duplicate='{Vtiger_Util_Helper::toSafeHTML(Zend_JSON::encode($CUSTOM_VIEWS_LIST))}'> </div> <div class="col-lg-5"> <label class="checkbox-inline"> diff --git a/layouts/v7/modules/CustomView/resources/CustomView.js b/layouts/v7/modules/CustomView/resources/CustomView.js index e82a8a249a0099bf07ce9f2c025c15cbfe8b9f98..c0b78fcd5d21a2c5188c743d94492136cb4abad8 100644 --- a/layouts/v7/modules/CustomView/resources/CustomView.js +++ b/layouts/v7/modules/CustomView/resources/CustomView.js @@ -153,12 +153,12 @@ jQuery.Class("Vtiger_CustomView_Js",{ var aDeferred = jQuery.Deferred(); var formElement = jQuery("#CustomView"); var formData = formElement.serializeFormData(); - + app.helper.showProgress(); app.request.post({'data':formData}).then( function(error,data){ - if(error === null){ + if(error === null){ app.helper.hideProgress(); window.onbeforeunload = null; aDeferred.resolve(data); @@ -174,26 +174,16 @@ jQuery.Class("Vtiger_CustomView_Js",{ }, saveAndViewFilter : function(){ - this.saveFilter().then( - function(response){ - app.helper.showSuccessNotification({'message':'' }); - var appName = app.getAppName(); + this.saveFilter().then(function (response) { + if (typeof response != "undefined") { + app.helper.showSuccessNotification({'message':app.vtranslate('JS_LIST_SAVED')}); + var appName = app.getAppName(); var url = response['listviewurl']+'&app='+appName; - window.location.href=url; -// } else { -// var params = { -// title: app.vtranslate('JS_DUPLICATE_RECORD'), -// text: response.error['message'] -// }; -// Vtiger_Helper_Js.showPnotify(params); -// } - }, - - function(error) { - + window.location.href = url; + } else { + app.helper.showErrorNotification({message: app.vtranslate('JS_FAILED_TO_SAVE')}); } - - ); + }); }, isAllUsersSelected : function() { diff --git a/layouts/v7/modules/Documents/AddFolder.tpl b/layouts/v7/modules/Documents/AddFolder.tpl index 83c2df7cc8e361755e4944d541f0b452fdf96d72..53dbdbdff53d3ba0760fb833b1f180553304bf12 100644 --- a/layouts/v7/modules/Documents/AddFolder.tpl +++ b/layouts/v7/modules/Documents/AddFolder.tpl @@ -39,7 +39,7 @@ {vtranslate('LBL_FOLDER_DESCRIPTION', $MODULE)} </label> <div class="controls col-sm-9"> - <textarea rows="3" class="inputElement" name="folderdesc" id="description" style="resize: vertical;">{if $FOLDER_DESC neq null}{$FOLDER_DESC}{/if}</textarea> + <textarea rows="3" class="inputElement form-control" name="folderdesc" id="description" style="resize: vertical;">{if $FOLDER_DESC neq null}{$FOLDER_DESC}{/if}</textarea> </div> </div> </div> diff --git a/layouts/v7/modules/Vtiger/ListViewContents.tpl b/layouts/v7/modules/Vtiger/ListViewContents.tpl index 1771522de14d030dfe4a1e58fa667d46ff6736d8..978fc88627a18c4d16398fa312ea6aed9ae158a7 100644 --- a/layouts/v7/modules/Vtiger/ListViewContents.tpl +++ b/layouts/v7/modules/Vtiger/ListViewContents.tpl @@ -12,12 +12,12 @@ {include file="PicklistColorMap.tpl"|vtemplate_path:$MODULE} <div class="col-sm-12 col-xs-12 "> - {if $MODULE neq 'EmailTemplates' && $SEARCH_MODE_RESULTS neq true} - {assign var=LEFTPANELHIDE value=$CURRENT_USER_MODEL->get('leftpanelhide')} - <div class="essentials-toggle" title="{vtranslate('LBL_LEFT_PANEL_SHOW_HIDE', 'Vtiger')}"> - <span class="essentials-toggle-marker fa {if $LEFTPANELHIDE eq '1'}fa-chevron-right{else}fa-chevron-left{/if} cursorPointer"></span> - </div> - {/if} + {if $MODULE neq 'EmailTemplates' && $SEARCH_MODE_RESULTS neq true} + {assign var=LEFTPANELHIDE value=$CURRENT_USER_MODEL->get('leftpanelhide')} + <div class="essentials-toggle" title="{vtranslate('LBL_LEFT_PANEL_SHOW_HIDE', 'Vtiger')}"> + <span class="essentials-toggle-marker fa {if $LEFTPANELHIDE eq '1'}fa-chevron-right{else}fa-chevron-left{/if} cursorPointer"></span> + </div> + {/if} <input type="hidden" name="view" id="view" value="{$VIEW}" /> <input type="hidden" name="cvid" value="{$VIEWID}" /> <input type="hidden" name="pageStartRange" id="pageStartRange" value="{$PAGING_MODEL->getRecordStartRange()}" /> @@ -61,13 +61,28 @@ <input class="listViewEntriesMainCheckBox" type="checkbox"> </span> </div> - {if $MODULE_MODEL->isFilterColumnEnabled()} + {if $MODULE_MODEL->isFilterColumnEnabled()} <div id="listColumnFilterContainer"> - <div class="listColumnFilter {if $CURRENT_CV_MODEL and !($CURRENT_CV_MODEL->isEditable() and $CURRENT_CV_MODEL->isMine())}disabled{/if}" title="{vtranslate('LBL_CLICK_HERE_TO_MANAGE_LIST_COLUMNS',$MODULE)}"> + <div class="listColumnFilter {if $CURRENT_CV_MODEL and !($CURRENT_CV_MODEL->isCvEditable())}disabled{/if}" + {if $CURRENT_CV_MODEL->isCvEditable()} + title="{vtranslate('LBL_CLICK_HERE_TO_MANAGE_LIST_COLUMNS',$MODULE)}" + {else} + {if $CURRENT_CV_MODEL->get('viewname') eq 'All' and !$CURRENT_USER_MODEL->isAdminUser()} + title="{vtranslate('LBL_SHARED_LIST_NON_ADMIN_MESSAGE',$MODULE)}" + {elseif !$CURRENT_CV_MODEL->isMine()} + {assign var=CURRENT_CV_USER_ID value=$CURRENT_CV_MODEL->get('userid')} + {if !Vtiger_Functions::isUserExist($CURRENT_CV_USER_ID)} + {assign var=CURRENT_CV_USER_ID value=Users::getActiveAdminId()} + {/if} + title="{vtranslate('LBL_SHARED_LIST_OWNER_MESSAGE',$MODULE, getUserFullName($CURRENT_CV_USER_ID))}" + {/if} + {/if} + {if $MODULE eq 'Documents'}style="width: 10%;"{/if} + data-toggle="tooltip" data-placement="bottom" data-container="body"> <i class="fa fa-th-large"></i> </div> - </div> - {/if} + </div> + {/if} </div> {elseif $SEARCH_MODE_RESULTS} {vtranslate('LBL_ACTIONS',$MODULE)} @@ -116,14 +131,14 @@ </thead> <tbody class="overflow-y"> {foreach item=LISTVIEW_ENTRY from=$LISTVIEW_ENTRIES name=listview} - {assign var=DATA_ID value=$LISTVIEW_ENTRY->getId()} - {assign var=DATA_URL value=$LISTVIEW_ENTRY->getDetailViewUrl()} - {if $SEARCH_MODE_RESULTS && $LISTVIEW_ENTRY->getModuleName() == "ModComments"} - {assign var=RELATED_TO value=$LISTVIEW_ENTRY->get('related_to_model')} - {assign var=DATA_ID value=$RELATED_TO->getId()} - {assign var=DATA_URL value=$RELATED_TO->getDetailViewUrl()} - {/if} - <tr class="listViewEntries" data-id='{$DATA_ID}' data-recordUrl='{$DATA_URL}&app={$SELECTED_MENU_CATEGORY}' id="{$MODULE}_listView_row_{$smarty.foreach.listview.index+1}" {if $MODULE eq 'Calendar'}data-recurring-enabled='{$LISTVIEW_ENTRY->isRecurringEnabled()}'{/if}> + {assign var=DATA_ID value=$LISTVIEW_ENTRY->getId()} + {assign var=DATA_URL value=$LISTVIEW_ENTRY->getDetailViewUrl()} + {if $SEARCH_MODE_RESULTS && $LISTVIEW_ENTRY->getModuleName() == "ModComments"} + {assign var=RELATED_TO value=$LISTVIEW_ENTRY->get('related_to_model')} + {assign var=DATA_ID value=$RELATED_TO->getId()} + {assign var=DATA_URL value=$RELATED_TO->getDetailViewUrl()} + {/if} + <tr class="listViewEntries" data-id='{$DATA_ID}' data-recordUrl='{$DATA_URL}&app={$SELECTED_MENU_CATEGORY}' id="{$MODULE}_listView_row_{$smarty.foreach.listview.index+1}" {if $MODULE eq 'Calendar'}data-recurring-enabled='{$LISTVIEW_ENTRY->isRecurringEnabled()}'{/if}> <td class = "listViewRecordActions"> {include file="ListViewRecordActions.tpl"|vtemplate_path:$MODULE} </td> diff --git a/layouts/v7/modules/Vtiger/resources/Detail.js b/layouts/v7/modules/Vtiger/resources/Detail.js index 34c4f5fb5c30ebfbef71582ee43b1f64b4268ab6..ce8e8db8e292dcc25f1590c4d4f852a6aaf6d83a 100644 --- a/layouts/v7/modules/Vtiger/resources/Detail.js +++ b/layouts/v7/modules/Vtiger/resources/Detail.js @@ -2104,15 +2104,6 @@ Vtiger.Class("Vtiger_Detail_Js",{ }); }, - registerAddTwitterToRecordEvent : function(elementId){ - jQuery('.searchProfileToolTip').tooltip({'placement': 'top','content':'html'}); - jQuery('#'+elementId).on('click', function(e){ - jQuery('.searchProfileToolTip').tooltip('hide'); - var twitterNameArray = elementId.split("__"); - Vtiger_Detail_Js.saveTwitterHandler(twitterNameArray[1]); - }); - }, - toggleRollupComments : function (e) { e.stopPropagation(); e.preventDefault(); diff --git a/layouts/v7/modules/Vtiger/resources/validation.js b/layouts/v7/modules/Vtiger/resources/validation.js index f34e0fc7e930b3bf8c6ddece57f7cceb5840527a..8904ae4fc19b4d182996de84eefe05f43019e59b 100644 --- a/layouts/v7/modules/Vtiger/resources/validation.js +++ b/layouts/v7/modules/Vtiger/resources/validation.js @@ -271,6 +271,22 @@ jQuery.validator.addMethod("owner", function(value, element, params) { }, jQuery.validator.format("Please enter the correct date") ); +jQuery.validator.addMethod("check-filter-duplicate", function (value, element, params) { + var duplicateExist = false; + var recordId = jQuery(element).data('recordId'); + for (var id in params) { + var filterName = params[id]; + if (recordId != id && filterName.toLowerCase() == value.toLowerCase().trim()) { + duplicateExist = true; + return false; + } + } + if (duplicateExist == false) { + return true; + } + }, jQuery.validator.format(app.vtranslate('JS_VIEW_ALREADY_EXISTS')) +); + jQuery.validator.addMethod("time", function(value, element, params) { if(!value) return true; try { diff --git a/modules/CustomView/models/Record.php b/modules/CustomView/models/Record.php index 1354ea671c2a37285ce772cbae79682738e90546..c2964abdd6c923dd46704d802394c9850d4a86e6 100644 --- a/modules/CustomView/models/Record.php +++ b/modules/CustomView/models/Record.php @@ -150,6 +150,18 @@ class CustomView_Record_Model extends Vtiger_Base_Model { return ($this->get('status') == self::CV_STATUS_PUBLIC || $this->get('status') == self::CV_STATUS_PENDING); } + public function isCvEditable() { + $currentUser = Users_Record_Model::getCurrentUserModel(); + if ($this->get('viewname') == 'All' && !$currentUser->isAdminUser()) { + return false; + } + if ($currentUser->isAdminUser() || $this->isMine()) { + return true; + } + + return false; + } + public function isEditable() { if($this->get('viewname') == 'All') { return false; @@ -1141,9 +1153,10 @@ class CustomView_Record_Model extends Vtiger_Base_Model { */ public function checkDuplicate() { $db = PearDatabase::getInstance(); + $currentUser = Users_Record_Model::getCurrentUserModel(); - $query = "SELECT 1 FROM vtiger_customview WHERE viewname = ? AND entitytype = ?"; - $params = array($this->get('viewname'), $this->getModule()->getName()); + $query = "SELECT 1 FROM vtiger_customview WHERE viewname = ? AND entitytype = ? AND userid = ?"; + $params = array($this->get('viewname'), $this->getModule()->getName(), $currentUser->getId()); $cvid = $this->getId(); if ($cvid) { diff --git a/modules/CustomView/views/EditAjax.php b/modules/CustomView/views/EditAjax.php index 65f47bf3d244f1b8c58929373cff09bd0c3711b0..0814e6303131ab7b92b2b3d72b6befee3aa88287 100644 --- a/modules/CustomView/views/EditAjax.php +++ b/modules/CustomView/views/EditAjax.php @@ -80,6 +80,17 @@ Class CustomView_EditAjax_View extends Vtiger_IndexAjax_View { $viewer->assign('CV_PUBLIC_VALUE', CustomView_Record_Model::CV_STATUS_PUBLIC); $viewer->assign('MODULE_MODEL',$moduleModel); + $allCustomViews = CustomView_Record_Model::getAllByGroup($moduleName); + $allViewNames = array(); + foreach ($allCustomViews as $views) { + foreach ($views as $view) { + if ($currentUserModel->getId() == $view->get('userid')) { + $allViewNames[$view->getId()] = strtolower(vtranslate($view->get('viewname'), $moduleName)); + } + } + } + $viewer->assign('CUSTOM_VIEWS_LIST', $allViewNames); + $customViewSharedMembers = $customViewModel->getMembers(); $listShared = ($customViewModel->get('status') == CustomView_Record_Model::CV_STATUS_PUBLIC) ? true : false; foreach ($customViewSharedMembers as $memberGroupLabel => $membersList) { diff --git a/modules/Vtiger/views/Detail.php b/modules/Vtiger/views/Detail.php index 87eddb907889fe45156c59a1824072f30dab69c0..d84912985707d6468e04f9ff2a21f4b253cb4392 100644 --- a/modules/Vtiger/views/Detail.php +++ b/modules/Vtiger/views/Detail.php @@ -25,8 +25,6 @@ class Vtiger_Detail_View extends Vtiger_Index_View { $this->exposeMethod('showChildComments'); $this->exposeMethod('getActivities'); $this->exposeMethod('showRelatedRecords'); - $this->exposeMethod('showSocialAcitivityView'); - $this->exposeMethod('showAddTwitterHandlerForm'); } function checkPermission(Vtiger_Request $request) { @@ -245,7 +243,6 @@ class Vtiger_Detail_View extends Vtiger_Index_View { "libraries.jquery.ckeditor.adapters.jquery", "modules.Emails.resources.MassEdit", "modules.Vtiger.resources.CkEditor", - "modules.Social.resources.Actions", "~/libraries/jquery/twitter-text-js/twitter-text.js", "libraries.jquery.multiplefileupload.jquery_MultiFile", '~/libraries/jquery/bootstrapswitch/js/bootstrap-switch.min.js', @@ -615,79 +612,6 @@ class Vtiger_Detail_View extends Vtiger_Index_View { return $viewer->view('SummaryWidgets.tpl', $moduleName, 'true'); } - public function showSocialAcitivityView($request) { - $recordId = $request->get('record'); - $moduleName = $request->getModule(); - $authorize = $request->get('authorize'); - if(!$this->record){ - $this->record = Vtiger_DetailView_Model::getInstance($moduleName, $recordId); - } - $recordModel = $this->record->getRecord(); - $twitterModuleModel = Social_Module_Model::getInstance(); - $viewer = $this->getViewer($request); - if($authorize == true) { - $entityName = getEntityName($moduleName, $recordId); - $publicProfiles = $twitterModuleModel->getPublicProfiles($entityName[$recordId]); - // added to log twitter request count - $this->logSocialRequestCount("Search", 1); - $viewer->assign('ASSOCIATE',false); - $viewer->assign('TWEETS',$publicProfiles); - } elseif($recordModel->get('primary_twitter')) { - $viewer->assign('ASSOCIATE',true); - $filter = array('screen_name'=>$recordModel->get('primary_twitter'), 'count'=>'40'); - $details = $twitterModuleModel->getUserTimeLineTweets($filter); - // added to log twitter request count - $this->logSocialRequestCount("Tweets", 1); - $viewer->assign('TWEETS',$details[0]); - $viewer->assign('TWITTERUSERMODEL',$details[1]); - } - - $viewer->assign('PROFILE_NAME', $recordModel->get('primary_twitter')); - $viewer->assign('MODULE_NAME',$moduleName); - $viewer->assign('RECORD_ID',$recordId); - $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel()); - - return $viewer->view('SocialAcitivityView.tpl', 'Social', true); - } - - /** - * Function to get related Records count from this relation - * @param <Vtiger_Request> $request - * @return <Number> Number of record from this relation - */ - public function getTwitterPublicProfiles(Vtiger_Request $request) { - $recordId = $request->get('record'); - $moduleName = $request->getModule(); - $entityName = getEntityName($moduleName, $recordId); - $twitterModuleModel = Social_Module_Model::getInstance(); - $userProfileModel = $twitterModuleModel->getPublicProfiles($entityName[$recordId]); - // added to log twitter request count - $this->logSocialRequestCount("Search", 1); - $viewer = $this->getViewer($request); - $viewer->assign('USER_PROFILE',$userProfileModel); - $viewer->assign('MODULE_NAME',$moduleName); - return $viewer->view('ShowTwitterPublicProfiles.tpl', 'Social', true); - } - - /** - * Function to show add twitter form in the detail view - * @param Vtiger_Request $request - */ - public function showAddTwitterHandlerForm(Vtiger_Request $request) { - $viewer = $this->getViewer($request); - $viewer->assign('MODULE_NAME',$moduleName); - return $viewer->view('ShowAddTwitterHandlerForm.tpl', 'Social', true); - } - - /** - * Function to log twitter request count in database - */ - function logSocialRequestCount($type, $count) { - $db = PearDatabase::getInstance(); - $db->pquery('INSERT INTO vtiger_social_log(date,type,count) VALUES(?,?,?) - ON DUPLICATE KEY UPDATE count = count + ?',array(date('Y-m-d'), $type, $count, $count)); - } - public function getHeaderCss(Vtiger_Request $request) { $headerCssInstances = parent::getHeaderCss($request); $cssFileNames = array( diff --git a/pkg/vtiger/modules/Projects/Project/modules/Project/actions/SaveAjax.php b/pkg/vtiger/modules/Projects/Project/modules/Project/actions/SaveAjax.php index 78aabf0ed7e4cfd60a8bf5eb7be6fb1f5a40f7d7..802005f8b21969d3298fc4272e997eb52f980724 100644 --- a/pkg/vtiger/modules/Projects/Project/modules/Project/actions/SaveAjax.php +++ b/pkg/vtiger/modules/Projects/Project/modules/Project/actions/SaveAjax.php @@ -18,7 +18,6 @@ class Project_SaveAjax_Action extends Vtiger_SaveAjax_Action { public function process(Vtiger_Request $request) { $mode = $request->getMode(); if (!empty($mode)) { - $this->twitterConnector = Social_Module_Model::getTwitterConnector(); echo $this->invokeExposedMethod($mode, $request); return; } else { diff --git a/vtlib/Vtiger/Functions.php b/vtlib/Vtiger/Functions.php index fb79ff449410247794297267dbd564380da73210..f8da7d3190102f6d98077dc82e2f144b9413d45a 100644 --- a/vtlib/Vtiger/Functions.php +++ b/vtlib/Vtiger/Functions.php @@ -1338,6 +1338,16 @@ class Vtiger_Functions { return (self::getUserSpecificTableName($moduleName) == $tableName) ? true : false; } + public static function isUserExist($userId) { + $adb = PearDatabase::getInstance(); + $query = "SELECT 1 FROM vtiger_users WHERE id=? AND deleted=? AND status = ?"; + $result = $adb->pquery($query, array($userId, 0, 'Active')); + if ($adb->num_rows($result) > 0) { + return true; + } else { + return false; + } + } /** * Function to decode JWT web token * @param <string> $id_token