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


PHP MetaModel::IsValidAttCode方法代码示例

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


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

示例1: Analyze

 /**
  * Split the string into placholders
  * @param Hash $aParamTypes Class of the expected parameters: hash array of '<param_id>' => '<class_name>'
  * @return void
  */
 protected function Analyze($aParamTypes = array())
 {
     if (!is_null($this->m_aPlaceholders)) {
         return;
     }
     $this->m_aPlaceholders = array();
     if (preg_match_all('/\\$([a-z0-9_]+(->[a-z0-9_]+)*)\\$/', $this->m_sRaw, $aMatches)) {
         foreach ($aMatches[1] as $sPlaceholder) {
             $oPlaceholder = new TemplateStringPlaceholder($sPlaceholder);
             $oPlaceholder->bIsValid = false;
             foreach ($aParamTypes as $sParamName => $sClass) {
                 $sParamPrefix = $sParamName . '->';
                 if (substr($sPlaceholder, 0, strlen($sParamPrefix)) == $sParamPrefix) {
                     // Todo - detect functions (label...)
                     $oPlaceholder->sFunction = '';
                     $oPlaceholder->sParamName = $sParamName;
                     $sAttcode = substr($sPlaceholder, strlen($sParamPrefix));
                     $oPlaceholder->sAttcode = $sAttcode;
                     $oPlaceholder->bIsValid = MetaModel::IsValidAttCode($sClass, $sAttcode, true);
                 }
             }
             $this->m_aPlaceholders[] = $oPlaceholder;
         }
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:30,代码来源:templatestring.class.inc.php

示例2: FilterByContext

/**
 * Adds the context parameters to the audit query
 */
function FilterByContext(DBSearch &$oFilter, ApplicationContext $oAppContext)
{
    $sObjClass = $oFilter->GetClass();
    $aContextParams = $oAppContext->GetNames();
    $aCallSpec = array($sObjClass, 'MapContextParam');
    if (is_callable($aCallSpec)) {
        foreach ($aContextParams as $sParamName) {
            $sValue = $oAppContext->GetCurrentValue($sParamName, null);
            if ($sValue != null) {
                $sAttCode = call_user_func($aCallSpec, $sParamName);
                // Returns null when there is no mapping for this parameter
                if ($sAttCode != null && MetaModel::IsValidAttCode($sObjClass, $sAttCode)) {
                    // Check if the condition points to a hierarchical key
                    if ($sAttCode == 'id') {
                        // Filtering on the objects themselves
                        $sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($sObjClass);
                        if ($sHierarchicalKeyCode !== false) {
                            $oRootFilter = new DBObjectSearch($sObjClass);
                            $oRootFilter->AddCondition($sAttCode, $sValue);
                            $oFilter->AddCondition_PointingTo($oRootFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
                            // Use the 'below' operator by default
                            $bConditionAdded = true;
                        }
                    } else {
                        $oAttDef = MetaModel::GetAttributeDef($sObjClass, $sAttCode);
                        $bConditionAdded = false;
                        if ($oAttDef->IsExternalKey()) {
                            $sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($oAttDef->GetTargetClass());
                            if ($sHierarchicalKeyCode !== false) {
                                $oRootFilter = new DBObjectSearch($oAttDef->GetTargetClass());
                                $oRootFilter->AddCondition('id', $sValue);
                                $oHKFilter = new DBObjectSearch($oAttDef->GetTargetClass());
                                $oHKFilter->AddCondition_PointingTo($oRootFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
                                // Use the 'below' operator by default
                                $oFilter->AddCondition_PointingTo($oHKFilter, $sAttCode);
                                $bConditionAdded = true;
                            }
                        }
                    }
                    if (!$bConditionAdded) {
                        $oFilter->AddCondition($sAttCode, $sValue);
                    }
                }
            }
        }
    }
}
开发者ID:henryavila,项目名称:itop,代码行数:50,代码来源:audit.php

示例3: DisplayBareRelations

 function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
 {
     parent::DisplayBareRelations($oPage, $bEditMode);
     $sTicketListAttCode = 'tickets_list';
     if (MetaModel::IsValidAttCode(get_class($this), $sTicketListAttCode)) {
         // Display one list per leaf class (the only way to display the status as of now)
         $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sTicketListAttCode);
         $sLnkClass = $oAttDef->GetLinkedClass();
         $sExtKeyToMe = $oAttDef->GetExtKeyToMe();
         $sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
         $iTotal = 0;
         $aSearches = array();
         foreach (MetaModel::EnumChildClasses('Ticket') as $sSubClass) {
             if (!MetaModel::HasChildrenClasses($sSubClass)) {
                 $sStateAttCode = MetaModel::GetStateAttributeCode($sSubClass);
                 if ($sStateAttCode != '') {
                     $oSearch = DBSearch::FromOQL("SELECT {$sSubClass} AS t JOIN {$sLnkClass} AS lnk ON lnk.{$sExtKeyToRemote} = t.id WHERE {$sExtKeyToMe} = :myself AND {$sStateAttCode} NOT IN ('rejected', 'resolved', 'closed')", array('myself' => $this->GetKey()));
                     $aSearches[$sSubClass] = $oSearch;
                     $oSet = new DBObjectSet($oSearch);
                     $iTotal += $oSet->Count();
                 }
             }
         }
         $sCount = $iTotal > 0 ? ' (' . $iTotal . ')' : '';
         $oPage->SetCurrentTab(Dict::S('Class:FunctionalCI/Tab:OpenedTickets') . $sCount);
         foreach ($aSearches as $sSubClass => $oSearch) {
             $sBlockId = __CLASS__ . '_opened_' . $sSubClass;
             $oPage->add('<fieldset>');
             $oPage->add('<legend>' . MetaModel::GetName($sSubClass) . '</legend>');
             $oBlock = new DisplayBlock($oSearch, 'list', false);
             $oBlock->Display($oPage, $sBlockId, array('menu' => false));
             $oPage->add('</fieldset>');
         }
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:35,代码来源:model.itop-config-mgmt.php

示例4: AddConditionAdvanced

 /**
  * Specify a condition on external keys or link sets
  * @param sAttSpec Can be either an attribute code or extkey->[sAttSpec] or linkset->[sAttSpec] and so on, recursively
  *                 Example: infra_list->ci_id->location_id->country	 
  * @param value The value to match (can be an array => IN(val1, val2...)
  * @return void
  */
 public function AddConditionAdvanced($sAttSpec, $value)
 {
     $sClass = $this->GetClass();
     $iPos = strpos($sAttSpec, '->');
     if ($iPos !== false) {
         $sAttCode = substr($sAttSpec, 0, $iPos);
         $sSubSpec = substr($sAttSpec, $iPos + 2);
         if (!MetaModel::IsValidAttCode($sClass, $sAttCode)) {
             throw new Exception("Invalid attribute code '{$sClass}/{$sAttCode}' in condition specification '{$sAttSpec}'");
         }
         $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
         if ($oAttDef->IsLinkSet()) {
             $sTargetClass = $oAttDef->GetLinkedClass();
             $sExtKeyToMe = $oAttDef->GetExtKeyToMe();
             $oNewFilter = new DBObjectSearch($sTargetClass);
             $oNewFilter->AddConditionAdvanced($sSubSpec, $value);
             $this->AddCondition_ReferencedBy($oNewFilter, $sExtKeyToMe);
         } elseif ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) {
             $sTargetClass = $oAttDef->GetTargetClass(EXTKEY_ABSOLUTE);
             $oNewFilter = new DBObjectSearch($sTargetClass);
             $oNewFilter->AddConditionAdvanced($sSubSpec, $value);
             $this->AddCondition_PointingTo($oNewFilter, $sAttCode);
         } else {
             throw new Exception("Attribute specification '{$sAttSpec}', '{$sAttCode}' should be either a link set or an external key");
         }
     } else {
         // $sAttSpec is an attribute code
         //
         if (is_array($value)) {
             $oField = new FieldExpression($sAttSpec, $this->GetClass());
             $oListExpr = ListExpression::FromScalars($value);
             $oInValues = new BinaryExpression($oField, 'IN', $oListExpr);
             $this->AddConditionExpression($oInValues);
         } else {
             $this->AddCondition($sAttSpec, $value);
         }
     }
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:45,代码来源:dbobjectsearch.class.php

示例5: GetValueDescription

 public function GetValueDescription($sValue)
 {
     if (is_null($sValue)) {
         // Unless a specific label is defined for the null value of this enum, use a generic "undefined" label
         $sDescription = Dict::S('Class:' . $this->GetHostClass() . '/Attribute:' . $this->GetCode() . '/Value:' . $sValue . '+', Dict::S('Enum:Undefined'));
     } else {
         $sDescription = Dict::S('Class:' . $this->GetHostClass() . '/Attribute:' . $this->GetCode() . '/Value:' . $sValue . '+', '', true);
         if (strlen($sDescription) == 0) {
             $sParentClass = MetaModel::GetParentClass($this->m_sHostClass);
             if ($sParentClass) {
                 if (MetaModel::IsValidAttCode($sParentClass, $this->m_sCode)) {
                     $oAttDef = MetaModel::GetAttributeDef($sParentClass, $this->m_sCode);
                     $sDescription = $oAttDef->GetValueDescription($sValue);
                 }
             }
         }
     }
     return $sDescription;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:19,代码来源:attributedef.class.inc.php

示例6: ForgotPwdGo

 protected function ForgotPwdGo()
 {
     $sAuthUser = utils::ReadParam('auth_user', '', true, 'raw_data');
     try {
         UserRights::Login($sAuthUser);
         // Set the user's language (if possible!)
         $oUser = UserRights::GetUserObject();
         if ($oUser == null) {
             throw new Exception(Dict::Format('UI:ResetPwd-Error-WrongLogin', $sAuthUser));
         }
         if (!MetaModel::IsValidAttCode(get_class($oUser), 'reset_pwd_token')) {
             throw new Exception(Dict::S('UI:ResetPwd-Error-NotPossible'));
         }
         if (!$oUser->CanChangePassword()) {
             throw new Exception(Dict::S('UI:ResetPwd-Error-FixedPwd'));
         }
         $sTo = $oUser->GetResetPasswordEmail();
         // throws Exceptions if not allowed
         if ($sTo == '') {
             throw new Exception(Dict::S('UI:ResetPwd-Error-NoEmail'));
         }
         // This token allows the user to change the password without knowing the previous one
         $sToken = substr(md5(APPROOT . uniqid()), 0, 16);
         $oUser->Set('reset_pwd_token', $sToken);
         CMDBObject::SetTrackInfo('Reset password');
         $oUser->DBUpdate();
         $oEmail = new Email();
         $oEmail->SetRecipientTO($sTo);
         $sFrom = MetaModel::GetConfig()->Get('forgot_password_from');
         if ($sFrom == '') {
             $sFrom = $sTo;
         }
         $oEmail->SetRecipientFrom($sFrom);
         $oEmail->SetSubject(Dict::S('UI:ResetPwd-EmailSubject'));
         $sResetUrl = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?loginop=reset_pwd&auth_user=' . urlencode($oUser->Get('login')) . '&token=' . urlencode($sToken);
         $oEmail->SetBody(Dict::Format('UI:ResetPwd-EmailBody', $sResetUrl));
         $iRes = $oEmail->Send($aIssues, true);
         switch ($iRes) {
             //case EMAIL_SEND_PENDING:
             case EMAIL_SEND_OK:
                 break;
             case EMAIL_SEND_ERROR:
             default:
                 IssueLog::Error('Failed to send the email with the NEW password for ' . $oUser->Get('friendlyname') . ': ' . implode(', ', $aIssues));
                 throw new Exception(Dict::S('UI:ResetPwd-Error-Send'));
         }
         $this->DisplayLoginHeader();
         $this->add("<div id=\"login\">\n");
         $this->add("<h1>" . Dict::S('UI:Login:ForgotPwdForm') . "</h1>\n");
         $this->add("<p>" . Dict::S('UI:ResetPwd-EmailSent') . "</p>");
         $this->add("<form method=\"post\">\n");
         $this->add("<table>\n");
         $this->add("<tr><td colspan=\"2\" class=\"center v-spacer\"><input type=\"button\" onClick=\"window.close();\" value=\"" . Dict::S('UI:Button:Done') . "\" /></td></tr>\n");
         $this->add("</table>\n");
         $this->add("</form>\n");
         $this->add("</div\n");
     } catch (Exception $e) {
         $this->DisplayForgotPwdForm(true, $e->getMessage());
     }
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:60,代码来源:loginwebpage.class.inc.php

示例7: UpdateObjectFromArray

 /**
  * Updates the object from a flat array of values
  * @param string $aValues array of attcode => scalar or array (N-N links)
  * @return void
  */
 public function UpdateObjectFromArray($aValues)
 {
     foreach ($aValues as $sAttCode => $value) {
         $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
         if ($oAttDef->IsLinkSet() && $oAttDef->IsIndirect()) {
             $aLinks = $value;
             $sLinkedClass = $oAttDef->GetLinkedClass();
             $sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
             $sExtKeyToMe = $oAttDef->GetExtKeyToMe();
             $oLinkedSet = DBObjectSet::FromScratch($sLinkedClass);
             if (is_array($aLinks)) {
                 foreach ($aLinks as $id => $aData) {
                     if (is_numeric($id)) {
                         if ($id < 0) {
                             // New link to be created, the opposite of the id (-$id) is the ID of the remote object
                             $oLink = MetaModel::NewObject($sLinkedClass);
                             $oLink->Set($sExtKeyToRemote, -$id);
                             $oLink->Set($sExtKeyToMe, $this->GetKey());
                         } else {
                             // Existing link, potentially to be updated...
                             $oLink = MetaModel::GetObject($sLinkedClass, $id);
                         }
                         // Now populate the attributes
                         foreach ($aData as $sName => $value) {
                             if (MetaModel::IsValidAttCode($sLinkedClass, $sName)) {
                                 $oLinkAttDef = MetaModel::GetAttributeDef($sLinkedClass, $sName);
                                 if ($oLinkAttDef->IsWritable()) {
                                     $oLink->Set($sName, $value);
                                 }
                             }
                         }
                         $oLinkedSet->AddObject($oLink);
                     }
                 }
             }
             $this->Set($sAttCode, $oLinkedSet);
         } elseif ($oAttDef->GetEditClass() == 'Document') {
             // There should be an uploaded file with the named attr_<attCode>
             $oDocument = $value['fcontents'];
             if (!$oDocument->IsEmpty()) {
                 // A new file has been uploaded
                 $this->Set($sAttCode, $oDocument);
             }
         } elseif ($oAttDef->GetEditClass() == 'One Way Password') {
             // Check if the password was typed/changed
             $aPwdData = $value;
             if (!is_null($aPwdData) && $aPwdData['changed']) {
                 // The password has been changed or set
                 $this->Set($sAttCode, $aPwdData['value']);
             }
         } elseif ($oAttDef->GetEditClass() == 'Duration') {
             $aDurationData = $value;
             if (!is_array($aDurationData)) {
                 continue;
             }
             $iValue = ((24 * $aDurationData['d'] + $aDurationData['h']) * 60 + $aDurationData['m']) * 60 + $aDurationData['s'];
             $this->Set($sAttCode, $iValue);
             $previousValue = $this->Get($sAttCode);
             if ($previousValue !== $iValue) {
                 $this->Set($sAttCode, $iValue);
             }
         } else {
             if ($oAttDef->GetEditClass() == 'LinkedSet' && !$oAttDef->IsIndirect() && ($oAttDef->GetEditMode() == LINKSET_EDITMODE_INPLACE || $oAttDef->GetEditMode() == LINKSET_EDITMODE_ADDREMOVE)) {
                 $oLinkset = $this->Get($sAttCode);
                 $sLinkedClass = $oLinkset->GetClass();
                 $aObjSet = array();
                 $oLinkset->Rewind();
                 $bModified = false;
                 while ($oLink = $oLinkset->Fetch()) {
                     if (in_array($oLink->GetKey(), $value['to_be_deleted'])) {
                         // The link is to be deleted, don't copy it in the array
                         $bModified = true;
                     } else {
                         if (!array_key_exists('to_be_removed', $value) || !in_array($oLink->GetKey(), $value['to_be_removed'])) {
                             $aObjSet[] = $oLink;
                         }
                     }
                 }
                 if (array_key_exists('to_be_created', $value) && count($value['to_be_created']) > 0) {
                     // Now handle the links to be created
                     foreach ($value['to_be_created'] as $aData) {
                         $sSubClass = $aData['class'];
                         if ($sLinkedClass == $sSubClass || is_subclass_of($sSubClass, $sLinkedClass)) {
                             $aObjData = $aData['data'];
                             $oLink = new $sSubClass();
                             $oLink->UpdateObjectFromArray($aObjData);
                             $aObjSet[] = $oLink;
                             $bModified = true;
                         }
                     }
                 }
                 if (array_key_exists('to_be_added', $value) && count($value['to_be_added']) > 0) {
                     // Now handle the links to be added by making the remote object point to self
                     foreach ($value['to_be_added'] as $iObjKey) {
                         $oLink = MetaModel::GetObject($sLinkedClass, $iObjKey, false);
//.........这里部分代码省略.........
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:101,代码来源:cmdbabstract.class.inc.php

示例8: _CreateResponseTicket

 /**
  * Create an ResponseTicket (Incident or UserRequest) from an external system
  * Some CIs might be specified (by their name/IP)
  *	 
  * @param string sClass The class of the ticket: Incident or UserRequest
  * @param string sTitle
  * @param string sDescription
  * @param array aCallerDesc
  * @param array aCustomerDesc
  * @param array aServiceDesc
  * @param array aServiceSubcategoryDesc
  * @param string sProduct
  * @param array aWorkgroupDesc
  * @param array aImpactedCIs
  * @param string sImpact
  * @param string sUrgency
  *
  * @return WebServiceResult
  */
 protected function _CreateResponseTicket($sClass, $sTitle, $sDescription, $aCallerDesc, $aCustomerDesc, $aServiceDesc, $aServiceSubcategoryDesc, $sProduct, $aWorkgroupDesc, $aImpactedCIs, $sImpact, $sUrgency)
 {
     $oRes = new WebServiceResult();
     try {
         $oMyChange = MetaModel::NewObject("CMDBChange");
         $oMyChange->Set("date", time());
         $oMyChange->Set("userinfo", "Administrator");
         $iChangeId = $oMyChange->DBInsertNoReload();
         $oNewTicket = MetaModel::NewObject($sClass);
         $this->MyObjectSetScalar('title', 'title', $sTitle, $oNewTicket, $oRes);
         $this->MyObjectSetScalar('description', 'description', $sDescription, $oNewTicket, $oRes);
         $this->MyObjectSetExternalKey('org_id', 'customer', $aCustomerDesc, $oNewTicket, $oRes);
         $this->MyObjectSetExternalKey('caller_id', 'caller', $aCallerDesc, $oNewTicket, $oRes);
         $this->MyObjectSetExternalKey('service_id', 'service', $aServiceDesc, $oNewTicket, $oRes);
         if (!array_key_exists('service_id', $aServiceSubcategoryDesc)) {
             $aServiceSubcategoryDesc['service_id'] = $oNewTicket->Get('service_id');
         }
         $this->MyObjectSetExternalKey('servicesubcategory_id', 'servicesubcategory', $aServiceSubcategoryDesc, $oNewTicket, $oRes);
         if (MetaModel::IsValidAttCode($sClass, 'product')) {
             // 1.x data models
             $this->MyObjectSetScalar('product', 'product', $sProduct, $oNewTicket, $oRes);
         }
         if (MetaModel::IsValidAttCode($sClass, 'workgroup_id')) {
             // 1.x data models
             $this->MyObjectSetExternalKey('workgroup_id', 'workgroup', $aWorkgroupDesc, $oNewTicket, $oRes);
         } else {
             if (MetaModel::IsValidAttCode($sClass, 'team_id')) {
                 // 2.x data models
                 $this->MyObjectSetExternalKey('team_id', 'workgroup', $aWorkgroupDesc, $oNewTicket, $oRes);
             }
         }
         if (MetaModel::IsValidAttCode($sClass, 'ci_list')) {
             // 1.x data models
             $aDevicesNotFound = $this->AddLinkedObjects('ci_list', 'impacted_cis', 'FunctionalCI', $aImpactedCIs, $oNewTicket, $oRes);
         } else {
             if (MetaModel::IsValidAttCode($sClass, 'functionalcis_list')) {
                 // 2.x data models
                 $aDevicesNotFound = $this->AddLinkedObjects('functionalcis_list', 'impacted_cis', 'FunctionalCI', $aImpactedCIs, $oNewTicket, $oRes);
             }
         }
         if (count($aDevicesNotFound) > 0) {
             $this->MyObjectSetScalar('description', 'n/a', $sDescription . ' - Related CIs: ' . implode(', ', $aDevicesNotFound), $oNewTicket, $oRes);
         } else {
             $this->MyObjectSetScalar('description', 'n/a', $sDescription, $oNewTicket, $oRes);
         }
         $this->MyObjectSetScalar('impact', 'impact', $sImpact, $oNewTicket, $oRes);
         $this->MyObjectSetScalar('urgency', 'urgency', $sUrgency, $oNewTicket, $oRes);
         $this->MyObjectInsert($oNewTicket, 'created', $oMyChange, $oRes);
     } catch (CoreException $e) {
         $oRes->LogError($e->getMessage());
     } catch (Exception $e) {
         $oRes->LogError($e->getMessage());
     }
     $this->LogUsage(__FUNCTION__, $oRes);
     return $oRes;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:75,代码来源:webservices.basic.php

示例9: GetContactId

 public static function GetContactId($sName = '')
 {
     if (empty($sName)) {
         $oUser = self::$m_oUser;
     } else {
         $oUser = FindUser($sName);
     }
     if (is_null($oUser)) {
         return '';
     }
     if (!MetaModel::IsValidAttCode(get_class($oUser), 'contactid')) {
         return '';
     }
     return $oUser->Get('contactid');
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:15,代码来源:userrights.class.inc.php

示例10: Get

 public function Get($sAttCode)
 {
     if (($iPos = strpos($sAttCode, '->')) === false) {
         return $this->GetStrict($sAttCode);
     } else {
         $sExtKeyAttCode = substr($sAttCode, 0, $iPos);
         $sRemoteAttCode = substr($sAttCode, $iPos + 2);
         if (!MetaModel::IsValidAttCode(get_class($this), $sExtKeyAttCode)) {
             throw new CoreException("Unknown external key '{$sExtKeyAttCode}' for the class " . get_class($this));
         }
         $oExtFieldAtt = MetaModel::FindExternalField(get_class($this), $sExtKeyAttCode, $sRemoteAttCode);
         if (!is_null($oExtFieldAtt)) {
             return $this->GetStrict($oExtFieldAtt->GetCode());
         } else {
             $oKeyAttDef = MetaModel::GetAttributeDef(get_class($this), $sExtKeyAttCode);
             $sRemoteClass = $oKeyAttDef->GetTargetClass();
             $oRemoteObj = MetaModel::GetObject($sRemoteClass, $this->GetStrict($sExtKeyAttCode), false);
             if (is_null($oRemoteObj)) {
                 return '';
             } else {
                 return $oRemoteObj->Get($sRemoteAttCode);
             }
         }
     }
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:25,代码来源:dbobject.class.php

示例11: GetOwnerOrganizationAttCode

 /**
  * Find out which attribute is corresponding the the dimension 'owner org'
  * returns null if no such attribute has been found (no filtering should occur)	 
  */
 public static function GetOwnerOrganizationAttCode($sClass)
 {
     $sAttCode = null;
     $aCallSpec = array($sClass, 'MapContextParam');
     if ($sClass == 'Organization' || is_subclass_of($sClass, 'Organization')) {
         $sAttCode = 'id';
     } elseif (is_callable($aCallSpec)) {
         $sAttCode = call_user_func($aCallSpec, 'org_id');
         // Returns null when there is no mapping for this parameter
         if (!MetaModel::IsValidAttCode($sClass, $sAttCode)) {
             // Skip silently. The data model checker will tell you something about this...
             $sAttCode = null;
         }
     } elseif (MetaModel::IsValidAttCode($sClass, 'org_id')) {
         $sAttCode = 'org_id';
     }
     return $sAttCode;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:22,代码来源:userrightsprofile.class.inc.php

示例12: IsValidAttCode

 public static final function IsValidAttCode($sClass, $sAttCode, $bExtended = false)
 {
     if (!array_key_exists($sClass, self::$m_aAttribDefs)) {
         return false;
     }
     if ($bExtended) {
         if (($iPos = strpos($sAttCode, '->')) === false) {
             $bRes = array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]);
         } else {
             $sExtKeyAttCode = substr($sAttCode, 0, $iPos);
             $sRemoteAttCode = substr($sAttCode, $iPos + 2);
             if (MetaModel::IsValidAttCode($sClass, $sExtKeyAttCode)) {
                 $oKeyAttDef = MetaModel::GetAttributeDef($sClass, $sExtKeyAttCode);
                 $sRemoteClass = $oKeyAttDef->GetTargetClass();
                 $bRes = MetaModel::IsValidAttCode($sRemoteClass, $sRemoteAttCode, true);
             } else {
                 $bRes = false;
             }
         }
     } else {
         $bRes = array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]);
     }
     return $bRes;
 }
开发者ID:henryavila,项目名称:itop,代码行数:24,代码来源:metamodel.class.php

示例13: SetDefaultOrgId

 /**
  * Give a default value for item_org_id (if relevant...)
  * @return void
  */
 public function SetDefaultOrgId()
 {
     // First check that the organization CAN be fetched from the target class
     //
     $sClass = $this->Get('item_class');
     $aCallSpec = array($sClass, 'MapContextParam');
     if (is_callable($aCallSpec)) {
         $sAttCode = call_user_func($aCallSpec, 'org_id');
         // Returns null when there is no mapping for this parameter
         if (MetaModel::IsValidAttCode($sClass, $sAttCode)) {
             // Second: check that the organization CAN be fetched from the current user
             //
             if (MetaModel::IsValidClass('Person')) {
                 $aCallSpec = array($sClass, 'MapContextParam');
                 if (is_callable($aCallSpec)) {
                     $sAttCode = call_user_func($aCallSpec, 'org_id');
                     // Returns null when there is no mapping for this parameter
                     if (MetaModel::IsValidAttCode($sClass, $sAttCode)) {
                         // OK - try it
                         //
                         $oCurrentPerson = MetaModel::GetObject('Person', UserRights::GetContactId(), false);
                         if ($oCurrentPerson) {
                             $this->Set('item_org_id', $oCurrentPerson->Get($sAttCode));
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:34,代码来源:model.itop-attachments.php

示例14: InitObjectFromContext

 /**
  * Initializes the given object with the default values provided by the context
  */
 public function InitObjectFromContext(DBObject &$oObj)
 {
     $sClass = get_class($oObj);
     foreach ($this->GetNames() as $key) {
         $aCallSpec = array($sClass, 'MapContextParam');
         if (is_callable($aCallSpec)) {
             $sAttCode = call_user_func($aCallSpec, $key);
             // Returns null when there is no mapping for this parameter
             if (MetaModel::IsValidAttCode($sClass, $sAttCode)) {
                 $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
                 if ($oAttDef->IsWritable()) {
                     $value = $this->GetCurrentValue($key, null);
                     if (!is_null($value)) {
                         $oObj->Set($sAttCode, $value);
                     }
                 }
             }
         }
     }
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:23,代码来源:applicationcontext.class.inc.php

示例15: LoadFile

 /**
  * Helper function to load the objects from a standard XML file into the database
  * @param $sFilePath string The full path to the XML file to load
  * @param $bUpdateKeyCacheOnly bool Set to true to *just* update the keys cache but not reload the objects
  */
 function LoadFile($sFilePath, $bUpdateKeyCacheOnly = false)
 {
     global $aKeys;
     $oXml = simplexml_load_file($sFilePath);
     $aReplicas = array();
     foreach ($oXml as $sClass => $oXmlObj) {
         if (!MetaModel::IsValidClass($sClass)) {
             SetupPage::log_error("Unknown class - {$sClass}");
             throw new Exception("Unknown class - {$sClass}");
         }
         $iSrcId = (int) $oXmlObj['id'];
         // Mandatory to cast
         // Import algorithm
         // Here enumerate all the attributes of the object
         // for all attribute that is neither an external field
         // not an external key, assign it
         // Store all external keys for further reference
         // Create the object an store the correspondance between its newly created Id
         // and its original Id
         // Once all the objects have been created re-assign all the external keys to
         // their actual Ids
         $iExistingId = $this->GetObjectKey($sClass, $iSrcId);
         if ($iExistingId != 0) {
             $oTargetObj = MetaModel::GetObject($sClass, $iExistingId);
         } else {
             $oTargetObj = MetaModel::NewObject($sClass);
         }
         foreach ($oXmlObj as $sAttCode => $oSubNode) {
             if (!MetaModel::IsValidAttCode($sClass, $sAttCode)) {
                 $sMsg = "Unknown attribute code - {$sClass}/{$sAttCode}";
                 continue;
                 // ignore silently...
                 //SetupPage::log_error($sMsg);
                 //throw(new Exception($sMsg));
             }
             $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
             if ($oAttDef->IsWritable() && $oAttDef->IsScalar()) {
                 if ($oAttDef->IsExternalKey()) {
                     if (substr(trim($oSubNode), 0, 6) == 'SELECT') {
                         $sQuery = trim($oSubNode);
                         $oSet = new DBObjectSet(DBObjectSearch::FromOQL($sQuery));
                         $iMatches = $oSet->Count();
                         if ($iMatches == 1) {
                             $oFoundObject = $oSet->Fetch();
                             $iExtKey = $oFoundObject->GetKey();
                         } else {
                             $sMsg = "Ext key not reconcilied - {$sClass}/{$iSrcId} - {$sAttCode}: '" . $sQuery . "' - found {$iMatches} matche(s)";
                             SetupPage::log_error($sMsg);
                             $this->m_aErrors[] = $sMsg;
                             $iExtKey = 0;
                         }
                     } else {
                         $iDstObj = (int) $oSubNode;
                         // Attempt to find the object in the list of loaded objects
                         $iExtKey = $this->GetObjectKey($oAttDef->GetTargetClass(), $iDstObj);
                         if ($iExtKey == 0) {
                             $iExtKey = -$iDstObj;
                             // Convention: Unresolved keys are stored as negative !
                             $oTargetObj->RegisterAsDirty();
                         }
                         // here we allow external keys to be invalid because we will resolve them later on...
                     }
                     //$oTargetObj->CheckValue($sAttCode, $iExtKey);
                     $oTargetObj->Set($sAttCode, $iExtKey);
                 } elseif ($oAttDef instanceof AttributeBlob) {
                     $sMimeType = (string) $oSubNode->mimetype;
                     $sFileName = (string) $oSubNode->filename;
                     $data = base64_decode((string) $oSubNode->data);
                     $oDoc = new ormDocument($data, $sMimeType, $sFileName);
                     $oTargetObj->Set($sAttCode, $oDoc);
                 } else {
                     $value = (string) $oSubNode;
                     if ($value == '') {
                         $value = $oAttDef->GetNullValue();
                     }
                     $res = $oTargetObj->CheckValue($sAttCode, $value);
                     if ($res !== true) {
                         // $res contains the error description
                         $sMsg = "Value not allowed - {$sClass}/{$iSrcId} - {$sAttCode}: '" . $oSubNode . "' ; {$res}";
                         SetupPage::log_error($sMsg);
                         $this->m_aErrors[] = $sMsg;
                     }
                     $oTargetObj->Set($sAttCode, $value);
                 }
             }
         }
         $this->StoreObject($sClass, $oTargetObj, $iSrcId, $bUpdateKeyCacheOnly, $bUpdateKeyCacheOnly);
     }
     return true;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:95,代码来源:xmldataloader.class.inc.php


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