示例#1
0
 protected function dtgContributions_Bind()
 {
     $objCondition = QQ::Equal(QQN::PackageContribution()->PackageId, $this->objPackage->Id);
     $this->dtgContributions->TotalItemCount = PackageContribution::QueryCount($objCondition);
     $objClauses = array();
     if ($objClause = $this->dtgContributions->LimitClause) {
         $objClauses[] = $objClause;
     }
     if ($objClause = $this->dtgContributions->OrderByClause) {
         $objClauses[] = $objClause;
     }
     $this->dtgContributions->DataSource = PackageContribution::QueryArray($objCondition, $objClauses);
 }
示例#2
0
    /**
     * Deletes all associated PackageContributions
     * @return void
     */
    public function DeleteAllPackageContributions()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociatePackageContribution on this unsaved Package.');
        }
        // Get the Database Object for this Class
        $objDatabase = Package::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (PackageContribution::LoadArrayByPackageId($this->intId) as $objPackageContribution) {
                $objPackageContribution->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`package_contribution`
				WHERE
					`package_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objPackageContribution) {
         $objObject->objPackageContribution = PackageContribution::GetSoapObjectFromObject($objObject->objPackageContribution, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPackageContributionId = null;
         }
     }
     if ($objObject->dttPostDate) {
         $objObject->dttPostDate = $objObject->dttPostDate->__toString(QDateTime::FormatSoap);
     }
     return $objObject;
 }
示例#4
0
 /**
  * Gets the most recently updated or uploaded contribution
  * @return PackageContribution
  */
 public function GetMostRecentContribution()
 {
     return PackageContribution::QuerySingle(QQ::Equal(QQN::PackageContribution()->PackageId, $this->intId), QQ::Clause(QQ::OrderBy(QQN::PackageContribution()->CurrentPostDate, false), QQ::LimitInfo(1)));
 }
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, PackageContribution::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
 /**
  * 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 = PackageContribution::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 PackageContribution, given the clauses above
     $this->DataSource = PackageContribution::QueryArray($objCondition, $objClauses);
 }
示例#7
0
 /**
  * @param string $strPackageName
  * @param string $strUsername
  * @param boolean $blnGzCompress
  * @return string
  */
 public function DownloadPackage($strPackageName, $strUsername, $blnGzCompress)
 {
     $objPerson = Person::LoadByUsername($strUsername);
     $objPackage = Package::Load($this->GetPackageId($strPackageName));
     if (!$objPerson) {
         return null;
     }
     if (!$objPackage) {
         return null;
     }
     $objPackageContribution = PackageContribution::LoadByPackageIdPersonId($objPackage->Id, $objPerson->Id);
     if (!$objPackageContribution) {
         return null;
     }
     if (!$objPackageContribution->CurrentPackageVersion) {
         return null;
     }
     $objPackageContribution->CurrentPackageVersion->DownloadCount++;
     $objPackageContribution->CurrentPackageVersion->Save();
     $objPackageContribution->RefreshStats();
     if ($blnGzCompress) {
         $strPath = $objPackageContribution->CurrentPackageVersion->GetFilePathCompressed();
     } else {
         $strPath = $objPackageContribution->CurrentPackageVersion->GetFilePath();
     }
     header('Content-Length: ' . filesize($strPath));
     return file_get_contents($strPath);
 }
 /**
  * Refresh this MetaControl with Data from the local PackageVersion object.
  * @param boolean $blnReload reload PackageVersion from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objPackageVersion->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objPackageVersion->Id;
         }
     }
     if ($this->lstPackageContribution) {
         $this->lstPackageContribution->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstPackageContribution->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objPackageContributionArray = PackageContribution::LoadAll();
         if ($objPackageContributionArray) {
             foreach ($objPackageContributionArray as $objPackageContribution) {
                 $objListItem = new QListItem($objPackageContribution->__toString(), $objPackageContribution->Id);
                 if ($this->objPackageVersion->PackageContribution && $this->objPackageVersion->PackageContribution->Id == $objPackageContribution->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPackageContribution->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPackageContributionId) {
         $this->lblPackageContributionId->Text = $this->objPackageVersion->PackageContribution ? $this->objPackageVersion->PackageContribution->__toString() : null;
     }
     if ($this->txtVersionNumber) {
         $this->txtVersionNumber->Text = $this->objPackageVersion->VersionNumber;
     }
     if ($this->lblVersionNumber) {
         $this->lblVersionNumber->Text = $this->objPackageVersion->VersionNumber;
     }
     if ($this->txtNotes) {
         $this->txtNotes->Text = $this->objPackageVersion->Notes;
     }
     if ($this->lblNotes) {
         $this->lblNotes->Text = $this->objPackageVersion->Notes;
     }
     if ($this->txtQcodoVersion) {
         $this->txtQcodoVersion->Text = $this->objPackageVersion->QcodoVersion;
     }
     if ($this->lblQcodoVersion) {
         $this->lblQcodoVersion->Text = $this->objPackageVersion->QcodoVersion;
     }
     if ($this->txtNewFileCount) {
         $this->txtNewFileCount->Text = $this->objPackageVersion->NewFileCount;
     }
     if ($this->lblNewFileCount) {
         $this->lblNewFileCount->Text = $this->objPackageVersion->NewFileCount;
     }
     if ($this->txtChangedFileCount) {
         $this->txtChangedFileCount->Text = $this->objPackageVersion->ChangedFileCount;
     }
     if ($this->lblChangedFileCount) {
         $this->lblChangedFileCount->Text = $this->objPackageVersion->ChangedFileCount;
     }
     if ($this->calPostDate) {
         $this->calPostDate->DateTime = $this->objPackageVersion->PostDate;
     }
     if ($this->lblPostDate) {
         $this->lblPostDate->Text = sprintf($this->objPackageVersion->PostDate) ? $this->objPackageVersion->__toString($this->strPostDateDateTimeFormat) : null;
     }
     if ($this->txtDownloadCount) {
         $this->txtDownloadCount->Text = $this->objPackageVersion->DownloadCount;
     }
     if ($this->lblDownloadCount) {
         $this->lblDownloadCount->Text = $this->objPackageVersion->DownloadCount;
     }
 }
 /**
  * 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 = PackageContribution::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 PackageContribution, given the clauses above
     $this->DataSource = PackageContribution::LoadAll($objClauses);
 }
示例#10
0
 /**
  * Counts all associated PackageContributions
  * @return int
  */
 public function CountPackageContributions()
 {
     if (is_null($this->intId)) {
         return 0;
     }
     return PackageContribution::CountByPersonId($this->intId);
 }
 /**
  * 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 PackageContributionMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing PackageContribution object creation - defaults to CreateOrEdit
  * @return PackageContributionMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objPackageContribution = PackageContribution::Load($intId);
         // PackageContribution was found -- return it!
         if ($objPackageContribution) {
             return new PackageContributionMetaControl($objParentObject, $objPackageContribution);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a PackageContribution 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 PackageContributionMetaControl($objParentObject, new PackageContribution());
 }
示例#12
0
$objPackageCategories = PackageCategory::QueryArray(QQ::NotEqual(QQN::PackageCategory()->Token, 'issues'));
while (QDataGen::DisplayWhileTask('Generating QPM Packages...', GENERATE_QPM)) {
    $objPackage = new Package();
    $objPackage->PackageCategory = QDataGen::GenerateFromArray($objPackageCategories);
    $objPackage->Name = QDataGen::GenerateTitle(1, 3);
    $objPackage->Token = Package::SanitizeForToken($objPackage->Name);
    while (Package::LoadByToken($objPackage->Token)) {
        $objPackage->Name = QDataGen::GenerateTitle(1, 3);
        $objPackage->Token = Package::SanitizeForToken($objPackage->Name);
    }
    $objPackage->Description = QDataGen::GenerateContent(rand(1, 3), 20, 80);
    $objPackage->Save();
    $objPackage->CreateTopicAndTopicLink(Person::Load(rand(1, $intMaxPersonId)));
    $intContributionCount = rand(1, 10);
    for ($intContribution = 0; $intContribution < $intContributionCount; $intContribution++) {
        while (PackageContribution::LoadByPackageIdPersonId($objPackage->Id, $objPerson->Id)) {
            $objPerson = Person::Load(rand(1, $intMaxPersonId));
        }
        $intVersionCount = rand(1, 4);
        $dttEndRange = QDataGen::GenerateDateTime($dttStartDate, QDateTime::Now());
        $dttEndRange = QDataGen::GenerateDateTime($dttStartDate, $dttEndRange);
        $dttEndRange = QDataGen::GenerateDateTime($dttStartDate, $dttEndRange);
        $dttPostDate = QDataGen::GenerateDateTime($dttStartDate, $dttEndRange);
        for ($intVersion = 0; $intVersion < $intVersionCount; $intVersion++) {
            // Randomize a Qcodo Version
            $strQcodoVersion = rand(0, 99) . '.' . rand(0, 99) . '.' . rand(0, 99);
            $strQcodoVersionType = rand(0, 1) ? 'Development' : 'Stable';
            // Randomize a New and Changed file count
            $intNewFileCount = rand(0, 10);
            $intChangedFileCount = rand(0, 10);
            // Randomize Notes