public static function getRolesPermissionsXml()
    {
        $localeCatalog = new \Innomatic\Locale\LocaleCatalog('innomatic::domain_profiles', \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentUser()->getLanguage());
        $rolesList = \Innomatic\Domain\User\Role::getAllRoles();
        $rolesCount = count($rolesList);
        // Build roles/permissions matrix
        $rolesPermissions = array();
        foreach ($rolesList as $roleId => $roleData) {
            $role = new \Innomatic\Domain\User\Role($roleId);
            $rolesPermissions[$roleId] = $role->getPermissions();
        }
        $permissionsList = \Innomatic\Domain\User\Permission::getAllPermissions();
        // Build table headers
        $headers = array();
        $headerCounter = 1;
        foreach ($rolesList as $roleId => $roleData) {
            $headers[$headerCounter++]['label'] = $roleData['title'];
        }
        $xml = '<vertgroup><children>
              <table>
                <args>
                  <headers type="array">' . WuiXml::encode($headers) . '</headers>
                </args>
                <children>';
        $row = 0;
        $prevApplication = '';
        foreach ($permissionsList as $permId => $permData) {
            if ($permData['application'] != $prevApplication) {
                $xml .= '<label row="' . $row++ . '" col="0" halign="left" valign="middle" nowrap="false" width="" colspan="' . ($rolesCount + 1) . '"><args><label>' . WuiXml::cdata($permData['application']) . '</label><bold>true</bold></args></label>';
            }
            $xml .= '<label row="' . $row . '" col="0" halign="left" valign="middle"><args><label>' . WuiXml::cdata($permData['title']) . '</label><nowrap>false</nowrap></args></label>';
            $col = 1;
            foreach ($rolesList as $roleId => $roleData) {
                if (isset($rolesPermissions[$roleId][$permId])) {
                    $checked = 'true';
                } else {
                    $checked = 'false';
                }
                $xml .= '<checkbox row="' . $row . '" col="' . $col++ . '" halign="center" valign="middle"><name>rolepermissioncb</name><args><id>cbrole_' . $roleId . '-' . $permId . '</id><checked>' . $checked . '</checked></args></checkbox>';
            }
            $prevApplication = $permData['application'];
            $row++;
        }
        $xml .= '</children>
              </table>
              <horizbar/>
              <button><name>save</name>
	<args><themeimage>buttonok</themeimage><label>' . WuiXml::cdata($localeCatalog->getStr('save_roles_permissions_button')) . '</label><action>javascript:void(0)</action><horiz>true</horiz><frame>false</frame></args>
  	<events>
    	<click>' . WuiXml::cdata("\nvar checkboxes = document.getElementsByName('wui[][evd][rolepermissioncb]');\nvar vals = '';\nfor (var i=0, n=checkboxes.length;i<n;i++) {\n  if (checkboxes[i].checked) vals += ','+checkboxes[i].id;\n}\nif (vals) vals = vals.substring(1);\n    \t\t\t\nxajax_SaveRolesPermissions(vals);") . '</click>
  	</events></button>
            </children></vertgroup>';
        return $xml;
    }
