本文整理汇总了PHP中Organization::lookup方法的典型用法代码示例。如果您正苦于以下问题:PHP Organization::lookup方法的具体用法?PHP Organization::lookup怎么用?PHP Organization::lookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Organization
的用法示例。
在下文中一共展示了Organization::lookup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run($args, $options) {
Bootstrap::connect();
switch ($args['action']) {
case 'import':
// Properly detect Macintosh style line endings
ini_set('auto_detect_line_endings', true);
if (!$options['file'])
$this->fail('CSV file to import users from is required!');
elseif (!($this->stream = fopen($options['file'], 'rb')))
$this->fail("Unable to open input file [{$options['file']}]");
$extras = array();
if ($options['org']) {
if (!($org = Organization::lookup($options['org'])))
$this->fail($options['org'].': Unknown organization ID');
$extras['org_id'] = $options['org'];
}
$status = User::importCsv($this->stream, $extras);
if (is_numeric($status))
$this->stderr->write("Successfully imported $status clients\n");
else
$this->fail($status);
break;
case 'export':
$stream = $options['file'] ?: 'php://stdout';
if (!($this->stream = fopen($stream, 'c')))
$this->fail("Unable to open output file [{$options['file']}]");
fputcsv($this->stream, array('Name', 'Email'));
foreach (User::objects() as $user)
fputcsv($this->stream,
array((string) $user->getName(), $user->getEmail()));
break;
default:
$this->stderr->write('Unknown action!');
}
@fclose($this->stream);
}
示例2: IndexOldStuff
/**
* Cooperates with the cron system to automatically find content that is
* not index in the _search table and add it to the index.
*/
function IndexOldStuff()
{
$class = get_class();
$auto_create = function ($db_error) use($class) {
if ($db_error != 1146) {
// Perform the standard error handling
return true;
}
// Create the search table automatically
$class::__init();
};
// THREADS ----------------------------------
$sql = "SELECT A1.`id`, A1.`title`, A1.`body`, A1.`format` FROM `" . TICKET_THREAD_TABLE . "` A1\n LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='H')\n WHERE A2.`object_id` IS NULL AND (A1.poster <> 'SYSTEM')\n AND (LENGTH(A1.`title`) + LENGTH(A1.`body`) > 0)\n ORDER BY A1.`id` DESC";
if (!($res = db_query_unbuffered($sql, $auto_create))) {
return false;
}
while ($row = db_fetch_row($res)) {
$body = ThreadBody::fromFormattedText($row[2], $row[3]);
$body = $body->getSearchable();
$title = Format::searchable($row[1]);
if (!$body && !$title) {
continue;
}
$record = array('H', $row[0], $title, $body);
if (!$this->__index($record)) {
return;
}
}
// TICKETS ----------------------------------
$sql = "SELECT A1.`ticket_id` FROM `" . TICKET_TABLE . "` A1\n LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`ticket_id` = A2.`object_id` AND A2.`object_type`='T')\n WHERE A2.`object_id` IS NULL\n ORDER BY A1.`ticket_id` DESC";
if (!($res = db_query_unbuffered($sql, $auto_create))) {
return false;
}
while ($row = db_fetch_row($res)) {
$ticket = Ticket::lookup($row[0]);
$cdata = $ticket->loadDynamicData();
$content = array();
foreach ($cdata as $k => $a) {
if ($k != 'subject' && ($v = $a->getSearchable())) {
$content[] = $v;
}
}
$record = array('T', $ticket->getId(), Format::searchable($ticket->getNumber() . ' ' . $ticket->getSubject()), implode("\n", $content));
if (!$this->__index($record)) {
return;
}
}
// USERS ------------------------------------
$sql = "SELECT A1.`id` FROM `" . USER_TABLE . "` A1\n LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='U')\n WHERE A2.`object_id` IS NULL\n ORDER BY A1.`id` DESC";
if (!($res = db_query_unbuffered($sql, $auto_create))) {
return false;
}
while ($row = db_fetch_row($res)) {
$user = User::lookup($row[0]);
$cdata = $user->getDynamicData();
$content = array();
foreach ($user->emails as $e) {
$content[] = $e->address;
}
foreach ($cdata as $e) {
foreach ($e->getAnswers() as $a) {
if ($c = $a->getSearchable()) {
$content[] = $c;
}
}
}
$record = array('U', $user->getId(), Format::searchable($user->getFullName()), trim(implode("\n", $content)));
if (!$this->__index($record)) {
return;
}
}
// ORGANIZATIONS ----------------------------
$sql = "SELECT A1.`id` FROM `" . ORGANIZATION_TABLE . "` A1\n LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='O')\n WHERE A2.`object_id` IS NULL\n ORDER BY A1.`id` DESC";
if (!($res = db_query_unbuffered($sql, $auto_create))) {
return false;
}
while ($row = db_fetch_row($res)) {
$org = Organization::lookup($row[0]);
$cdata = $org->getDynamicData();
$content = array();
foreach ($cdata as $e) {
foreach ($e->getAnswers() as $a) {
if ($c = $a->getSearchable()) {
$content[] = $c;
}
}
}
$record = array('O', $org->getId(), Format::searchable($org->getName()), trim(implode("\n", $content)));
if (!$this->__index($record)) {
return null;
}
}
// KNOWLEDGEBASE ----------------------------
require_once INCLUDE_DIR . 'class.faq.php';
$sql = "SELECT A1.`faq_id` FROM `" . FAQ_TABLE . "` A1\n LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`faq_id` = A2.`object_id` AND A2.`object_type`='K')\n WHERE A2.`object_id` IS NULL\n ORDER BY A1.`faq_id` DESC";
if (!($res = db_query_unbuffered($sql, $auto_create))) {
//.........这里部分代码省略.........
示例3: updateOrg
function updateOrg($id, $orgId = 0)
{
global $thisstaff;
if (!$thisstaff) {
Http::response(403, 'Login Required');
} elseif (!($user = User::lookup($id))) {
Http::response(404, 'Unknown customer');
}
$info = array();
$info['title'] = 'Organization for ' . Format::htmlchars($user->getName());
$info['action'] = '#users/' . $user->getId() . '/org';
$info['onselect'] = 'ajax.php/users/' . $user->getId() . '/org';
if ($_POST) {
if ($_POST['orgid']) {
//Existing org.
if (!($org = Organization::lookup($_POST['orgid']))) {
$info['error'] = 'Unknown organization selected';
}
} else {
//Creating new org.
$form = OrganizationForm::getDefaultForm()->getForm($_POST);
if (!($org = Organization::fromForm($form))) {
$info['error'] = 'Unable to create organization - try again!';
}
}
if ($org && $user->setOrganization($org)) {
Http::response(201, $org->to_json());
} elseif (!$info['error']) {
$info['error'] = 'Unable to add organization - try again!';
}
} elseif ($orgId) {
$org = Organization::lookup($orgId);
} elseif ($org = $user->getOrganization()) {
$info['title'] = sprintf('%s — %s', Format::htmlchars($user->getName()), 'Organization');
$info['action'] = $info['onselect'] = '';
$tmpl = 'org.tmpl.php';
}
if ($org && $user->getOrgId() && $org->getId() != $user->getOrgId()) {
$info['warning'] = 'Are you sure you want to change customer\'s organization?';
}
$tmpl = $tmpl ?: 'org-lookup.tmpl.php';
ob_start();
include STAFFINC_DIR . "templates/{$tmpl}";
$resp = ob_get_contents();
ob_end_clean();
return $resp;
}
示例4: foreach
if (($acct = $U->getAccount()) && $acct->sendResetEmail()) {
$count++;
}
}
break;
case 'register':
foreach ($users as $U) {
if (($acct = $U->getAccount()) && $acct->sendConfirmEmail()) {
$count++;
} elseif ($acct = UserAccount::register($U, array('sendemail' => true), $errors)) {
$count++;
}
}
break;
case 'setorg':
if (!($org = Organization::lookup($_POST['org_id']))) {
$errors['err'] = __('Unknown action - get technical help.');
}
foreach ($users as $U) {
if ($U->setOrganization($org)) {
$count++;
}
}
break;
default:
$errors['err'] = __('Unknown action - get technical help.');
}
if (!$errors['err'] && !$count) {
$errors['err'] = __('Unable to manage any of the selected end users');
} elseif ($_POST['count'] && $count != $_POST['count']) {
$warn = __('Not all selected items were updated');
示例5: updateForms
function updateForms($org_id)
{
global $thisstaff;
if (!$thisstaff) {
Http::response(403, "Login required");
} elseif (!($org = Organization::lookup($org_id))) {
Http::response(404, "No such ticket");
} elseif (!isset($_POST['forms'])) {
Http::response(422, "Send updated forms list");
}
// Add new forms
$forms = DynamicFormEntry::forOrganization($org_id);
foreach ($_POST['forms'] as $sort => $id) {
$found = false;
foreach ($forms as $e) {
if ($e->get('form_id') == $id) {
$e->set('sort', $sort);
$e->save();
$found = true;
break;
}
}
// New form added
if (!$found && ($new = DynamicForm::lookup($id))) {
$org->addForm($new, $sort);
}
}
// Deleted forms
foreach ($forms as $idx => $e) {
if (!in_array($e->get('form_id'), $_POST['forms'])) {
$e->delete();
}
}
Http::response(201, 'Successfully managed');
}
示例6: fromForm
static function fromForm($form)
{
if (!$form) {
return null;
}
//Validate the form
$valid = true;
if (!$form->isValid()) {
$valid = false;
}
//Make sure the email is not in-use
if (($field = $form->getField('name')) && $field->getClean() && Organization::lookup(array('name' => $field->getClean()))) {
$field->addError('Organization with the same name already exists');
$valid = false;
}
return $valid ? self::fromVars($form->getClean()) : null;
}
示例7: Copyright
Peter Rotich <peter@osticket.com>
Jared Hancock <jared@osticket.com>
Copyright (c) 2006-2014 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require 'staff.inc.php';
require_once INCLUDE_DIR . 'class.note.php';
$org = null;
if ($_REQUEST['id'] || $_REQUEST['org_id']) {
$org = Organization::lookup($_REQUEST['org_id'] ?: $_REQUEST['id']);
}
if ($_POST) {
switch ($_REQUEST['a']) {
case 'import-users':
if (!$org) {
$errors['err'] = 'Organization ID must be specified for import';
break;
}
$status = User::importFromPost($_FILES['import'] ?: $_POST['pasted'], array('org_id' => $org->getId()));
if (is_numeric($status)) {
$msg = "Successfully imported {$status} clients";
} else {
$errors['err'] = $status;
}
break;