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


PHP midcom_connection::get_user方法代码示例

本文整理汇总了PHP中midcom_connection::get_user方法的典型用法代码示例。如果您正苦于以下问题:PHP midcom_connection::get_user方法的具体用法?PHP midcom_connection::get_user怎么用?PHP midcom_connection::get_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在midcom_connection的用法示例。


在下文中一共展示了midcom_connection::get_user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _handler_edit

 /**
  * Handle the request for editing contact list
  *
  * @param String $handler_id    Name of the request handler
  * @param array $args           Variable arguments
  * @param array &$data          Public request data, passed by reference
  */
 public function _handler_edit($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     // Get the current user
     $this->_person = new midcom_db_person(midcom_connection::get_user());
     $this->_person->require_do('midgard:update');
     // Load the controller
     $data['controller'] = $this->get_controller('simple', $this->_person);
     // Process the form
     switch ($data['controller']->process_form()) {
         case 'save':
         case 'cancel':
             if (isset($_GET['org_openpsa_calendar_returnurl'])) {
                 $url = $_GET['org_openpsa_calendar_returnurl'];
             } else {
                 $url = '';
             }
             return new midcom_response_relocate($url);
     }
     // Add the breadcrumb pieces
     if (isset($_GET['org_openpsa_calendar_returnurl'])) {
         $this->add_breadcrumb($_GET['org_openpsa_calendar_returnurl'], $this->_l10n->get('calendar'));
     }
     $this->add_breadcrumb('filters/', $this->_l10n->get('choose calendars'));
 }
开发者ID:nemein,项目名称:openpsa,代码行数:32,代码来源:filters.php

示例2: _on_creating

 public function _on_creating()
 {
     $this->_locale_set();
     $this->orgOpenpsaObtype = ORG_OPENPSA_OBTYPE_TASK;
     if (!$this->manager) {
         $this->manager = midcom_connection::get_user();
     }
     return $this->_prepare_save();
 }
开发者ID:nemein,项目名称:openpsa,代码行数:9,代码来源:task.php