function main_keyring($eventData)
{
    global $gXmlDefinition, $gLocale, $gPageTitle, $gStatus;
    $query = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->Execute('SELECT * ' . 'FROM applications_keyring_keys ' . 'ORDER BY application,version,domain');
    $gXmlDefinition .= '<vertgroup><name>vg</name><children>';
    if ($query->getNumberRows()) {
        $headers[0]['label'] = $gLocale->getStr('application.header');
        $headers[1]['label'] = $gLocale->getStr('version.header');
        $headers[2]['label'] = $gLocale->getStr('domain.header');
        $headers[3]['label'] = $gLocale->getStr('maxdomainusers.header');
        $headers[4]['label'] = $gLocale->getStr('validip.header');
        $headers[5]['label'] = $gLocale->getStr('validrange.header');
        $headers[6]['label'] = $gLocale->getStr('expirydate.header');
        $gXmlDefinition .= '<table>
  <args>
    <headers type="array">' . WuiXml::encode($headers) . '</headers>
    <rowsperpage>20</rowsperpage>
    <pagesactionfunction>keys_page_action_builder</pagesactionfunction>
    <pagenumber>' . (isset($eventData['page']) ? $eventData['page'] : '') . '</pagenumber>
  </args>
  <children>';
        $row = 0;
        while (!$query->eof) {
            $toolbars = '<button>
                    <args>
              <label>' . WuiXml::cdata($gLocale->getStr('removekey.button')) . '</label>
        <themeimage>trash</themeimage>
        <horiz>true</horiz>
                <needconfirm>true</needconfirm>
                    <confirmmessage>' . WuiXml::cdata($gLocale->getStr('remove_key.confirm')) . '</confirmmessage>
        <action>' . WuiXml::cdata(\Innomatic\Wui\Dispatch\WuiEventsCall::buildEventsCallString('', array(array('view', 'keyring'), array('action', 'removekey', array('id' => $query->getFields('id')))))) . '</action>
                  </args>
                </button>';
            $gXmlDefinition .= '<label row="' . $row . '" col="0">
  <args>
    <label type="encoded">' . urlencode($query->getFields('application')) . '</label>
  </args>
</label>
<label row="' . $row . '" col="1">
  <args>
    <label type="encoded">' . urlencode($query->getFields('version')) . '</label>
  </args>
</label>
<label row="' . $row . '" col="2">
  <args>
    <label type="encoded">' . urlencode($query->getFields('domain')) . '</label>
  </args>
</label>
<label row="' . $row . '" col="3">
  <args>
    <label type="encoded">' . urlencode($query->getFields('maxdomainusers')) . '</label>
  </args>
</label>
<label row="' . $row . '" col="4">
  <args>
    <label type="encoded">' . urlencode($query->getFields('validip')) . '</label>
  </args>
</label>
<label row="' . $row . '" col="5">
  <args>
    <label type="encoded">' . urlencode($query->getFields('validrange')) . '</label>
  </args>
</label>
<label row="' . $row . '" col="6">
  <args>
    <label type="encoded">' . urlencode($query->getFields('expirydate')) . '</label>
  </args>
</label>
<horizgroup row="' . $row . '" col="7">
    <children>' . $toolbars . '</children>
</horizgroup>';
            $query->moveNext();
            $row++;
        }
        $gXmlDefinition .= '  </children>
</table>

<horizbar><name>hb</name></horizbar>';
    } else {
        if (!strlen($gStatus)) {
            $gStatus = $gLocale->getStr('nokeys.status');
        }
    }
    $gXmlDefinition .= '<vertgroup>
  <children>

    <form><name>newkey</name>
      <args>
        <action type="encoded">' . urlencode(\Innomatic\Wui\Dispatch\WuiEventsCall::buildEventsCallString('', array(array('view', 'keyring'), array('action', 'newkey')))) . '</action>
      </args>
      <children>

        <grid>
          <children>

            <label row="0" col="0">
              <args>
                <label type="encoded">' . urlencode($gLocale->getStr('key.label')) . '</label>
              </args>
            </label>

            <file row="0" col="1"><name>key</name>
              <args>
                <disp>action</disp>
              </args>
            </file>

    <button row="0" col="2">
      <args>
        <horiz>true</horiz>
        <frame>false</frame>
        <themeimage>mathadd</themeimage>
        <formsubmit>newkey</formsubmit>
        <label type="encoded">' . urlencode($gLocale->getStr('newkey.submit')) . '</label>
        <action type="encoded">' . urlencode(\Innomatic\Wui\Dispatch\WuiEventsCall::buildEventsCallString('', array(array('view', 'keyring'), array('action', 'newkey')))) . '</action>
      </args>
    </button>

          </children>
        </grid>

      </children>
    </form>

  </children>
</vertgroup>';
    $gXmlDefinition .= '</children></vertgroup>';
    $gPageTitle .= ' - ' . $gLocale->getStr('keys.title');
}
 function _FillDefinition()
 {
     $result = true;
     require_once 'innomatic/locale/LocaleCatalog.php';
     require_once 'innomatic/locale/LocaleCountry.php';
     $row = 0;
     $this->mDefinition = '
                 <vertgroup><name>searchresult</name><children>';
     while (list($type, $results) = each($this->mSearchResult)) {
         if (count($results)) {
             $tmp_locale = new LocaleCatalog($this->mSummaries[$type]['catalog'], \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentUser()->getLanguage());
             /*
                             $itemtype_call = new WuiEventsCall( $val['domainpanel'] );
                             $itemtype_call->addEvent( new WuiEvent( 'view', 'default', '' ) );
                     <button>
                       <name>itemtypeimage</name>
                       <args><themeimage>'.$val['icon'].'</themeimage><themeimagetype>'.$val['icontype'].'</themeimagetype><action>'.$itemtype_call->getEventsCallString().'</action></args>
                     </button>
             */
             $this->mDefinition .= '<button><name>type</name>
                                   <args>
                                     <themeimage>' . $this->mSummaries[$type]['icon'] . '</themeimage>
                                     <themeimagetype>' . $this->mSummaries[$type]['icontype'] . '</themeimagetype>
                                     <action>' . WuiXml::cdata(WuiEventsCall::buildEventsCallString($this->mSummaries[$type]['domainpanel'], array(array('view', 'default', '')))) . '</action>
                                     <label type="encoded">' . WuiXml::cdata(urlencode($this->mSummaries[$type]['label'])) . '</label>
                                     <horiz>true</horiz>
                                   </args>
                                 </button>';
             $headers = array();
             $header_count = 1;
             $locale_country = new LocaleCountry(\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentUser()->getCountry());
             while (list(, $keyname) = each($this->mSummaries[$type]['viewablesearchresultkeys'])) {
                 $headers[$header_count++]['label'] = $tmp_locale->getStr($keyname);
             }
             $this->mDefinition .= '<table><name>searchresult</name><args><headers type="array">' . WuiXml::encode($headers) . '</headers></args><children>';
             $row = 0;
             //$col = 1;
             while (list($id, $result) = each($results)) {
                 $col = 1;
                 switch ($result['_acl']['type']) {
                     case InnoworkAcl::TYPE_PRIVATE:
                         $image = 'user';
                         break;
                     case InnoworkAcl::TYPE_PUBLIC:
                     case InnoworkAcl::TYPE_ACL:
                         $image = 'useradd';
                         break;
                 }
                 $this->mDefinition .= '<button row="' . $row . '" col="0"><name>acl</name>
                                           <args>
                                             <themeimage>' . $image . '</themeimage>
                                             <themeimagetype>mini</themeimagetype>
                                             <compact>true</compact>
                                             <action>' . WuiXml::cdata(WuiEventsCall::buildEventsCallString($this->mSummaries[$type]['domainpanel'], array(array($this->mSummaries[$type]['showdispatcher'], $this->mSummaries[$type]['showevent'], array('id' => $result['id']))))) . '</action>
                                           </args>
                                         </button>';
                 foreach ($this->mSummaries[$type]['viewablesearchresultkeys'] as $key) {
                     $value = $result[$key];
                     if ($col == 1) {
                         $this->mDefinition .= '<link row="' . $row . '" col="' . $col . '"><name>key</name>
                                                           <args>
                                                             <compact>true</compact>
                                                             <link>' . WuiXml::cdata(WuiEventsCall::buildEventsCallString($this->mSummaries[$type]['domainpanel'], array(array($this->mSummaries[$type]['showdispatcher'], $this->mSummaries[$type]['showevent'], array('id' => $result['id']))))) . '</link>
                                                             <label type="encoded">' . WuiXml::cdata(strlen($value) > 35 ? urlencode(substr($value, 0, 32)) . '...' : urlencode($value)) . '</label>
                                                             <title type="encoded">' . WuiXml::cdata(urlencode(str_replace('"', '', $value))) . '</title>
                                                           </args>
                                                         </link>';
                     } else {
                         $key_type = explode(':', $this->mSummaries[$type]['keys'][$key]);
                         switch ($key_type[0]) {
                             case 'text':
                                 $value = strlen($value) > 35 ? substr($value, 0, 32) . '...' : $value;
                                 break;
                             case 'timestamp':
                                 $value = $locale_country->FormatShortArrayDate(\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getDataAccess()->GetDateArrayFromTimestamp($value));
                                 break;
                             case 'boolean':
                                 if ($value == \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getDataAccess()->fmttrue) {
                                     $value = 'true';
                                 } else {
                                     $value = 'false';
                                 }
                                 break;
                             case 'table':
                                 if (strlen($value)) {
                                     $tmp_query = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getDataAccess()->execute('SELECT ' . $key_type[2] . ' FROM ' . $key_type[1] . ' WHERE id=' . $value);
                                     if ($tmp_query->getNumberRows()) {
                                         $value = $tmp_query->getFields($key_type[2]);
                                     } else {
                                         $value = '';
                                     }
                                     $tmp_query->Free();
                                 } else {
                                     $value = '';
                                 }
                                 break;
                             case 'userid':
                                 if (strlen($value)) {
                                     $tmp_query = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getDataAccess()->execute('SELECT id,username,fname,lname FROM domain_users WHERE id=' . $value);
                                     if ($tmp_query->getNumberRows()) {
                                         $value = $tmp_query->getFields('fname') . ' ' . $tmp_query->getFields('lname');
                                     } else {
                                         $value = '';
                                     }
                                     $tmp_query->Free();
                                 } else {
                                     $value = '';
                                 }
                                 break;
                             default:
                                 break;
                         }
                         $this->mDefinition .= '<label row="' . $row . '" col="' . $col . '"><name>key</name>
                                                           <args>
                                                             <compact>true</compact>
                         									<nowrap>false</nowrap>
                                                             <label type="encoded">' . WuiXml::cdata(urlencode($value)) . '</label>
                                                           </args>
                                                         </label>';
                     }
                     $col++;
                 }
                 if ($this->mTrashcan == 'true') {
                     $locale = new LocaleCatalog('innowork-core::misc', \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentUser()->getLanguage());
                     $this->mDefinition .= '<button row="' . $row . '" col="' . $col . '"><name>restore</name>
                                                   <args>
                                                     <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('restore.button'))) . '</label>
                                                     <horiz>true</horiz>
                                                     <frame>false</frame>
                                                     <themeimagetype>mini</themeimagetype>
                                                     <themeimage>undo</themeimage>
                                                              <action>' . WuiXml::cdata(WuiEventsCall::buildEventsCallString('1innoworkcore', array(array('view', 'trashcan'), array('action', 'restore_item', array('itemtype' => $type, 'itemid' => $result['id']))))) . '</action>
                                                   </args>
                                                 </button>';
                 }
                 if ($this->mClipping == 'true' and $this->mClippingId) {
                     $locale = new LocaleCatalog('innowork-core::misc', \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentUser()->getLanguage());
                     $this->mDefinition .= '<button row="' . $row . '" col="' . $col . '"><name>remove</name>
                                                   <args>
                                                     <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('remove_from_clipping.button'))) . '</label>
                                                     <horiz>true</horiz>
                                                     <frame>false</frame>
                                                     <themeimagetype>mini</themeimagetype>
                                                     <themeimage>editdelete</themeimage>
                                                              <action>' . WuiXml::cdata(WuiEventsCall::buildEventsCallString('innoworkclippings', array(array('view', 'showclipping', array('id' => $this->mClippingId)), array('action', 'remove_item', array('id' => $this->mClippingId, 'itemtype' => $type, 'itemid' => $result['id']))))) . '</action>
                                                   </args>
                                                 </button>';
                 }
                 $row++;
             }
             $this->mDefinition .= '</children></table>';
         }
     }
     $this->mDefinition .= '</children></vertgroup>';
     return $result;
 }
    public function viewEditrole($eventData)
    {
        $role = new \Innomatic\Domain\User\Role((int) $eventData['id']);
        $formEventsCall = new WuiEventsCall();
        $formEventsCall->addEvent(new WuiEvent('action', 'editrole', array('id' => $eventData['id'])));
        $formEventsCall->addEvent(new WuiEvent('view', 'roles', ''));
        $xml = '<vertgroup><children>
            <form><name>roledata</name>
              <args>
                <action>' . WuiXml::cdata($formEventsCall->getEventsCallString()) . '</action>
              </args>
              <children>
              <vertgroup><children>
                <vertgroup><children>
                <grid>
                  <children>
                    <label row="0" col="0"><args><label>' . WuiXml::cdata($this->localeCatalog->getStr('rolename_label')) . '</label></args></label>
                    <string row="0" col="1"><name>name</name><args><disp>action</disp><value>' . WuiXml::cdata($role->getName()) . '</value><size>25</size></args></string>
                    <label row="1" col="0"><args><label>' . WuiXml::cdata($this->localeCatalog->getStr('roledescription_label')) . '</label></args></label>
                    <text row="1" col="1"><name>description</name><args><disp>action</disp><value>' . WuiXml::cdata($role->getDescription()) . '</value><rows>5</rows><cols>40</cols></args></text>

                  </children>
                </grid>
                </children></vertgroup>

                </children></vertgroup>
                <horizbar />

                <horizgroup><children>
                  <button><name>save</name>
	                <args>
                      <themeimage>buttonok</themeimage>
                      <label>' . WuiXml::cdata($this->localeCatalog->getStr('saverole_button')) . '</label>
                      <action>' . WuiXml::cdata($formEventsCall->getEventsCallString()) . '</action>
                      <formsubmit>roledata</formsubmit>
                      <horiz>true</horiz>
                      <frame>false</frame>
                    </args>
                  </button>
                </children></horizgroup>
              </children>
            </form>
            </children></vertgroup>';
        $this->wuiMainframe->addChild(new WuiXml('user', array('definition' => $xml)));
        $this->wuiTitlebar->mTitle .= ' - ' . $userData['username'] . ' - ' . $this->localeCatalog->getStr('edituser_title');
    }
    private function fillDefinition()
    {
        $result = false;
        $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
        if (!(strlen($this->mItemType) and $this->mItemId)) {
            return $result;
        }
        // Locale
        $locale = new \Innomatic\Locale\LocaleCatalog('innowork-core::misc', $container->getCurrentUser()->getLanguage());
        // Core
        $tmp_innoworkcore = \Innowork\Core\InnoworkCore::instance('\\Innowork\\Core\\InnoworkCore', $container->getDataAccess(), $container->getCurrentDomain()->getDataAccess());
        $summaries = $tmp_innoworkcore->getSummaries();
        // Default parent ACL mode
        $parentAcl = false;
        // Item object
        if (isset($summaries[$this->mItemType]) and class_exists($summaries[$this->mItemType]['classname'])) {
            $class_name = $summaries[$this->mItemType]['classname'];
            $item_object = new $class_name($container->getDataAccess(), $container->getCurrentDomain()->getDataAccess(), $this->mItemId);
            $acl = $item_object->mAcl;
            // Check parent ACL mode
            if (strlen($item_object->mParentType) and $item_object->mParentId > 0) {
                $parentAcl = true;
            }
        } else {
            $item_object = null;
            // Access list
            require_once 'innowork/core/InnoworkAcl.php';
            $acl = new InnoworkAcl($container->getDataAccess(), $container->getCurrentDomain()->getDataAccess(), $this->mItemType, $this->mItemId);
        }
        $tmp_acl_type = $acl->getType();
        if (strlen($tmp_acl_type)) {
            $this->mAclType = $tmp_acl_type;
        }
        /*
        $acls_query = $container->getCurrentDomain()->getDataAccess()->execute(
        	'SELECT groupid, userid, rights '.
        	'FROM innowork_core_acls '.
        	'WHERE itemtype='.$container->getCurrentDomain()->getDataAccess()->formatText($acl->mItemType).
        	' '.'AND itemid='.$acl->mItemId
        		);
        */
        $owner = '';
        // Log
        if (isset($summaries[$this->mItemType]['loggable']) and $summaries[$this->mItemType]['loggable']) {
            require_once 'innowork/core/InnoworkItemLog.php';
            $item_log = new InnoworkItemLog($this->mItemType, $this->mItemId);
        }
        if ($this->mItemOwnerId) {
            $owner_user = new \Innomatic\Domain\User\User($container->getCurrentDomain()->domaindata['id'], $this->mItemOwnerId);
            $owner_user_data = $owner_user->getUserData();
            $owner = (strlen($owner_user_data['fname']) ? $owner_user_data['fname'] . ' ' : '') . $owner_user_data['lname'];
        }
        $acl_mode_sk = new \Shared\Wui\WuiSessionKey('innowork_acl_mode', array('sessionobjectnopage' => 'true'));
        if ($acl_mode_sk->mValue == 'advanced') {
            $acl_mode = 'advanced';
        } else {
            $acl_mode = 'simple';
        }
        $row = 0;
        if ($acl_mode == 'advanced') {
            $domainDa = $container->getCurrentDomain()->getDataAccess();
            $groups_query = $domainDa->execute('SELECT id,groupname FROM domain_users_groups ORDER BY groupname');
            $users_query = $domainDa->execute('SELECT id,groupid,username,fname,lname FROM domain_users WHERE disabled IS NULL or disabled <> ' . $domainDa->formatText($domainDa->fmttrue) . ' ORDER BY username');
            $limited_acls = array();
            $users = array();
            while (!$users_query->eof) {
                $fname = $users_query->getFields('fname');
                $lname = $users_query->getFields('lname');
                if (strlen($fname) and strlen($lname)) {
                    $tmp_username = $lname . ' ' . $fname;
                } else {
                    $tmp_username = $users_query->getFields('username');
                    if (strpos($tmp_username, '@')) {
                        $tmp_username = substr($tmp_username, 0, strpos($tmp_username, '@'));
                    }
                }
                $users[$users_query->getFields('groupid')][$users_query->getFields('id')] = $tmp_username;
                $users_query->moveNext();
            }
            while (!$groups_query->eof) {
                $group_perms = $acl->checkPermission($groups_query->getFields('id'));
                switch ($group_perms) {
                    case InnoworkAcl::PERMS_NONE:
                        $limited_acls['g' . $groups_query->getFields('id')] = '[-] ' . $groups_query->getFields('groupname');
                        break;
                    case InnoworkAcl::PERMS_SEARCH:
                        $limited_acls['g' . $groups_query->getFields('id')] = '[' . $locale->getStr('perm_search_short.label') . '] ' . $groups_query->getFields('groupname');
                        break;
                    case InnoworkAcl::PERMS_READ:
                        $limited_acls['g' . $groups_query->getFields('id')] = '[' . $locale->getStr('perm_read_short.label') . '] ' . $groups_query->getFields('groupname');
                        break;
                    case InnoworkAcl::PERMS_EDIT:
                        $limited_acls['g' . $groups_query->getFields('id')] = '[' . $locale->getStr('perm_edit_short.label') . '] ' . $groups_query->getFields('groupname');
                        break;
                    case InnoworkAcl::PERMS_DELETE:
                        $limited_acls['g' . $groups_query->getFields('id')] = '[' . $locale->getStr('perm_delete_short.label') . '] ' . $groups_query->getFields('groupname');
                        break;
                    case InnoworkAcl::PERMS_ALL:
                        $limited_acls['g' . $groups_query->getFields('id')] = '[+] ' . $groups_query->getFields('groupname');
                        break;
                }
                /*
                $limited_acls['g'.$groups_query->getFields( 'id' )] =
                (  > InnoworkAcl::PERMS_NONE ?
                '[+] ' :
                '[-] ' ).
                $groups_query->getFields( 'groupname' );
                */
                foreach ($users[$groups_query->getFields('id')] as $id => $username) {
                    $user_perms = $acl->checkPermission('', $id);
                    /*
                    $limited_acls['u'.$id] = '-> '.
                        ( $acl->checkPermission( '', $id ) > InnoworkAcl::PERMS_NONE ?
                        '[+] ' :
                        '[-] ' ).
                        $username;
                    */
                    if ($id == $this->mItemOwnerId) {
                        $limited_acls['u' . $id] = '- ' . '[+] ' . $username;
                    } else {
                        switch ($user_perms) {
                            case InnoworkAcl::PERMS_NONE:
                                $limited_acls['u' . $id] = '- ' . '[-] ' . $username;
                                break;
                            case InnoworkAcl::PERMS_SEARCH:
                                $limited_acls['u' . $id] = '- ' . '[' . $locale->getStr('perm_search_short.label') . '] ' . $username;
                                break;
                            case InnoworkAcl::PERMS_READ:
                                $limited_acls['u' . $id] = '- ' . '[' . $locale->getStr('perm_read_short.label') . '] ' . $username;
                                break;
                            case InnoworkAcl::PERMS_EDIT:
                                $limited_acls['u' . $id] = '- ' . '[' . $locale->getStr('perm_edit_short.label') . '] ' . $username;
                                break;
                            case InnoworkAcl::PERMS_DELETE:
                                $limited_acls['u' . $id] = '- ' . '[' . $locale->getStr('perm_delete_short.label') . '] ' . $username;
                                break;
                            case InnoworkAcl::PERMS_ALL:
                                $limited_acls['u' . $id] = '- ' . '[+] ' . $username;
                                break;
                        }
                    }
                }
                $groups_query->MoveNext();
            }
            $limited_acls['g0'] = '[-] No group';
            foreach ($users[0] as $id => $username) {
                $limited_acls['u' . $id] = '-> ' . ($acl->checkPermission('', $id) > InnoworkAcl::PERMS_NONE ? '[+] ' : '[-] ') . $username;
            }
        }
        // Clippings
        require_once 'innowork/core/clipping/InnoworkClipping.php';
        $innowork_clippings = new InnoworkClipping($container->getDataAccess(), $container->getCurrentDomain()->getDataAccess());
        $clippings_search = $innowork_clippings->search('');
        $clippings = array();
        if ($this->mItemType != 'defaultaclitem' and count($clippings_search)) {
            foreach ($clippings_search as $id => $data) {
                $clippings[$id] = $data['name'];
            }
        }
        $item_actions = array();
        // Other items widget actions
        if (is_object($item_object) && $acl->checkPermission('', $container->getCurrentUser()->getUserId()) > InnoworkAcl::PERMS_NONE) {
            foreach ($summaries as $item_type => $item_desc) {
                if ($item_type == $this->mItemType) {
                    continue;
                }
                $tmp_class = $item_desc['classname'];
                $tmp_obj = new $tmp_class($container->getDataAccess(), $container->getCurrentDomain()->getDataAccess());
                $item_action = $tmp_obj->getExternalItemWidgetXmlData($item_object);
                if (strlen($item_action)) {
                    $item_actions[] = $item_action;
                }
            }
        }
        if ($acl->checkPermission('', $container->getCurrentUser()->getUserId()) == InnoworkAcl::PERMS_NONE) {
            $this->mDefinition = '<empty/>';
        } elseif (!$parentAcl and ($this->mItemOwnerId == $container->getCurrentUser()->getUserId() or User::isAdminUser($container->getCurrentUser()->getUserName(), $container->getCurrentDomain()->getDomainId()) or $acl->checkPermission('', $container->getCurrentUser()->getUserId()) >= InnoworkAcl::PERMS_RESPONSIBLE)) {
            $this->mDefinition = '
<empty><name>innoworkitemacl</name>
  <children>
    <form><name>opts' . md5($this->mItemType . '-' . $this->mItemId) . '</name>
      <args>
        <action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
      </args>
      <children>
        <formarg><name>aclmode</name>
          <args>
        <disp>wui</disp>
        <value>' . ($acl_mode == 'advanced' ? 'simple' : 'advanced') . '</value>
          </args>
        </formarg>
      </children>
    </form>
        <table><name>acl</name>
          <args>
        <headers type="array">' . WuiXml::encode(array('0' => array('label' => $locale->getStr('item_properties.label')))) . '</headers>
          </args>
          <children>';
            if (count($item_actions)) {
                foreach ($item_actions as $item_action) {
                    $this->mDefinition .= '<vertgroup row="' . $row++ . '" col="0"><children>';
                    $this->mDefinition .= $item_action;
                    $this->mDefinition .= '</children></vertgroup>';
                }
            }
            $this->mDefinition .= '<vertgroup row="' . $row++ . '" col="0" halign="" valign="" nowrap="true">
      <children>
    <form><name>itemacl' . md5($this->mItemType . '-' . $this->mItemId) . '</name>
      <args>
        <method>post</method>
        <action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
      </args>
      <children>

        <vertgroup><name>vg</name><children>
  <horizgroup>
    <args>
      <align>middle</align>
      <width>0%</width>
    </args>
    <children>
      <button>
        <args>
          <themeimage>lock</themeimage>
          <themeimagetype>mini</themeimagetype>
          <compact>true</compact>
        </args>
      </button>
          <label><name>convert</name>
        <args>
          <bold>true</bold>
          <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('access_mode.label'))) . '</label>
          <compact>true</compact>
        </args>
          </label>
    </children>
  </horizgroup>
