本文整理汇总了PHP中DAO_Worker::lookupAgentEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP DAO_Worker::lookupAgentEmail方法的具体用法?PHP DAO_Worker::lookupAgentEmail怎么用?PHP DAO_Worker::lookupAgentEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DAO_Worker
的用法示例。
在下文中一共展示了DAO_Worker::lookupAgentEmail方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _handleImportWorker
private function _handleImportWorker($xml)
{
$settings = CerberusSettings::getInstance();
$logger = DevblocksPlatform::getConsoleLog();
$sFirstName = (string) $xml->first_name;
$sLastName = (string) $xml->last_name;
$sEmail = (string) $xml->email;
$sPassword = (string) $xml->password;
$isSuperuser = (int) $xml->is_superuser;
// Dupe check worker email
if (null != ($worker_id = DAO_Worker::lookupAgentEmail($sEmail))) {
$logger->info('[Importer] Avoiding creating duplicate worker #' . $worker_id . ' (' . $sEmail . ')');
return true;
}
$worker_id = DAO_Worker::create($sEmail, CerberusApplication::generatePassword(8), $sFirstName, $sLastName, '');
DAO_Worker::updateAgent($worker_id, array(DAO_Worker::PASSWORD => $sPassword, DAO_Worker::IS_SUPERUSER => intval($isSuperuser)));
// Address to Worker
DAO_AddressToWorker::assign($sEmail, $worker_id);
DAO_AddressToWorker::update($sEmail, array(DAO_AddressToWorker::IS_CONFIRMED => 1));
$logger->info('[Importer] Imported worker #' . $worker_id . ' (' . $sEmail . ')');
DAO_Worker::clearCache();
return true;
}
示例2: saveWorkerPeekAction
function saveWorkerPeekAction()
{
$translate = DevblocksPlatform::getTranslationService();
$active_worker = CerberusApplication::getActiveWorker();
if (!$active_worker || !$active_worker->is_superuser || DEMO_MODE) {
return;
}
@($id = DevblocksPlatform::importGPC($_POST['id'], 'integer'));
@($view_id = DevblocksPlatform::importGPC($_POST['view_id'], 'string'));
@($first_name = DevblocksPlatform::importGPC($_POST['first_name'], 'string'));
@($last_name = DevblocksPlatform::importGPC($_POST['last_name'], 'string'));
@($title = DevblocksPlatform::importGPC($_POST['title'], 'string'));
@($email = DevblocksPlatform::importGPC($_POST['email'], 'string'));
@($password = DevblocksPlatform::importGPC($_POST['password'], 'string'));
@($is_superuser = DevblocksPlatform::importGPC($_POST['is_superuser'], 'integer', 0));
@($disabled = DevblocksPlatform::importGPC($_POST['is_disabled'], 'integer', 0));
@($group_ids = DevblocksPlatform::importGPC($_POST['group_ids'], 'array'));
@($group_roles = DevblocksPlatform::importGPC($_POST['group_roles'], 'array'));
@($delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0));
// [TODO] The superuser set bit here needs to be protected by ACL
if (empty($first_name)) {
$first_name = "Anonymous";
}
if (!empty($id) && !empty($delete)) {
// Can't delete or disable self
if ($active_worker->id != $id) {
DAO_Worker::deleteAgent($id);
}
} else {
if (empty($id) && null == DAO_Worker::lookupAgentEmail($email)) {
$workers = DAO_Worker::getAll();
$license = CerberusLicense::getInstance();
if (!empty($license) && !empty($license['serial']) || count($workers) < 3) {
// Creating new worker. If password is empty, email it to them
if (empty($password)) {
$settings = DevblocksPlatform::getPluginSettingsService();
$replyFrom = $settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_FROM);
$replyPersonal = $settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_PERSONAL, '');
$url = DevblocksPlatform::getUrlService();
$password = CerberusApplication::generatePassword(8);
try {
$mail_service = DevblocksPlatform::getMailService();
$mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults());
$mail = $mail_service->createMessage();
$mail->setTo(array($email => $first_name . ' ' . $last_name));
$mail->setFrom(array($replyFrom => $replyPersonal));
$mail->setSubject('Your new helpdesk login information!');
$mail->generateId();
$headers = $mail->getHeaders();
$headers->addTextHeader('X-Mailer', 'Cerberus Helpdesk (Build ' . APP_BUILD . ')');
$body = sprintf("Your new helpdesk login information is below:\r\n" . "\r\n" . "URL: %s\r\n" . "Login: %s\r\n" . "Password: %s\r\n" . "\r\n" . "You should change your password from Preferences after logging in for the first time.\r\n" . "\r\n", $url->write('', true), $email, $password);
$mail->setBody($body);
if (!$mailer->send($mail)) {
throw new Exception('Password notification email failed to send.');
}
} catch (Exception $e) {
// [TODO] need to report to the admin when the password email doesn't send. The try->catch
// will keep it from killing php, but the password will be empty and the user will never get an email.
}
}
$id = DAO_Worker::create($email, $password, '', '', '');
}
}
// end create worker
// Update
$fields = array(DAO_Worker::FIRST_NAME => $first_name, DAO_Worker::LAST_NAME => $last_name, DAO_Worker::TITLE => $title, DAO_Worker::EMAIL => $email, DAO_Worker::IS_SUPERUSER => $is_superuser, DAO_Worker::IS_DISABLED => $disabled);
// if we're resetting the password
if (!empty($password)) {
$fields[DAO_Worker::PASSWORD] = md5($password);
}
// Update worker
DAO_Worker::updateAgent($id, $fields);
// Update group memberships
if (is_array($group_ids) && is_array($group_roles)) {
foreach ($group_ids as $idx => $group_id) {
if (empty($group_roles[$idx])) {
DAO_Group::unsetTeamMember($group_id, $id);
} else {
DAO_Group::setTeamMember($group_id, $id, 2 == $group_roles[$idx]);
}
}
}
// Add the worker e-mail to the addresses table
if (!empty($email)) {
DAO_Address::lookupAddress($email, true);
}
// Addresses
if (null == DAO_AddressToWorker::getByAddress($email)) {
DAO_AddressToWorker::assign($email, $id);
DAO_AddressToWorker::update($email, array(DAO_AddressToWorker::IS_CONFIRMED => 1));
}
// Custom field saves
@($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array()));
DAO_CustomFieldValue::handleFormPost(ChCustomFieldSource_Worker::ID, $id, $field_ids);
}
if (!empty($view_id)) {
$view = C4_AbstractViewLoader::getView($view_id);
$view->render();
}
//DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config','workers')));
//.........这里部分代码省略.........
示例3: authenticate
function authenticate($params = array())
{
$server = $params['server'];
$port = $params['port'];
$dn = $params['dn'];
$password = $params['password'];
$worker_id = null;
// attempt login
$conn = ldap_connect($server, $port);
ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($conn) {
$auth = ldap_bind($conn, $dn, $password);
if ($auth) {
// search for this user
$search_results = ldap_search($conn, $dn, '(objectclass=*)', array('mail'));
if ($search_results) {
$user_entry = ldap_first_entry($conn, $search_results);
if ($user_entry) {
// get email addresses for this user
$emails = ldap_get_values($conn, $user_entry, 'mail');
if ($emails) {
foreach ($emails as $email) {
if (is_null($worker_id)) {
$worker_id = DAO_Worker::lookupAgentEmail($email);
}
}
}
}
}
}
}
// we found a worker, continue login
if (!is_null($worker_id)) {
$worker = DAO_Worker::getAgent($worker_id);
$session = DevblocksPlatform::getSessionService();
$visit = new CerberusVisit();
$visit->setWorker($worker);
$session->setVisit($visit);
return true;
} else {
return false;
}
}
示例4: doRecoverStep3Action
function doRecoverStep3Action()
{
@($password = DevblocksPlatform::importGPC($_REQUEST['password'], 'string'));
$email = $_SESSION[self::KEY_FORGOT_EMAIL];
$sentcode = $_SESSION[self::KEY_FORGOT_SENTCODE];
$code = $_SESSION[self::KEY_FORGOT_CODE];
$worker_id = DAO_Worker::lookupAgentEmail($email);
if (empty($email) || empty($code) || empty($worker_id)) {
return;
}
if (0 == strcmp($sentcode, $code)) {
// passed
DAO_Worker::updateAgent($worker_id, array(DAO_Worker::PASSWORD => md5($password)));
unset($_SESSION[self::KEY_FORGOT_EMAIL]);
unset($_SESSION[self::KEY_FORGOT_CODE]);
unset($_SESSION[self::KEY_FORGOT_SENTCODE]);
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login')));
} else {
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login', 'forgot', 'step2')));
}
}
示例5: array
$support_spam_bid = DAO_Bucket::create('Spam', $support_gid);
DAO_GroupSettings::set($support_gid, DAO_GroupSettings::SETTING_SPAM_ACTION, '2');
DAO_GroupSettings::set($support_gid, DAO_GroupSettings::SETTING_SPAM_ACTION_PARAM, $support_spam_bid);
DAO_GroupSettings::set($support_gid, DAO_GroupSettings::SETTING_SPAM_THRESHOLD, '85');
// Sales Group
$sales_gid = DAO_Group::createTeam(array(DAO_Group::TEAM_NAME => 'Sales'));
// Sales Spam Bucket
$sales_spam_bid = DAO_Bucket::create('Spam', $sales_gid);
DAO_GroupSettings::set($sales_gid, DAO_GroupSettings::SETTING_SPAM_ACTION, '2');
DAO_GroupSettings::set($sales_gid, DAO_GroupSettings::SETTING_SPAM_ACTION_PARAM, $sales_spam_bid);
DAO_GroupSettings::set($sales_gid, DAO_GroupSettings::SETTING_SPAM_THRESHOLD, '85');
// Default catchall
DAO_Group::updateTeam($dispatch_gid, array(DAO_Group::IS_DEFAULT => 1));
}
// If this worker doesn't exist, create them
if (null === ($lookup = DAO_Worker::lookupAgentEmail($worker_email))) {
$worker_id = DAO_Worker::create($worker_email, $worker_pass, 'Super', 'User', 'Administrator');
// Superuser bit
$fields = array(DAO_Worker::IS_SUPERUSER => 1);
DAO_Worker::updateAgent($worker_id, $fields);
// Add the worker e-mail to the addresses table
if (!empty($worker_email)) {
DAO_Address::lookupAddress($worker_email, true);
}
// Authorize this e-mail address (watchers, etc.)
DAO_AddressToWorker::assign($worker_email, $worker_id);
DAO_AddressToWorker::update($worker_email, array(DAO_AddressToWorker::IS_CONFIRMED => 1));
// Default group memberships
if (!empty($dispatch_gid)) {
DAO_Group::setTeamMember($dispatch_gid, $worker_id, true);
}
示例6: newTicketComment
private function newTicketComment($event)
{
DevblocksPlatform::getExtensions('cerberusweb.ticket.tab', true);
// ticket_comment.id
@($comment_id = $event->params['comment_id']);
// Event context
@($context = $event->params['context']);
// ticket.id if context == ticket.
@(${$ticket_id} = $event->params['context_id']);
@($address_id = $event->params['address_id']);
// text of actual comment.
@($comment_text = $event->params['comment']);
if (CerberusContexts::CONTEXT_TICKET != $context) {
return;
}
if (empty($ticket_id) || empty($address_id) || empty($comment_text)) {
return;
}
$settings = DevblocksPlatform::getPluginSettingsService();
$al_merge_enabled = intval($settings->get('cerb5blog.last_action_and_audit_log', 'al_merge_enabled', 0));
if (class_exists('DAO_TicketAuditLog', true)) {
$al_comment_enabled = intval($settings->get('cerb5blog.last_action_and_audit_log', 'al_comment_enabled', 0));
if ($al_comment_enabled) {
@($address = DAO_Address::get($address_id));
@($worker_id = DAO_Worker::lookupAgentEmail($address->email));
$fields = array(DAO_TicketAuditLog::TICKET_ID => $ticket_id, DAO_TicketAuditLog::WORKER_ID => $worker_id, DAO_TicketAuditLog::CHANGE_DATE => time(), DAO_TicketAuditLog::CHANGE_FIELD => "cerb5blog.last_action_and_audit_log.type.comment", DAO_TicketAuditLog::CHANGE_VALUE => substr($comment_text, 0, 128));
$log_id = DAO_TicketAuditLog::create($fields);
unset($fields);
}
}
$uf_comment_enabled = intval($settings->get('cerb5blog.last_action_and_audit_log', 'uf_comment_enabled', 0));
if ($uf_comment_enabled) {
$change_fields[DAO_Ticket::UPDATED_DATE] = time();
DAO_Ticket::update($ticket_id, $change_fields);
unset($change_fields);
}
}
示例7: newTicketComment
private function newTicketComment($event)
{
DevblocksPlatform::getExtensions('cerberusweb.ticket.tab', true);
// ticket_comment.id
@($comment_id = $event->params['comment_id']);
// ticket.id
@($ticket_id = $event->params['ticket_id']);
// address.id
@($address_id = $event->params['address_id']);
// text of actual comment.
@($comment_text = $event->params['comment']);
if (empty($ticket_id) || empty($address_id) || empty($comment_text)) {
return;
}
$setting_manifest = DevblocksPlatform::getExtension(AnswernetLastActionAndAuditLogConfigTab::ID);
$setting = $setting_manifest->createInstance();
/* @var $job CerberusCronPageExtension */
$al_comment_enabled = intval($setting->getParam(AnswernetLastActionAndAuditLogConfigTab::AL_COMMENT_ENABLED, 0));
$uf_comment_enabled = intval($setting->getParam(AnswernetLastActionAndAuditLogConfigTab::UF_COMMENT_ENABLED, 0));
if (class_exists('DAO_TicketAuditLog', true)) {
if ($al_comment_enabled) {
@($address = DAO_Address::get($address_id));
@($worker_id = DAO_Worker::lookupAgentEmail($address->email));
$fields = array(DAO_TicketAuditLog::TICKET_ID => $ticket_id, DAO_TicketAuditLog::WORKER_ID => $worker_id, DAO_TicketAuditLog::CHANGE_DATE => time(), DAO_TicketAuditLog::CHANGE_FIELD => "answernet.last_action_and_audit_log.type.comment", DAO_TicketAuditLog::CHANGE_VALUE => substr($comment_text, 0, 128));
$log_id = DAO_TicketAuditLog::create($fields);
unset($fields);
}
}
if ($uf_comment_enabled) {
$change_fields[DAO_Ticket::UPDATED_DATE] = time();
DAO_Ticket::updateTicket($ticket_id, $change_fields);
unset($change_fields);
}
}