/**
  * 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 = GroupAuthorizedSender::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 GroupAuthorizedSender, given the clauses above
     $this->DataSource = GroupAuthorizedSender::QueryArray($objCondition, $objClauses);
 }
示例#2
0
    /**
     * Deletes all associated GroupAuthorizedSenders
     * @return void
     */
    public function DeleteAllGroupAuthorizedSenders()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateGroupAuthorizedSender on this unsaved Person.');
        }
        // Get the Database Object for this Class
        $objDatabase = Person::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (GroupAuthorizedSender::LoadArrayByPersonId($this->intId) as $objGroupAuthorizedSender) {
                $objGroupAuthorizedSender->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`group_authorized_sender`
				WHERE
					`person_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
示例#3
0
 public function RenderAuthorizedSender(Person $objPerson)
 {
     $objGroupAuthorizedsender = GroupAuthorizedSender::LoadByGroupIdPersonId($this->objGroup->Id, $objPerson->Id);
     if ($objGroupAuthorizedsender) {
         return 'Y';
     } else {
         return '';
     }
 }
 /**
  * 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 GroupAuthorizedSenderMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing GroupAuthorizedSender object creation - defaults to CreateOrEdit
  * @return GroupAuthorizedSenderMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objGroupAuthorizedSender = GroupAuthorizedSender::Load($intId);
         // GroupAuthorizedSender was found -- return it!
         if ($objGroupAuthorizedSender) {
             return new GroupAuthorizedSenderMetaControl($objParentObject, $objGroupAuthorizedSender);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a GroupAuthorizedSender 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 GroupAuthorizedSenderMetaControl($objParentObject, new GroupAuthorizedSender());
 }
示例#5
0
 /**
  * Given the locally set Login and CommListEntry link, and given an array of Person[] objects all which
  * represent the FromEmailAddress, iterate through the array of Group objects to see which ones
  * the sender can send to.  Associate any valid ones to this object as a new EmailMessageRoute.
  * Return any invalid (e.g. unauthorized) ones as an array.
  * @param Group[] $objGroupArray
  * @param mixed[] $objSenderArray
  * @return Group[] returns any unauthorized Groups that the sender is not allowed to send to
  */
 protected function SetupGroupRoutes($objGroupArray, $objSenderArray)
 {
     // Pull out the components of the $objSenderArray
     $objLogin = $objSenderArray[0];
     $objCommunicationListEntry = $objSenderArray[1];
     $objPersonArray = $objSenderArray[2];
     $objUnauthorizedArray = array();
     // Do the calculation for Each Group being attempted to emailed to
     foreach ($objGroupArray as $objGroup) {
         $objSource = null;
         // Figure out if there is a valid "Source" of this email that is authorized
         // to send to $objGroup
         if ($objLogin && $objGroup->IsLoginCanSendEmail($objLogin)) {
             $objSource = $objLogin;
         } else {
             foreach ($objPersonArray as $objPerson) {
                 if ($objGroup->IsPersonCanSendEmail($objPerson)) {
                     $objSource = $objPerson;
                     break;
                 }
                 // If authorized sender then allow send also
                 if (GroupAuthorizedSender::LoadByGroupIdPersonId($objGroup->Id, $objPerson->Id)) {
                     $objSource = $objPerson;
                     break;
                 }
             }
         }
         // If a Valid Source, or if a PublicList, create the EmailRoute for the group,
         // otherwise, add the group to the list of Unauthorized
         if ($objSource || $objGroup->IsAnyoneCanSendEmail()) {
             EmailMessageRoute::CreateNewRoute($this, $objSource, $objGroup);
         } else {
             $objUnauthorizedArray[] = $objGroup;
         }
     }
     return $objUnauthorizedArray;
 }
 public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     $objArrayToDelete = array();
     foreach (GroupParticipation::LoadArrayByPersonIdGroupId($this->pnlContent->objPerson->Id, $this->pnlContent->objGroup->Id) as $objParticipation) {
         $objArrayToDelete[$objParticipation->Id] = $objParticipation;
     }
     // Save all the participation records
     foreach ($this->objParticipationArray as $objParticipation) {
         $objParticipation->Save();
         if (array_key_exists($objParticipation->Id, $objArrayToDelete)) {
             unset($objArrayToDelete[$objParticipation->Id]);
         }
     }
     // Delete any that are supposed to be deleted
     foreach ($objArrayToDelete as $objParticipation) {
         $objParticipation->Delete();
     }
     // Update groupAuthorizedSender table
     if ($this->chkIsAuthorizedSender->Checked && !GroupAuthorizedSender::LoadByGroupIdPersonId($this->pnlContent->objGroup->Id, $this->pnlContent->objPerson->Id)) {
         $objGroupAuthorizedSender = new GroupAuthorizedSender();
         $objGroupAuthorizedSender->GroupId = $this->pnlContent->objGroup->Id;
         $objGroupAuthorizedSender->PersonId = $this->pnlContent->objPerson->Id;
         $objGroupAuthorizedSender->Save();
     } else {
         if (!$this->chkIsAuthorizedSender->Checked) {
             $objGroupAuthorizedSender = GroupAuthorizedSender::LoadByGroupIdPersonId($this->pnlContent->objGroup->Id, $this->pnlContent->objPerson->Id);
             if ($objGroupAuthorizedSender) {
                 $objGroupAuthorizedSender->Delete();
             }
         }
     }
     $this->pnlContent->ReturnTo($this->strReturnUrl);
 }