';
            if (strlen($owner)) {
                $this->mDefinition .= '          <label><name>owner</name>
                <args>
                  <bold>true</bold>
                  <label type="encoded">' . WuiXml::cdata(urlencode(sprintf($locale->getStr('owner.label'), $owner))) . '</label>
                </args>
              </label>';
            }
            // Only the owner and the root user can change the acl type
            if ($this->mItemOwnerId == $container->getCurrentUser()->getUserId() or User::isAdminUser($container->getCurrentUser()->getUserName(), $container->getCurrentDomain()->getDomainId())) {
                $this->mDefinition .= '          <formarg><name>aclitemtype</name><args><disp>wui</disp><value>' . $this->mItemType . '</value></args></formarg>
              <formarg><name>aclitemid</name><args><disp>wui</disp><value>' . $this->mItemId . '</value></args></formarg>
              <radio><name>acltype</name>
               <args>
                  <disp>wui</disp>
                  <value>' . InnoworkAcl::TYPE_PRIVATE . '</value>
                  <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('acl_type_private.label'))) . '</label>
                  <checked>' . ($this->mAclType == InnoworkAcl::TYPE_PRIVATE ? 'true' : 'false') . '</checked>
                </args>
              </radio>
              <radio><name>acltype</name>
                <args>
                  <disp>wui</disp>
                  <value>' . InnoworkAcl::TYPE_PUBLIC . '</value>
                  <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('acl_type_public.label'))) . '</label>
                  <checked>' . ($this->mAclType == InnoworkAcl::TYPE_PUBLIC ? 'true' : 'false') . '</checked>
                </args>
              </radio>
              <radio><name>acltype</name>
                <args>
                  <disp>wui</disp>
                  <value>' . InnoworkAcl::TYPE_ACL . '</value>
                  <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('acl_type_acl.label'))) . '</label>
                  <checked>' . ($this->mAclType == InnoworkAcl::TYPE_ACL ? 'true' : 'false') . '</checked>
                </args>
              </radio>';
            } else {
                $this->mDefinition .= '          <label><name>acltype</name>
               <args>
                  <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('acl_type_private.label'))) . '</label>
                  <bold>' . ($this->mAclType == InnoworkAcl::TYPE_PRIVATE ? 'true' : 'false') . '</bold>
                </args>
              </label>
              <label><name>acltype</name>
                <args>
                  <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('acl_type_public.label'))) . '</label>
                  <bold>' . ($this->mAclType == InnoworkAcl::TYPE_PUBLIC ? 'true' : 'false') . '</bold>
                </args>
              </label>
              <label><name>acltype</name>
                <args>
                  <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('acl_type_acl.label'))) . '</label>
                  <bold>' . ($this->mAclType == InnoworkAcl::TYPE_ACL ? 'true' : 'false') . '</bold>
                </args>
              </label>';
            }
            $this->mDefinition .= '        </children></vertgroup>
          </children>
    </form>
