Specifies the value of an element
Author: Boris Sanègre (boris.sanegre@ldc.fr)
Inheritance: extends AbstractAttributeTypeMixed
 public function safeUp()
 {
     $this->createTable('{{store_product_attribute_value}}', ['id' => 'pk', 'product_id' => 'INTEGER NOT NULL', 'attribute_id' => 'INTEGER NOT NULL', 'number_value' => 'REAL', 'string_value' => 'VARCHAR(250)', 'text_value' => 'TEXT', 'option_value' => 'INTEGER', 'create_time' => 'DATETIME'], $this->getOptions());
     //fk
     $this->addForeignKey('{{fk_product_attribute_product}}', '{{store_product_attribute_value}}', 'product_id', '{{store_product}}', 'id', 'CASCADE');
     $this->addForeignKey('{{fk_product_attribute_attribute}}', '{{store_product_attribute_value}}', 'attribute_id', '{{store_attribute}}', 'id', 'CASCADE');
     $this->addForeignKey('{{fk_product_attribute_option}}', '{{store_product_attribute_value}}', 'option_value', '{{store_attribute_option}}', 'id', 'CASCADE');
     //ix
     $this->createIndex('{{ix_product_attribute_number_value}}', '{{store_product_attribute_value}}', 'number_value');
     $this->createIndex('{{ix_product_attribute_string_value}}', '{{store_product_attribute_value}}', 'string_value');
     //перенести аттрибуты
     $attributes = Yii::app()->getDb()->createCommand('SELECT * FROM {{store_product_attribute_eav}}')->queryAll();
     $modelsAttr = [];
     foreach ($attributes as $attribute) {
         $product = Product::model()->findByPk($attribute['product_id']);
         if (null === $product) {
             continue;
         }
         if (!isset($modelsAttr[$attribute['attribute']])) {
             $model = Attribute::model()->find('name = :name', [':name' => $attribute['attribute']]);
             if (null === $model) {
                 continue;
             }
             $modelsAttr[$attribute['attribute']] = $model;
         }
         $value = new AttributeValue();
         $value->store($modelsAttr[$attribute['attribute']]->id, $attribute['value'], $product);
     }
     $this->dropTable('{{store_product_attribute_eav}}');
 }
Example #2
0
	public static function getByID($avID) {
		$av = new AttributeValue();
		$av->load($avID);
		if ($av->getAttributeValueID() == $avID) {
			return $av;
		}
	}
Example #3
0
 public function RenderValue(AttributeValue $objValue)
 {
     switch ($objValue->Attribute->AttributeDataTypeId) {
         case AttributeDataType::Text:
             return QApplication::HtmlEntities($objValue->TextValue);
         case AttributeDataType::Checkbox:
             return $objValue->BooleanValue ? 'Yes' : 'No';
         case AttributeDataType::Date:
             return $objValue->DateValue->ToString('MMMM D, YYYY');
         case AttributeDataType::DateTime:
             return $objValue->DatetimeValue->ToString('MMMM D, YYYY') . ' at ' . $objValue->DatetimeValue->ToString('h:mmz');
         case AttributeDataType::ImmutableSingleDropdown:
         case AttributeDataType::MutableSingleDropdown:
             return $objValue->SingleAttributeOption != null ? QApplication::HtmlEntities($objValue->SingleAttributeOption->Name) : ' ';
         case AttributeDataType::ImmutableMultipleDropdown:
         case AttributeDataType::MutableMultipleDropdown:
             $strArray = array();
             foreach ($objValue->GetAttributeOptionAsMultipleArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
                 $strArray[] = '• ' . QApplication::HtmlEntities($objOption->Name);
             }
             return implode('<br/>', $strArray);
         default:
             throw new Exception('Unhandled Attribute Data Type');
     }
 }
 public function testConstructorAndGetters()
 {
     $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $attributeBuilder = $helper->getObject('\\Magento\\Framework\\Service\\Data\\Eav\\AttributeValueBuilder')->setAttributeCode(self::ATTRIBUTE_CODE)->setValue(self::VALUE);
     $attribute = new AttributeValue($attributeBuilder);
     $this->assertSame(self::ATTRIBUTE_CODE, $attribute->getAttributeCode());
     $this->assertSame(self::VALUE, $attribute->getValue());
 }
 public function __construct(Product $product, Attribute $attribute, AttributeValue $attributeValue)
 {
     $this->setId();
     $this->setCreated();
     $this->product = $product;
     $this->attribute = $attribute;
     $this->attributeValue = $attributeValue;
     $product->addProductAttribute($this);
     $attribute->addProductAttribute($this);
     $attributeValue->addProductAttribute($this);
 }
 public function __construct($pa_value_array = null)
 {
     parent::__construct($pa_value_array);
     if (!DateRangeAttributeValue::$o_tep) {
         DateRangeAttributeValue::$o_tep = new TimeExpressionParser();
     }
 }
