예제 #1
0
 protected function Form_Create()
 {
     parent::Form_Create();
     // "New" is a special keyword
     if (($strToken = trim(strtolower(QApplication::PathInfo(0)))) == 'new') {
         $strToken = null;
     }
     $objPackage = Package::LoadByToken($strToken);
     if (!$objPackage) {
         $objPackage = new Package();
         $this->blnEditMode = false;
         $this->strPageTitle .= 'Create New';
         $this->strHeadline = 'Create a New QPM Package';
     } else {
         if (!$objPackage->IsEditableForPerson(QApplication::$Person)) {
             QApplication::RedirectToLogin();
         }
         $this->blnEditMode = true;
         $this->strPageTitle .= 'Edit Package ' . $objPackage->Token;
         $this->strHeadline = 'Edit Package ' . $objPackage->Token;
     }
     $this->mctPackage = new PackageMetaControl($this, $objPackage);
     $this->txtToken = $this->mctPackage->txtToken_Create();
     $this->txtToken->Required = true;
     $this->lstCategory = $this->mctPackage->lstPackageCategory_Create();
     $this->lstCategory->Required = true;
     // Remove "Issue"
     for ($intIndex = 0; $intIndex < $this->lstCategory->ItemCount; $intIndex++) {
         $objListItem = $this->lstCategory->GetItem($intIndex);
         $objCategory = PackageCategory::Load($objListItem->Value);
         if ($objCategory && $objCategory->Token == 'issues') {
             $this->lstCategory->RemoveItem($intIndex);
             break;
         }
     }
     $this->txtName = $this->mctPackage->txtName_Create();
     $this->txtName->Required = true;
     $this->txtDescription = $this->mctPackage->txtDescription_Create();
     $this->txtDescription->Required = true;
     $this->btnOkay = new QButton($this);
     $this->btnOkay->CausesValidation = true;
     $this->btnOkay->Text = $this->blnEditMode ? 'Update Package' : 'Save New Package';
     $this->btnCancel = new QLinkButton($this);
     $this->btnCancel->Text = 'Cancel';
     $this->btnOkay->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnOkay));
     $this->btnOkay->AddAction(new QClickEvent(), new QAjaxAction('btnOkay_Click'));
     $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
     $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction());
     if (!$this->blnEditMode) {
         $this->txtToken->Focus();
     } else {
         $this->txtName->Focus();
     }
 }
