public function addCommandsFromClass($className, $passThrough = null) { $roboTasks = new $className(); $commandNames = array_filter(get_class_methods($className), function ($m) { return !in_array($m, ['__construct']); }); foreach ($commandNames as $commandName) { $command = $this->createCommand(new TaskInfo($className, $commandName)); $command->setCode(function (InputInterface $input) use($roboTasks, $commandName, $passThrough) { // get passthru args $args = $input->getArguments(); array_shift($args); if ($passThrough) { $args[key(array_slice($args, -1, 1, TRUE))] = $passThrough; } $args[] = $input->getOptions(); $res = call_user_func_array([$roboTasks, $commandName], $args); if (is_int($res)) { exit($res); } if (is_bool($res)) { exit($res ? 0 : 1); } if ($res instanceof Result) { exit($res->getExitCode()); } }); $this->add($command); } }
function calculateGFRResult() { $tmpArr = array(); $tmpArr[] = date('Y-m-d H:i:s'); //observation time $tmpArr[] = 'GFR (CALC)'; //desc $gender = NSDR::populate($this->_patientId . "::com.clearhealth.person.displayGender"); $crea = NSDR::populate($this->_patientId . "::com.clearhealth.labResults[populate(@description=CREA)]"); $genderFactor = null; $creaValue = null; $personAge = null; $raceFactor = 1; switch ($gender[key($gender)]) { case 'M': $genderFactor = 1; break; case 'F': $genderFactor = 0.742; break; } if ((int) strtotime($crea['observation_time']) >= strtotime('now - 60 days') && strtolower($crea[key($crea)]['units']) == 'mg/dl') { $creaValue = $crea[key($crea)]['value']; } $person = new Person(); $person->personId = $this->_patientId; $person->populate(); if ($person->age > 0) { $personAge = $person->age; } $personStat = new PatientStatistics(); $personStat->personId = $this->_patientId; $personStat->populate(); if ($personStat->race == "AFAM") { $raceFactor = 1.21; } $gfrValue = "INC"; if ($personAge > 0 && $creaValue > 0) { $gfrValue = "" . (int) round(pow($creaValue, -1.154) * pow($personAge, -0.203) * $genderFactor * $raceFactor * 186); } trigger_error("gfr:: " . $gfrValue, E_USER_NOTICE); $tmpArr[] = $gfrValue; // lab value $tmpArr[] = 'mL/min/1.73 m2'; //units $tmpArr[] = ''; //ref range $tmpArr[] = ''; //abnormal $tmpArr[] = 'F'; //status $tmpArr[] = date('Y-m-d H:i:s') . '::' . '0'; // observationTime::(boolean)normal; 0 = abnormal, 1 = normal $tmpArr[] = '0'; //sign //$this->_calcLabResults[uniqid()] = $tmpArr; $this->_calcLabResults[1] = $tmpArr; // temporarily set index to one(1) to be able to include in selected lab results return $tmpArr; }
/** * {@inheritdoc} */ public function prepare_form($request, $template, $user, $row, &$error) { $avatar_list = $this->get_avatar_list($user); $category = $request->variable('avatar_local_cat', key($avatar_list)); foreach ($avatar_list as $cat => $null) { if (!empty($avatar_list[$cat])) { $template->assign_block_vars('avatar_local_cats', array('NAME' => $cat, 'SELECTED' => $cat == $category)); } if ($cat != $category) { unset($avatar_list[$cat]); } } if (!empty($avatar_list[$category])) { $template->assign_vars(array('AVATAR_LOCAL_SHOW' => true)); $table_cols = isset($row['avatar_gallery_cols']) ? $row['avatar_gallery_cols'] : 4; $row_count = $col_count = $avatar_pos = 0; $avatar_count = sizeof($avatar_list[$category]); reset($avatar_list[$category]); while ($avatar_pos < $avatar_count) { $img = current($avatar_list[$category]); next($avatar_list[$category]); if ($col_count == 0) { ++$row_count; $template->assign_block_vars('avatar_local_row', array()); } $template->assign_block_vars('avatar_local_row.avatar_local_col', array('AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], 'AVATAR_NAME' => $img['name'], 'AVATAR_FILE' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar'])); $template->assign_block_vars('avatar_local_row.avatar_local_option', array('AVATAR_FILE' => $img['filename'], 'S_OPTIONS_AVATAR' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar'])); $col_count = ($col_count + 1) % $table_cols; ++$avatar_pos; } } return true; }
/** * Validates a partial array. Some data may be missing from the given $array, then it will be taken from the * full array. * * Since the array can be incomplete, this method does not validate required parameters. * * @param array $array * @param array $fullArray * * @return bool */ public function validatePartial(array $array, array $fullArray) { $unvalidatedFields = array_flip(array_keys($array)); // field validators foreach ($this->validators as $field => $validator) { unset($unvalidatedFields[$field]); // if the value is present if (isset($array[$field])) { // validate it if a validator is given, skip it otherwise if ($validator && !$validator->validate($array[$field])) { $this->setError($validator->getError()); return false; } } } // check if any unsupported fields remain if ($unvalidatedFields) { reset($unvalidatedFields); $field = key($unvalidatedFields); $this->error($this->messageUnsupported, $field); return false; } // post validators foreach ($this->postValidators as $validator) { if (!$validator->validatePartial($array, $fullArray)) { $this->setError($validator->getError()); return false; } } return true; }
function foo(&$state) { $contentDict = end($state); for ($contentDict = end($state); $contentDict !== false; $contentDict = prev($state)) { echo key($state) . " => " . current($state) . "\n"; } }
public function projectImport($api, $args) { $this->checkACL($api, $args); $this->requireArgs($args, array('module')); $bean = BeanFactory::getBean($args['module']); if (!$bean->ACLAccess('save') || !$bean->ACLAccess('import')) { throw new SugarApiExceptionNotAuthorized('EXCEPTION_NOT_AUTHORIZED'); } if (isset($_FILES) && count($_FILES) === 1) { reset($_FILES); $first_key = key($_FILES); if (isset($_FILES[$first_key]['tmp_name']) && $this->isUploadedFile($_FILES[$first_key]['tmp_name']) && isset($_FILES[$first_key]['size']) && isset($_FILES[$first_key]['size']) > 0) { try { $importerObject = new PMSEProjectImporter(); $name = $_FILES[$first_key]['name']; $extension = pathinfo($name, PATHINFO_EXTENSION); if ($extension == $importerObject->getExtension()) { $data = $importerObject->importProject($_FILES[$first_key]['tmp_name']); $results = array('project_import' => $data); } else { throw new SugarApiExceptionRequestMethodFailure('ERROR_UPLOAD_FAILED'); } } catch (SugarApiExceptionNotAuthorized $e) { throw new SugarApiExceptionNotAuthorized('ERROR_UPLOAD_ACCESS_PD'); } catch (Exception $e) { throw new SugarApiExceptionRequestMethodFailure('ERROR_UPLOAD_FAILED'); } return $results; } } else { throw new SugarApiExceptionMissingParameter('ERROR_UPLOAD_FAILED'); } }
function getFilteredWords() { global $Weblogs; if (file_exists('db/search/filtered_words.txt')) { $filtered_file = file('db/search/filtered_words.txt'); foreach ($filtered_file as $val) { if (substr($val, 0, 2) !== "//") { $filtered_words[] = trim($val); } } } else { $filtered_words = array(); } @reset($Weblogs); @($Current_weblog = key($Weblogs)); $theLang = $Weblogs[$Current_weblog]['language']; if ('' != $theLang && file_exists('db/search/filtered_words_' . $theLang . '.txt')) { // echo '*' ; $filtered_file = file('db/search/filtered_words_' . $theLang . '.txt'); foreach ($filtered_file as $val) { $filtered_words[] = trim($val); } } return $filtered_words; }
/** * Implement json_encode for PHP that does not support it * * @param mixed $elements PHP Object to json encode * @return string Json encoded string * @deprecated PHP >= 5.3 supports native json_encode * @see json_encode() */ function dol_json_encode($elements) { dol_syslog('dol_json_encode() is deprecated. Please update your code to use native json_encode().', LOG_WARNING); $num = count($elements); if (is_object($elements)) { $num = 0; foreach ($elements as $key => $value) { $num++; } } //var_dump($num); // determine type if (is_numeric(key($elements)) && key($elements) == 0) { // indexed (list) $keysofelements = array_keys($elements); // Elements array mus have key that does not start with 0 and end with num-1, so we will use this later. $output = '['; for ($i = 0, $last = $num - 1; $i < $num; $i++) { if (!isset($elements[$keysofelements[$i]])) { continue; } if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) { $output .= json_encode($elements[$keysofelements[$i]]); } else { $output .= _val($elements[$keysofelements[$i]]); } if ($i !== $last) { $output .= ','; } } $output .= ']'; } else { // associative (object) $output = '{'; $last = $num - 1; $i = 0; $tmpelements = array(); if (is_array($elements)) { $tmpelements = $elements; } if (is_object($elements)) { $tmpelements = get_object_vars($elements); } foreach ($tmpelements as $key => $value) { $output .= '"' . $key . '":'; if (is_array($value)) { $output .= json_encode($value); } else { $output .= _val($value); } if ($i !== $last) { $output .= ','; } ++$i; } $output .= '}'; } // return return $output; }
/** * Executes parent method parent::render(), creates deliveryset category tree, * passes data to Smarty engine and returns name of template file "deliveryset_main.tpl". * * @return string */ public function render() { $myConfig = $this->getConfig(); parent::render(); $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId(); if ($soxId != "-1" && isset($soxId)) { // load object $odeliveryset = oxNew("oxdeliveryset"); $odeliveryset->loadInLang($this->_iEditLang, $soxId); $oOtherLang = $odeliveryset->getAvailableInLangs(); if (!isset($oOtherLang[$this->_iEditLang])) { // echo "language entry doesn't exist! using: ".key($oOtherLang); $odeliveryset->loadInLang(key($oOtherLang), $soxId); } $this->_aViewData["edit"] = $odeliveryset; // remove already created languages $aLang = array_diff(oxLang::getInstance()->getLanguageNames(), $oOtherLang); if (count($aLang)) { $this->_aViewData["posslang"] = $aLang; } foreach ($oOtherLang as $id => $language) { $oLang = new oxStdClass(); $oLang->sLangDesc = $language; $oLang->selected = $id == $this->_iEditLang; $this->_aViewData["otherlang"][$id] = clone $oLang; } } if (oxConfig::getParameter("aoc")) { $aColumns = array(); include_once 'inc/' . strtolower(__CLASS__) . '.inc.php'; $this->_aViewData['oxajax'] = $aColumns; return "popups/deliveryset_main.tpl"; } return "deliveryset_main.tpl"; }
function getTypeName($val, $argument = null) { $type = gettype($val); global $detectDateMode; switch ($type) { case "string": if ($detectDateMode == 1 && isDate($val)) { return "Date"; } else { if ($detectDateMode == 2 && (bool) strtotime($val)) { return "Date"; } else { return "String"; } } case "integer": return "int"; case "double": return "float"; case "boolean": return "boolean"; case "array": if (is_numeric(key($val))) { return "RealmList<" . $argument . ">"; } else { return $argument; } } return null; }
/** * Edit a blog. * * @param string $id * * @return Response */ public function edit($id) { $blog = Blog::find($id); $file_size = key(config('image.image_sizes')); $files = $this->getFiles('images/blogs/' . $blog->id . '/' . $file_size); return view('admin/blog/edit', ['blog' => $blog, 'files' => $files, 'file_size' => $file_size]); }
/** * Print a concise, human readable representation of a value. * * @param wild Any value. * @return string Human-readable short representation of the value. * @task print */ public static function printShort($value) { if (is_object($value)) { return 'Object ' . get_class($value); } else { if (is_array($value)) { $str = 'Array '; if ($value) { if (count($value) > 1) { $str .= 'of size ' . count($value) . ' starting with: '; } reset($value); // Prevent key() from giving warning message in HPHP. $str .= '{ ' . self::printShort(key($value)) . ' => ' . self::printShort(head($value)) . ' }'; } return $str; } else { // NOTE: Avoid PhutilUTF8StringTruncator here since the data may not be // UTF8 anyway, it's slow for large inputs, and it might not be loaded // yet. $limit = 1024; $str = self::printableValue($value); if (strlen($str) > $limit) { if (is_string($value)) { $str = "'" . substr($str, 1, $limit) . "...'"; } else { $str = substr($str, 0, $limit) . '...'; } } return $str; } } }
function finalize() { // get parent's output parent::finalize(); $output = parent::getOutput(); $tex_output = ''; foreach ($output as $token) { if ($this->_enumerated) { $class = $token[0]; $content = $token[1]; } else { $key = key($token); $class = $key; $content = $token[$key]; } $iswhitespace = ctype_space($content); if (!$iswhitespace) { if ($class === 'special') { $class = 'code'; } $tex_output .= sprintf('\\textcolor{%s}{%s}', $class, $this->escape($content)); } else { $tex_output .= $content; } } $this->_output = "\\begin{alltt}\n" . $tex_output . "\\end{alltt}"; }
/** * @param mixed $item * @return mixed * @throws \Exception */ public function convert($item) { foreach ($this->processors as $field => $actions) { // If field doesn't exist: // - Create new column with null value // - Add new route to this column if (!array_key_exists($field, $item)) { $item[$field] = null; $this->route[$field] = $field; } // An array of actions has been given if (is_array($actions) && count($actions) > 0) { foreach ($actions as $action) { // Get action name and options $name = is_array($action) ? key($action) : $action; $options = is_array($action) ? current($action) : null; // Set processor name in CamelCase $name = implode('', array_map('ucwords', explode('_', $name))); // Get processor class from action name $class = 'Stratis\\Component\\Migrator\\Processor\\' . $name . 'Processor'; // Check if class exists if (!class_exists($class)) { throw new \Exception($class . ' does not exists'); } // Use processor exec function $item[$field] = $class::exec($item[$field], $options, $item); } } } return $item; }
/** * Generates Xml of Array * @param string $rootName [optional] default 'root' * @return String xml string if available otherwise false */ public function saveArrayToXml($rootName = "") { $this->document = new Uni_Data_XDOMDocument(); $arr = array(); if (count($this->_xmlArray) > 1) { if ($rootName != "") { $root = $this->document->createElement($rootName); } else { $root = $this->document->createElement("root"); } $arr = $this->_xmlArray; } else { $key = key($this->_xmlArray); if (!is_int($key)) { $root = $this->document->createElement($key); } else { if ($rootName != "") { $root = $this->document->createElement($rootName); } else { $root = $this->document->createElement("root"); } } $arr = $this->_xmlArray[$key]; } $root = $this->document->appendchild($root); $this->addArray($arr, $root); if ($xmlString = $this->document->saveXML()) { return $xmlString; } else { return false; } }
function processView() { $params = array(); if (!empty($_REQUEST['name'])) { $GLOBALS['system']->includeDBClass('person'); $this->_person_data = Person::getPersonsByName($_REQUEST['name']); } else { foreach ($this->_search_terms as $term) { if (!empty($_REQUEST[$term])) { $params[$term] = $_REQUEST[$term]; } } if (!empty($params)) { $this->_person_data = $GLOBALS['system']->getDBObjectData('person', $params, 'AND', 'last_name'); } } if (count($this->_person_data) == 1) { add_message('One matching person found'); redirect('persons', array('name' => NULL, 'personid' => key($this->_person_data))); } $archiveds = array(); foreach ($this->_person_data as $k => $v) { if ($v['status'] == 'archived') { $archiveds[$k] = $v; unset($this->_person_data[$k]); } } foreach ($archiveds as $k => $v) { $this->_person_data[$k] = $v; } }
/** * Add an item of type BaseField to the field collection * * @param BaseField $objItem */ public function addItem(BaseField $objItem) { $this->items[] = $objItem; end($this->items); $key = key($this->items); $this->index[$key] = $objItem->get('colName'); }
public static function buildRows($filename) { $data = self::getCsv($filename); $header = array(); $sid1 = array(); $sid_sec = array(); foreach ($data as $id => $d) { $header[$d[self::COL_DESC]] = $d[self::COL_DESC]; $sid1[$d[self::COL_SID]] = $d[self::COL_SID]; $sid_sec[$d[self::COL_SID]][][$d[self::COL_DESC]] = $d[self::COL_SEC]; } $c = count($header); $sid_sec_2 = array(); foreach ($sid_sec as $sid => $sec) { for ($i = 0; $i < count($sec); $i += $c) { for ($j = 0; $j < $c; $j++) { $key = key($sec[$i + $j]); $value = reset($sec[$i + $j]); $sid_sec_2[$sid][$i][$key] = $value; } } } $i = 0; $rows = array(); foreach ($sid_sec_2 as $sid => $tab) { foreach ($tab as $id => $m) { $i++; $rows[$i] = array('SID' => $sid); foreach ($header as $h) { $rows[$i][$h] = $m[$h]; } } } return $rows; }
/** * Action for AJAX request * * @return void */ public function execute() { $bookmark = $this->bookmarkFactory->create(); $jsonData = $this->_request->getParam('data'); if (!$jsonData) { throw new \InvalidArgumentException('Invalid parameter "data"'); } $data = $this->jsonDecoder->decode($jsonData); $action = key($data); switch ($action) { case self::ACTIVE_IDENTIFIER: $this->updateCurrentBookmark($data[$action]); break; case self::CURRENT_IDENTIFIER: $this->updateBookmark($bookmark, $action, $bookmark->getTitle(), $jsonData); break; case self::VIEWS_IDENTIFIER: foreach ($data[$action] as $identifier => $data) { $this->updateBookmark($bookmark, $identifier, isset($data['label']) ? $data['label'] : '', $jsonData); $this->updateCurrentBookmark($identifier); } break; default: throw new \LogicException(__('Unsupported bookmark action.')); } }
public function __construct($lang = "") { if (\file_exists(\pocketmine\PATH . "src/pocketmine/lang/Installer/" . $lang . ".ini")) { $this->lang = $lang; $this->langfile = \pocketmine\PATH . "src/pocketmine/lang/Installer/" . $lang . ".ini"; } else { $files = []; foreach (new \DirectoryIterator(\pocketmine\PATH . "src/pocketmine/lang/Installer/") as $file) { if ($file->getExtension() === "ini" and \substr($file->getFilename(), 0, 2) === $lang) { $files[$file->getFilename()] = $file->getSize(); } } if (\count($files) > 0) { \arsort($files); \reset($files); $l = \key($files); $l = \substr($l, 0, -4); $this->lang = isset(self::$languages[$l]) ? $l : $lang; $this->langfile = \pocketmine\PATH . "src/pocketmine/lang/Installer/" . $l . ".ini"; } else { $this->lang = "en"; $this->langfile = \pocketmine\PATH . "src/pocketmine/lang/Installer/en.ini"; } } $this->loadLang(\pocketmine\PATH . "src/pocketmine/lang/Installer/en.ini", "en"); if ($this->lang !== "en") { $this->loadLang($this->langfile, $this->lang); } }
/** * 编辑用户组 */ public function editAction() { list($gid, $category, $isManage) = $this->getInput(array('gid', 'category', 'manage'), 'get'); settype($isManage, 'boolean'); //权限分类 $topLevelCategories = $this->_getPermissionService()->getTopLevelCategories($isManage); $category or $category = key($topLevelCategories); $permissionConfigs = $topLevelCategoryClasses = array(); foreach ($topLevelCategories as $k => $v) { $topLevelCategoryClasses[$k] = $category == $k ? ' class="current"' : ''; //TODO $permissionConfigs[$k] = $this->_getPermissionService()->getPermissionConfigByCategory($gid, $k); } //group info $group = $this->_getGroupDs()->getGroupByGid($gid); $groupTypes = $isManage ? array('system', 'special') : array('member', 'default', 'system', 'special'); $groups = array(); foreach ($groupTypes as $v) { $groups += $this->_getGroupDs()->getGroupsByTypeInUpgradeOrder($v); } $this->setOutput($groups, 'groups'); $this->setOutput($gid, 'gid'); $this->setOutput($isManage, 'isManage'); $this->setOutput($category, 'category'); $this->setOutput($group, 'group'); $this->setOutput($topLevelCategoryClasses, 'topLevelCategoryClasses'); $this->setOutput($topLevelCategories, 'topLevelCategories'); $this->setOutput($permissionConfigs, 'permissionConfigs'); }
/** * Perform operations after collection load * * @param string $tableName * @param string $columnName * @return void */ protected function performAfterLoad($tableName, $columnName) { $items = $this->getColumnValues($columnName); if (count($items)) { $connection = $this->getConnection(); $select = $connection->select()->from(['cms_entity_store' => $this->getTable($tableName)])->where('cms_entity_store.' . $columnName . ' IN (?)', $items); $result = $connection->fetchPairs($select); if ($result) { foreach ($this as $item) { $entityId = $item->getData($columnName); if (!isset($result[$entityId])) { continue; } if ($result[$entityId] == 0) { $stores = $this->storeManager->getStores(false, true); $storeId = current($stores)->getId(); $storeCode = key($stores); } else { $storeId = $result[$item->getData($columnName)]; $storeCode = $this->storeManager->getStore($storeId)->getCode(); } $item->setData('_first_store_id', $storeId); $item->setData('store_code', $storeCode); $item->setData('store_id', [$result[$entityId]]); } } } }
/** (non-PHPdoc) * @see IfwPsn_Wp_Plugin_Admin_Menu_ListTable_Data_Interface::getItems() */ public function getItems($limit, $page, $order = null, $where = null) { $offset = ($page - 1) * $limit; if (empty($order)) { $order = array('name' => 'asc'); } $data = IfwPsn_Wp_ORM_Model::factory('Psn_Model_Rule')->limit($limit)->offset($offset); if (!empty($order)) { $orderBy = key($order); $orderDir = $order[$orderBy]; if ($orderDir == 'desc') { $data->order_by_desc($orderBy); } else { $data->order_by_asc($orderBy); } } if (!empty($where)) { $data->where_like('name', '%' . $where . '%'); } $result = $data->find_array(); if (Psn_Model_Rule::hasMax()) { $result = array_slice($result, 0, Psn_Model_Rule::getMax()); } return $result; }
static function create($params) { // FIXME Reconcile with CRM_Admin_Form_PaymentProcessor::updatePaymentProcessor $processor = new CRM_Financial_DAO_PaymentProcessor(); $processor->copyValues($params); $ppTypeDAO = new CRM_Financial_DAO_PaymentProcessorType(); $ppTypeDAO->id = $params['payment_processor_type_id']; if (!$ppTypeDAO->find(TRUE)) { CRM_Core_Error::fatal(ts('Could not find payment processor meta information')); } // also copy meta fields from the info DAO $processor->is_recur = $ppTypeDAO->is_recur; $processor->billing_mode = $ppTypeDAO->billing_mode; $processor->class_name = $ppTypeDAO->class_name; $processor->payment_type = $ppTypeDAO->payment_type; $processor->save(); // CRM-11826, add entry in civicrm_entity_financial_account // if financial_account_id is not NULL if (CRM_Utils_Array::value('financial_account_id', $params)) { $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); $values = array('entity_table' => 'civicrm_payment_processor', 'entity_id' => $processor->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $params['financial_account_id']); CRM_Financial_BAO_FinancialTypeAccount::add($values); } return $processor; }
public function run() { if (!version_compare($this->from_version, '7.0', '>') || !version_compare($this->from_version, '7.6', '<')) { // only need to run this upgrading for greater than 7.0 and less than 7.7 return; } $customModules = $this->getCustomModules(); if (empty($customModules)) { // No MB modules - nothing to do return; } foreach ($customModules as $module) { $path = 'modules/' . $module . '/clients/base/menus/header/header.php'; $this->foundPattern = false; $viewdefs = null; include $path; if (!empty($viewdefs)) { $module = key($viewdefs); $array = $viewdefs[$module]['base']['menu']['header']; $this->fixIcons($array); if ($this->foundPattern) { sugar_file_put_contents($path, "<?php\n\n/* This file was generated by the 7_FixIconNameChanges upgrader */\n\$viewdefs['{$module}']['base']['menu']['header'] = " . var_export($array, true) . ";\n"); } } $viewdefs = null; } }
public function setUserEntityTheme($file, $dataarr) { $getpersonalcount = DB::table('tbl_bankaccounts')->leftjoin('tbl_bankbranches', 'bankaccount_branch', '=', 'branch_id')->leftjoin('tbl_banks', 'branch_bankid', '=', 'bank_id')->where('bank_isproduct', '0')->where('bankaccount_userentity', 'Personal')->where('bankaccount_createdby', Auth::user()->id)->count(); $getbusinesscount = DB::table('tbl_bankaccounts')->leftjoin('tbl_bankbranches', 'bankaccount_branch', '=', 'branch_id')->leftjoin('tbl_banks', 'branch_bankid', '=', 'bank_id')->where('bank_isproduct', '0')->where('bankaccount_userentity', 'Business')->where('bankaccount_createdby', Auth::user()->id)->count(); $resultbViewAcctype = DB::table('tbl_bankaccounttypes')->get(); $resultbViewAcctypearr = array(); foreach ($resultbViewAcctype as $data) { $resultbViewAcctypearr[$data->accounttype_id] = $data->accounttype_name; } $resultbViewBanks = DB::table('tbl_banks')->where('bank_isproduct', 0)->where('bank_status', '1')->orderBy('bank_name', 'ASC')->get(); $resultbViewBanksarr = array(); foreach ($resultbViewBanks as $data) { $resultbViewBanksarr[$data->bank_id] = $data->bank_name; } $resultbViewBankbranchs = DB::table('tbl_bankbranches')->where("branch_bankid", key($resultbViewBanksarr))->where("branch_status", "1")->get(); $resultbViewBankBrancharr = array(); foreach ($resultbViewBankbranchs as $data) { $resultbViewBankBrancharr[$data->branch_id] = $data->branch_name; } if ($getpersonalcount <= 0 and $getbusinesscount <= 0) { $data = array('bankaccttype' => $resultbViewAcctypearr, 'bankname' => $resultbViewBanksarr, 'bankbranch' => $resultbViewBankBrancharr); $MyTheme = Theme::uses('fonebayad')->layout('ezibills_9_0'); return $MyTheme->of('registration.firstloginaddbankacct', $data)->render(); } else { // $MyTheme = Theme::uses('fonebayad')->layout('ezibills_9_0'); $MyTheme = Theme::uses('fonebayad')->layout('newDefault_myBills'); return $MyTheme->of($file, $dataarr)->render(); } }
/** * Sort input array by $subkey * Taken from: http://php.net/manual/en/function.ksort.php */ function w2l_sksort(&$array, $subkey = "id", $sort_ascending = false) { if (!is_array($array)) { return $array; } $temp_array = array(); if (count($array)) { $temp_array[key($array)] = array_shift($array); } foreach ($array as $key => $val) { $offset = 0; $found = false; foreach ($temp_array as $tmp_key => $tmp_val) { if (!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) { $temp_array = array_merge((array) array_slice($temp_array, 0, $offset), array($key => $val), array_slice($temp_array, $offset)); $found = true; } $offset++; } if (!$found) { $temp_array = array_merge($temp_array, array($key => $val)); } } if ($sort_ascending) { $array = array_reverse($temp_array); } else { $array = $temp_array; } }
public function executeIndex(sfWebRequest $request) { app::setPageTitle('Gantt Chart', $this->getResponse()); if ($request->hasParameter('projects_id')) { $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id'))); $this->checkProjectsAccess($this->projects); $this->checkTasksAccess('view', false, $this->projects); } else { $this->checkTasksAccess('view'); } if (!$this->getUser()->hasAttribute('gantt_filter' . $this->get_pid($request))) { $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), Tasks::getDefaultFilter($request, $this->getUser(), 'ganttChart')); } $this->filter_by = $this->getUser()->getAttribute('gantt_filter' . $this->get_pid($request)); if ($fb = $request->getParameter('filter_by')) { $this->filter_by[key($fb)] = current($fb); $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), $this->filter_by); $this->redirect('ganttChart/index' . $this->add_pid($request)); } if ($request->hasParameter('remove_filter')) { unset($this->filter_by[$request->getParameter('remove_filter')]); $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), $this->filter_by); $this->redirect('ganttChart/index' . $this->add_pid($request)); } $this->tasks_tree = array(); $this->tasks_list = $this->getTasks($request, $this->tasks_tree); }
/** * Implements FacetapiQueryTypeInterface::execute(). */ public function execute($query) { $active = $this->getActiveItems(); if (!empty($active)) { $facet_query = $this->adapter->getFacetQueryExtender(); $query_info = $this->adapter->getQueryInfo($this->facet); $tables_joined = array(); // Get the configured date ranges for the facet, or defaults if none have // been set up. $settings = $this->adapter->getFacetSettings($this->facet, facetapi_realm_load('block')); $ranges = isset($settings->settings['ranges']) ? $settings->settings['ranges'] : date_facets_default_ranges(); // Generate our start and end filters since a facet has been chosen. $range = $ranges[key($active)]; list($start, $end) = $this->generateRange($range); // Iterate over the facet's fields and adds SQL clauses. foreach ($query_info['fields'] as $field_info) { // Adds join to the facet query. $facet_query->addFacetJoin($query_info, $field_info['table_alias']); // Adds adds join to search query, makes sure it is only added once. if (isset($query_info['joins'][$field_info['table_alias']])) { if (!isset($tables_joined[$field_info['table_alias']])) { $tables_joined[$field_info['table_alias']] = TRUE; $join_info = $query_info['joins'][$field_info['table_alias']]; $query->join($join_info['table'], $join_info['alias'], $join_info['condition']); } } // Adds field conditions to the facet and search query. $field = $field_info['table_alias'] . '.' . $this->facet['field']; $query->condition($field, $start, '>='); $query->condition($field, $end, '<'); $facet_query->condition($field, $start, '>='); $facet_query->condition($field, $end, '<'); } } }
public static function event_save_meta($result, $EM_Event) { if ($result && EM_ML::is_original($EM_Event)) { //save post meta for all others as well foreach (EM_ML::get_langs() as $lang_code => $language) { $event = EM_ML::get_translation($EM_Event, $lang_code); /* @var $EM_Event EM_Event */ if ($event->event_id != $EM_Event->event_id) { self::event_merge_original_meta($event, $EM_Event); //if we execute a meta save here, we will screw up the current em_event_save_meta $wp_filter pointer executed in do_action() //therefore, we save the current pointer position (priority) and set it back after saving the location further down global $wp_filter, $wp_current_filter; $wp_filter_priority = key($wp_filter['em_event_save_meta']); $tag = end($wp_current_filter); //save the event meta $event->save_meta(); //reset save_post pointer in $wp_filter to its original position reset($wp_filter[$tag]); do { if (key($wp_filter[$tag]) == $wp_filter_priority) { break; } } while (next($wp_filter[$tag]) !== false); } } } return $result; }