Example #7
0
function CreateGroupParticipations(mysqli $objAcsDatabase, Group $objGroup, GroupRole $objRole, $intAcsGroupId, $intAcsReserveId)
{
    print "Adding for Group: " . $objGroup->Name . "\r\n      ";
    if ($intAcsReserveId) {
        $objResult = $objAcsDatabase->query(sprintf('select * from awgrrost where groupid=%s AND reserveid1=%s', $intAcsGroupId, $intAcsReserveId));
    } else {
        $objResult = $objAcsDatabase->query(sprintf('select * from awgrrost where groupid=%s', $intAcsGroupId));
    }
    while ($objRow = $objResult->fetch_array()) {
        $objAttributeValueArray = AttributeValue::QueryArray(QQ::AndCondition(QQ::Equal(QQN::AttributeValue()->AttributeId, 2), QQ::Equal(QQN::AttributeValue()->TextValue, $objRow['indvid'])));
        if (count($objAttributeValueArray) != 1) {
            printf("Issue with awgrrost.pkid of %s - IndvId %s for Group %s - AVCount of %s\r\n", $objRow['pkid'], $objRow['indvid'], $objGroup->Name, count($objAttributeValueArray));
        } else {
            $objPerson = $objAttributeValueArray[0]->Person;
            $dttStartDate = new QDateTime($objRow['dateadded']);
            if ($objRow['dateremoved']) {
                $dttEndDate = new QDateTime($objRow['dateremoved']);
            } else {
                $dttEndDate = null;
            }
            $objGroup->AddPerson($objPerson, $objRole->Id, $dttStartDate, $dttEndDate);
            print "*";
        }
    }
    print "\r\n      Done.\r\n\r\n";
}
Example #8
0
 public static function getTeacherAttributeValue($teacher, $attribute){
     $result = '';
     switch($attribute){
         case '1': //capacity
             $result = AttributeValue::model()->findByAttributes(array('teacher'=>$teacher, 'attribute'=>$attribute))->value;
             break;
         case '2': //trainer's students
             $result = TeacherHelper::getTrainerStudents($teacher);
             break;
         case '3': //consultant_modules
             $result = TeacherHelper::getConsultantModules($teacher);
             break;
         case '4':// leader's projects
             $result = TeacherHelper::getLeaderProjects($teacher);
             break;
         case '6'://leader's modules
             $result = TeacherHelper::getLeaderModules($teacher);
             break;
         case '7'://author's modules
             $result = TeacherHelper::getLeaderModules($teacher);
             break;
         case '8'://leader's capacity
             $result = AttributeValue::model()->findByAttributes(array('teacher'=>$teacher, 'attribute'=>$attribute))->value;
             break;
         default:
             $result = AttributeValue::model()->findByAttributes(array('teacher'=>$teacher, 'attribute'=>$attribute))->value;
     }
     return $result;
 }
Example #9
0
 public function add($aChild, $sName = null, $bTakeover = true)
 {
     if ($aChild instanceof Macro) {
         $aAttrVal = new AttributeValue(null, '', $aChild->position(), $aChild->line());
         $aAttrVal->setEndPosition($aChild->endPosition());
         $aAttrVal->add($aChild);
         $this->attributes()->add($aAttrVal);
         $aAttrVal->setParent($this);
         $aChild->setParent($this);
     }
 }
 private static function buildDBAttr($dbAttr, $pdo)
 {
     $attr = Attribute::__build($dbAttr['ID'], $dbAttr['NAME'], null);
     $valstmt = $pdo->prepare("SELECT * FROM ATTRIBUTEVALUE WHERE " . "ATTRIBUTE_ID = :id ORDER BY VALUE");
     $valstmt->execute(array(':id' => $dbAttr['ID']));
     while ($dbVal = $valstmt->fetch()) {
         $val = AttributeValue::__build($dbVal['ID'], $dbVal['VALUE']);
         $attr->addValue($val);
     }
     return $attr;
 }
Example #11
0
 public function actionDeleteFile()
 {
     if (!Yii::app()->getRequest()->getIsPostRequest()) {
         throw new CHttpException();
     }
     $product = (int) Yii::app()->getRequest()->getPost('product');
     $attribute = (int) Yii::app()->getRequest()->getPost('attribute');
     $model = AttributeValue::model()->find('product_id = :product AND attribute_id = :attribute', [':product' => $product, ':attribute' => $attribute]);
     if (null === $model || null === $model->getFilePath()) {
         Yii::app()->ajax->success();
     }
     $model->delete();
     Yii::app()->ajax->success();
 }