<horizgroup><args><width>0%</width></args>
  <children>';
            if ($this->mItemOwnerId == $container->getCurrentUser()->getUserId() or $container->getCurrentDomain()->getDomainId() == $container->getCurrentUser()->getUserName()) {
                $this->mDefinition .= '    <button><name>setactl</name>
          <args>
            <action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
            <formsubmit>itemacl' . md5($this->mItemType . '-' . $this->mItemId) . '</formsubmit>
            <horiz>true</horiz>
            <frame>false</frame>
            <themeimage>buttonok</themeimage>
            <themeimagetype>mini</themeimagetype>
            <compact>true</compact>
            <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('apply.submit'))) . '</label>
          </args>
        </button>';
            }
            $this->mDefinition .= '    <button><name>setopts</name>
      <args>
        <action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
        <formsubmit>opts' . md5($this->mItemType . '-' . $this->mItemId) . '</formsubmit>
        <horiz>true</horiz>
        <frame>false</frame>
        <themeimage>' . ($acl_mode == 'advanced' ? 'info' : 'info') . '</themeimage>
        <themeimagetype>mini</themeimagetype>
        <compact>true</compact>
        <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr($acl_mode == 'advanced' ? 'acl_simple.submit' : 'acl_advanced.submit'))) . '</label>
      </args>
    </button>
  </children>
