예제 #1
0
 public static function get($var)
 {
     $return = FALSE;
     if (MEMCACHED_ENABLED) {
         $cache = Cache::Instance();
         $return = $cache->get(array('system_company_settings', $var));
     }
     if (FALSE === $return) {
         //if it's a constant, use that
         $c_var = 'self::' . $var;
         if (defined($c_var)) {
             $return = constant($c_var);
         } else {
             //check for a db-field corresponding to the value. and use that
             $sc = new Systemcompany();
             if (EGS_COMPANY_ID !== 'null' && $sc->isField($var)) {
                 $res = $sc->load(EGS_COMPANY_ID);
                 $return = $sc->{$var};
             } else {
                 //_ indicates a default for a DB-value
                 $c_var = 'self::_' . $var;
                 if (defined($c_var)) {
                     $return = constant($c_var);
                 }
             }
         }
         if (MEMCACHED_ENABLED) {
             $cache->add(array('system_company_settings', $var), $return, 28800);
         }
     }
     return $return;
 }
 public function _new()
 {
     //		$SystemcompanyCollection = new SystemcompanyCollection;
     //		$this->view->set('options',$SystemcompanyCollection->getCompanies());
     //		$user = new User;
     //		$this->view->set('users',$user->getAll());
     $Systemcompany = new Systemcompany();
     $users = $Systemcompany->getNonUsers();
     $system = System::Instance();
     if ($users) {
         $this->view->set('users', $users);
     } elseif (strtolower($system->action) != 'edit') {
         $flash = Flash::Instance();
         $flash->addMessage('All users have been allocated to this company');
         sendBack();
     }
     parent::_new();
 }
예제 #3
0
파일: Publish.php 프로젝트: uzerpllp/uzerp
 public function addUser(&$do, &$errors)
 {
     $systemcompany = new Systemcompany();
     $systemcompany->load($do->usercompanyid);
     if (!is_null($systemcompany->published_username)) {
         $format = new xmlrpcmsg('elgg.user.newUser', array(new xmlrpcval($do->firstname . ' ' . $do->surname, "string"), new xmlrpcval($do->email, "string"), new xmlrpcval($systemcompany->published_username, "string"), new xmlrpcval("person", "string")));
         $client = new xmlrpc_client("_rpc/RPC2.php", "tech2.severndelta.co.uk", 8091);
         $request = $client->send($format);
         if (!$request->faultCode()) {
             $response = $request->value();
             $do->published_username = $response->scalarval();
             $do->save();
         } else {
             $errors[] = "Code: " . $request->faultCode() . " Reason '" . $request->faultString();
             return false;
         }
     } else {
         $errors[] = 'The Company has not been published';
         return false;
     }
     return true;
 }
예제 #4
0
 public function _new()
 {
     parent::_new();
     $ticket = $this->_uses[$this->modeltype];
     if (isset($this->_data['originator_company_id'])) {
         $company = new Company();
         $company->load($this->_data['originator_company_id']);
         $this->view->set('originator_company', $company->name);
         $this->view->set('people', $company->getPeople());
         $this->view->set('email', Ticket::getCompanyEmail($this->_data['originator_company_id']));
     } else {
         $company = new Systemcompany();
         $company->load(EGS_COMPANY_ID);
         $this->view->set('originator_company', $company->company);
         $this->view->set('people', $company->systemcompany->getPeople());
     }
     $ticketreleaseversion = new TicketReleaseVersion();
     $releaseversion_cc = new ConstraintChain();
     $releaseversion_cc->add(new Constraint('status', '<>', $ticketreleaseversion->releasedStatus()));
     if (!$ticket->isLoaded()) {
         $defaults = new TicketConfiguration();
         if (isset($this->_data['originator_company_id'])) {
             $cc = new ConstraintChain();
             $cc->add(new Constraint('company_id', '=', $this->_data['originator_company_id']));
             $defaults->loadBy($cc);
         }
         if (!$defaults->isLoaded()) {
             $cc = new ConstraintChain();
             $cc->add(new Constraint('company_id', '=', EGS_COMPANY_ID));
             $defaults->loadBy($cc);
         }
         if ($defaults->isLoaded()) {
             $this->view->set('client_ticket_status_default', $defaults->client_ticket_status_id);
             $this->view->set('internal_ticket_status_default', $defaults->internal_ticket_status_id);
             $this->view->set('ticket_queue_default', $defaults->ticket_queue_id);
             $this->view->set('ticket_category_default', $defaults->ticket_category_id);
             $this->view->set('client_ticket_severity_default', $defaults->client_ticket_severity_id);
             $this->view->set('internal_ticket_severity_default', $defaults->internal_ticket_severity_id);
             $this->view->set('client_ticket_priority_default', $defaults->client_ticket_priority_id);
             $this->view->set('internal_ticket_priority_default', $defaults->internal_ticket_priority_id);
         }
     }
     if (!empty($this->_data['ticket_release_version_id'])) {
         $ticket->ticket_release_version_id = $this->_data['ticket_release_version_id'];
     }
     if (!is_null($ticket->ticket_release_version_id)) {
         $releaseversion_cc->add(new Constraint('id', '=', $ticket->ticket_release_version_id), 'OR');
     }
     $ticket->belongsTo['release_version']['cc'] = $releaseversion_cc;
 }