예제 #2
0
 protected function Form_Create()
 {
     parent::Form_Create();
     $this->objCategory = PackageCategory::LoadByToken(QApplication::PathInfo(0));
     if (!$this->objCategory) {
         QApplication::Redirect('/qpm/');
     }
     $this->strPageTitle .= $this->objCategory->Name;
     $this->dtgPackages = new PackageDataGrid($this);
     $this->dtgPackages->SetDataBinder('dtgPackages_Bind');
     $this->dtgPackages->AlternateRowStyle->CssClass = 'alternate';
     $this->dtgPackages->MetaAddColumn('Name', 'VerticalAlign=top', 'Width=250px');
     $this->dtgPackages->MetaAddColumn('Token', 'Name=Path', 'VerticalAlign=top', 'Width=190px', 'HtmlEntities=false', 'Html=<a href="/qpm/package.php/<?= $_ITEM->Token; ?>" title="View Package Details"><?= $_ITEM->Token; ?></a>');
     $this->dtgPackages->MetaAddColumn('Description', 'CssClass=small', 'Width=300px');
     $this->dtgPackages->MetaAddColumn('LastPostDate', 'Name=Last Upload', 'Width=100px', 'VerticalAlign=top', 'CssClass=small');
     $this->dtgPackages->MetaAddColumn(QQN::Package()->LastPostedByPerson->DisplayName, 'Name=By', 'Html=<?= $_FORM->RenderPostedBy($_ITEM); ?>', 'HtmlEntities=false', 'Width=100px', 'CssClass=small reverseLink', 'VerticalAlign=top');
     $this->dtgPackages->Paginator = new QPaginator($this->dtgPackages);
     $this->btnNew = new RoundedLinkButton($this);
     $this->btnNew->CssClass = 'searchOption';
     $this->btnNew->ToolTip = 'Create a new QPM package';
     $this->btnNew->LinkUrl = '/qpm/edit.php/new';
 }
 /**
  * Refresh this MetaControl with Data from the local Package object.
  * @param boolean $blnReload reload Package from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objPackage->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objPackage->Id;
         }
     }
     if ($this->lstPackageCategory) {
         $this->lstPackageCategory->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstPackageCategory->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objPackageCategoryArray = PackageCategory::LoadAll();
         if ($objPackageCategoryArray) {
             foreach ($objPackageCategoryArray as $objPackageCategory) {
                 $objListItem = new QListItem($objPackageCategory->__toString(), $objPackageCategory->Id);
                 if ($this->objPackage->PackageCategory && $this->objPackage->PackageCategory->Id == $objPackageCategory->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPackageCategory->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPackageCategoryId) {
         $this->lblPackageCategoryId->Text = $this->objPackage->PackageCategory ? $this->objPackage->PackageCategory->__toString() : null;
     }
     if ($this->txtToken) {
         $this->txtToken->Text = $this->objPackage->Token;
     }
     if ($this->lblToken) {
         $this->lblToken->Text = $this->objPackage->Token;
     }
     if ($this->txtName) {
         $this->txtName->Text = $this->objPackage->Name;
     }
     if ($this->lblName) {
         $this->lblName->Text = $this->objPackage->Name;
     }
     if ($this->txtDescription) {
         $this->txtDescription->Text = $this->objPackage->Description;
     }
     if ($this->lblDescription) {
         $this->lblDescription->Text = $this->objPackage->Description;
     }
     if ($this->calLastPostDate) {
         $this->calLastPostDate->DateTime = $this->objPackage->LastPostDate;
     }
     if ($this->lblLastPostDate) {
         $this->lblLastPostDate->Text = sprintf($this->objPackage->LastPostDate) ? $this->objPackage->__toString($this->strLastPostDateDateTimeFormat) : null;
     }
     if ($this->lstLastPostedByPerson) {
         $this->lstLastPostedByPerson->RemoveAllItems();
         $this->lstLastPostedByPerson->AddItem(QApplication::Translate('- Select One -'), null);
         $objLastPostedByPersonArray = Person::LoadAll();
         if ($objLastPostedByPersonArray) {
             foreach ($objLastPostedByPersonArray as $objLastPostedByPerson) {
                 $objListItem = new QListItem($objLastPostedByPerson->__toString(), $objLastPostedByPerson->Id);
                 if ($this->objPackage->LastPostedByPerson && $this->objPackage->LastPostedByPerson->Id == $objLastPostedByPerson->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLastPostedByPerson->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLastPostedByPersonId) {
         $this->lblLastPostedByPersonId->Text = $this->objPackage->LastPostedByPerson ? $this->objPackage->LastPostedByPerson->__toString() : null;
     }
     if ($this->lstTopicLink) {
         $this->lstTopicLink->RemoveAllItems();
         $this->lstTopicLink->AddItem(QApplication::Translate('- Select One -'), null);
         $objTopicLinkArray = TopicLink::LoadAll();
         if ($objTopicLinkArray) {
             foreach ($objTopicLinkArray as $objTopicLink) {
                 $objListItem = new QListItem($objTopicLink->__toString(), $objTopicLink->Id);
                 if ($objTopicLink->PackageId == $this->objPackage->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstTopicLink->AddItem($objListItem);
             }
         }
     }
     if ($this->lblTopicLink) {
         $this->lblTopicLink->Text = $this->objPackage->TopicLink ? $this->objPackage->TopicLink->__toString() : null;
     }
 }
예제 #4
0
 protected function dtrPackageCategories_Bind()
 {
     $this->dtrPackageCategories->DataSource = PackageCategory::LoadAll(QQ::OrderBy(QQN::PackageCategory()->OrderNumber));
 }
예제 #5
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objPackageCategory) {
         $objObject->objPackageCategory = PackageCategory::GetSoapObjectFromObject($objObject->objPackageCategory, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPackageCategoryId = null;
         }
     }
     if ($objObject->dttLastPostDate) {
         $objObject->dttLastPostDate = $objObject->dttLastPostDate->__toString(QDateTime::FormatSoap);
     }
     if ($objObject->objLastPostedByPerson) {
         $objObject->objLastPostedByPerson = Person::GetSoapObjectFromObject($objObject->objLastPostedByPerson, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intLastPostedByPersonId = null;
         }
     }
     return $objObject;
 }
예제 #6
0
 /**
  * Creates the QPM Package for this Issue object.
  * @return Package
  */
 public function CreatePackage()
 {
     $objPackage = new Package();
     $objPackage->PackageCategory = PackageCategory::LoadByToken('issues');
     $objPackage->Token = 'issue_' . $this->intId;
     $objPackage->Name = 'Fix for Issue #' . $this->intId;
     $objPackage->Description = 'This package is for user-submitted fixes for Issue #' . $this->intId;
     $objPackage->Save();
     $objPackage->CreateTopicAndTopicLink($this->PostedByPerson);
     $objPackage->PackageCategory->RefreshStats();
     return $objPackage;
 }
 /**
  * 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 = PackageCategory::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 PackageCategory, given the clauses above
     $this->DataSource = PackageCategory::QueryArray($objCondition, $objClauses);
 }
 /**
  * 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 = PackageCategory::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 PackageCategory, given the clauses above
     $this->DataSource = PackageCategory::LoadAll($objClauses);
 }
예제 #9
0
            $strQpmXml .= '<changedFiles>';
            for ($intFileCount = 0; $intFileCount < $intChangedFileCount; $intFileCount++) {
                $strContent = QDataGen::GenerateContent(rand(1, 3), 20, 80);
                $strQpmXml .= sprintf('<file directoryToken="__FOOBAR__" path="some/random/path.txt" md5="%s">%s</file>', md5($strContent), base64_encode($strContent));
            }
            $strQpmXml .= '</changedFiles>';
            $strQpmXml .= '</package></qpm>';
            $objPackage->PostContributionVersion($objPerson, $strQpmXml, $dttPostDate);
            $dttEndRange = QDataGen::GenerateDateTime($dttPostDate, QDateTime::Now());
            $dttEndRange = QDataGen::GenerateDateTime($dttPostDate, $dttEndRange);
            $dttEndRange = QDataGen::GenerateDateTime($dttPostDate, $dttEndRange);
            $dttPostDate = QDataGen::GenerateDateTime($dttPostDate, $dttEndRange);
        }
    }
}
foreach (PackageCategory::LoadAll() as $objCategory) {
    $objCategory->RefreshStats();
}
// Generate Messages for Packages
QDataGen::DisplayForEachTaskStart($strTitle = 'Generating Messages for QPM Packages', Package::CountAll());
foreach (Package::LoadAll() as $objPackage) {
    QDataGen::DisplayForEachTaskNext($strTitle);
    $intCount = rand(1, GENERATE_MESSAGES_PER_PACKAGE_UBOUND);
    if (rand(0, 1)) {
        $intCount = round($intCount / 2);
    }
    if (rand(0, 1)) {
        $intCount = round($intCount / 2);
    }
    if (rand(0, 1)) {
        $intCount = round($intCount / 2);