</horizgroup>
  </children>
</vertgroup>';
            if ($acl_mode == 'advanced') {
                if ($this->mAclType == InnoworkAcl::TYPE_ACL) {
                    $this->mDefinition .= '<vertgroup row="' . $row++ . '" col="0">
              <children>
            <form><name>limitedacl' . md5($this->mItemType . '-' . $this->mItemId) . '</name>
              <args>
                <action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
              </args>
              <children>

              <horizgroup>
                <args>
                  <align>top</align><width>0%</width>
                </args>
                <children>
                <listbox><name>limitedacl</name>
                  <args>
                <disp>wui</disp>
                <elements type="array">' . WuiXml::encode($limited_acls) . '</elements>
                <multiselect>true</multiselect>
                <size>10</size>
                  </args>
                </listbox>

                <vertgroup>
                  <args>
                <align>left</align>
                  </args>
                  <children>
                <radio><name>aclperms</name>
                  <args>
                <disp>wui</disp>
                <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('perm_all.label'))) . '</label>
                <value>' . InnoworkAcl::PERMS_ALL . '</value>
                <checked>true</checked>
                  </args>
                </radio>
                <radio><name>aclperms</name>
                  <args>
                <disp>wui</disp>
                <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('perm_delete.label'))) . '</label>
                <value>' . InnoworkAcl::PERMS_DELETE . '</value>
                  </args>
                </radio>
                <radio><name>aclperms</name>
                  <args>
                <disp>wui</disp>
                <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('perm_edit.label'))) . '</label>
                <value>' . InnoworkAcl::PERMS_EDIT . '</value>
                  </args>
                </radio>
                <radio><name>aclperms</name>
                  <args>
                <disp>wui</disp>
                <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('perm_read.label'))) . '</label>
                <value>' . InnoworkAcl::PERMS_READ . '</value>
                  </args>
                </radio>
                <radio><name>aclperms</name>
                  <args>
                <disp>wui</disp>
                <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('perm_search.label'))) . '</label>
                <value>' . InnoworkAcl::PERMS_SEARCH . '</value>
                  </args>
                </radio>

                </children>
                  </vertgroup>
                </children>
              </horizgroup>

                  <formarg><name>aclitemtype</name><args><disp>wui</disp><value>' . $this->mItemType . '</value></args></formarg>
                  <formarg><name>aclitemid</name><args><disp>wui</disp><value>' . $this->mItemId . '</value></args></formarg>

              </children>
            </form>

            <horizgroup>
              <args><width>0%</width></args>
              <children>
                <button><name>add</name>
                  <args>
                <action>' . WuiXml::cdata($this->mDefaultAction . '&wui[wui][evn]=innoworkacladd') . '</action>
                <formsubmit>limitedacl' . md5($this->mItemType . '-' . $this->mItemId) . '</formsubmit>
                <horiz>true</horiz>
                <frame>false</frame>
                <themeimage>useradd</themeimage>
                <themeimagetype>mini</themeimagetype>
                <compact>true</compact>
                <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('add_acl.submit'))) . '</label>
                  </args>
                </button>
                <button><name>remove</name>
                  <args>
                <action>' . WuiXml::cdata($this->mDefaultAction . '&wui[wui][evn]=innoworkaclremove') . '</action>
                <formsubmit>limitedacl' . md5($this->mItemType . '-' . $this->mItemId) . '</formsubmit>
                <horiz>true</horiz>
                <frame>false</frame>
                <themeimage>userremove</themeimage>
                <themeimagetype>mini</themeimagetype>
                <compact>true</compact>
                <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('remove_acl.submit'))) . '</label>
                  </args>
                </button>
              </children>
            </horizgroup>
              </children>
            </vertgroup>';
                }
                /*
                $this->mDefinition .=
                '<form row="'.$row++.'" col="0" halign="" valign="" nowrap="true"><name>responsibles'.md5( $this->mItemType.'-'.$this->mItemId ).'</name>
                  <args>
                  </args>
                  <children>
                
                <listbox><name>responsibles</name>
                  <args>
                    <disp>wui</disp>
                    <size>2</size>
                  </args>
                </listbox>
                
                  </children>
                </form>
                
                <form row="'.$row++.'" col="0" halign="" valign="" nowrap="true"><name>participants'.md5( $this->mItemType.'-'.$this->mItemId ).'</name>
                  <args>
                  </args>
                  <children>
                
                <listbox><name>participants</name>
                  <args>
                    <disp>wui</disp>
                    <size>2</size>
                  </args>
                </listbox>
                
                  </children>
                </form>';
                */
                if ($summaries[$this->mItemType]['loggable']) {
                    $this->mDefinition .= '<vertgroup row="' . $row++ . '" col="0">
              <children>
              <horizgroup>
                <args>
                  <align>middle</align><width>0%</width>
                </args>
                <children>
                  <button>
                <args>
                  <themeimage>alignright</themeimage>
                  <themeimagetype>mini</themeimagetype>
                  <compact>true</compact>
                </args>
                  </button>
                  <label><name>itemlog</name>
                    <args>
                      <bold>true</bold>
                      <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('history.label'))) . '</label>
                      <compact>true</compact>
                    </args>
                  </label>
                </children>
              </horizgroup>
                <listbox><name>itemlog</name>
                  <args>
                <readonly>true</readonly>
                <elements type="array">' . WuiXml::encode(array_reverse($item_log->GetLog())) . '</elements>
                <size>3</size>
                  </args>
                </listbox>
              </children>
            </vertgroup>';
                }
                if ($summaries[$this->mItemType]['convertible']) {
                    $convert_types = array();
                    foreach ($summaries as $type => $item) {
                        if ($item['convertible'] and $type != $this->mItemType) {
                            $tmp_locale = new \Innomatic\Locale\LocaleCatalog($item['catalog'], $container->getCurrentUser()->getLanguage());
                            $convert_types[$type] = $tmp_locale->getStr($type);
                            unset($tmp_locale);
                        }
                    }
                    if (count($convert_types)) {
                        $this->mDefinition .= '<vertgroup row="' . $row++ . '" col="0">
                  <children>
                  <horizgroup>
                    <args>
                      <align>middle</align><width>0%</width>
                    </args>
                    <children>
                      <button>
<args>
  <themeimage>elementadd</themeimage>
  <themeimagetype>mini</themeimagetype>
  <compact>true</compact>
</args>
                      </button>
  <label><name>convert</name>
<args>
  <bold>true</bold>
  <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('convert.label'))) . '</label>
  <compact>true</compact>
