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


PHP Asset::LoadArrayByAssetModelId方法代码示例

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


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

示例1: btnMassDeleteConfirm_Click

 protected function btnMassDeleteConfirm_Click()
 {
     $this->dlgMassDelete->HideDialogBox();
     $items = $this->dtgAssetModel->getSelected('AssetModelId');
     $this->lblWarning->Text = "";
     $arrToSkip = array();
     foreach ($items as $item) {
         // First check that the user is authorized to edit this model
         $objAssetModel = AssetModel::Load($item);
         if (!QApplication::AuthorizeEntityBoolean($objAssetModel, 3)) {
             $this->lblWarning->Text = 'You are not authorized to delete one or more of the selected models.';
             $this->dlgMassDelete->HideDialogBox();
             return;
         }
     }
     // Separating items able to be deleted
     foreach ($items as $item) {
         $arrAssetAssigned = Asset::LoadArrayByAssetModelId($item);
         if (!$arrAssetAssigned || count($arrAssetAssigned) <= 0) {
             $this->arrToDelete[] = $item;
         } else {
             $arrToSkip[] = $item;
         }
     }
     if (count($arrToSkip) > 0) {
         if (count($arrToSkip) == 1) {
             $toBe = 'is';
             $ending = '';
             $skipping = 'this';
         } else {
             $toBe = 'are';
             $ending = 's';
             $skipping = 'these';
         }
         if (count($arrToSkip) == count($items)) {
             $this->lblWarning->Text = 'Models with assigned assets cannot be deleted.';
             $this->dlgMassDelete->HideDialogBox();
             return;
         }
         $intToDelete = count($items) - count($arrToSkip);
         $this->dlgMassDelete->Text = sprintf('<div class="title"> Model Mass Delete - %s records</div><hr/>', $intToDelete);
         $this->dlgMassDelete->Text .= sprintf("%s of the selected Models %s assigned to an asset and cannot be deleted.\n\t\t\t\t\t\t\t\t   Would you like to continue the deletion process,\n\t\t\t\t\t\t\t\t   skipping %s Model%s?<br /><br />", count($arrToSkip), $toBe, count($arrToSkip) > 1 ? $skipping . ' ' . count($arrToSkip) : $skipping, $ending);
         $this->btnMassDeleteConfirm->Display = false;
         $this->btnMassDeleteConfirmSkip->Display = true;
         $this->dlgMassDelete->ShowDialogBox();
     } else {
         if (count($this->arrToDelete) > 0) {
             AssetModel::DeleteSelected($this->arrToDelete);
             $this->arrToDelete = array();
             QApplication::Redirect('');
         }
     }
 }
开发者ID:proxymoron,项目名称:tracmor,代码行数:53,代码来源:asset_model_list.php

