예제 #1
0
파일: toolbars.php 프로젝트: nemein/openpsa
 /**
  * Adds the Host management commands to the specified toolbar.
  *
  * Repeated calls to the same toolbar are intercepted accordingly.
  *
  * @param midcom_helper_toolbar &$toolbar A reference to the toolbar to use.
  * @param int $context_id The context to use (the topic is drawn from there). This defaults
  *     to the currently active context.
  */
 function add_host_management_commands(&$toolbar, $context_id = null)
 {
     if (array_key_exists('midcom_services_toolbars_bound_to_host', $toolbar->customdata)) {
         // We already processed this toolbar, skipping further adds.
         return;
     } else {
         $toolbar->customdata['midcom_services_toolbars_bound_to_host'] = true;
     }
     if (midcom::get('auth')->user) {
         $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => midcom_connection::get_url('self') . "midcom-logout-", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('logout', 'midcom'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/exit.png', MIDCOM_TOOLBAR_ACCESSKEY => 'l'));
     }
     $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => midcom_connection::get_url('self') . "__mfa/asgard/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('midgard.admin.asgard', 'midgard.admin.asgard'), MIDCOM_TOOLBAR_ICON => 'midgard.admin.asgard/asgard2-16.png', MIDCOM_TOOLBAR_ACCESSKEY => 'a', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard.admin.asgard:access', null, 'midgard_admin_asgard_plugin', 'midgard.admin.asgard')));
     if (midcom_connection::is_admin()) {
         $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => midcom_connection::get_url('self') . "midcom-cache-invalidate", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('invalidate cache', 'midcom'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_refresh.png'));
         $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => midcom_connection::get_url('self') . "midcom-exec-midcom/config-test.php", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('test settings', 'midcom'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/start-here.png'));
     }
 }
예제 #2
0
파일: main.php 프로젝트: nemein/openpsa
 /**
  * Internal startup helper, synchronizes the authenticated user with the Midgard Authentication
  * for startup. This will be overridden by MidCOM Auth, but is there for compatibility reasons.
  */
 private function _initialize_user_from_midgard()
 {
     if (midcom_connection::get_user() && ($user = $this->get_user(midcom_connection::get_user()))) {
         $this->user = $user;
         if (midcom_connection::is_admin() || midcom_connection::get('root')) {
             $this->admin = true;
         }
     }
 }
예제 #3
0
파일: tree.php 프로젝트: nemein/openpsa
 /**
  * Get children of given object
  *
  * @param midgard_object &$object object to get children for
  * @param boolean $deleted whether to get (only) deleted or not-deleted objects
  * @return array multidimensional array (keyed by classname) of objects or false on failure
  */
 public static function get_child_objects(&$object, $deleted = false)
 {
     // PONDER: Check for some generic user privilege instead  ??
     if ($deleted && !midcom_connection::is_admin()) {
         debug_add('Non-admins are not allowed to list deleted objects', MIDCOM_LOG_ERROR);
         return false;
     }
     $resolver = new midcom_helper_reflector_tree($object);
     $child_classes = $resolver->get_child_classes();
     if (!$child_classes) {
         if ($child_classes === false) {
             debug_add('resolver returned false (critical failure) from get_child_classes()', MIDCOM_LOG_ERROR);
         }
         return false;
     }
     //make sure children of the same type come out on top
     $i = 0;
     foreach ($child_classes as $child_class) {
         if (midcom::get('dbfactory')->is_a($object, $child_class)) {
             unset($child_classes[$i]);
             array_unshift($child_classes, $child_class);
             break;
         }
         $i++;
     }
     $child_objects = array();
     foreach ($child_classes as $schema_type) {
         $type_children = $resolver->_get_child_objects_type($schema_type, $object, $deleted);
         // PONDER: check for boolean false as result ??
         if (empty($type_children)) {
             unset($type_children);
             continue;
         }
         $child_objects[$schema_type] = $type_children;
         unset($type_children);
     }
     return $child_objects;
 }