예제 #5
0
 private function newRequest(&$data = array(), &$errors = array())
 {
     $config = new TicketConfiguration();
     $companyid = $data['Ticket']['originator_company_id'];
     if (!empty($companyid)) {
         $cc = new ConstraintChain();
         $cc->add(new Constraint('company_id', '=', $companyid));
         $config->loadBy($cc);
     }
     if (!$config->isLoaded()) {
         $sc = new Systemcompany();
         $sc->load($data['Ticket']['usercompanyid']);
         if ($sc->isLoaded()) {
             $cc = new ConstraintChain();
             $cc->add(new Constraint('company_id', '=', $sc->company_id));
             $config->loadBy($cc);
         }
     }
     if ($config->isLoaded()) {
         $data['Ticket']['ticket_category_id'] = $config->ticket_category_id;
         $data['Ticket']['ticket_queue_id'] = $config->ticket_queue_id;
         $data['Ticket']['client_ticket_priority_id'] = $config->client_ticket_priority_id;
         $data['Ticket']['internal_ticket_priority_id'] = $config->internal_ticket_priority_id;
         $data['Ticket']['client_ticket_severity_id'] = $config->client_ticket_severity_id;
         $data['Ticket']['internal_ticket_severity_id'] = $config->internal_ticket_severity_id;
         $data['Ticket']['client_ticket_status_id'] = $config->client_ticket_status_id;
         $data['Ticket']['internal_ticket_status_id'] = $config->internal_ticket_status_id;
     } else {
         //	'TicketCategory' - get default
         $data['Ticket']['ticket_category_id'] = self::getDefault(new TicketCategory());
         //	'TicketQueue' - get default
         $data['Ticket']['ticket_queue_id'] = self::getDefault(new TicketQueue());
         //	'TicketPriority' - get default
         $priority = self::getDefault(new TicketPriority());
         $data['Ticket']['client_ticket_priority_id'] = $priority;
         $data['Ticket']['internal_ticket_priority_id'] = $priority;
         //	'TicketSeverity' - get default
         $severity = self::getDefault(new TicketSeverity());
         $data['Ticket']['client_ticket_severity_id'] = $severity;
         $data['Ticket']['internal_ticket_severity_id'] = $severity;
         //	'TicketStatus' - get default
         $status = self::getDefault(new TicketStatus());
         $data['Ticket']['client_ticket_status_id'] = $status;
         $data['Ticket']['internal_ticket_status_id'] = $status;
     }
     //	'User' - get default assigned to/raised by
     $data['Ticket']['assigned_to'] = '';
     $data['Ticket']['raised_by'] = '';
     //	'Person' - get name of person making request
     $data['Ticket']['originator_person_id'] = '';
     $db = DB::Instance();
     $db->StartTrans();
     $ticket = DataObject::Factory($data['Ticket'], $errors, new Ticket());
     if (count($errors) == 0 && !$ticket->save()) {
         $errors[] = $db->ErrorMsg();
         $errors[] = 'Error saving Ticket';
         $db->FailTrans();
     }
     if (count($errors) == 0) {
         $data['TicketResponse']['ticket_id'] = $ticket->id;
         if (!self::saveResponse($data, $errors)) {
             $errors[] = $db->ErrorMsg();
             $db->FailTrans();
         }
     }
     if (count($errors) == 0 && count($data['attachments']) > 0) {
         if (!self::saveAttachments($data, $db, $errors)) {
             $errors[] = $db->ErrorMsg();
             $db->FailTrans();
         }
     }
     $db->CompleteTrans();
     // Build the response.
     if (count($errors) === 0) {
         self::emailConfirmation($ticket, $data);
         $data['message'] = 'This ticket has been assigned to you.';
         self::notifyQueueOwner($ticket, $data);
     }
     return;
 }