示例3: initialize_index_article

 public static function initialize_index_article($topic)
 {
     $page = new net_nemein_wiki_wikipage();
     $page->topic = $topic->id;
     $page->name = 'index';
     $page->title = $topic->extra;
     $page->content = midcom::get('i18n')->get_string('wiki default page content', 'net.nemein.wiki');
     $page->author = midcom_connection::get_user();
     if ($page->create()) {
         return $page;
     }
     return false;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:13,代码来源:viewer.php

示例4: _create_article

 /**
  * DM2 creation callback, binds to the current content topic.
  */
 private function _create_article($title)
 {
     $this->_article = new midcom_db_article();
     $author = $this->_find_email_person($this->_request_data['from']);
     if (!$author) {
         debug_add("Author '{$this->_request_data['from']}' not found", MIDCOM_LOG_WARN);
         if ($this->_config->get('api_email_abort_authornotfound') !== false) {
             throw new midcom_error("Author '{$this->_request_data['from']}' not found");
         }
         $this->_article->author = midcom_connection::get_user();
     } else {
         // TODO: This code needs a bit of rethinking
         $author_user = midcom::get('auth')->get_user($author->guid);
         if (!$this->_content_topic->can_do('midgard:create', $author_user)) {
             throw new midcom_error('Author doesn\'t have posting privileges');
         }
         $this->_article->author = $author->id;
     }
     //Default to first user in DB if author is not set
     if (!$this->_article->author) {
         $qb = midcom_db_person::new_query_builder();
         $qb->add_constraint('username', '<>', '');
         $qb->set_limit(1);
         $results = $qb->execute();
         unset($qb);
         if (empty($results)) {
             //No users found
             throw new midcom_error('Cannot set any author for the article');
         }
         $this->_article->author = $results[0]->id;
     }
     $resolver = new midcom_helper_reflector_nameresolver($this->_article);
     $this->_article->topic = $this->_content_topic->id;
     $this->_article->title = $title;
     $this->_article->allow_name_catenate = true;
     $this->_article->name = $resolver->generate_unique_name('title');
     if (empty($this->_article->name)) {
         debug_add('Could not generate unique name for the new article from title, using timestamp', MIDCOM_LOG_INFO);
         $this->_article->name = time();
         $resolver = new midcom_helper_reflector_nameresolver($this->_article);
         if (!$resolver->name_is_unique()) {
             throw new midcom_error('Failed to create unique name for the new article, aborting.');
         }
     }
     if (!$this->_article->create()) {
         debug_print_r('Failed to create article:', $this->_article);
         throw new midcom_error('Failed to create a new article. Last Midgard error was: ' . midcom_connection::get_error_string());
     }
     $this->_article->parameter('midcom.helper.datamanager2', 'schema_name', $this->_config->get('api_email_schema'));
     return true;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:54,代码来源:email.php

示例5: _load_create_controller

 /**
  * Internal helper, fires up the creation mode controller. Any error triggers a 500.
  */
 private function _load_create_controller()
 {
     $this->_defaults['task'] = $this->_request_data['task'];
     $this->_defaults['person'] = midcom_connection::get_user();
     $this->_defaults['date'] = time();
     $this->_controller = midcom_helper_datamanager2_controller::create('create');
     $this->_controller->schemadb =& $this->_schemadb;
     $this->_controller->schemaname = $this->_schema;
     $this->_controller->defaults = $this->_defaults;
     $this->_controller->callback_object =& $this;
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 create controller.");
     }
 }
开发者ID:nemein,项目名称:openpsa,代码行数:17,代码来源:admin.php

示例6: testLogin

 public function testLogin()
 {
     $auth = midcom::get('auth');
     $stat = $auth->login(self::$_username, self::$_password);
     $this->assertTrue($stat);
     $auth->_sync_user_with_backend();
     $this->assertTrue($auth->is_valid_user());
     $user = $auth->user;
     $this->assertTrue($user instanceof midcom_core_user);
     $this->assertEquals(self::$_person->guid, $user->guid);
     $this->assertEquals(self::$_person->id, midcom_connection::get_user());
     $auth->logout();
     $this->assertTrue(is_null($auth->user));
     $this->assertFalse($auth->is_valid_user());
 }
开发者ID:nemein,项目名称:openpsa,代码行数:15,代码来源:loginTest.php

示例7: _prepare_save

 private function _prepare_save()
 {
     //Make sure our hours property is a float
     $this->hours = (double) $this->hours;
     $this->hours = round($this->hours, 2);
     //Make sure date is set
     if (!$this->date) {
         $this->date = time();
     }
     //Make sure person is set
     if (!$this->person) {
         $this->person = midcom_connection::get_user();
     }
     return true;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:15,代码来源:report.php

示例8: net_nemein_wiki_wikipage

 /**
  * DM2 creation callback, binds to the current content topic.
  */
 public function &dm2_create_callback(&$controller)
 {
     $this->_page = new net_nemein_wiki_wikipage();
     $this->_page->topic = $this->_topic->id;
     $this->_page->title = $this->_wikiword;
     $this->_page->author = midcom_connection::get_user();
     // We can clear the session now
     $this->_request_data['session']->remove('wikiword');
     if (!$this->_page->create()) {
         debug_print_r('We operated on this object:', $this->_page);
         throw new midcom_error('Failed to create a new page. Last Midgard error was: ' . midcom_connection::get_error_string());
     }
     $this->_page = new net_nemein_wiki_wikipage($this->_page->id);
     return $this->_page;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:18,代码来源:create.php

示例9: _prepare_save

 private function _prepare_save()
 {
     //Make sure date is set
     if (!$this->date) {
         $this->date = time();
     }
     //Make sure person is set
     if (!$this->person) {
         $this->person = midcom_connection::get_user();
     }
     //Is task is not set abort
     if (!$this->task) {
         return false;
     }
     return true;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:16,代码来源:expense.php

示例10: _list_work_hours

 /**
  * Function to list invoiceable and uninvoicable hours
  */
 private function _list_work_hours()
 {
     $hours_mc = org_openpsa_projects_hour_report_dba::new_collector('person', midcom_connection::get_user());
     $hours_mc->add_value_property('task');
     $hours_mc->add_value_property('invoiceable');
     $hours_mc->add_value_property('hours');
     $hours_mc->add_constraint('date', '>=', $this->_request_data['week_start']);
     $hours_mc->add_constraint('date', '<=', $this->_request_data['week_end']);
     $hours_mc->execute();
     $hours = $hours_mc->list_keys();
     $this->_request_data['customers'] = array();
     $this->_request_data['hours'] = array('invoiceable' => array(), 'uninvoiceable' => array(), 'total_invoiceable' => 0, 'total_uninvoiceable' => 0);
     foreach ($hours as $guid => $values) {
         $this->_add_hour_data($hours_mc->get($guid));
     }
     return true;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:20,代码来源:workingon.php

示例11: _handler_view

 /**
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_view($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     $this->_person = new org_openpsa_contacts_person_dba($args[0]);
     $data['view'] = midcom_helper_datamanager2_handler::get_view_controller($this, $this->_person);
     $this->add_breadcrumb('', $this->_person->get_label());
     $auth = midcom::get('auth');
     if ($this->_person->id == midcom_connection::get_user() || $auth->can_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface')) {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "edit/{$this->_person->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get("edit"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_person->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e'));
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "delete/{$this->_person->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get("delete"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $this->_person->can_do('midgard:delete')));
         if (midcom_connection::is_user($this->_person)) {
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "privileges/{$this->_person->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("permissions"), MIDCOM_TOOLBAR_ICON => 'midgard.admin.asgard/permissions-16.png', MIDCOM_TOOLBAR_ENABLED => $this->_person->can_do('midgard:privileges')));
         }
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "person/notifications/{$this->_person->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("notification settings"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock-discussion.png', MIDCOM_TOOLBAR_ENABLED => $this->_person->can_do('midgard:update')));
     }
     $this->bind_view_to_object($this->_person);
 }
开发者ID:nemein,项目名称:openpsa,代码行数:22,代码来源:view.php

示例12: _generate_invoice

 private function _generate_invoice()
 {
     $invoice = new org_openpsa_invoices_invoice_dba();
     $invoice->customer = (int) $_POST['org_openpsa_invoices_invoice_customer'];
     $invoice->number = $invoice->generate_invoice_number();
     $invoice->owner = midcom_connection::get_user();
     $invoice->vat = $invoice->get_default('vat');
     $invoice->description = $invoice->get_default('remarks');
     if (!$invoice->create()) {
         midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.invoices'), $this->_l10n->get('failed to create invoice, reason ') . midcom_connection::get_error_string(), 'error');
         return false;
     }
     // create invoice_items
     foreach ($_POST['org_openpsa_invoices_invoice_tasks'] as $task_id => $invoiceable) {
         if (!$invoiceable) {
             continue;
         }
         $task = $this->_tasks[$task_id];
         //instance the invoice_items
         $item = new org_openpsa_invoices_invoice_item_dba();
         $item->task = $task_id;
         try {
             $deliverable = org_openpsa_sales_salesproject_deliverable_dba::get_cached($task->agreement);
             $item->deliverable = $deliverable->id;
         } catch (midcom_error $e) {
             $e->log();
         }
         $item->invoice = $invoice->id;
         $item->description = $task->title;
         $item->pricePerUnit = (double) $_POST['org_openpsa_invoices_invoice_tasks_price'][$task_id];
         $item->units = (double) $_POST['org_openpsa_invoices_invoice_tasks_units'][$task_id];
         $item->create();
         // Connect invoice to the tasks involved
         org_openpsa_projects_workflow::mark_invoiced($task, $invoice);
     }
     // Generate "Send invoice" task
     $invoice_sender_guid = $this->_config->get('invoice_sender');
     if (!empty($invoice_sender_guid)) {
         $invoice->generate_invoicing_task($invoice_sender_guid);
     }
     midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.invoices'), sprintf($this->_l10n->get('invoice %s created'), $invoice->get_label()), 'ok');
     midcom::get()->relocate("invoice/edit/{$invoice->guid}/");
     // This will exit
 }
开发者ID:nemein,项目名称:openpsa,代码行数:44,代码来源:projects.php

示例13: _handler_edit

 /**
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_edit($handler_id, array $args, array &$data)
 {
     $this->_person = new org_openpsa_contacts_person_dba($args[0]);
     if ($this->_person->id != midcom_connection::get_user()) {
         midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface');
     }
     $data['controller'] = $this->get_controller('simple', $this->_person);
     switch ($data['controller']->process_form()) {
         case 'save':
             midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.user'), sprintf($this->_l10n->get('person %s saved'), $this->_person->name));
             // Fall-through
         // Fall-through
         case 'cancel':
             return new midcom_response_relocate('view/' . $this->_person->guid . '/');
     }
     $this->add_breadcrumb('', sprintf($this->_l10n_midcom->get('edit %s'), $this->_person->get_label()));
     org_openpsa_helpers::dm2_savecancel($this);
     $this->bind_view_to_object($this->_person);
 }
开发者ID:nemein,项目名称:openpsa,代码行数:24,代码来源:edit.php

示例14: _initialize

 private function _initialize($unconditional_start = false)
 {
     static $initialized = false;
     if ($initialized) {
         return true;
     }
     if (!$GLOBALS['midcom_config']['sessioning_service_enable'] && !($GLOBALS['midcom_config']['sessioning_service_always_enable_for_users'] && midcom_connection::get_user())) {
         return false;
     }
     // Try to start session only if the client sends the id OR we need to set data
     if (!isset($_REQUEST[session_name()]) && !$unconditional_start) {
         return false;
     }
     if (_midcom_headers_sent()) {
         // Don't try starting a session if we're past the headers phase
         debug_add("Aborting session start, headers have already been sent", MIDCOM_LOG_WARN);
         return;
     }
     $track_state = ini_get('track_errors');
     ini_set('track_errors', true);
     @session_start();
     $session_err = null;
     if (isset($php_errormsg)) {
         $session_err = (string) $php_errormsg;
     }
     ini_set('track_errors', $track_state);
     unset($track_state);
     if (!isset($_SESSION)) {
         debug_add("\$_SESSION is not set, error message was: {$session_err}", MIDCOM_LOG_ERROR);
         unset($session_err, $php_errormsg);
         return false;
     }
     unset($session_err);
     /* Cache disabling made conditional based on domain/key existence */
     // Check for session data and load or initialize it, if necessary
     if (!array_key_exists('midcom_session_data', $_SESSION)) {
         $_SESSION['midcom_session_data'] = array();
         $_SESSION['midcom_session_data']['midcom.service.sessioning']['startup'] = serialize(time());
     }
     $initialized = true;
     return true;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:42,代码来源:_sessioning.php

示例15: generate_invoicing_task

 /**
  * Generate "Send invoice" task
  */
 function generate_invoicing_task($invoicer)
 {
     try {
         $invoice_sender = new midcom_db_person($invoicer);
     } catch (midcom_error $e) {
         return;
     }
     $config = midcom_baseclasses_components_configuration::get('org.openpsa.invoices', 'config');
     $task = new org_openpsa_projects_task_dba();
     $task->get_members();
     $task->resources[$invoice_sender->id] = true;
     $task->manager = midcom_connection::get_user();
     // TODO: Connect the customer as the contact?
     $task->orgOpenpsaObtype = ORG_OPENPSA_OBTYPE_TASK;
     $task->title = sprintf(midcom::get('i18n')->get_string('send invoice %s', 'org.openpsa.invoices'), sprintf($config->get('invoice_number_format'), sprintf($config->get('invoice_number_format'), $this->number)));
     // TODO: Store link to invoice into description
     $task->end = time() + 24 * 3600;
     if ($task->create()) {
         org_openpsa_relatedto_plugin::create($task, 'org.openpsa.projects', $this, 'org.openpsa.invoices');
         midcom::get('uimessages')->add(midcom::get('i18n')->get_string('org.openpsa.invoices', 'org.openpsa.invoices'), sprintf(midcom::get('i18n')->get_string('created "%s" task to %s', 'org.openpsa.invoices'), $task->title, $invoice_sender->name), 'ok');
     }
 }
开发者ID:nemein,项目名称:openpsa,代码行数:25,代码来源:invoice.php


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