</args>
  </label>
                    </children>
                  </horizgroup>

                    <form><name>convert' . md5($this->mItemType . '-' . $this->mItemId) . '</name>
                      <args>
<action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
                      </args>
                      <children>

                    <horizgroup>
                      <args>
<align>middle</align><width>0%</width>
                      </args>
                      <children>

<combobox><name>type</name>
  <args>
<disp>wui</disp>
<elements type="array">' . WuiXml::encode($convert_types) . '</elements>
  </args>
</combobox>

<button><name>convert</name>
  <args>
<horiz>true</horiz>
<frame>false</frame>
<themeimage>arrowright</themeimage>
<themeimagetype>mini</themeimagetype>
<compact>true</compact>
<formsubmit>convert' . md5($this->mItemType . '-' . $this->mItemId) . '</formsubmit>
<action>' . WuiXml::cdata($this->mDefaultAction . '&wui[wui][evn]=innoworkconvert') . '</action>
  </args>
</button>

  <formarg><name>aclitemtype</name><args><disp>wui</disp><value>' . $this->mItemType . '</value></args></formarg>
  <formarg><name>aclitemid</name><args><disp>wui</disp><value>' . $this->mItemId . '</value></args></formarg>

                      </children>
                    </horizgroup>

                      </children>
                    </form>
                  </children>
                </vertgroup>';
                    }
                }
                // Clippings
                if (count($clippings)) {
                    $this->mDefinition .= '<vertgroup row="' . $row++ . '" col="0">
              <children>
              <horizgroup>
                <args>
                  <align>middle</align><width>0%</width>
                </args>
                <children>
                  <button>
                <args>
                  <themeimage>clip</themeimage>
                  <themeimagetype>mini</themeimagetype>
                  <compact>true</compact>
                </args>
                  </button>
                  <label><name>clipping</name>
                    <args>
                      <bold>true</bold>
                      <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('clipping.label'))) . '</label>
                      <compact>true</compact>
                    </args>
                  </label>
                </children>
              </horizgroup>

                <form><name>clipping' . md5($this->mItemType . '-' . $this->mItemId) . '</name>
                  <args>
                <action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
                  </args>
                  <children>

                <horizgroup>
                  <args>
                <align>middle</align><width>0%</width>
                  </args>
                  <children>

                <combobox><name>clippingid</name>
                  <args>
                    <disp>wui</disp>
                    <elements type="array">' . WuiXml::encode($clippings) . '</elements>
                  </args>
                </combobox>

                <button><name>clipping</name>
                  <args>
                    <horiz>true</horiz>
                    <frame>false</frame>
                    <themeimage>arrowright</themeimage>
                    <themeimagetype>mini</themeimagetype>
                    <compact>true</compact>
                    <formsubmit>clipping' . md5($this->mItemType . '-' . $this->mItemId) . '</formsubmit>
                    <action>' . WuiXml::cdata($this->mDefaultAction . '&wui[wui][evn]=innoworkaddtoclipping') . '</action>
                  </args>
                </button>

                  <formarg><name>aclitemtype</name><args><disp>wui</disp><value>' . $this->mItemType . '</value></args></formarg>
                  <formarg><name>aclitemid</name><args><disp>wui</disp><value>' . $this->mItemId . '</value></args></formarg>

                  </children>
                </horizgroup>

                  </children>
                </form>
              </children>
            </vertgroup>';
                }
            }
            if (isset($GLOBALS['innoworkcore']['itemacl'][$this->mItemType][$this->mItemId])) {
                $this->mDefinition .= '<label row="' . $row++ . '" col="0">
          <args>
        <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('acl_changed.label'))) . '</label>
        <bold>true</bold>
          </args>
        </label>';
            }
            $this->mDefinition .= '          </children>
        </table>

  </children>
