<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3">
  <classes>
    <class id="Communication" _delta="define">
      <properties>
        <category>bizmodel,searchable</category>
        <abstract>false</abstract>
        <db_table>communication</db_table>
        <icon>
          <fileref ref="communication_90109793268989a4709622ad7341c32d"/>
        </icon>
        <reconciliation>
          <attributes>
            <attribute id="org_id"/>
            <attribute id="org_name"/>
            <attribute id="ref"/>
          </attributes>
        </reconciliation>
        <naming>
          <attributes>
            <attribute id="ref"/>
          </attributes>
        </naming>
      </properties>
      <fields>
        <field id="ref" xsi:type="AttributeString">
          <sql>ref</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
          <validation_pattern/>
        </field>
        <field id="start_date" xsi:type="AttributeDateTime">
          <sql>start_date</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="end_date" xsi:type="AttributeDateTime">
          <sql>end_date</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="status" xsi:type="AttributeEnum">
          <sql>status</sql>
          <values>
            <value id="ongoing">ongoing</value>
            <value id="closed">closed</value>
          </values>
          <default_value>ongoing</default_value>
          <is_null_allowed>false</is_null_allowed>
          <display_style>list</display_style>
        </field>
        <field id="org_id" xsi:type="AttributeExternalKey">
          <sql>org_id</sql>
          <filter/>
          <dependencies/>
          <is_null_allowed>false</is_null_allowed>
          <target_class>Organization</target_class>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="org_name" xsi:type="AttributeExternalField">
          <extkey_attcode>org_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="icon" xsi:type="AttributeEnum">
          <sql>icon</sql>
          <values>
            <value id="none">none</value>
            <value id="information">information</value>
            <value id="warning">warning</value>
            <value id="tip">tip</value>
            <value id="scoop">scoop</value>
          </values>
          <default_value>none</default_value>
          <is_null_allowed>false</is_null_allowed>
          <display_style>list</display_style>
        </field>
        <field id="title" xsi:type="AttributeString">
          <sql>title</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
          <validation_pattern/>
        </field>
        <field id="message" xsi:type="AttributeHTML">
          <sql>message</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
          <validation_pattern/>
          <width/>
          <height/>
        </field>
        <field id="organizations_list" xsi:type="AttributeLinkedSetIndirect">
          <linked_class>lnkCommunicationToOrganization</linked_class>
          <ext_key_to_me>communication_id</ext_key_to_me>
          <count_min>0</count_min>
          <count_max>0</count_max>
          <ext_key_to_remote>org_id</ext_key_to_remote>
          <duplicates/>
        </field>
        <field id="org_match_type" xsi:type="AttributeEnum">
          <sql>org_match_type</sql>
          <values>
            <value id="direct">direct</value>
            <value id="cascade">cascade</value>
            <value id="oql">oql</value>
          </values>
          <default_value>cascade</default_value>
          <is_null_allowed>false</is_null_allowed>
          <display_style>list</display_style>
        </field>
        <field id="org_oql" xsi:type="AttributeOQL">
          <sql>org_oql</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
          <width/>
          <height/>
          <tracking_level>all</tracking_level>
        </field>
      </fields>
      <lifecycle>
        <attribute>status</attribute>
        <highlight_scale>
        </highlight_scale>
        <states>
          <state id="ongoing">
            <flags>
              <attribute id="end_date"/>
              <attribute id="message">
                <mandatory/>
              </attribute>
              <attribute id="org_id">
                <mandatory/>
              </attribute>
              <attribute id="ref">
                <hidden/>
              </attribute>
              <attribute id="start_date">
                <mandatory/>
              </attribute>
              <attribute id="end_date">
                <must_prompt/>
              </attribute>
            </flags>
            <transitions>
              <transition id="ev_close">
                <stimulus>ev_close</stimulus>
                <target>closed</target>
                <actions>
                  <action>
                    <verb>SetCurrentDate</verb>
                    <params>
                      <param xsi:type="attcode">end_date</param>
                    </params>
                  </action>
                </actions>
              </transition>
            </transitions>
          </state>
          <state id="closed">
            <inherit_flags_from>ongoing</inherit_flags_from>
            <flags>
              <attribute id="end_date">
                <read_only/>
              </attribute>
              <attribute id="message">
                <read_only/>
              </attribute>
              <attribute id="org_id">
                <read_only/>
              </attribute>
              <attribute id="start_date">
                <read_only/>
              </attribute>
              <attribute id="ref">
                <read_only/>
              </attribute>
              <attribute id="organizations_list">
                <read_only/>
              </attribute>
              <attribute id="org_match_type">
                <read_only/>
              </attribute>
              <attribute id="org_oql">
                <read_only/>
              </attribute>
            </flags>
            <transitions>
              <transition id="ev_reopen">
                <stimulus>ev_reopen</stimulus>
                <target>ongoing</target>
                <actions></actions>
              </transition>
            </transitions>
          </state>
        </states>
        <stimuli>
          <stimulus id="ev_close" xsi:type="StimulusUserAction"/>
          <stimulus id="ev_reopen" xsi:type="StimulusUserAction"/>
        </stimuli>
      </lifecycle>
      <methods>
        <method id="DBInsertNoReload">
          <static>false</static>
          <access>public</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[
    public function DBInsertNoReload()
    {
          // N°2407: Temp. backward compatibility with iTop 2.6 and older
          // Remove usage of iTopMutex / MetaModel::GetNextKey() in next functional version of the extension
          if (!is_callable(array('ItopCounter', 'IncClass')))
          {
            $oMutex = new iTopMutex('communication_insert');
            $oMutex->Lock();
            $iCounter = MetaModel::GetNextKey(get_class($this));
          }
          else
          {
            $iCounter = ItopCounter::IncClass(get_class($this));
          }

          $sRef = sprintf('COM-%06d', $iCounter);
          $this->Set('ref', $sRef);
          $iKey = parent::DBInsertNoReload();

          // N°2407: Temp. backward compatibility with iTop 2.6 and older
          // Remove usage of iTopMutex / MetaModel::GetNextKey() in next functional version of the extension
          if (!is_callable(array('ItopCounter', 'IncClass')))
          {
            $oMutex->Unlock();
          }

          return $iKey;
    }
        ]]></code>
        </method>
        <method id="IsUserInScope">
          <static>false</static>
          <access>public</access>
          <type>Custom</type>
          <comment><![CDATA[/**
	 * Override to filter the communications
	 * @param User $oUser User account to check
	 * @return bool
	 */]]></comment>
          <code><![CDATA[    public function IsUserInScope(User $oUser)
    {
		// Is the user org within the target organizations
		$iContact = $oUser->Get('contactid');
		if ($iContact > 0) {
          $oContact = MetaModel::GetObject('Contact', $iContact, true, true);
          $iUserOrg = $oContact->Get('org_id');
        } else {
            $iUserOrg = 0;
        }
		$sMatchType = $this->Get('org_match_type');
        $bRet = false;

		if ($sMatchType === 'oql') {
            try {
                 // Target organizations defined as an OQL
                $oOrgSearch = DBSearch::FromOQL_AllData($this->Get('org_oql'));
                $oOrgSet = new DBObjectSet($oOrgSearch, array(), $this->ToArgs('this'));
                $aTargetOrgs = $oOrgSet->GetColumnAsArray('id');
                $bRet = in_array($iUserOrg, $aTargetOrgs);
            }  catch(Exception $e) {
                IssueLog::Error( "Communication:".$this->GetKey()." | ".Dict::Format('Class:Communication/Error:OQLNotValid', $e->getMessage()));
            }
		}
		else {
		    // Target organizations are those linked to the Communication
			$oOrgSearch = DBSearch::FromOQL_AllData('SELECT lnkCommunicationToOrganization WHERE communication_id = :communication_id');
		    $oOrgSet = new DBObjectSet($oOrgSearch, array(), array('communication_id' => $this->GetKey()));
		    $aTargetOrgs = $oOrgSet->GetColumnAsArray('org_id');
		    if (count($aTargetOrgs) == 0) {
		        // Target organizations are "All organizations" when none are explicitly linked to the Communication
			    $bRet = true;
		    }
		    elseif ($sMatchType === 'direct') {
    			// Target organizations are those directly linked to the communication
    			$bRet = in_array($iUserOrg, $aTargetOrgs);
			}
    		else { // ($sMatchType === 'cascade')
    		    // Target organizations are those directly linked to the communication or one of their sub-organizations
        		$oOrgHierarchical = DBSearch::FromOQL_AllData('SELECT Organization AS child JOIN Organization AS root ON child.parent_id BELOW root.id WHERE root.id IN (:target_org_list) AND child.id = :contact_org_id');
        		$oOrgHSet = new DBObjectSet($oOrgHierarchical, array(), array('contact_org_id' => $iUserOrg, 'target_org_list' => $aTargetOrgs));
        		$bRet = $oOrgHSet->Count() > 0;
    		}
    	}
		return $bRet;
    }
        ]]></code>
        </method>
        <method id="GetFontAwesomeIcon">
          <static>false</static>
          <access>public</access>
          <type>Custom</type>
          <comment><![CDATA[/**
	 * Override to change the icons
	 * @return string
	 */]]></comment>
          <code><![CDATA[    public function GetFontAwesomeIcon()
    {
		switch ($this->Get('icon'))
		{
			case 'information':
				$sIcon = 'info-circle';
				break;
			case 'warning':
				$sIcon = 'exclamation-triangle';
				break;
			case 'scoop':
				$sIcon = 'bullhorn';
				break;
			case 'tip':
				$sIcon = 'lightbulb';
				break;
			default:
				$sIcon = '';
		}
		return $sIcon;
    }
        ]]></code>
        </method>
        <method id="GetColorFromIcon">
          <static>false</static>
          <access>public</access>
          <type>Custom</type>
          <comment><![CDATA[/**
	 * Override to change colors in backoffice
	 * @return string
	 */]]></comment>
          <code><![CDATA[    public function GetColorFromIcon()
    {
		switch ($this->Get('icon'))
		{
			case 'information':
				$sColor = Combodo\iTop\Application\UI\Base\Component\Alert\Alert::ENUM_COLOR_SCHEME_INFORMATION;
				break;
			case 'warning':
				$sColor = Combodo\iTop\Application\UI\Base\Component\Alert\Alert::ENUM_COLOR_SCHEME_WARNING;
				break;
			case 'scoop':
				$sColor = Combodo\iTop\Application\UI\Base\Component\Alert\Alert::ENUM_COLOR_SCHEME_NEUTRAL;
				break;
			case 'tip':
				$sColor = Combodo\iTop\Application\UI\Base\Component\Alert\Alert::ENUM_COLOR_SCHEME_SUCCESS;
				break;
			default:
				$sColor = Combodo\iTop\Application\UI\Base\Component\Alert\Alert::ENUM_COLOR_SCHEME_NEUTRAL;
		}
		return $sColor;
    }
        ]]></code>
        </method>
        <method id="DoCheckToWrite">
          <static>false</static>
          <access>public</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[public function DoCheckToWrite()
    {
      parent::DoCheckToWrite();
      if ($this->Get('start_date') > $this->Get('end_date')) {
          $this->m_aCheckIssues[] = Dict::S('Class:Communication/Error:EndDateMustBeGreaterThanStartDate');
      }
      $sOql = $this->Get('org_oql');
      if ($this->Get('org_match_type') === 'oql') {
          if (empty($sOql)) {
              $this->m_aCheckIssues[] = Dict::S('Class:Communication/Error:OQLMustBeProvided');
          } else {
              try {
                  $oSearch = DBObjectSearch::FromOQL($sOql);
                  $sOqlClass = $oSearch->GetClass();
                  if ($sOqlClass !== 'Organization') {
                      $this->m_aCheckIssues[] = Dict::S('Class:Communication/Error:OQLMustReturnOrganization');
                  }
                  $oSet = new DBObjectSet($oSearch, [], $this->ToArgs('this'));
                  $oSet->CountWithLimit(10);
              } catch(Exception $e) {
                  $this->m_aCheckIssues[] = Dict::Format('Class:Communication/Error:OQLNotValid', $e->getMessage());
              }
          }
      } elseif (!empty($sOql)) {
          $this->m_aCheckWarnings[] = Dict::S('Class:Communication/Warning:OQLProvidedButUnused');
          if (count($this->Get('organizations_list'))<1) {
              $this->m_aCheckWarnings[] = Dict::S('Class:Communication/Warning:NoOrgSoAll');
          }
      }
    }]]></code>
        </method>
        <method id="DisplayBareRelations">
          <static>false</static>
          <access>public</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[
            public function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
    {
        parent::DisplayBareRelations($oPage, $bEditMode);
        $sMatchType = $this->Get('org_match_type');
        if (!$bEditMode) {
            $iKey = $this->GetKey();
            $aParams = array(
                'menu' => false,
                'table_id' => 'communication_preview_orgs_'.$iKey,
                'panel_icon' => MetaModel::GetClassIcon('Organization', false)
            );
            if ($sMatchType === 'oql') { // Result of OQL query regardless of user rights
                $oSearch = DBSearch::FromOQL_AllData($this->Get('org_oql'));
                $aParams['panel_title'] = Dict::S('Class:Communication/Attribute:org_match_type/Value:oql+');
            } elseif (count($this->Get('organizations_list')) == 0) { // All organizations visible to the current user
        		$oSearch = DBSearch::FromOQL('SELECT Organization');
        		$aParams['panel_title'] =Dict::S('Class:Communication/Tab:PreviewAll');
            } elseif ($sMatchType === 'direct') { // All Target organizations regardless of user rights
        		$oSearch = DBSearch::FromOQL_AllData('SELECT Organization AS O JOIN lnkCommunicationToOrganization AS L ON L.org_id=O.id WHERE L.communication_id = '.$iKey);
        		$aParams['panel_title'] = Dict::S('Class:Communication/Attribute:org_match_type/Value:direct+');
            } elseif ($sMatchType === 'cascade') {  // All Target organizations and any organization below regardless of user rights
        		$oSearch = DBSearch::FromOQL_AllData('SELECT Organization AS child JOIN Organization AS root ON child.parent_id BELOW root.id WHERE root.id IN (SELECT Organization AS O JOIN lnkCommunicationToOrganization AS L ON L.org_id=O.id WHERE L.communication_id = '.$iKey.')');
        		$aParams['panel_title'] = Dict::S('Class:Communication/Attribute:org_match_type/Value:cascade+');
            }
            try {
                $oSet = new DBObjectSet($oSearch, [], $this->ToArgs('this'));
                $oSet->SetShowObsoleteData(utils::ShowObsoleteData());
                $iCount = $oSet->CountWithLimit(100);
                $sCount = ($iCount == 100) ? '99+': $iCount;
                $oPage->SetCurrentTab(Dict::S('Class:Communication/Tab:Preview').' ('.$sCount.')');
                $oBlock = new DisplayBlock($oSearch, 'list', true);
                $aParams['this->id'] = $this->GetKey();
                $aParams['this->class'] = get_class($this);
                $oBlock->Display($oPage, 'communication_preview_'.$iKey, $aParams);
            } catch(Exception $e) {
                $this::SetSessionMessage(get_class($this), $this->GetKey(), 1, Dict::Format('Class:Communication/Error:OQLNotValid', $e->getMessage()), WebPage::ENUM_SESSION_MESSAGE_SEVERITY_ERROR, 1);
            }
        }
    }
            ]]>
          </code>
        </method>
        <method id="IsAllowedPortalsValid">
          <static>false</static>
          <access>public</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[	public function IsAllowedPortalsValid($sPortalToCheck = null)
	{
		// Check the context
		$oAllowedPortals = $this->Get('allowed_portals');
		$bChecked = false;
		$bValid = false;
		foreach ($oAllowedPortals->GetValues() as $sValue)
		{
			$bChecked = true;
			if (ContextTag::Check($sValue) || (isset($sPortalToCheck) && $sPortalToCheck === $sValue))
			{
				$bValid = true;
				break;
			}
		}
		if ($bChecked && !$bValid)
		{
			return false;
		}
		return true;
	}

            ]]></code>
        </method>
        <method id="PrefillCreationForm">
          <static>false</static>
          <type>Overload-DBObject</type>
          <code><![CDATA[
    public function PrefillCreationForm(&$aContextParam)
    {
      $this->Set('allowed_portals', ContextTag::TAG_PORTAL);
  
      parent::PrefillCreationForm($aContextParam);
    }
            ]]></code>
        </method>
      </methods>
      <presentation>
        <list>
          <items>
            <item id="title">
              <rank>20</rank>
            </item>
            <item id="org_id">
              <rank>20</rank>
            </item>
            <item id="start_date">
              <rank>30</rank>
            </item>
            <item id="end_date">
              <rank>40</rank>
            </item>
            <item id="status">
              <rank>50</rank>
            </item>
            <item id="icon">
              <rank>60</rank>
            </item>
          </items>
        </list>
        <default_search>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="title">
              <rank>20</rank>
            </item>
            <item id="status">
              <rank>30</rank>
            </item>
            <item id="start_date">
              <rank>40</rank>
            </item>
            <item id="end_date">
              <rank>50</rank>
            </item>
            <item id="org_id">
              <rank>60</rank>
            </item>
          </items>
        </default_search>
        <search>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="org_id">
              <rank>20</rank>
            </item>
            <item id="status">
              <rank>30</rank>
            </item>
            <item id="start_date">
              <rank>40</rank>
            </item>
            <item id="end_date">
              <rank>50</rank>
            </item>
            <item id="icon">
              <rank>60</rank>
            </item>
          </items>
        </search>
        <details>
          <items>
            <item id="col:col0">
              <items>
                <item id="fieldset:Communication:when">
                  <rank>10</rank>
                  <items>
                    <item id="ref">
                      <rank>10</rank>
                    </item>
                    <item id="org_id">
                      <rank>20</rank>
                    </item>
                    <item id="status">
                      <rank>30</rank>
                    </item>
                    <item id="start_date">
                      <rank>50</rank>
                    </item>
                    <item id="end_date">
                      <rank>60</rank>
                    </item>
                  </items>
                </item>
                <item id="fieldset:Communication:to_whom">
                  <rank>20</rank>
                  <items>
                    <item id="org_match_type">
                      <rank>70</rank>
                    </item>
                    <item id="org_oql" _delta="define">
                      <rank>80</rank>
                    </item>
                    <item id="allowed_portals">
                      <rank>90</rank>
                    </item>
                  </items>
                </item>
              </items>
              <rank>10</rank>
            </item>
            <item id="col:col1">
              <items>
                <item id="fieldset:Communication:what">
                  <rank>10</rank>
                  <items>
                    <item id="icon">
                      <rank>10</rank>
                    </item>
                    <item id="title">
                      <rank>20</rank>
                    </item>
                    <item id="message">
                      <rank>30</rank>
                    </item>
                  </items>
                  <rank>20</rank>
                </item>
              </items>
            </item>
            <item id="organizations_list">
                <rank>80</rank>
            </item>
          </items>
        </details>
      </presentation>
      <parent>cmdbAbstractObject</parent>
    </class>
    <class id="lnkCommunicationToOrganization" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <is_link>1</is_link>
        <category>bizmodel</category>
        <abstract>false</abstract>
        <key_type>autoincrement</key_type>
        <db_table>lnkcommunicationtoorganization</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="communication_ref"/>
            <attribute id="org_name"/>
          </attributes>
        </naming>
        <display_template/>
        <icon/>
        <reconciliation>
          <attributes>
            <attribute id="communication_id"/>
            <attribute id="org_id"/>
          </attributes>
        </reconciliation>
        <uniqueness_rules>
          <rule id="no_duplicate">
            <attributes>
              <attribute id="org_id"/>
              <attribute id="communication_id"/>
            </attributes>
            <filter><![CDATA[]]></filter>
            <disabled>false</disabled>
            <is_blocking>true</is_blocking>
          </rule>
        </uniqueness_rules>
      </properties>
      <fields>
        <field id="org_id" xsi:type="AttributeExternalKey">
          <sql>org_id</sql>
          <target_class>Organization</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="org_name" xsi:type="AttributeExternalField">
          <extkey_attcode>org_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="communication_id" xsi:type="AttributeExternalKey">
          <sql>communication_id</sql>
          <target_class>Communication</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="communication_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>communication_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
      </fields>
      <methods/>
      <presentation>
        <details>
          <items>
            <item id="communication_id">
              <rank>10</rank>
            </item>
            <item id="org_id">
              <rank>20</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="communication_id">
              <rank>10</rank>
            </item>
            <item id="org_id">
              <rank>20</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="communication_id">
              <rank>10</rank>
            </item>
            <item id="org_id">
              <rank>20</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
  </classes>
  <menus>
    <menu xsi:type="OQLMenuNode" id="Communication" _delta="define">
      <parent>ServiceManagement</parent>
      <rank>15</rank>
      <oql>SELECT Communication WHERE status != "closed"</oql>
      <do_search>1</do_search>
    </menu>
  </menus>
  <files>
    <file id="communication_90109793268989a4709622ad7341c32d" xsi:type="File" _delta="define_if_not_exists">
      <name>communication.png</name>
      <mime_type>image/png</mime_type>
      <width>48</width>
      <height>48</height>
      <data>iVBORw0KGgoAAAANSUhEUgAAAPAAAADwCAYAAAA+VemSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAO2ElEQVR4nO3dbYxc1XnA8bsmgEtFIG8SnlnXCiFS1IoAnXsW4kAdoqS0aey9EG/TpiUvakobNRVqmjLj9sOm73aJlDqNCtQzRkoIIU7aqv0QCTnWnLO7JEh15ZSZCBtinLlmFwjgPWdtXpP4VHe8JuCs7dnZmXnunfv/Sc9HS97d+59z574GAQAAAAAAAAAAAAAAAAAAAAAAAAAAADD8lHbviua8/7mZ9ceiOb9/fM7fGz3hf3ui6c+T/r8COEVo3K4lAz5lxmf9D6I5f9Op/x6AkNIe+7bQ2B93EvCrVubbJ71fxR8NEBYad68yrvN4fzbbpP/vQK6V9NHLlbY/7TLgZJc6kv4ZgNxSxu1O4u024GjWP8aBLUBAaOyHT8bbdcBz3t/4hJ/gDwgM0PqZpy8MjX28FwGPz/l7+OMBA6S0/cKr411JwMl5Yv54wICM6YXrQmN/0quAx2f9Uf54wABcUZ+/WGnXOjXeFa7Anj8eMMBzvoqAgWwJ6+7m08XLCgykmKrPX6mMO0bAQMao3e5NoXaPnSleVmAghUp7/blKW322eAkYSCGl3Z2dxEvAQMoo7T7TabwEDKSIM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Xg8kO/Jf3jAfk4Ol1u/EVQbj7Zw4D/VvrHAvL43fjaoNy8Pag0H2gHvZy7mMqNo+3dZlZeAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCTPh/p5hII4SvtykAAAAASUVORK5CYII=</data>
    </file>
  </files>
  <user_rights>
    <groups>
      <group id="Communication" _delta="define">
        <classes>
          <class id="Communication"/>
        </classes>
      </group>
    </groups>
    <profiles>
      <profile id="107" _delta="define">
        <name>Communication Manager</name>
        <description>Person responsible for managing communications to the customers</description>
        <groups>
          <group id="Communication">
            <actions>
              <action id="action:write">allow</action>
              <action id="action:bulk write">allow</action>
              <action id="action:delete">allow</action>
              <action id="action:bulk delete">allow</action>
              <action id="stimulus:ev_close">allow</action>
              <action id="stimulus:ev_reopen">allow</action>
              <action id="action:bulk read">allow</action>
            </actions>
          </group>
          <group id="*">
            <actions>
              <action id="action:read">allow</action>
            </actions>
          </group>
        </groups>
      </profile>
    </profiles>
  </user_rights>
  <module_designs>
    <module_design id="itop-portal" xsi:type="portal" _delta="if_exists">
      <bricks>
        <brick id="communication" xsi:type="Combodo\iTop\Portal\Brick\CommunicationBrick" _delta="define">
          <!-- Should be the class name (eg : CommunicationBrick) -->
          <active>true</active>
          <!-- yes|no -->
          <rank>1</rank>
          <!-- float -->
          <height>15</height>
          <!-- integer , size in em -->
          <width>12</width>
          <!-- integer , must be between 1 and 12 -->
          <title>Portal:Communications</title>
          <!-- string -->
          <oql></oql>
          <!-- Query for the displayed communications (if authorized to the current user, see Communication::IsAllowedToUser). Leave empty to preserve the default behavior. Use :now instead of NOW(). -->
          <security>
            <!-- Order is deny/allow Pseudo OQL traduction : WHERE user_profile NOT IN (:denied_profiles) AND user_profile IN (:allowed_profiles) -->
            <denied_profiles/>
            <!-- OQL query. Used only when not empty -->
            <allowed_profiles/>
            <!-- OQL query. Used only when not empty -->
          </security>
        </brick>
      </bricks>
    </module_design>
  </module_designs>
  <snippets>
    <snippet id="_Communication" _delta="define">
      <placement>module</placement>
      <module>itop-communications</module>
      <rank>2</rank>
      <content>
        <![CDATA[
abstract class _Communication extends cmdbAbstractObject
{
	/**
	 * @throws \CoreException
	 */
	public static function Init()
	{	
		$aParams = array
		(
			"category"            => "",
			"key_type"            => "autoincrement",
			"name_attcode"        => "",
			"state_attcode"       => "",
			"reconc_keys"         => array(),
			"db_table"            => "_communication",
			"db_key_field"        => "id",
			"db_finalclass_field" => "realclass",
		);
		MetaModel::Init_Params($aParams);
		
	
    // - Declare an attribute for class Communication in PHP as we need all declared portals in runtime
		$aAllTags = ContextTag::GetTags();
		$aPortalTags = array('Login' => 'Login');
		foreach($aAllTags as $sTagKey => $sTagValue){
			if(substr($sTagKey, 0, 4) === 'GUI:' || substr($sTagKey, 0, 7) === 'Portal:'){
				$aPortalTags[$sTagKey] = $sTagValue;
			}
		}

		MetaModel::Init_AddAttribute( new AttributeEnumSet("allowed_portals", array("allowed_values" => null, "possible_values" => new ValueSetEnumPadded($aPortalTags), "sql" => "allowed_portals", "depends_on" => array(), "is_null_allowed" => true, "max_items" => 12)), 'Communication');
	}
}
        ]]>
      </content>
    </snippet>
  </snippets>
</itop_design>
