コード例 #1
0
function GenerateOptionsForField($strFieldName, $strOptionNameArray)
{
    $objIssueField = IssueField::QuerySingle(QQ::Equal(QQN::IssueField()->Name, $strFieldName));
    $intOrderNumber = 0;
    foreach ($strOptionNameArray as $strOptionName) {
        $intOrderNumber++;
        $objOption = new IssueFieldOption();
        $objOption->IssueField = $objIssueField;
        $objOption->Name = $strOptionName;
        $objOption->SetToken();
        $objOption->OrderNumber = $intOrderNumber;
        $objOption->ActiveFlag = true;
        $objOption->Save();
    }
}
コード例 #2
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, IssueFieldOption::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
コード例 #3
0
 /**
  * Refresh this MetaControl with Data from the local IssueFieldValue object.
  * @param boolean $blnReload reload IssueFieldValue from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objIssueFieldValue->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objIssueFieldValue->Id;
         }
     }
     if ($this->lstIssue) {
         $this->lstIssue->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstIssue->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objIssueArray = Issue::LoadAll();
         if ($objIssueArray) {
             foreach ($objIssueArray as $objIssue) {
                 $objListItem = new QListItem($objIssue->__toString(), $objIssue->Id);
                 if ($this->objIssueFieldValue->Issue && $this->objIssueFieldValue->Issue->Id == $objIssue->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstIssue->AddItem($objListItem);
             }
         }
     }
     if ($this->lblIssueId) {
         $this->lblIssueId->Text = $this->objIssueFieldValue->Issue ? $this->objIssueFieldValue->Issue->__toString() : null;
     }
     if ($this->lstIssueField) {
         $this->lstIssueField->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstIssueField->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objIssueFieldArray = IssueField::LoadAll();
         if ($objIssueFieldArray) {
             foreach ($objIssueFieldArray as $objIssueField) {
                 $objListItem = new QListItem($objIssueField->__toString(), $objIssueField->Id);
                 if ($this->objIssueFieldValue->IssueField && $this->objIssueFieldValue->IssueField->Id == $objIssueField->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstIssueField->AddItem($objListItem);
             }
         }
     }
     if ($this->lblIssueFieldId) {
         $this->lblIssueFieldId->Text = $this->objIssueFieldValue->IssueField ? $this->objIssueFieldValue->IssueField->__toString() : null;
     }
     if ($this->lstIssueFieldOption) {
         $this->lstIssueFieldOption->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstIssueFieldOption->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objIssueFieldOptionArray = IssueFieldOption::LoadAll();
         if ($objIssueFieldOptionArray) {
             foreach ($objIssueFieldOptionArray as $objIssueFieldOption) {
                 $objListItem = new QListItem($objIssueFieldOption->__toString(), $objIssueFieldOption->Id);
                 if ($this->objIssueFieldValue->IssueFieldOption && $this->objIssueFieldValue->IssueFieldOption->Id == $objIssueFieldOption->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstIssueFieldOption->AddItem($objListItem);
             }
         }
     }
     if ($this->lblIssueFieldOptionId) {
         $this->lblIssueFieldOptionId->Text = $this->objIssueFieldValue->IssueFieldOption ? $this->objIssueFieldValue->IssueFieldOption->__toString() : null;
     }
 }
コード例 #4
0
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this IssueFieldOptionMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing IssueFieldOption object creation - defaults to CreateOrEdit
  * @return IssueFieldOptionMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objIssueFieldOption = IssueFieldOption::Load($intId);
         // IssueFieldOption was found -- return it!
         if ($objIssueFieldOption) {
             return new IssueFieldOptionMetaControl($objParentObject, $objIssueFieldOption);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a IssueFieldOption object with PK arguments: ' . $intId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new IssueFieldOptionMetaControl($objParentObject, new IssueFieldOption());
 }
コード例 #5
0
 /**
  * Default / simple DataBinder for this Meta DataGrid.  This can easily be overridden
  * by calling SetDataBinder() on this DataGrid with another DataBinder of your choice.
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  */
 public function MetaDataBinder()
 {
     // Remember!  We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = IssueFieldOption::CountAll();
     }
     // Setup the $objClauses Array
     $objClauses = array();
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from IssueFieldOption, given the clauses above
     $this->DataSource = IssueFieldOption::LoadAll($objClauses);
 }
コード例 #6
0
ファイル: edit.php プロジェクト: qcodo/qcodo-website
 protected function lstField_Save(QListBox $lstField)
 {
     if ($lstField->SelectedValue) {
         // Did the user select "OTHER"?
         if ($lstField->SelectedValue == -1) {
             // Yes -- we need to create the new IssueFieldOption
             $objIssueField = IssueField::Load($lstField->ActionParameter);
             $objIssueFieldOption = $objIssueField->CreateNewIssueFieldOption($this->txtMutableFields[$lstField->ActionParameter]->Text);
         } else {
             // No -- let's use theexisting IssueFieldOption
             $objIssueFieldOption = IssueFieldOption::Load($lstField->SelectedValue);
         }
         // Now let's set it to the Issue!
         $this->mctIssue->Issue->SetFieldOption($objIssueFieldOption);
     }
 }
コード例 #7
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objIssue) {
         $objObject->objIssue = Issue::GetSoapObjectFromObject($objObject->objIssue, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intIssueId = null;
         }
     }
     if ($objObject->objIssueField) {
         $objObject->objIssueField = IssueField::GetSoapObjectFromObject($objObject->objIssueField, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intIssueFieldId = null;
         }
     }
     if ($objObject->objIssueFieldOption) {
         $objObject->objIssueFieldOption = IssueFieldOption::GetSoapObjectFromObject($objObject->objIssueFieldOption, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intIssueFieldOptionId = null;
         }
     }
     return $objObject;
 }
コード例 #8
0
    /**
     * Deletes all associated IssueFieldOptions
     * @return void
     */
    public function DeleteAllIssueFieldOptions()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateIssueFieldOption on this unsaved IssueField.');
        }
        // Get the Database Object for this Class
        $objDatabase = IssueField::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (IssueFieldOption::LoadArrayByIssueFieldId($this->intId) as $objIssueFieldOption) {
                $objIssueFieldOption->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`issue_field_option`
				WHERE
					`issue_field_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
コード例 #9
0
 /**
  * This will set the Token field of this object to the TokenizeName-d version of the Name field of this object.
  * @return void
  */
 public function SetToken()
 {
     $this->strToken = IssueFieldOption::TokenizeName($this->strName);
 }
コード例 #10
0
 /**
  * Gets the array of active IssueFieldOptions for this IssueField in the appropriate order
  * @return IssueFieldOption[]
  */
 public function GetOptionArray()
 {
     return IssueFieldOption::LoadArrayByIssueFieldIdActiveFlag($this->intId, true, QQ::OrderBy(QQN::IssueFieldOption()->OrderNumber));
 }
コード例 #11
0
 /**
  * Main utility method to aid with data binding.  It is used by the default BindAllRows() databinder but
  * could and should be used by any custom databind methods that would be used for instances of this
  * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. 
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  *
  * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
  * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query		 
  * @return void
  */
 public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
 {
     // Setup input parameters to default values if none passed in
     if (!$objCondition) {
         $objCondition = QQ::All();
     }
     $objClauses = $objOptionalClauses ? $objOptionalClauses : array();
     // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = IssueFieldOption::QueryCount($objCondition, $objClauses);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from IssueFieldOption, given the clauses above
     $this->DataSource = IssueFieldOption::QueryArray($objCondition, $objClauses);
 }