Example #12
0
    /**
     * Deletes all associated AttributeValues
     * @return void
     */
    public function DeleteAllAttributeValues()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAttributeValue on this unsaved Person.');
        }
        // Get the Database Object for this Class
        $objDatabase = Person::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (AttributeValue::LoadArrayByPersonId($this->intId) as $objAttributeValue) {
                $objAttributeValue->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`attribute_value`
				WHERE
					`person_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
 /**
  * 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 = AttributeValue::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 AttributeValue, given the clauses above
     $this->DataSource = AttributeValue::QueryArray($objCondition, $objClauses);
 }
Example #14
0
 protected function SetupPanel()
 {
     $this->objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($this->strUrlHashArgument, $this->objPerson->Id);
     if (!$this->objAttributeValue) {
         $this->objAttributeValue = new AttributeValue();
         $this->objAttributeValue->AttributeId = $this->strUrlHashArgument;
         $this->objAttributeValue->Person = $this->objPerson;
     } else {
         $this->btnDelete = new QLinkButton($this);
         $this->btnDelete->Text = 'Delete';
         $this->btnDelete->CssClass = 'delete';
         $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to DELETE this attribute?'));
         $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
         $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction());
     }
     switch ($this->objAttributeValue->Attribute->AttributeDataTypeId) {
         case AttributeDataType::Checkbox:
             $this->chkValue = new QRadioButtonList($this);
             $this->chkValue->Name = $this->objAttributeValue->Attribute->Name;
             $this->chkValue->Required = true;
             $this->chkValue->AddItem('Yes', true, $this->objAttributeValue->BooleanValue === true);
             $this->chkValue->AddItem('No', false, $this->objAttributeValue->BooleanValue === false);
             break;
         case AttributeDataType::Date:
         case AttributeDataType::DateTime:
             $this->dtxValue = new QDateTimeTextBox($this);
             $this->dtxValue->Name = $this->objAttributeValue->Attribute->Name;
             $this->dtxValue->Required = true;
             if ($this->objAttributeValue->Attribute->AttributeDataTypeId == AttributeDataType::Date) {
                 $this->dtxValue->Text = $this->objAttributeValue->DateValue ? $this->objAttributeValue->DateValue->ToString() : null;
             } else {
                 $this->dtxValue->Text = $this->objAttributeValue->DatetimeValue ? $this->objAttributeValue->DatetimeValue->ToString() : null;
             }
             $this->calValue = new QCalendar($this, $this->dtxValue);
             $this->dtxValue->RemoveAllActions(QClickEvent::EventName);
             break;
         case AttributeDataType::Text:
             $this->txtValue = new QTextBox($this);
             $this->txtValue->Name = $this->objAttributeValue->Attribute->Name;
             $this->txtValue->Required = true;
             $this->txtValue->TextMode = QTextMode::MultiLine;
             $this->txtValue->Text = trim($this->objAttributeValue->TextValue);
             $this->txtValue->FontNames = QFontFamily::Arial;
             $this->txtValue->FontSize = '11px';
             $this->txtValue->Width = '400px';
             $this->txtValue->Height = '200px';
             break;
         case AttributeDataType::ImmutableSingleDropdown:
             $this->lstValue = new QListBox($this);
             $this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
             $this->lstValue->Required = true;
             if (!$this->objAttributeValue->SingleAttributeOptionId) {
                 $this->lstValue->AddItem('- Select One -');
             }
             foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
                 $this->lstValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $this->objAttributeValue->SingleAttributeOptionId);
             }
             break;
         case AttributeDataType::ImmutableMultipleDropdown:
             $this->lstValue = new QListBox($this);
             $this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
             $this->lstValue->Required = true;
             $this->lstValue->SelectionMode = QSelectionMode::Multiple;
             $this->lstValue->Width = '200px';
             $this->lstValue->Height = '200px';
             $intSelectedIdArray = array();
             if ($this->objAttributeValue->Id) {
                 foreach ($this->objAttributeValue->GetAttributeOptionAsMultipleArray() as $objOption) {
                     $intSelectedIdArray[$objOption->Id] = $objOption->Id;
                 }
             }
             foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
                 $this->lstValue->AddItem($objOption->Name, $objOption->Id, array_key_exists($objOption->Id, $intSelectedIdArray));
             }
             break;
         case AttributeDataType::MutableSingleDropdown:
             $this->lstValue = new QListBox($this);
             $this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
             $this->lstValue->Required = true;
             if (!$this->objAttributeValue->SingleAttributeOptionId) {
                 $this->lstValue->AddItem('- Select One -');
             }
             foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
                 $this->lstValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $this->objAttributeValue->SingleAttributeOptionId);
             }
             $this->lstValue->AddItem('- Other... -', -1);
             $this->txtAddItem = new QTextBox($this);
             $this->txtAddItem->Name = 'Add a Value';
             $this->txtAddItem->Visible = false;
             $this->lstValue->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'lstValue_Change'));
             $this->txtAddItem->AddAction(new QEnterKeyEvent(), new QTerminateAction());
             break;
         case AttributeDataType::MutableMultipleDropdown:
             $this->lstValue = new QListBox($this);
             $this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
             $this->lstValue->Required = true;
             $this->lstValue->SelectionMode = QSelectionMode::Multiple;
             $this->lstValue->Width = '200px';
             $this->lstValue->Height = '200px';
             $intSelectedIdArray = array();
             if ($this->objAttributeValue->Id) {
                 foreach ($this->objAttributeValue->GetAttributeOptionAsMultipleArray() as $objOption) {
                     $intSelectedIdArray[$objOption->Id] = $objOption->Id;
                 }
             }
             foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
                 $this->lstValue->AddItem($objOption->Name, $objOption->Id, array_key_exists($objOption->Id, $intSelectedIdArray));
             }
             $this->txtAddItem = new QTextBox($this);
             $this->txtAddItem->Name = 'Add a Value';
             $this->txtAddItem->AddAction(new QEnterKeyEvent(), new QAjaxControlAction($this, 'txtAddItem_Enter'));
             $this->txtAddItem->AddAction(new QEnterKeyEvent(), new QTerminateAction());
             break;
         default:
             throw new Exception('Unhandled AttributeDataTypeId: ' . $this->objAttributeValue->Attribute->AttributeDataTypeId);
     }
 }
Example #15
0
	public function __destruct() {
		parent::__destruct();
		unset($this->c);
	}
 /**
  * @param $model
  */
 protected function uploadAttributesFiles($model)
 {
     if (!empty($_FILES['Attribute']['name'])) {
         foreach ($_FILES['Attribute']['name'] as $key => $file) {
             $value = AttributeValue::model()->find('product_id = :product AND attribute_id = :attribute', [':product' => $model->id, ':attribute' => $key]);
             $value = $value ?: new AttributeValue();
             $value->setAttributes(['product_id' => $model->id, 'attribute_id' => $key]);
             $value->addFileInstanceName('Attribute[' . $key . '][name]');
             if (false === $value->save()) {
                 Yii::app()->getUser()->setFlash(\yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('StoreModule.store', 'Error uploading some files...'));
             }
         }
     }
 }
 /**
  * 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 AttributeValueMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing AttributeValue object creation - defaults to CreateOrEdit
  * @return AttributeValueMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objAttributeValue = AttributeValue::Load($intId);
         // AttributeValue was found -- return it!
         if ($objAttributeValue) {
             return new AttributeValueMetaControl($objParentObject, $objAttributeValue);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a AttributeValue 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 AttributeValueMetaControl($objParentObject, new AttributeValue());
 }
Example #18
0
File: index.php Project: alcf/chms
 protected function btnUnsubscribe_Click()
 {
     $objCommunicationListEntry = CommunicationListEntry::LoadByEmail($this->txtEmail->Text);
     $objEmailArray = Email::LoadArrayByAddress($this->txtEmail->Text);
     foreach ($objEmailArray as $objEmail) {
         $objPerson = Person::LoadByPrimaryEmailId($objEmail->Id);
         if ($objPerson != null) {
             $strUnsubscribedList = '';
             $success = false;
             foreach ($this->chkBtnListArray as $objItem) {
                 if ($objItem->Checked) {
                     $this->objList = CommunicationList::LoadByToken($objItem->Name);
                     if ($this->objList) {
                         $bFound = false;
                         if ($this->objList->IsPersonAssociated($objPerson)) {
                             $this->objList->UnassociatePerson($objPerson);
                             // If church newletter is the one being unsubscribed, document reason.
                             if ($this->lstTerminationReason->SelectedValue == -1) {
                                 $objAttributeOption = new AttributeOption();
                                 $objAttributeOption->AttributeId = $this->objAttributeValue->AttributeId;
                                 $objAttributeOption->Name = trim($this->txtOther->Text);
                                 $objAttributeOption->Save();
                                 $objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($this->objAttribute->Id, $objPerson->Id);
                                 if ($objAttributeValue) {
                                     $objAttributeValue->SingleAttributeOption = $objAttributeOption;
                                     $objAttributeValue->Save();
                                 } else {
                                     $objAttributeValue = new AttributeValue();
                                     $objAttributeValue->AttributeId = $this->objAttribute->Id;
                                     $objAttributeValue->PersonId = $objPerson->Id;
                                     $objAttributeValue->SingleAttributeOption = $objAttributeOption;
                                     $objAttributeValue->Save();
                                     $objPerson->AssociateAttributeValue($objAttributeValue);
                                 }
                             } else {
                                 $objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($this->objAttribute->Id, $objPerson->Id);
                                 if ($objAttributeValue) {
                                     $objAttributeValue->SingleAttributeOptionId = $this->lstTerminationReason->SelectedValue;
                                     $objAttributeValue->Save();
                                 } else {
                                     $objAttributeValue = new AttributeValue();
                                     $objAttributeValue->AttributeId = $this->objAttribute->Id;
                                     $objAttributeValue->PersonId = $objPerson->Id;
                                     $objAttributeValue->SingleAttributeOptionId = $this->lstTerminationReason->SelectedValue;
                                     $objAttributeValue->Save();
                                     $objPerson->AssociateAttributeValue($objAttributeValue);
                                 }
                             }
                             $strUnsubscribedList .= $objItem->Text . ',';
                             $success = true;
                             $bFound = true;
                         }
                         if (!$bFound) {
                             $this->lblMessage->Text = '(Person Entry) You cannot Unsubscribe because you are not subscribed to the ' . $objItem->Text . ' Mailing List.';
                             $this->lblMessage->Visible = true;
                         }
                     }
                 }
             }
             if ($success) {
                 $strUnsubscribedList = substr($strUnsubscribedList, 0, strlen($strUnsubscribedList) - 1);
                 QApplication::Redirect('/unsubscribe/success.php/' . urlencode($strUnsubscribedList) . '/' . $objPerson->Id);
             }
         }
     }
     if ($objCommunicationListEntry) {
         $strUnsubscribedList = '';
         $success = false;
         $bChecked = false;
         foreach ($this->chkBtnListArray as $objItem) {
             if ($objItem->Checked) {
                 $this->objList = CommunicationList::LoadByToken($objItem->Name);
                 if ($this->objList) {
                     $bFound = false;
                     if ($objCommunicationListEntry != null) {
                         if ($this->objList->IsCommunicationListEntryAssociated($objCommunicationListEntry)) {
                             $this->objList->UnassociateCommunicationListEntry($objCommunicationListEntry);
                             $strUnsubscribedList .= $objItem->Text . ',';
                             $success = true;
                             $bFound = true;
                         }
                     }
                     if (!$bFound) {
                         $this->lblMessage->Text = '(CommunicationsEntry) You cannot Unsubscribe because you are not subscribed to the ' . $objItem->Text . ' Mailing List.';
                         $this->lblMessage->Visible = true;
                     }
                 }
             }
         }
         if ($success) {
             $strUnsubscribedList = substr($strUnsubscribedList, 0, strlen($strUnsubscribedList) - 1);
             QApplication::Redirect('/unsubscribe/success.php/' . urlencode($strUnsubscribedList));
         }
     }
     $bChecked = false;
     foreach ($this->chkBtnListArray as $objItem) {
         if ($objItem->Checked) {
             $bChecked = true;
             break;
         }
     }
     if (!$bChecked) {
         $this->lblMessage->Text = 'You must select a list to subscribe to.';
         $this->lblMessage->Visible = true;
     } else {
         $this->lblMessage->Text = 'Failed to unsubscribe from the list. The email may not exist.';
         $this->lblMessage->Visible = true;
     }
 }
Example #19
0
 public function __construct()
 {
     parent::__construct(null, null);
 }
Example #20
0
<?php

$intPersonIdByIndvId = array();
foreach (AttributeValue::LoadArrayByAttributeId(2) as $objAttributeValue) {
    $intPersonIdByIndvId[$objAttributeValue->TextValue] = $objAttributeValue->PersonId;
}
$objMySqli = new mysqli('localhost', 'root', '', 'alcf_acs');
$objResult = $objMySqli->query('SELECT * FROM awperelt');
$intCount = $objResult->num_rows;
while (QDataGen::DisplayWhileTask('Importing Family Relationships', $intCount) && ($objRow = $objResult->fetch_array())) {
    if ($objRow['indvid'] != $objRow['reltindvid']) {
        $intRelationshipTypeId = null;
        switch (strtolower($objRow['relationship'])) {
            case 'mother':
            case 'father':
                $intRelationshipTypeId = RelationshipType::Parental;
                break;
            case 'son':
            case 'daughter':
                $intRelationshipTypeId = RelationshipType::Child;
                break;
            case 'brother':
            case 'sister':
                $intRelationshipTypeId = RelationshipType::Sibling;
                break;
            case 'grandmother':
            case 'grandfather':
                $intRelationshipTypeId = RelationshipType::Grandparent;
                break;
            case 'grandchild':
            case 'grandson':
 public function __construct($pa_value_array = null)
 {
     $this->opo_media_info_coder = new MediaInfoCoder();
     parent::__construct($pa_value_array);
 }
Example #22
0
 /**
  * Merges two records together.
  * @param Person $objPersonMergeWith
  * @param boolean $blnUseThisDetails boolean on whether to use this person's Person object details, or if false, use the PersonMergeWith's
  */
 public function MergeWith(Person $objPersonMergeWith, $blnUseThisDetails)
 {
     QLog::Log(sprintf('Merging %s (ID %s) with %s (ID %s) - %s', $this->Name, $this->Id, $objPersonMergeWith->Name, $objPersonMergeWith->Id, $blnUseThisDetails ? 'left' : 'right'));
     Person::GetDatabase()->TransactionBegin();
     // Household Participation Records
     if ($this->HouseholdAsHead && $objPersonMergeWith->HouseholdAsHead) {
         $this->HouseholdAsHead->MergeHousehold($objPersonMergeWith->HouseholdAsHead, $this);
     } else {
         if ($this->HouseholdAsHead) {
             // Go through each MergeWith HouseholdParticipation -- Throw if it's another household, Delete if it's this Household-as-Head
             foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
                 if ($objHouseholdParticipation->HouseholdId != $this->HouseholdAsHead->Id) {
                     throw new QCallerException('Cannot merge this head of household with a person record that exists in other households');
                 } else {
                     $objHouseholdParticipation->Delete();
                 }
             }
         } else {
             if ($objHousehold = $objPersonMergeWith->HouseholdAsHead) {
                 // Go through each of this's HouseholdParticipation -- Throw if it's another household, Delete if it's MergeWith's Household-as-Head
                 foreach ($this->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
                     if ($objHouseholdParticipation->HouseholdId != $objPersonMergeWith->HouseholdAsHead->Id) {
                         throw new QCallerException('Cannot merge MergeWith head of household with this person record which exists in other households');
                     } else {
                         $objHouseholdParticipation->Delete();
                     }
                 }
                 $objHousehold->HeadPerson = $this;
                 $objHousehold->Save();
                 $objParticipation = HouseholdParticipation::LoadByPersonIdHouseholdId($objPersonMergeWith->Id, $objHousehold->Id);
                 $objParticipation->PersonId = $this->Id;
                 $objParticipation->Save();
             } else {
                 // Otherwise: members of multiple households! but head of none
                 foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
                     if (HouseholdParticipation::LoadByPersonIdHouseholdId($this->Id, $objHouseholdParticipation->HouseholdId)) {
                         $objHouseholdParticipation->Delete();
                     } else {
                         $objHouseholdParticipation->PersonId = $this->Id;
                         $objHouseholdParticipation->Save();
                     }
                 }
             }
         }
     }
     if (!$blnUseThisDetails) {
         $this->FirstName = $objPersonMergeWith->FirstName;
         $this->MiddleName = $objPersonMergeWith->MiddleName;
         $this->LastName = $objPersonMergeWith->LastName;
         $this->MailingLabel = $objPersonMergeWith->MailingLabel;
         $this->PriorLastNames = $objPersonMergeWith->PriorLastNames;
         $this->Nickname = $objPersonMergeWith->Nickname;
         $this->Title = $objPersonMergeWith->Title;
         $this->Suffix = $objPersonMergeWith->Suffix;
         $this->Gender = $objPersonMergeWith->Gender;
         $this->DateOfBirth = $objPersonMergeWith->DateOfBirth;
         $this->DobYearApproximateFlag = $objPersonMergeWith->DobYearApproximateFlag;
         $this->DobGuessedFlag = $objPersonMergeWith->DobGuessedFlag;
         $this->Age = $objPersonMergeWith->Age;
         $this->DeceasedFlag = $objPersonMergeWith->DeceasedFlag;
         $this->DateDeceased = $objPersonMergeWith->DateDeceased;
     }
     // Attributes
     foreach ($objPersonMergeWith->GetAttributeValueArray() as $objAttributeValue) {
         // Check for double-defined attributes
         if ($objDoubleDefinedAttribute = AttributeValue::LoadByAttributeIdPersonId($objAttributeValue->AttributeId, $this->Id)) {
             if ($blnUseThisDetails) {
                 $objAttributeValue->Delete();
             } else {
                 $objDoubleDefinedAttribute->Delete();
                 $objAttributeValue->PersonId = $this->Id;
                 $objAttributeValue->Save();
             }
             // Nothing double-defined -- just move it over!
         } else {
             $objAttributeValue->PersonId = $this->Id;
             $objAttributeValue->Save();
         }
     }
     // Comments
     foreach ($objPersonMergeWith->GetCommentArray() as $objComment) {
         $objComment->PersonId = $this->Id;
         $objComment->Save();
     }
     // Memberships
     foreach ($objPersonMergeWith->GetMembershipArray() as $objMembership) {
         $objMembership->PersonId = $this->Id;
         $objMembership->Save();
     }
     // Communication Lists
     foreach ($objPersonMergeWith->GetCommunicationListArray() as $objCommList) {
         $objPersonMergeWith->UnassociateCommunicationList($objCommList);
         if (!$this->IsCommunicationListAssociated($objCommList)) {
             $this->AssociateCommunicationList($objCommList);
         }
     }
     // Head Shots
     foreach ($objPersonMergeWith->GetHeadShotArray() as $objHeadShot) {
         $objHeadShot->PersonId = $this->Id;
         $objHeadShot->Save();
     }
     // Group Participation
     foreach ($objPersonMergeWith->GetGroupParticipationArray() as $objGroupParticipation) {
         $objGroupParticipation->PersonId = $this->Id;
         $objGroupParticipation->Save();
     }
     // NameItemAssn
     $objPersonMergeWith->UnassociateAllNameItems();
     // Marrriage Records
     foreach ($objPersonMergeWith->GetMarriageArray() as $objMarriage) {
         $this->CreateMarriageWith($objMarriage->MarriedToPerson, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId);
         $objMarriage->DeleteThisAndLinked();
     }
     foreach ($objPersonMergeWith->GetMarriageAsMarriedToArray() as $objMarriage) {
         $this->CreateMarriageWith($objMarriage->Person, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId);
         $objMarriage->DeleteThisAndLinked();
     }
     // Family Relationships
     foreach ($objPersonMergeWith->GetRelationshipArray() as $objRelationship) {
         if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->RelatedToPersonId)) {
             $this->AddRelationship($objRelationship->RelatedToPerson, $objRelationship->RelationshipTypeId);
         }
         $objRelationship->DeleteThisAndLinked();
     }
     foreach ($objPersonMergeWith->GetRelationshipAsRelatedToArray() as $objRelationship) {
         if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->PersonId)) {
             $this->AddRelationship($objRelationship->Person, $objRelationship->RelationshipTypeId);
         }
         $objRelationship->DeleteThisAndLinked();
     }
     // Phones
     foreach ($objPersonMergeWith->GetPhoneArray() as $objContact) {
         $objContact->PersonId = $this->Id;
         $objContact->Save();
     }
     // Addresses
     foreach ($objPersonMergeWith->GetAddressArray() as $objContact) {
         $objContact->PersonId = $this->Id;
         $objContact->Save();
     }
     // Email
     foreach ($objPersonMergeWith->GetEmailArray() as $objContact) {
         $objContact->PersonId = $this->Id;
         $objContact->Save();
     }
     // Other Contact Info
     foreach ($objPersonMergeWith->GetOtherContactInfoArray() as $objContact) {
         $objContact->PersonId = $this->Id;
         $objContact->Save();
     }
     // Checking Account Lookups
     foreach ($objPersonMergeWith->GetCheckingAccountLookupArray() as $objCheckingAccount) {
         $objPersonMergeWith->UnassociateCheckingAccountLookup($objCheckingAccount);
         if (!$this->IsCheckingAccountLookupAssociated($objCheckingAccount)) {
             $this->AssociateCheckingAccountLookup($objCheckingAccount);
         }
     }
     // Stewardship Contributions
     foreach ($objPersonMergeWith->GetStewardshipContributionArray() as $objStewardship) {
         $objStewardship->PersonId = $this->Id;
         $objStewardship->Save();
     }
     // Stewardship Pledges
     foreach ($objPersonMergeWith->GetStewardshipPledgeArray() as $objPledge) {
         // Check for double-defined pledge
         if ($objDoubleDefinedPledge = StewardshipPledge::LoadByPersonIdStewardshipFundId($this->Id, $objPledge->StewardshipFundId)) {
             if ($blnUseThisDetails) {
                 $objPledge->Delete();
             } else {
                 $objDoubleDefinedPledge->Delete();
                 $objPledge->PersonId = $this->Id;
                 $objPledge->Save();
             }
             // Nope, just move it over like normal
         } else {
             $objPledge->PersonId = $this->Id;
             $objPledge->Save();
         }
     }
     // Online Donations
     foreach ($objPersonMergeWith->GetOnlineDonationArray() as $objOnlineDonation) {
         $objOnlineDonation->PersonId = $this->Id;
         $objOnlineDonation->Save();
     }
     // Public Login
     if ($objPublicLogin = $objPersonMergeWith->PublicLogin) {
         $objPublicLogin->PersonId = $this->Id;
         $objPublicLogin->Save();
     }
     // Events and Classes
     foreach ($objPersonMergeWith->GetSignupEntryArray() as $objSignupEntry) {
         $objSignupEntry->PersonId = $this->Id;
         $objSignupEntry->Save();
     }
     foreach ($objPersonMergeWith->GetSignupEntryAsSignupByArray() as $objSignupEntry) {
         $objSignupEntry->SignupByPersonId = $this->Id;
         $objSignupEntry->Save();
     }
     foreach ($objPersonMergeWith->GetClassRegistrationArray() as $objClassRegistration) {
         $objClassRegistration->PersonId = $this->Id;
         $objClassRegistration->Save();
     }
     // Stewardship Post Line Items
     foreach ($objPersonMergeWith->GetStewardshipPostLineItemArray() as $objStewardship) {
         $objStewardship->PersonId = $this->Id;
         $objStewardship->Save();
     }
     // Email Message Route
     foreach ($objPersonMergeWith->GetEmailMessageRouteArray() as $objEmailMessageRoute) {
         $objEmailMessageRoute->PersonId = $this->Id;
         $objEmailMessageRoute->Save();
     }
     // Search Query
     foreach ($objPersonMergeWith->GetSearchQueryArray() as $objSearchQuery) {
         $objSearchQuery->PersonId = $this->Id;
         $objSearchQuery->Save();
     }
     // Final Refresh/Cleanup
     $this->RefreshAge(false);
     $this->RefreshMaritalStatusTypeId(false);
     $this->RefreshMembershipStatusTypeId(false);
     $this->RefreshPrimaryContactInfo(false);
     $this->Save();
     $this->RefreshNameItemAssociations();
     $objPersonMergeWith->Delete();
     Person::GetDatabase()->TransactionCommit();
 }
Example #23
0
 /** 
  * Adds a generic attribute record (with this type) to the AttributeValues table
  */
 public function addAttributeValue()
 {
     $db = Loader::db();
     $u = new User();
     $dh = Loader::helper('date');
     $uID = $u->isRegistered() ? $u->getUserID() : 0;
     $avDate = $dh->getLocalDateTime();
     $v = array($this->atID, $this->akID, $uID, $avDate);
     $db->Execute('insert into AttributeValues (atID, akID,  uID, avDateAdded) values (?, ?, ?, ?)', $v);
     $avID = $db->Insert_ID();
     return AttributeValue::getByID($avID);
 }
 public function __construct($pa_value_array = null)
 {
     require_once __CA_MODELS_DIR__ . '/ca_metadata_elements.php';
     parent::__construct($pa_value_array);
 }
 public function __construct($pa_value_array = null)
 {
     parent::__construct($pa_value_array);
 }
Example #26
0
 public function __toString()
 {
     return sprintf("%s%s", get_class($this), $this->attribute->__toString());
 }
Example #27
0
	public function delete() {
		$db = Loader::db();
		$db->Execute('delete from FileAttributeValues where fID = ? and fvID = ? and akID = ? and avID = ?', array(
			$this->f->getFileID(), 
			$this->f->getFileVersionID(),
			$this->attributeKey->getAttributeKeyID(),
			$this->getAttributeValueID()
		));

		// Before we run delete() on the parent object, we make sure that attribute value isn't being referenced in the table anywhere else
		$num = $db->GetOne('select count(avID) from FileAttributeValues where avID = ?', array($this->getAttributeValueID()));
		if ($num < 1) {
			parent::delete();
		}
	}
Example #28
0
 /**
  * @param CHttpRequest $request
  * @return array
  */
 public function getTypeAttributesForSearchFromQuery(CHttpRequest $request)
 {
     $attributes = Yii::app()->getCache()->get('Store::filter::attributes');
     if (false === $attributes) {
         $attributes = [];
         $models = Attribute::model()->findAll(['select' => ['name', 'id', 'type']]);
         foreach ($models as $model) {
             $attributes[$model->name] = $model;
         }
         Yii::app()->getCache()->set('Store::filter::attributes', $attributes);
     }
     $result = [];
     $attributeValue = new AttributeValue();
     foreach ($attributes as $name => $attribute) {
         $searchParams = $request->getQuery($attribute->name);
         //пропускаем пустые значения
         if (null === $searchParams) {
             continue;
         }
         if (is_array($searchParams)) {
             if (isset($searchParams['from']) && null == $searchParams['from']) {
                 unset($searchParams['from']);
             }
             if (isset($searchParams['to']) && null == $searchParams['to']) {
                 unset($searchParams['to']);
             }
             if (empty($searchParams)) {
                 continue;
             }
         }
         $result[$attribute->name] = ['value' => $searchParams, 'attribute_id' => (int) $attribute->id, 'column' => $attributeValue->column($attribute->type)];
     }
     return $result;
 }
 protected function lstAttributeValuesAsMultiple_Update()
 {
     if ($this->lstAttributeValuesAsMultiple) {
         $this->objAttributeOption->UnassociateAllAttributeValuesAsMultiple();
         $objSelectedListItems = $this->lstAttributeValuesAsMultiple->SelectedItems;
         if ($objSelectedListItems) {
             foreach ($objSelectedListItems as $objListItem) {
                 $this->objAttributeOption->AssociateAttributeValueAsMultiple(AttributeValue::Load($objListItem->Value));
             }
         }
     }
 }
Example #30
0
 /**
  * @param array $attributes
  * @return bool
  */
 public function saveTypeAttributes(array $attributes)
 {
     $transaction = Yii::app()->getDb()->beginTransaction();
     try {
         foreach ($attributes as $attribute => $value) {
             if (null === $value) {
                 continue;
             }
             $model = AttributeValue::model()->find('product_id = :product AND attribute_id = :attribute', [':product' => $this->id, ':attribute' => $attribute]);
             //множественные значения
             if (is_array($value)) {
                 AttributeValue::model()->deleteAll('product_id = :product AND attribute_id = :attribute', [':product' => $this->id, ':attribute' => $attribute]);
                 foreach ($value as $val) {
                     $model = new AttributeValue();
                     if (false === $model->store($attribute, $val, $this)) {
                         throw new InvalidArgumentException('Error store attribute!');
                     }
                 }
             } else {
                 $model = $model ?: new AttributeValue();
                 if (false === $model->store($attribute, $value, $this)) {
                     throw new InvalidArgumentException('Error store attribute!');
                 }
             }
         }
         $transaction->commit();
         return true;
     } catch (Exception $e) {
         $transaction->rollback();
         return false;
     }
 }