</empty>';
        } else {
            $this->mDefinition = '
<empty><name>innoworkitemacl</name>
  <children>
    <form><name>opts' . md5($this->mItemType . '-' . $this->mItemId) . '</name>
      <args>
        <action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
      </args>
      <children>
        <formarg><name>aclmode</name>
          <args>
        <disp>wui</disp>
        <value>' . ($acl_mode == 'advanced' ? 'simple' : 'advanced') . '</value>
          </args>
        </formarg>
      </children>
    </form>

        <table><name>acl</name>
          <args>
        <headers type="array">' . WuiXml::encode(array('0' => array('label' => $locale->getStr('item_properties.label')))) . '</headers>
          </args>
          <children>';
            if (count($item_actions)) {
                foreach ($item_actions as $item_action) {
                    $this->mDefinition .= '<vertgroup row="' . $row++ . '" col="0"><children>';
                    $this->mDefinition .= $item_action;
                    $this->mDefinition .= '</children></vertgroup>';
                }
            }
            $this->mDefinition .= '
        <vertgroup row="' . $row++ . '" col="0" halign="" valign="" nowrap="true"><name>vg</name><children>
        <horizgroup>
    <args>
      <align>middle</align><width>0%</width>
    </args>
    <children>
      <button>
        <args>
          <themeimage>lock</themeimage>
          <themeimagetype>mini</themeimagetype>
          <compact>true</compact>
        </args>
      </button>
          <label><name>convert</name>
        <args>
          <bold>true</bold>
          <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('access_mode.label'))) . '</label>
          <compact>true</compact>
        </args>
          </label>
    </children>
  </horizgroup>';
            if (strlen($owner)) {
                $this->mDefinition .= '          <label><name>owner</name>
                <args>
                  <bold>true</bold>
                  <label type="encoded">' . WuiXml::cdata(urlencode(sprintf($locale->getStr('owner.label'), $owner))) . '</label>
                </args>
              </label>';
            }
            $this->mDefinition .= '          <label><name>acltype</name>
           <args>
          <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('acl_type_private.label'))) . '</label>
          <bold>' . ($this->mAclType == InnoworkAcl::TYPE_PRIVATE ? 'true' : 'false') . '</bold>
        </args>
          </label>
          <label><name>acltype</name>
        <args>
          <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('acl_type_public.label'))) . '</label>
          <bold>' . ($this->mAclType == InnoworkAcl::TYPE_PUBLIC ? 'true' : 'false') . '</bold>
        </args>
          </label>
          <label><name>acltype</name>
        <args>
          <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('acl_type_acl.label'))) . '</label>
          <bold>' . ($this->mAclType == InnoworkAcl::TYPE_ACL ? 'true' : 'false') . '</bold>
        </args>
          </label>

<horizgroup><args><width>0%</width></args>
  <children>
    <button><name>setopts</name>
      <args>
        <action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
        <formsubmit>opts' . md5($this->mItemType . '-' . $this->mItemId) . '</formsubmit>
        <horiz>true</horiz>
        <frame>false</frame>
        <themeimage>' . ($acl_mode == 'advanced' ? 'info' : 'info') . '</themeimage>
        <themeimagetype>mini</themeimagetype>
        <compact>true</compact>
        <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr($acl_mode == 'advanced' ? 'acl_simple.submit' : 'acl_advanced.submit'))) . '</label>
      </args>
    </button>
  </children>
