Created
October 9, 2015 22:45
-
-
Save betobaz/60a00befea04e74631e3 to your computer and use it in GitHub Desktop.
SugarCRM: Visibility: Modify SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); | |
class YourVisibilityClass extends SugarVisibility{ | |
protected $bean; | |
public function __construct($bean) | |
{ | |
$this->bean = $bean; | |
$this->module_dir = $this->bean->module_dir; | |
} | |
public function addVisibilityWhereQuery(SugarQuery $sugarQuery, $options = array()) | |
{ | |
global $current_user, $timedate; | |
$aclRole = new ACLRole(); | |
$rolesNames = $aclRole->getUserRoleNames($current_user->id); // | |
$where = null; | |
//$GLOBALS['log']->fatal('Tasks_By_Day_Mobile::addVisibilityWhere:: llamando al where personalizado'.print_r($sugarQuery,true)); | |
if( count($rolesNames) && in_array('Salesman', $rolesNames) ){ | |
$meeting_dateStart = new SugarDateTime(); | |
$meeting_dateEnd = new SugarDateTime(); | |
$dateStart = $timedate->tzUser($meeting_dateStart, $current_user)->setTime('00','00','00')->asDb(); | |
$dateEnd = $timedate->tzUser($meeting_dateEnd, $current_user)->setTime('23','59','59')->asDb(); | |
$sugarQuery->where()->between('date_start', $dateStart, $dateEnd); | |
} | |
//$GLOBALS['log']->fatal("query ".$sugarQuery->compileSql()); | |
return $sugarQuery; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dictionary['Task']['visibility'] = array( | |
"YourVisibilityClass" => true, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment