本文整理汇总了PHP中SearchHandler::AddConstraint方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchHandler::AddConstraint方法的具体用法?PHP SearchHandler::AddConstraint怎么用?PHP SearchHandler::AddConstraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchHandler
的用法示例。
在下文中一共展示了SearchHandler::AddConstraint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCompanyEmail
static function getCompanyEmail($company_id)
{
// Get the email address for the company
// Use the first Technical address that is not defined as name TICKET_SUPPORT
// TICKET_SUPPORT is defined in conf/config.php
// If that does not exist, use the main address
$config = Config::Instance();
$contact = '';
$company = new Company();
$company->load($company_id);
$party = $company->party;
$sh = new SearchHandler(new PartyContactMethodCollection(new PartyContactMethod()), false);
$sh->AddConstraint(new Constraint('type', '=', 'E'));
$ticket_support = $config->get('TICKET_SUPPORT');
if (!empty($ticket_support)) {
$sh->AddConstraint(new Constraint('name', '!=', $ticket_support));
}
$party->addSearchHandler('contactmethods', $sh);
$methods = $party->contactmethods;
foreach ($methods as $method) {
if ($method->technical == true) {
// Technical contact favoured above all else
$contact = $method->contact;
break;
}
if ($method->main == true) {
// If no contact yet found and this contact is the main contact, use this instead
$contact = $method->contact;
}
}
return $contact;
}
示例2: RoleCollection
function __construct($getCurrentValues = true)
{
parent::__construct();
$userPreferences = UserPreferences::instance();
$this->setModuleName('contacts');
$roleCollection = new RoleCollection();
$sh = new SearchHandler($roleCollection, false);
$sh->AddConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
$sh->setOrderby('name');
$roleCollection->load($sh);
$roles = array();
foreach ($roleCollection->getContents() as $role) {
$roles[$role->id] = array('value' => $role->id, 'label' => $role->name);
if ($getCurrentValues) {
if (in_array($role->id, $userPreferences->getPreferenceValue('default-read-roles', 'contacts'))) {
$roles[$role->id]['selected'] = true;
}
}
}
$this->registerPreference(array('name' => 'default-read-roles', 'display_name' => 'Default Read Access', 'type' => 'select_multiple', 'data' => $roles, 'default' => array()));
foreach ($roleCollection->getContents() as $role) {
$roles[$role->id] = array('value' => $role->id, 'label' => $role->name);
if ($getCurrentValues) {
if (in_array($role->id, $userPreferences->getPreferenceValue('default-write-roles', 'contacts'))) {
$roles[$role->id]['selected'] = true;
}
}
}
$this->registerPreference(array('name' => 'default-write-roles', 'display_name' => 'Default Write Access', 'type' => 'select_multiple', 'data' => $roles, 'default' => array()));
}
示例3: getallids
function getallids()
{
$personoverview = new PersonCollection($this->_templateobject);
$sh = new SearchHandler($personoverview, false);
$sh->AddConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
$sh->AddConstraint(new Constraint('usernameaccess', '=', EGS_USERNAME));
$sh->setLimit(1);
$return = $personoverview->load($sh);
echo json_encode($return);
exit;
}
示例4: add_response
public function add_response()
{
parent::_new();
$ticket = $this->_uses['Ticket'];
$ticket->load($this->_data['id']);
$ticketResponse = $this->_uses['TicketResponse'];
$ticketResponse->ticket_id = $ticket->id;
$responses = new TicketResponseCollection(new TicketResponse());
$sh = new SearchHandler($responses, false);
$sh->AddConstraint(new Constraint('ticket_id', '=', $ticket->id));
$responses->load($sh);
$this->view->set('responses', $responses->getContents());
}
示例5: sharing
public function sharing($model = '')
{
$flash = Flash::Instance();
if (!$this->checkParams(array('id', 'model'), $flash)) {
sendTo();
}
if (empty($model)) {
$modelname = $this->_data['model'];
} else {
$modelname = $model;
}
$object = $this->_uses[$modelname];
$object->load($this->_data['id']);
// What if 'owner' is not a field on the model?
if ($object->owner != EGS_USERNAME && !isModuleAdmin()) {
// We're not the owner, are we /really/ allowed to read this object?
$objectPermissions = new ObjectRoleCollection();
if ($objectPermissions->getRows($object->id, $object->getTableName(), 'write')->count() == 0) {
if (empty($model)) {
$flash = Flash::Instance();
$flash->addError('You do not have permission to edit this ' . $modelname);
sendTo($this->name, 'view', $this->_data['module'], array('id' => $this->_data['id']));
}
return false;
}
}
$roles = array();
$roleCollection = new RoleCollection();
$sh = new SearchHandler($roleCollection, false);
$sh->AddConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
$roleCollection->load($sh);
// $ObjectRole = new ObjectRole;
$ObjectRole = DataObjectFactory::Factory('ObjectRole');
$writeRoles = $ObjectRole->getRoleID($this->_data['id'], $object->getTableName(), 'write');
if ($writeRoles === false) {
$writeRoles = array();
}
foreach ($roleCollection->getContents() as $role) {
$roles[$role->id]['name'] = $role->name;
if (array_key_exists($role->id, $writeRoles)) {
$roles[$role->id]['selected'] = true;
}
}
$this->view->set('writeRoles', $roles);
// $ObjectRole = new ObjectRole;
$ObjectRole = DataObjectFactory::Factory('ObjectRole');
$readRoles = $ObjectRole->getRoleID($this->_data['id'], $object->getTableName(), 'read');
if ($readRoles === false) {
$readRoles = array();
}
foreach ($roleCollection->getContents() as $role) {
$roles[$role->id]['name'] = $role->name;
if (array_key_exists($role->id, $readRoles)) {
$roles[$role->id]['selected'] = true;
}
}
$this->view->set('readRoles', $roles);
// FIXME: I'm sure this isn't the way this is done
$this->view->set('id', $this->_data['id']);
$this->view->set('model_name', $this->_data['model']);
$this->view->set('model', $object);
return true;
}