</horizgroup>
  </children>
</vertgroup>';
            if ($acl_mode == 'advanced') {
                if ($this->mAclType == InnoworkAcl::TYPE_ACL) {
                    $this->mDefinition .= '<form row="' . $row++ . '" col="0"><name>limitedacl' . md5($this->mItemType . '-' . $this->mItemId) . '</name>
              <args>
                <action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
              </args>
              <children>

                <listbox><name>limitedacl</name>
                  <args>
                <disp>wui</disp>
                <elements type="array">' . WuiXml::encode($limited_acls) . '</elements>
                <multiselect>true</multiselect>
                <size>10</size>
                  </args>
                </listbox>

                  <formarg><name>aclitemtype</name><args><disp>wui</disp><value>' . $this->mItemType . '</value></args></formarg>
                  <formarg><name>aclitemid</name><args><disp>wui</disp><value>' . $this->mItemId . '</value></args></formarg>

              </children>
            </form>';
                }
                if ($summaries[$this->mItemType]['loggable']) {
                    $this->mDefinition .= '<vertgroup row="' . $row++ . '" col="0">
              <children>
                <horizgroup>
                <args>
                  <align>middle</align><width>0%</width>
                </args>
                <children>
                  <button>
                <args>
                  <themeimage>alignright</themeimage>
                  <themeimagetype>mini</themeimagetype>
                  <compact>true</compact>
                </args>
                  </button>
                  <label><name>convert</name>
                    <args>
                      <bold>true</bold>
                      <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('history.label'))) . '</label>
                      <compact>true</compact>
                    </args>
                  </label>
                </children>
              </horizgroup>
                <listbox><name>itemlog</name>
                  <args>
                <readonly>true</readonly>
                <elements type="array">' . WuiXml::encode(array_reverse($item_log->GetLog())) . '</elements>
                <size>3</size>
                  </args>
                </listbox>
              </children>
            </vertgroup>';
                }
                if ($summaries[$this->mItemType]['convertible']) {
                    $convert_types = array();
                    foreach ($summaries as $type => $item) {
                        if ($item['convertible'] and $type != $this->mItemType) {
                            $tmp_locale = new \Innomatic\Locale\LocaleCatalog($item['catalog'], $container->getCurrentUser()->getLanguage());
                            $convert_types[$type] = $tmp_locale->getStr($type);
                            unset($tmp_locale);
                        }
                    }
                    if (count($convert_types)) {
                        $this->mDefinition .= '<vertgroup row="' . $row++ . '" col="0">
                  <children>
                  <horizgroup>
                    <args>
                      <align>middle</align><width>0%</width>
                    </args>
                    <children>
                      <button>
<args>
  <themeimage>elementadd</themeimage>
  <themeimagetype>mini</themeimagetype>
  <compact>true</compact>
</args>
                      </button>
  <label><name>convert</name>
<args>
  <bold>true</bold>
  <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('convert.label'))) . '</label>
  <compact>true</compact>
</args>
  </label>
                    </children>
                  </horizgroup>

                    <form><name>convert' . md5($this->mItemType . '-' . $this->mItemId) . '</name>
                      <args>
<action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
                      </args>
                      <children>

                    <horizgroup>
                      <args>
<align>middle</align><width>0%</width>
                      </args>
                      <children>

<combobox><name>type</name>
  <args>
<disp>wui</disp>
<elements type="array">' . WuiXml::encode($convert_types) . '</elements>
  </args>
</combobox>

<button><name>convert</name>
  <args>
<horiz>true</horiz>
<frame>false</frame>
<themeimage>arrowright</themeimage>
<themeimagetype>mini</themeimagetype>
<compact>true</compact>
<formsubmit>convert' . md5($this->mItemType . '-' . $this->mItemId) . '</formsubmit>
<action>' . WuiXml::cdata($this->mDefaultAction . '&wui[wui][evn]=innoworkconvert') . '</action>
  </args>
</button>

  <formarg><name>aclitemtype</name><args><disp>wui</disp><value>' . $this->mItemType . '</value></args></formarg>
  <formarg><name>aclitemid</name><args><disp>wui</disp><value>' . $this->mItemId . '</value></args></formarg>

                      </children>
                    </horizgroup>

                      </children>
                    </form>
                  </children>
                </vertgroup>';
                    }
                }
                // Clippings
                if (count($clippings)) {
                    $this->mDefinition .= '<vertgroup row="' . $row++ . '" col="0">
              <children>
              <horizgroup>
                <args>
                  <align>middle</align><width>0%</width>
                </args>
                <children>
                  <button>
                <args>
                  <themeimage>clip</themeimage>
                  <themeimagetype>mini</themeimagetype>
                  <compact>true</compact>
                </args>
                  </button>
                  <label><name>clipping</name>
                    <args>
                      <bold>true</bold>
                      <label type="encoded">' . WuiXml::cdata(urlencode($locale->getStr('clipping.label'))) . '</label>
                      <compact>true</compact>
                    </args>
                  </label>
                </children>
              </horizgroup>

                <form><name>clipping' . md5($this->mItemType . '-' . $this->mItemId) . '</name>
                  <args>
                <action>' . WuiXml::cdata($this->mDefaultAction) . '</action>
                  </args>
                  <children>

                <horizgroup>
                  <args>
                <align>middle</align><width>0%</width>
                  </args>
                  <children>

                <combobox><name>clippingid</name>
                  <args>
                    <disp>wui</disp>
                    <elements type="array">' . WuiXml::encode($clippings) . '</elements>
                  </args>
                </combobox>

                <button><name>clipping</name>
                  <args>
                    <horiz>true</horiz>
                    <frame>false</frame>
                    <themeimage>arrowright</themeimage>
                    <themeimagetype>mini</themeimagetype>
                    <compact>true</compact>
                    <formsubmit>clipping' . md5($this->mItemType . '-' . $this->mItemId) . '</formsubmit>
                    <action>' . WuiXml::cdata($this->mDefaultAction . '&wui[wui][evn]=innoworkaddtoclipping') . '</action>
                  </args>
                </button>

                  <formarg><name>aclitemtype</name><args><disp>wui</disp><value>' . $this->mItemType . '</value></args></formarg>
                  <formarg><name>aclitemid</name><args><disp>wui</disp><value>' . $this->mItemId . '</value></args></formarg>

                  </children>
                </horizgroup>

                  </children>
                </form>
              </children>
            </vertgroup>';
                }
            }
            $this->mDefinition .= '
          </children>
        </table>

  </children>
</empty>';
        }
        $result = true;
    }