function processPost($formvalues) { // trim spaces from the name field if (isArrayKeyAnEmptyString('type', $formvalues)) { unset($formvalues['type']); } if (isArrayKeyAnEmptyString('benefitid', $formvalues)) { unset($formvalues['benefitid']); } if (isArrayKeyAnEmptyString('amount', $formvalues)) { unset($formvalues['amount']); } if (isArrayKeyAnEmptyString('benefitfrequency', $formvalues)) { unset($formvalues['benefitfrequency']); } if (isArrayKeyAnEmptyString('leavetypeid', $formvalues)) { unset($formvalues['leavetypeid']); } if (isArrayKeyAnEmptyString('accrualtype', $formvalues)) { unset($formvalues['accrualtype']); } if (isArrayKeyAnEmptyString('accrualfrequency', $formvalues)) { unset($formvalues['accrualfrequency']); } if (isArrayKeyAnEmptyString('accrualvalue', $formvalues)) { unset($formvalues['accrualvalue']); } // debugMessage($formvalues); exit(); parent::processPost($formvalues); }
/** * Returns this model's validation rules. * * @return array */ public function rules() { $rules = parent::rules(); $rules[] = array('startDate', 'validateStartDate'); $rules[] = array('endDate', 'validateEndDate'); return $rules; }
function processPost($formvalues) { // trim spaces from the name field if (isArrayKeyAnEmptyString('companyid', $formvalues)) { $formvalues['companyid'] = getCompanyID(); } if (isArrayKeyAnEmptyString('hours', $formvalues)) { unset($formvalues['hours']); } if (isArrayKeyAnEmptyString('starttime', $formvalues)) { unset($formvalues['starttime']); } else { $formvalues['starttime'] = date("H:i:s", strtotime($formvalues['starttime'])); } if (isArrayKeyAnEmptyString('endtime', $formvalues)) { unset($formvalues['endtime']); } else { $formvalues['endtime'] = date("H:i:s", strtotime($formvalues['endtime'])); } if (isArrayKeyAnEmptyString('overduestarttime', $formvalues)) { unset($formvalues['overduestarttime']); } else { $formvalues['overduestarttime'] = date("H:i:s", strtotime($formvalues['overduestarttime'])); } if (isArrayKeyAnEmptyString('breakhrs', $formvalues)) { unset($formvalues['breakhrs']); } // debugMessage($formvalues); exit(); parent::processPost($formvalues); }
/** * @inheritDoc BaseRecord::rules() * * @return array */ public function rules() { $rules = parent::rules(); if (!$this->hasTitleField) { $rules[] = array('titleFormat', 'required'); } return $rules; }
/** * @inheritDoc BaseRecord::validate() * * @param null $attributes * @param bool $clearErrors * * @return bool|null */ public function validate($attributes = null, $clearErrors = true) { // Don't allow whitespace in the username. if (preg_match('/\\s+/', $this->username)) { $this->addError('username', Craft::t('Spaces are not allowed in the username.')); } return parent::validate($attributes, false); }
function processPost($formvalues) { # force setting of default none string column values. enum, int and date if (isArrayKeyAnEmptyString('isread', $formvalues)) { $formvalues['isread'] = '0'; } parent::processPost($formvalues); }
/** * @return array */ public function rules() { $rules = parent::rules(); $rules[] = array('replyTo', 'validateEmailWithOptionalPlaceholder'); $rules[] = array('fromEmail', 'validateEmailWithOptionalPlaceholder'); $rules[] = array('recipients', 'validateOnTheFlyRecipients'); return $rules; }
/** * Constructor * * @param string $data Metadata * @param string $oaiID Record ID received from OAI-PMH (or empty string for * file import) * @param string $source Source ID * @param string $idPrefix Record ID prefix */ public function __construct($data, $oaiID, $source, $idPrefix) { parent::__construct($data, $oaiID, $source, $idPrefix); $this->doc = simplexml_load_string($data); if (empty($this->doc->recordID)) { $p = strpos($oaiID, ':'); $p = strpos($oaiID, ':', $p + 1); $this->doc->addChild('recordID', substr($oaiID, $p + 1)); } }
/** * Clean up the post array before populating the values of the object: * - Remove the blank values for the executedby field which will cause a foreign key error * * @param Array $post_array The post array * * @see BaseRecord::processPost */ public function processPost($formvalues) { // remove the executedby field if it is empty if (isArrayKeyAnEmptyString('isupdate', $formvalues)) { unset($formvalues['isupdate']); } if (isArrayKeyAnEmptyString('userid', $formvalues)) { unset($formvalues['userid']); } parent::processPost($formvalues); }
/** * Returns the validation rules for the record. * Excludes unique validators if flag is set (@link validateUniques). * * @return array */ public function rules() { $rules = parent::rules(); if (!$this->_validateUniques) { // Remove unique validators from the rule set return array_filter($rules, function ($rule) { return $rule[1] != 'Craft\\CompositeUniqueValidator'; }); } return $rules; }
/** * @inheritDoc BaseRecord::rules() * * @return array */ public function rules() { $rules = parent::rules(); if (!$this->validateUniques) { foreach ($rules as $i => $rule) { if ($rule[1] == 'Craft\\CompositeUniqueValidator') { unset($rules[$i]); } } } return $rules; }
/** * Pre process model data */ function processPost($formvalues) { # force setting of default none string column values. enum, int and date if (isArrayKeyAnEmptyString('parentid', $formvalues)) { unset($formvalues['parentid']); } if (isArrayKeyAnEmptyString('type', $formvalues)) { unset($formvalues['type']); } if (isArrayKeyAnEmptyString('refid', $formvalues)) { unset($formvalues['refid']); } parent::processPost($formvalues); }
/** * Preprocess model data */ function processPost($formvalues) { // set default values for integers, dates, decimals if (isArrayKeyAnEmptyString('userid', $formvalues)) { unset($formvalues['userid']); } if (isArrayKeyAnEmptyString('personid', $formvalues)) { unset($formvalues['personid']); } if (isArrayKeyAnEmptyString('namesection', $formvalues)) { unset($formvalues['namesection']); } if (isArrayKeyAnEmptyString('familysection', $formvalues)) { unset($formvalues['familysection']); } if (isArrayKeyAnEmptyString('clansection', $formvalues)) { unset($formvalues['clansection']); } if (isArrayKeyAnEmptyString('personalsection', $formvalues)) { unset($formvalues['personalsection']); } if (isArrayKeyAnEmptyString('emailaddresssection', $formvalues)) { unset($formvalues['emailaddresssection']); } if (isArrayKeyAnEmptyString('phonesection', $formvalues)) { unset($formvalues['phonesection']); } if (isArrayKeyAnEmptyString('physicaladdresssection', $formvalues)) { unset($formvalues['physicaladdresssection']); } if (isArrayKeyAnEmptyString('webaddresssection', $formvalues)) { unset($formvalues['webaddresssection']); } if (isArrayKeyAnEmptyString('birthsection', $formvalues)) { unset($formvalues['birthsection']); } if (isArrayKeyAnEmptyString('birthrule', $formvalues)) { unset($formvalues['birthrule']); } if (isArrayKeyAnEmptyString('defaultprivacy', $formvalues)) { unset($formvalues['defaultprivacy']); } parent::processPost($formvalues); }
/** * Contructor method for custom functionality - add the fields to be marked as dates */ public function construct() { parent::construct(); // set the custom error messages $this->addCustomErrorMessages(array("groupid.notblank" => $this->translate->_("usergroup_groupid_error"))); }
/** * Creates the model's table. * * @return null */ public function createTable() { parent::createTable(); // There's no TemplateCachesRecord – need to set the FK manually craft()->db->createCommand()->addForeignKey($this->getTableName(), 'cacheId', 'templatecaches', 'id', static::CASCADE); }
/** * Set the max field handle length based on the current field column prefix length. * * @return array */ public function getAttributeConfigs() { $attributeConfigs = parent::getAttributeConfigs(); // Field handles must be <= 58 chars so that with "field_" prepended, they're <= 64 chars (MySQL's column // name limit). $attributeConfigs['handle']['maxLength'] = 64 - strlen(craft()->content->fieldColumnPrefix); return $attributeConfigs; }
/** * Constructor * * @param string $data Metadata * @param string $oaiID Record ID received from OAI-PMH * (or empty string for file import) * @param string $source Source ID * @param string $idPrefix Record ID prefix */ public function __construct($data, $oaiID, $source, $idPrefix) { parent::__construct($data, $oaiID, $source, $idPrefix); $this->doc = simplexml_load_string($data); }
function processPost($formvalues) { # force setting of default none string column values. enum, int and date if (isArrayKeyAnEmptyString('empstatus', $formvalues)) { unset($formvalues['empstatus']); } if (isArrayKeyAnEmptyString('rate', $formvalues)) { unset($formvalues['rate']); } if (isArrayKeyAnEmptyString('ratetype', $formvalues)) { unset($formvalues['ratetype']); } if (isArrayKeyAnEmptyString('istimesheetuser', $formvalues)) { unset($formvalues['istimesheetuser']); } if (isArrayKeyAnEmptyString('payrolltype', $formvalues)) { unset($formvalues['payrolltype']); } if (isArrayKeyAnEmptyString('isignored', $formvalues)) { unset($formvalues['isignored']); } if (isArrayKeyAnEmptyString('daysworked', $formvalues)) { unset($formvalues['daysworked']); } if (isArrayKeyAnEmptyString('hourspending', $formvalues)) { unset($formvalues['hourspending']); } if (isArrayKeyAnEmptyString('halfhoursworked', $formvalues)) { unset($formvalues['halfhoursworked']); } if (isArrayKeyAnEmptyString('fullhoursworked', $formvalues)) { unset($formvalues['fullhoursworked']); } if (isArrayKeyAnEmptyString('leavehrs', $formvalues)) { unset($formvalues['leavehrs']); } if (isArrayKeyAnEmptyString('sickhrs', $formvalues)) { unset($formvalues['sickhrs']); } if (isArrayKeyAnEmptyString('midgross', $formvalues)) { unset($formvalues['midgross']); } if (isArrayKeyAnEmptyString('endgross', $formvalues)) { unset($formvalues['endgross']); } if (isArrayKeyAnEmptyString('nssf', $formvalues)) { unset($formvalues['nssf']); } if (isArrayKeyAnEmptyString('paye', $formvalues)) { unset($formvalues['paye']); } if (isArrayKeyAnEmptyString('otherdebit', $formvalues)) { unset($formvalues['otherdebit']); } if (isArrayKeyAnEmptyString('netearning', $formvalues)) { unset($formvalues['netearning']); } if (isArrayKeyAnEmptyString('transport', $formvalues)) { unset($formvalues['transport']); } if (isArrayKeyAnEmptyString('othercredit', $formvalues)) { unset($formvalues['othercredit']); } if (isArrayKeyAnEmptyString('netpay', $formvalues)) { unset($formvalues['netpay']); } if (isArrayKeyAnEmptyString('totaltaxable', $formvalues)) { unset($formvalues['totaltaxable']); } if (isArrayKeyAnEmptyString('totalbenefits', $formvalues)) { unset($formvalues['totalbenefits']); } parent::processPost($formvalues); }
public function construct() { parent::construct(); // add the custom error messages for the fields in the base entity $this->addCustomErrorMessages(array("createdby.notblank" => "Please provide the user")); }
public function __construct($config) { parent::__construct($config); }
public function getPeer() { if (self::$peer === null) { self::$peer = new RecordPeer(); } return self::$peer; }
/** * Init */ public function init() { parent::init(); // Store the old handle in case it's ever requested. $this->attachEventHandler('onAfterFind', array($this, 'storeOldHandle')); }
function processPost($formvalues) { // trim spaces from the name field if (isArrayKeyAnEmptyString('status', $formvalues)) { unset($formvalues['status']); } if (isArrayKeyAnEmptyString('starttime', $formvalues)) { $formvalues['starttime'] = NULL; } else { $formvalues['starttime'] = date("H:i:s", strtotime($formvalues['starttime'])); } if (isArrayKeyAnEmptyString('endtime', $formvalues)) { $formvalues['endtime'] = NULL; } else { $formvalues['endtime'] = date("H:i:s", strtotime($formvalues['endtime'])); } if (isArrayKeyAnEmptyString('startdate', $formvalues)) { if (!isArrayKeyAnEmptyString('startdate_old', $formvalues)) { $formvalues['startdate'] = NULL; } else { unset($formvalues['startdate']); } } else { $formvalues['startdate'] = date('Y-m-d', strtotime($formvalues['startdate'])); } if (isArrayKeyAnEmptyString('enddate', $formvalues)) { if (!isArrayKeyAnEmptyString('enddate_old', $formvalues)) { $formvalues['enddate'] = NULL; } else { unset($formvalues['enddate']); } } else { $formvalues['enddate'] = date('Y-m-d', strtotime($formvalues['enddate'])); } if (!isArrayKeyAnEmptyString('workingdaysids', $formvalues)) { $formvalues['workingdays'] = implode(',', $formvalues['workingdaysids']); } else { if (!isArrayKeyAnEmptyString('workingdays_old', $formvalues)) { if (isArrayKeyAnEmptyString('workingdaysids', $formvalues)) { $formvalues['workingdays'] = NULL; } } else { unset($formvalues['workingdays']); } } // debugMessage($formvalues); exit(); parent::processPost($formvalues); }
/** * Return fields to be indexed in Solr (an alternative to an XSL transformation) * * @return string[] */ public function toSolrArray() { // Add source prefix to IDs in link fields $fields = ['760', '762', '765', '767', '770', '772', '773', '774', '775', '776', '777', '780', '785', '786', '787']; foreach ($fields as $code) { if (isset($this->fields[$code])) { foreach ($this->fields[$code] as &$marcfield) { if (isset($marcfield['s'])) { foreach ($marcfield['s'] as &$marcsubfield) { if (key($marcsubfield) == 'w') { $marcsubfield['w'] = $this->idPrefix . '.' . $marcsubfield['w']; } } } } } } $data = parent::toSolrArray(); // building $data['building'] = []; if ($this->getDriverParam('holdingsInBuilding', true)) { foreach ($this->getFields('852') as $field) { $location = $this->getSubfield($field, 'b'); if ($location) { $data['building'][] = $location; } } } // long_lat $field = $this->getField('034'); if ($field) { $westOrig = $this->getSubfield($field, 'd'); $eastOrig = $this->getSubfield($field, 'e'); $northOrig = $this->getSubfield($field, 'f'); $southOrig = $this->getSubfield($field, 'g'); $west = MetadataUtils::coordinateToDecimal($westOrig); $east = MetadataUtils::coordinateToDecimal($eastOrig); $north = MetadataUtils::coordinateToDecimal($northOrig); $south = MetadataUtils::coordinateToDecimal($southOrig); if (!is_nan($west) && !is_nan($north)) { if (!is_nan($east)) { $longitude = ($west + $east) / 2; } else { $longitude = $west; } if (!is_nan($south)) { $latitude = ($north + $south) / 2; } else { $latitude = $north; } if ($longitude < -180 || $longitude > 180 || ($latitude < -90 || $latitude > 90)) { global $logger; $logger->log('MarcRecord', "Discarding invalid coordinates {$longitude},{$latitude} " . "decoded from w={$westOrig}, e={$eastOrig}, n={$northOrig}, " . "s={$southOrig}, record {$this->source}." . $this->getID(), Logger::WARNING); } else { $data['long_lat'] = "{$longitude},{$latitude}"; } } } // lccn $data['lccn'] = $this->getFieldSubfields('010', ['a' => 1]); $data['ctrlnum'] = $this->getFieldsSubfields([[MarcRecord::GET_NORMAL, '035', ['a' => 1]]]); $data['fullrecord'] = $this->toISO2709(); if (!$data['fullrecord']) { // In case the record exceeds 99999 bytes... $data['fullrecord'] = $this->toXML(); } $data['allfields'] = $this->getAllFields(); // language $languages = $this->getLanguages(); foreach ($languages as $language) { if (preg_match('/^\\w{3}$/', $language) && $language != 'zxx' && $language != 'und') { $data['language'][] = $language; } } $data['format'] = $this->getFormat(); $data['author'] = $this->getFieldSubfields('100', ['a' => 1, 'b' => 1, 'c' => 1, 'd' => 1, 'e' => 1]); $data['author_fuller'] = $this->getFieldSubfields('100', ['q' => 1]); $data['author-letter'] = $this->getFieldSubfields('100', ['a' => 1]); $data['author2'] = $this->getFieldsSubfields([[MarcRecord::GET_ALT, '100', ['a' => 1, 'b' => 1, 'c' => 1, 'd' => 1]], [MarcRecord::GET_BOTH, '110', ['a' => 1, 'b' => 1]], [MarcRecord::GET_BOTH, '111', ['a' => 1, 'b' => 1]], [MarcRecord::GET_BOTH, '700', ['a' => 1, 'q' => 1, 'b' => 1, 'c' => 1, 'd' => 1, 'e' => 1]], [MarcRecord::GET_BOTH, '710', ['a' => 1, 'b' => 1]], [MarcRecord::GET_BOTH, '711', ['a' => 1, 'b' => 1]]]); $key = array_search($data['author'], $data['author2']); if ($key !== false) { unset($data['author2'][$key]); } $data['author2'] = array_filter(array_values($data['author2'])); $data['author2-role'] = $this->getFieldsSubfields([[MarcRecord::GET_BOTH, '700', ['e' => 1]], [MarcRecord::GET_BOTH, '710', ['e' => 1]]], true); $data['author_additional'] = $this->getFieldsSubfields([[MarcRecord::GET_BOTH, '505', ['r' => 1]]], true); $data['title'] = $this->getTitle(); $data['title_sub'] = $this->getFieldSubfields('245', ['b' => 1, 'n' => 1, 'p' => 1]); $data['title_short'] = $this->getFieldSubfields('245', ['a' => 1]); $data['title_full'] = $this->getFieldSubfields('245', ['a' => 1, 'b' => 1, 'c' => 1, 'f' => 1, 'g' => 1, 'h' => 1, 'k' => 1, 'n' => 1, 'p' => 1, 's' => 1]); $data['title_alt'] = array_values(array_unique($this->getFieldsSubfields([[MarcRecord::GET_ALT, '245', ['a' => 1, 'b' => 1]], [MarcRecord::GET_BOTH, '130', ['a' => 1, 'd' => 1, 'f' => 1, 'g' => 1, 'k' => 1, 'l' => 1, 'n' => 1, 'p' => 1, 's' => 1, 't' => 1]], [MarcRecord::GET_BOTH, '240', ['a' => 1]], [MarcRecord::GET_BOTH, '246', ['g' => 1]], [MarcRecord::GET_BOTH, '730', ['a' => 1, 'd' => 1, 'f' => 1, 'g' => 1, 'k' => 1, 'l' => 1, 'n' => 1, 'p' => 1, 's' => 1, 't' => 1]], [MarcRecord::GET_BOTH, '740', ['a' => 1]]]))); $data['title_old'] = $this->getFieldsSubfields([[MarcRecord::GET_BOTH, '780', ['a' => 1, 's' => 1, 't' => 1]]]); $data['title_new'] = $this->getFieldsSubfields([[MarcRecord::GET_BOTH, '785', ['a' => 1, 's' => 1, 't' => 1]]]); $data['title_sort'] = $this->getTitle(true); if (!$data['title_short']) { $data['title_short'] = $this->getFieldSubfields('240', ['a' => 1, 'n' => 1, 'p' => 1]); $data['title_full'] = $this->getFieldSubfields('240'); } $data['series'] = $this->getFieldsSubfields([[MarcRecord::GET_BOTH, '440', ['a' => 1]], [MarcRecord::GET_BOTH, '490', ['a' => 1]], [MarcRecord::GET_BOTH, '800', ['a' => 1, 'b' => 1, 'c' => 1, 'd' => 1, 'f' => 1, 'p' => 1, 'q' => 1, 't' => 1]], [MarcRecord::GET_BOTH, '830', ['a' => 1, 'p' => 1]]]); $data['publisher'] = $this->getFieldsSubfields([[MarcRecord::GET_BOTH, '260', ['b' => 1]]], false, true); if (!$data['publisher']) { $fields = $this->getFields('264'); foreach ($fields as $field) { if ($this->getIndicator($field, 2) == '1') { $data['publisher'] = metadataUtils::stripTrailingPunctuation($this->getSubfield($field, 'b')); break; } } } $publicationYear = $this->getPublicationYear(); if ($publicationYear) { $data['publishDateSort'] = $publicationYear; $data['publishDate'] = [$publicationYear]; } $data['physical'] = $this->getFieldsSubfields([[MarcRecord::GET_BOTH, '300', ['a' => 1, 'b' => 1, 'c' => 1, 'e' => 1, 'f' => 1, 'g' => 1]], [MarcRecord::GET_BOTH, '530', ['a' => 1, 'b' => 1, 'c' => 1, 'd' => 1]]]); $data['dateSpan'] = $this->getFieldsSubfields([[MarcRecord::GET_BOTH, '362', ['a' => 1]]]); $data['edition'] = $this->getFieldSubfields('250', ['a' => 1]); $data['contents'] = $this->getFieldsSubfields([[MarcRecord::GET_BOTH, '505', ['a' => 1]], [MarcRecord::GET_BOTH, '505', ['t' => 1]]]); $data['isbn'] = $this->getISBNs(); foreach ($this->getFieldsSubfields([[MarcRecord::GET_NORMAL, '773', ['z' => 1]]]) as $isbn) { $isbn = str_replace('-', '', $isbn); if (!preg_match('{([0-9]{9,12}[0-9xX])}', $isbn, $matches)) { continue; } $isbn = $matches[1]; if (strlen($isbn) == 10) { $isbn = MetadataUtils::isbn10to13($isbn); } if ($isbn) { $data['isbn'][] = $isbn; } } $data['issn'] = $this->getFieldsSubfields([[MarcRecord::GET_NORMAL, '022', ['a' => 1]], [MarcRecord::GET_NORMAL, '440', ['x' => 1]], [MarcRecord::GET_NORMAL, '490', ['x' => 1]], [MarcRecord::GET_NORMAL, '730', ['x' => 1]], [MarcRecord::GET_NORMAL, '773', ['x' => 1]], [MarcRecord::GET_NORMAL, '776', ['x' => 1]], [MarcRecord::GET_NORMAL, '780', ['x' => 1]], [MarcRecord::GET_NORMAL, '785', ['x' => 1]]]); foreach ($data['issn'] as &$value) { $value = str_replace('-', '', $value); } $data['callnumber-first'] = $this->getFirstFieldSubfields([[MarcRecord::GET_NORMAL, '099', ['a' => 1]], [MarcRecord::GET_NORMAL, '090', ['a' => 1]], [MarcRecord::GET_NORMAL, '050', ['a' => 1]]]); $values = $this->getFirstFieldSubfields([[MarcRecord::GET_NORMAL, '090', ['a' => 1]], [MarcRecord::GET_NORMAL, '050', ['a' => 1]]]); if ($values) { if (preg_match('/^([A-Z]+)/', strtoupper($values[0]), $matches)) { $data['callnumber-subject'] = $matches[1]; } $dotPos = strstr($values[0], '.'); if ($dotPos > 0) { $data['callnumber-label'] = strtoupper(substr($values[1], 0, $dotPos)); } else { $data['callnumber-label'] = strtoupper($values[0]); } } $data['callnumber-raw'] = array_map('strtoupper', $this->getFieldsSubfields([[MarcRecord::GET_NORMAL, '080', ['a' => 1, 'b' => 1]], [MarcRecord::GET_NORMAL, '084', ['a' => 1, 'b' => 1]], [MarcRecord::GET_NORMAL, '050', ['a' => 1, 'b' => 1]]])); foreach ($data['callnumber-raw'] as $callnumber) { $cn = new LcCallNumber($callnumber); if ($cn->isValid()) { $data['callnumber-sort'] = $cn->getSortKey(); } } if (empty($data['callnumber-sort']) && !empty($data['callnumber-raw'])) { $cn = new LcCallNumber($data['callnumber-raw'][0]); $data['callnumber-sort'] = $cn->getSortKey(); } $data['topic'] = $this->getTopics(); $data['genre'] = $this->getGenres(); $data['geographic'] = $this->getGeographicTopics(); $data['era'] = $this->getEras(); $data['topic_facet'] = $this->getTopicFacets(); $data['genre_facet'] = $this->getGenreFacets(); $data['geographic_facet'] = $this->getGeographicFacets(); $data['era_facet'] = $this->getEraFacets(); $data['url'] = $this->getFieldsSubfields([[MarcRecord::GET_NORMAL, '856', ['u' => 1]]]); $data['illustrated'] = $this->getIllustrated(); // TODO: dewey fields and OCLC numbers return $data; }