当前位置: 首页>>代码示例>>PHP>>正文


PHP Organization::objects方法代码示例

本文整理汇总了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);
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:44,代码来源:org.php

示例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;
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:101,代码来源:class.installer.php

示例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');
开发者ID:KingsleyGU,项目名称:osticket,代码行数:31,代码来源:orgs.php

示例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']) {
开发者ID:gizur,项目名称:osticket,代码行数:31,代码来源:orgs.php


注:本文中的Organization::objects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。