本文整理汇总了PHP中Organization::objects方法的典型用法代码示例。如果您正苦于以下问题:PHP Organization::objects方法的具体用法?PHP Organization::objects怎么用?PHP Organization::objects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Organization
的用法示例。
在下文中一共展示了Organization::objects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run($args, $options) {
Bootstrap::connect();
switch ($args['action']) {
case 'import':
if (!$options['file'])
$this->fail('Import CSV file required!');
elseif (!($this->stream = fopen($options['file'], 'rb')))
$this->fail("Unable to open input file [{$options['file']}]");
//Read the header (if any)
if (($data = fgetcsv($this->stream, 1000, ","))) {
if (strcasecmp($data[0], 'name'))
fseek($this->stream, 0); // We don't have an header!
else;
// TODO: process the header here to figure out the columns
// for now we're assuming one column of Name
}
while (($data = fgetcsv($this->stream, 1000, ",")) !== FALSE) {
if (!$data[0])
$this->stderr->write('Invalid data format: Name
required');
elseif (!Organization::fromVars(array('name' => $data[0], 'email')))
$this->stderr->write('Unable to import record: '.print_r($data, true));
}
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'));
foreach (Organization::objects() as $org)
fputcsv($this->stream,
array((string) $org->getName()));
break;
default:
$this->stderr->write('Unknown action!');
}
@fclose($this->stream);
}
示例2: install
//.........这里部分代码省略.........
.', username='.db_input($vars['username'])
.', passwd='.db_input(Passwd::hash($vars['passwd']));
if(!db_query($sql, false) || !($uid=db_insert_id()))
$this->errors['err']=__('Unable to create admin user (#6)');
}
if(!$this->errors) {
//Create default emails!
$email = $vars['email'];
list(,$domain)=explode('@',$vars['email']);
$sql='INSERT INTO '.TABLE_PREFIX.'email (`name`,`email`,`created`,`updated`) VALUES '
." ('Support','$email',NOW(),NOW())"
.",('osTicket Alerts','alerts@$domain',NOW(),NOW())"
.",('','noreply@$domain',NOW(),NOW())";
$support_email_id = db_query($sql, false) ? db_insert_id() : 0;
$sql='SELECT `email_id` FROM '.TABLE_PREFIX."email WHERE `email`='alerts@$domain' LIMIT 1";
$alert_email_id = db_result(db_query($sql, false));
//Create config settings---default settings!
$defaults = array(
'default_email_id'=>$support_email_id,
'alert_email_id'=>$alert_email_id,
'default_dept_id'=>$dept_id_1, 'default_sla_id'=>$sla_id_1,
'default_template_id'=>$template_id_1,
'admin_email'=>$vars['admin_email'],
'schema_signature'=>$streams['core'],
'helpdesk_url'=>URL,
'helpdesk_title'=>$vars['name']);
$config = new Config('core');
if (!$config->updateAll($defaults))
$this->errors['err']=__('Unable to create config settings').' (#7)';
// Set company name
require_once(INCLUDE_DIR.'class.company.php');
$company = new Company();
$company->getForm()->setAnswer('name', $vars['name']);
$company->getForm()->save();
foreach ($streams as $stream=>$signature) {
if ($stream != 'core') {
$config = new Config($stream);
if (!$config->update('schema_signature', $signature))
$this->errors['err']=__('Unable to create config settings').' (#8)';
}
}
}
if($this->errors) return false; //Abort on internal errors.
//Rewrite the config file - MUST be done last to allow for installer recovery.
$configFile= str_replace("define('OSTINSTALLED',FALSE);","define('OSTINSTALLED',TRUE);",$configFile);
$configFile= str_replace('%ADMIN-EMAIL',$vars['admin_email'],$configFile);
$configFile= str_replace('%CONFIG-DBHOST',$vars['dbhost'],$configFile);
$configFile= str_replace('%CONFIG-DBNAME',$vars['dbname'],$configFile);
$configFile= str_replace('%CONFIG-DBUSER',$vars['dbuser'],$configFile);
$configFile= str_replace('%CONFIG-DBPASS',$vars['dbpass'],$configFile);
$configFile= str_replace('%CONFIG-PREFIX',$vars['prefix'],$configFile);
$configFile= str_replace('%CONFIG-SIRI',Misc::randCode(32),$configFile);
if(!$fp || !ftruncate($fp,0) || !fwrite($fp,$configFile)) {
$this->errors['err']=__('Unable to write to config file. Permission denied! (#5)');
return false;
}
@fclose($fp);
/************* Make the system happy ***********************/
$sql='UPDATE '.TABLE_PREFIX."email SET dept_id=$dept_id_1";
db_query($sql, false);
global $cfg;
$cfg = new OsticketConfig();
//Create a ticket to make the system warm and happy.
$errors = array();
$ticket_vars = $i18n->getTemplate('templates/ticket/installed.yaml')
->getData();
$ticket = Ticket::create($ticket_vars, $errors, 'api', false, false);
if ($ticket
&& ($org = Organization::objects()->order_by('id')->one())) {
$user=User::lookup($ticket->getOwnerId());
$user->setOrganization($org);
}
//TODO: create another personalized ticket and assign to admin??
//Log a message.
$msg=__("Congratulations osTicket basic installation completed!\n\nThank you for choosing osTicket!");
$sql='INSERT INTO '.TABLE_PREFIX.'syslog SET created=NOW(), updated=NOW(), log_type="Debug" '
.', title="osTicket installed!"'
.', log='.db_input($msg)
.', ip_address='.db_input($_SERVER['REMOTE_ADDR']);
db_query($sql, false);
return true;
}
示例3: elseif
elseif ($i > 0)
$warn = sprintf(__('%1$d of %2$d %3$s removed'), $i, $count,
_N('selected end user', 'selected end users', $count));
elseif (!$errors['err'])
$errors['err'] = sprintf(__('Unable to remove %s'),
_N('selected end user', 'selected end users', $count));
}
break;
case 'mass_process':
if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {
$errors['err'] = sprintf(__('You must select at least %s.'),
__('one organization'));
}
else {
$orgs = Organization::objects()->filter(
array('id__in' => $_POST['ids'])
);
$count = 0;
switch (strtolower($_POST['do'])) {
case 'delete':
foreach ($orgs as $O)
if ($O->delete())
$count++;
break;
default:
$errors['err']=__('Unknown action - get technical help.');
}
if (!$errors['err'] && !$count) {
$errors['err'] = __('Unable to manage any of the selected organizations');
示例4: count
}
$num = count($_POST['ids']);
if ($i && $i == $num) {
$msg = sprintf(__('Successfully removed %s'), _N('selected end user', 'selected end users', $count));
} elseif ($i > 0) {
$warn = sprintf(__('%1$d of %2$d %3$s removed'), $i, $count, _N('selected end user', 'selected end users', $count));
} elseif (!$errors['err']) {
$errors['err'] = sprintf(__('Unable to remove %s'), _N('selected end user', 'selected end users', $count));
}
}
break;
case 'mass_process':
if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {
$errors['err'] = sprintf(__('You must select at least %s.'), __('one organization'));
} else {
$orgs = Organization::objects()->filter(array('id__in' => $_POST['ids']));
$count = 0;
switch (strtolower($_POST['do'])) {
case 'delete':
foreach ($orgs as $O) {
if ($O->delete()) {
$count++;
}
}
break;
default:
$errors['err'] = __('Unknown action - get technical help.');
}
if (!$errors['err'] && !$count) {
$errors['err'] = __('Unable to manage any of the selected organizations');
} elseif ($_POST['count'] && $count != $_POST['count']) {