Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
comanage-grouper-widget/Model/CoGrouperLiteWidget.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
159 lines (147 sloc)
5.25 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* COmanage Registry Grouper Lite Widget Dashboard Widget | |
* | |
* Portions licensed to the University Corporation for Advanced Internet | |
* Development, Inc. ("UCAID") under one or more contributor license agreements. | |
* See the NOTICE file distributed with this work for additional information | |
* regarding copyright ownership. | |
* | |
* UCAID licenses this file to you under the Apache License, Version 2.0 | |
* (the "License"); you may not use this file except in compliance with the | |
* License. You may obtain a copy of the License at: | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
* | |
* @link http://www.internet2.edu/comanage COmanage Project | |
* @package registry-plugin | |
* @since COmanage Registry v3.2.0 | |
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | |
*/ | |
App::uses("CoDashboardWidgetBackend", "Model"); | |
class CoGrouperLiteWidget extends CoDashboardWidgetBackend { | |
// Define class name for cake | |
public $name = "CoGrouperLiteWidget"; | |
// Association rules from this model to other models | |
public $belongsTo = array( | |
"CoDashboardWidget" | |
); | |
// Add behaviors | |
public $actsAs = array('Containable'); | |
// Validation rules for table elements | |
//Tried adding rule to each field to make alphaNumeric, but keeps throwing errors. will research. | |
public $validate = array( | |
'co_dashboard_widget_id' => array( | |
'rule' => 'numeric', | |
'required' => true, | |
'allowEmpty' => false | |
), | |
'conn_url' => array( | |
'rule' => array('custom', '/^https?:\/\/.*/'), | |
'required' => true, | |
'allowEmpty' => false | |
), | |
'conn_ver' => array( | |
'rule' => array('minLength', 4), | |
'required' => true, | |
'allowEmpty' => false | |
), | |
'grouper_url' => array( | |
'rule' => array('custom', '/^https?:\/\/.*/'), | |
'required' => true, | |
'allowEmpty' => false | |
), | |
'conn_user' => array( | |
'rule' => array('minLength', 1), | |
'required' => true, | |
'allowEmpty' => false | |
), | |
'conn_pass' => array( | |
'rule' => array('minLength', 1), | |
'required' => true, | |
'allowEmpty' => false | |
), | |
'adhoc_heading' => array( | |
'rule' => array('minLength', 1), | |
'required' => false, | |
'allowEmpty' => true, | |
'default' => 'Ad-hoc groups' | |
), | |
'wg_heading' => array( | |
'rule' => array('minLength', 1), | |
'required' => false, | |
'allowEmpty' => true, | |
'default' => 'Working groups' | |
), | |
'default_collapse' => array( | |
'rule' => array('minLength', 1), | |
'required' => false, | |
'default' => 'collapsed' | |
), | |
'identifier_type' => array( | |
'content' => array( | |
'rule' => array( | |
'validateExtendedType', | |
array('attribute' => 'Identifier.type', | |
'default' => array(IdentifierEnum::AffiliateSOR, | |
IdentifierEnum::Badge, | |
IdentifierEnum::Enterprise, | |
IdentifierEnum::ePPN, | |
IdentifierEnum::ePTID, | |
IdentifierEnum::ePUID, | |
IdentifierEnum::GuestSOR, | |
IdentifierEnum::HRSOR, | |
IdentifierEnum::Mail, | |
IdentifierEnum::National, | |
IdentifierEnum::Network, | |
IdentifierEnum::OIDCsub, | |
IdentifierEnum::OpenID, | |
IdentifierEnum::ORCID, | |
IdentifierEnum::ProvisioningTarget, | |
IdentifierEnum::Reference, | |
IdentifierEnum::SamlPairwise, | |
IdentifierEnum::SamlSubject, | |
IdentifierEnum::SORID, | |
IdentifierEnum::StudentSOR, | |
IdentifierEnum::UID))), | |
'required' => true, | |
'allowEmpty' => false | |
) | |
), | |
// TODO: Are there any limitation regarding the acceptable group name characters | |
// For COmanage there are so we need to check this as well | |
'act_as_grp_name' => array( | |
'rule' => '/.*/', | |
'required' => false, | |
'allowEmpty' => true | |
) | |
); | |
/** | |
* Actions to take before a validate operation is executed. | |
* | |
* @since COmanage Registry v4.4.0 | |
*/ | |
public function beforeValidate($options = array()) { | |
if(!empty($this->data[$this->alias]['co_dashboard_widget_id']) | |
&& isset($this->id)) { | |
// Dashboard Widget Plugins will refer to Dashboard Widget, which in turn | |
// refers to a Dashboard | |
$args = array(); | |
$args['conditions'][$this->alias.'.id'] = $this->id; | |
$args['contain']['CoDashboardWidget'][] = 'CoDashboard'; | |
$codw = $this->find('first', $args); | |
if(!empty($codw["CoDashboardWidget"]["CoDashboard"]["co_id"])) { | |
$contentRule = $this->validator()->getField('identifier_type')->getRule('content')->rule; | |
$contentRule[1]['coid'] = $codw["CoDashboardWidget"]["CoDashboard"]["co_id"]; | |
$this->validator()->getField('identifier_type')->getRule('content')->rule = $contentRule; | |
} | |
} | |
return parent::beforeValidate($options); | |
} | |
} |