本文整理汇总了PHP中CostbenefitprojectionHelper::getVars方法的典型用法代码示例。如果您正苦于以下问题:PHP CostbenefitprojectionHelper::getVars方法的具体用法?PHP CostbenefitprojectionHelper::getVars怎么用?PHP CostbenefitprojectionHelper::getVars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CostbenefitprojectionHelper
的用法示例。
在下文中一共展示了CostbenefitprojectionHelper::getVars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSaveHook
/**
* Function that allows child controller access to model data
* after the data has been saved.
*
* @param JModel &$model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 11.1
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
if ($validData['id'] >= 0) {
// get user object
$user = JFactory::getUser();
// if id is 0 get id
if (0 >= (int) $validData['id']) {
// Get the created by id
$created_by = isset($validData['created_by']) && $validData['created_by'] > 0 ? $validData['created_by'] : $user->id;
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select id of this company
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__costbenefitprojection_company'));
$query->where($db->quoteName('name') . ' = ' . $db->quote($validData['name']));
$query->where($db->quoteName('email') . ' = ' . $db->quote($validData['email']));
$query->where($db->quoteName('country') . ' = ' . (int) $validData['country']);
$query->where($db->quoteName('service_provider') . ' = ' . (int) $validData['service_provider']);
$query->where($db->quoteName('created_by') . ' = ' . (int) $created_by);
if (isset($validData['created'])) {
$query->where($db->quoteName('created') . ' = ' . $db->quote($validData['created']));
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows()) {
$validData['id'] = $db->loadResult();
} else {
return;
}
}
// user setup if not set
if (0 >= (int) $validData['user'] && (int) $validData['id'] > 0) {
$userIs = CostbenefitprojectionHelper::userIs($user->id);
if (1 == $userIs) {
// this is a company so just use its id
$userId = $user->id;
// add this user id to this company
$validData['user'] = $userId;
$model->save($validData);
} else {
// setup config array
$newUser = array('name' => $validData['name'], 'email' => $validData['email']);
$userId = CostbenefitprojectionHelper::createUser($newUser);
if (!is_int($userId)) {
$this->setMessage($userId, 'error');
} else {
// add this user id to this company
$validData['user'] = $userId;
$model->save($validData);
}
}
}
// only continue if we have a company id
if ((int) $validData['id'] > 0) {
// get params
$params = JComponentHelper::getParams('com_costbenefitprojection');
// get all this users companies
$hisCompanies = CostbenefitprojectionHelper::hisCompanies($validData['user']);
if (CostbenefitprojectionHelper::checkArray($hisCompanies)) {
// set the user group based on the overall status of its companies
$departments = CostbenefitprojectionHelper::getVars('company', $hisCompanies, 'id', 'department');
if (in_array(2, $departments)) {
$memberGroups = $params->get('advancedmembergroup');
} else {
$memberGroups = $params->get('memberbasicgroup');
}
} else {
// first company so act simply on this company department status
if (2 == $validData['department']) {
$memberGroups = $params->get('advancedmembergroup');
} else {
$memberGroups = $params->get('memberbasicgroup');
}
}
// update the user groups
JUserHelper::setUserGroups((int) $validData['user'], (array) $memberGroups);
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select all records in scaling factors the belong to this company
$query->select($db->quoteName(array('id', 'causerisk', 'published')));
$query->from($db->quoteName('#__costbenefitprojection_scaling_factor'));
$query->where($db->quoteName('company') . ' = ' . (int) $validData['id']);
$db->setQuery($query);
$db->execute();
if ($db->getNumRows()) {
//.........这里部分代码省略.........