示例2: GetAssetArray

 /**
  * Gets all associated Assets as an array of Asset objects
  * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  * @return Asset[]
  */
 public function GetAssetArray($objOptionalClauses = null)
 {
     if (is_null($this->intAssetModelId)) {
         return array();
     }
     try {
         return Asset::LoadArrayByAssetModelId($this->intAssetModelId, $objOptionalClauses);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
开发者ID:heshuai64,项目名称:einv2,代码行数:17,代码来源:AssetModelGen.class.php

示例3: UpdateEntityQtypeCustomFields


//.........这里部分代码省略.........
                 }
             }
         }
     }
     // Insert the new EntityQtypeCustomFields
     if ($this->lstCustomFieldQtype->SelectedItems) {
         foreach ($this->chkEntityQtype->SelectedItems as $objEntityQtypeItem) {
             // If the field doesn't already exist, then it needs to be created
             if (!($objEntityQtypeCustomField = EntityQtypeCustomField::LoadByEntityQtypeIdCustomFieldId($objEntityQtypeItem->Value, $this->objCustomField->CustomFieldId))) {
                 // add asset models
                 if ($objEntityQtypeItem->Value == 1) {
                     $this->AppendAssetModels();
                 }
                 $objEntityQtypeCustomField = new EntityQtypeCustomField();
                 $objEntityQtypeCustomField->CustomFieldId = $this->objCustomField->CustomFieldId;
                 $objEntityQtypeCustomField->EntityQtypeId = $objEntityQtypeItem->Value;
                 $objEntityQtypeCustomField->Save();
                 // If the helper table exists for that EntityQtype then create new column in the helper table
                 if ($strHelperTableArray = CustomFieldValue::GetHelperTableByEntityQtypeId($objEntityQtypeItem->Value)) {
                     $strHelperTable = $strHelperTableArray[0];
                     $objDatabase = CustomField::GetDatabase();
                     $strQuery = sprintf("ALTER TABLE %s ADD `cfv_%s` TEXT DEFAULT NULL;", $strHelperTable, $this->objCustomField->CustomFieldId);
                     $objDatabase->NonQuery($strQuery);
                     // If the helper table exists and have no values (empty).
                     // It happens when the QtypeItem does not yet have the custom fields.
                     // Uses SQL-hack to fix this issue.
                     $strParentTableName = $strHelperTableArray[1];
                     $strHelperTableItemId = sprintf("%s_id", $strParentTableName);
                     $strQuery = sprintf("INSERT INTO %s (`%s`) (SELECT `%s` FROM `%s` WHERE `%s` NOT IN (SELECT `%s` FROM %s));", $strHelperTable, $strHelperTableItemId, $strHelperTableItemId, $strParentTableName, $strHelperTableItemId, $strHelperTableItemId, $strHelperTable);
                     $objDatabase->NonQuery($strQuery);
                 }
                 // Insert the new EntityQtypeCustomField to the RoleEntityQTypeCustomFieldAuthorization table, to all the roles, with authorized_flag set to true, one for View Auth and another for Edit Auth
                 foreach (Role::LoadAll() as $objRole) {
                     //Insert the view Auth
                     $objRoleEntityQtypeCustomFieldAuth = new RoleEntityQtypeCustomFieldAuthorization();
                     $objRoleEntityQtypeCustomFieldAuth->RoleId = $objRole->RoleId;
                     $objRoleEntityQtypeCustomFieldAuth->EntityQtypeCustomFieldId = $objEntityQtypeCustomField->EntityQtypeCustomFieldId;
                     $objRoleEntityQtypeCustomFieldAuth->AuthorizationId = 1;
                     $objRoleEntityQtypeCustomFieldAuth->AuthorizedFlag = 1;
                     $objRoleEntityQtypeCustomFieldAuth->Save();
                     //Insert the Edit Auth
                     $objRoleEntityQtypeCustomFieldAuth = new RoleEntityQtypeCustomFieldAuthorization();
                     $objRoleEntityQtypeCustomFieldAuth->RoleId = $objRole->RoleId;
                     $objRoleEntityQtypeCustomFieldAuth->EntityQtypeCustomFieldId = $objEntityQtypeCustomField->EntityQtypeCustomFieldId;
                     $objRoleEntityQtypeCustomFieldAuth->AuthorizationId = 2;
                     $objRoleEntityQtypeCustomFieldAuth->AuthorizedFlag = 1;
                     $objRoleEntityQtypeCustomFieldAuth->Save();
                 }
             }
             // If this field is a required field
             if ($this->objCustomField->RequiredFlag) {
                 // Add the DefaultValue into the helper table
                 if ($strHelperTableArray = CustomFieldValue::GetHelperTableByEntityQtypeId($objEntityQtypeItem->Value)) {
                     $strHelperTable = $strHelperTableArray[0];
                     $blnError = false;
                     // If the custom field is text or textarea
                     if ($this->objCustomField->CustomFieldQtypeId != 2) {
                         if ($this->txtDefaultValue->Text != null) {
                             $txtDefaultValue = $this->txtDefaultValue->Text;
                         } else {
                             $blnError = true;
                         }
                     } elseif ($this->objCustomField->DefaultCustomFieldValueId != null) {
                         $txtDefaultValue = CustomFieldValue::LoadByCustomFieldValueId($this->objCustomField->DefaultCustomFieldValueId);
                     } else {
                         $blnError = true;
                     }
                     if (!$blnError) {
                         if (!($objEntityQtypeItem->Value == 1 && $this->rblAllAssetModels->SelectedValue == 2)) {
                             //print($objEntityQtypeItem->Value.$this->rblAllAssetModels->SelectedValue);exit;
                             $objDatabase = CustomField::GetDatabase();
                             $strQuery = sprintf("UPDATE %s SET `cfv_%s`='%s' WHERE `cfv_%s` is NULL;", $strHelperTable, $this->objCustomField->CustomFieldId, $txtDefaultValue, $this->objCustomField->CustomFieldId);
                             $objDatabase->NonQuery($strQuery);
                         } else {
                             // define assets to set default value
                             $chosenAssetModels = array();
                             foreach ($this->arrAssetModels as $chosenAssetModel) {
                                 $assetsToFill = Asset::LoadArrayByAssetModelId($chosenAssetModel->AssetModelId);
                                 if (count($assetsToFill > 0)) {
                                     foreach ($assetsToFill as $assetToFill) {
                                         array_push($chosenAssetModels, $assetToFill->AssetId);
                                     }
                                 }
                             }
                             $chosenAssetModels = implode(",", $chosenAssetModels);
                             //  Check if Model has any Assets need to be updated with new custom field and update them
                             if ($chosenAssetModels) {
                                 $objDatabase = CustomField::GetDatabase();
                                 $strQuery = sprintf("UPDATE %s SET `cfv_%s`='%s' WHERE `asset_id` IN ({$chosenAssetModels}) AND cfv_%s IS NULL;", $strHelperTable, $this->objCustomField->CustomFieldId, $txtDefaultValue, $this->objCustomField->CustomFieldId, $this->objCustomField->CustomFieldId);
                                 $objDatabase->NonQuery($strQuery);
                                 $strQuery = sprintf("UPDATE %s SET `cfv_%s`= NULL WHERE `asset_id` NOT IN({$chosenAssetModels});", $strHelperTable, $this->objCustomField->CustomFieldId);
                                 $objDatabase->NonQuery($strQuery);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:proxymoron,项目名称:tracmor,代码行数:101,代码来源:custom_field_edit.php

示例4: DeleteAllAssets

    /**
     * Deletes all associated Assets
     * @return void
     */
    public function DeleteAllAssets()
    {
        if (is_null($this->intAssetModelId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAsset on this unsaved AssetModel.');
        }
        // Get the Database Object for this Class
        $objDatabase = AssetModel::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (Asset::LoadArrayByAssetModelId($this->intAssetModelId) as $objAsset) {
                $objAsset->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`asset`
				WHERE
					`asset_model_id` = ' . $objDatabase->SqlVariable($this->intAssetModelId) . '
			');
    }
开发者ID:proxymoron,项目名称:tracmor,代码行数:25,代码来源:AssetModelGen.class.php


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