function updateRelatedMeetingsGeocodeInfo(&$bean, $event, $arguments) { // after_save $jjwg_Maps = get_module_info('jjwg_Maps'); if ($jjwg_Maps->settings['logic_hooks_enabled']) { $jjwg_Maps->updateRelatedMeetingsGeocodeInfo($bean); } }
function action_marker_detail_map() { $this->view = 'marker_detail_map'; $jjwg_Markers = get_module_info('jjwg_Markers'); // Get the map object if (is_guid($_REQUEST['id'])) { $jjwg_Markers->retrieve($_REQUEST['id']); } $GLOBALS['loc'] = $jjwg_Markers->define_loc(); }
function action_area_detail_map() { $this->view = 'area_detail_map'; $jjwg_Areas = get_module_info('jjwg_Areas'); // Get the map object if (is_guid($_REQUEST['id'])) { $jjwg_Areas->retrieve($_REQUEST['id']); } $GLOBALS['polygon'] = $jjwg_Areas->define_polygon(); $GLOBALS['loc'] = $jjwg_Areas->define_area_loc(); }
function deleteRelationship(&$bean, $event, $arguments) { // after_relationship_delete // $arguments['module'], $arguments['related_module'], $arguments['id'] and $arguments['related_id'] if ($this->jjwg_Maps->settings['logic_hooks_enabled']) { $focus = get_module_info($arguments['module']); if (!empty($arguments['id'])) { $focus->retrieve($arguments['id']); $focus->custom_fields->retrieve(); $this->jjwg_Maps->updateGeocodeInfo($focus, true); if ($focus->jjwg_maps_address_c != $focus->fetched_row['jjwg_maps_address_c']) { $focus->save(false); } } } }
function deleteRelationship(&$bean, $event, $arguments) { // after_relationship_delete $GLOBALS['log']->info(__METHOD__ . ' $arguments: ' . print_r($arguments, true)); // $arguments['module'], $arguments['related_module'], $arguments['id'] and $arguments['related_id'] $jjwg_Maps = get_module_info('jjwg_Maps'); if ($jjwg_Maps->settings['logic_hooks_enabled']) { $focus = get_module_info($arguments['module']); if (!empty($arguments['id'])) { $focus->retrieve($arguments['id']); $focus->custom_fields->retrieve(); $jjwg_Maps->updateGeocodeInfo($focus, true); if ($focus->jjwg_maps_address_c != $focus->fetched_row['jjwg_maps_address_c']) { $focus->save(false); } } } }
function settings_run() { global $session; $op = httpget('op'); $category = stripslashes(rawurldecode(httpget('cat'))) ?: 'Account'; page_header("Settings - {$category}"); switch ($op) { case 'save': $accounts = db_prefix('accounts'); $post = httpallpost(); unset($post['showFormTabIndex']); foreach ($post as $key => $val) { $post[$key] = stripcslashes($val); } $post['oldvalues'] = json_decode($post['oldvalues'], true); foreach ($post['oldvalues'] as $key => $val) { $post['oldvalues'][$key] = stripslashes($val); } $post = modulehook('prefs-change', $post); if ($post['return'] != '') { $return = $post['return']; unset($post['return']); } //Fix template changes. if (md5(md5($post['oldpass'])) == $session['user']['password'] && $post['newpass'] != '') { require_once 'lib/systemmail.php'; $newPass = md5(md5($post['newpass'])); db_query("UPDATE {$accounts}\n SET password = '******'\n WHERE acctid = '{$session['user']['acctid']}'"); systemmail($session['user']['acctid'], 'Account Settings', "`@Your password was changed successfully!"); } unset($post['newpass']); unset($post['oldpass']); foreach ($post as $key => $val) { if ($key == 'bio' && $val != $post['oldvalues']['bio']) { $session['user']['bio'] = $val; } else { if (!is_array($val) && $val != $post['oldvalues'][$key]) { if (strpos($key, '__user') || strpos($key, '__check')) { $moduleKey = explode('__', $key); set_module_pref($moduleKey[1], $val, $moduleKey[0]); unset($moduleKey); } else { $session['user']['prefs'][$key] = $val; } } } } $prefs = @serialize($session['user']['prefs']); db_query("UPDATE {$accounts} SET prefs = '{$prefs}'\n WHERE acctid = '{$session['user']['acctid']}'"); redirect("runmodule.php?module=settings&cat={$return}&save=true"); addnav('Go back', 'runmodule.php?module=settings'); break; default: $modules = db_prefix('modules'); $userprefs = db_prefix('module_userprefs'); $rewrite = trim(get_module_setting('rewrite')); $rewrite = json_decode($rewrite, true); $languages = getsetting('serverlanguages', 'en, English'); $prefs = $session['user']['prefs']; $prefs['bio'] = $session['user']['bio']; $prefs['template'] = $_COOKIE['template'] ?: getsetting('defaultskin', 'jade.htm'); $prefs['email'] = $session['user']['emailaddress']; $prefsFormat = ['Account' => ['bio' => 'Short biography, textarea', 'newpass' => 'New password, password', 'oldpass' => 'If you are changing your password, type your old one, password', 'email' => 'Email, text'], 'Display' => ['template' => 'Skin, theme', 'language' => 'Which language do you prefer?, enum, ' . $languages, 'timestamp' => 'Show timestamps in commentary?, enum, 0, None, 1, Real Time, 2, Relative Time'], 'Game Behavior' => ['emailonmail' => 'Receive emails when you receive a mail?, bool', 'systemmail' => 'Receive emails for system messages?, bool', 'Be sure to check your email\'s spam folder and add our email as a trusted sender!, note', 'dirtyemail' => 'Allow profanity in mail?, bool', 'timeoffset' => sprintf_translate('Hours to offset time (currently %s)?, int', date($prefs['timeformat'], strtotime('now') + $prefs['timeoffset'] * 3600)), 'ihavenocheer' => 'Disable holiday text?, bool', 'nojump' => 'Disable jumping to the commentary when posting or refreshing?, bool']]; if (count(explode(',', $languages)) < 3) { unset($prefs['Display']['language']); } $prefsFormat = modulehook('prefs-format', $prefsFormat); $prefsTemp = []; $modulesFound = []; $sql = db_query("SELECT modulename, formalname FROM {$modules}\n WHERE infokeys LIKE '%|prefs|%'\n AND active = 1\n ORDER BY modulename"); while ($row = db_fetch_assoc($sql)) { $formal = $row['formalname']; $modulesFound[$row['modulename']] = true; if (module_status($row['modulename']) == MODULE_FILE_NOT_PRESENT) { foreach ($rewrite as $key => $moduleName) { if ($moduleName == $formal || strpos($key, $row['modulename']) !== false) { unset($rewrite[$key]); } } set_module_setting('rewrite', json_encode($rewrite)); } else { $prefsTemp[$formal] = get_module_info($row['modulename'])['prefs']; } unset($prefsTemp[$formal][0]); foreach ($prefsTemp[$formal] as $setting => $description) { $description = explode('|', $description)[0]; if (strpos($setting, 'user_') === false) { unset($prefsTemp[$formal][$setting]); } else { $structuredKey = "{$row['modulename']}__{$setting}"; if ($rewrite[$structuredKey] != $formal) { $prefsTemp[$rewrite[$structuredKey]][$structuredKey] = $description; } else { $prefsTemp[$formal][$structuredKey] = $description; } unset($prefsTemp[$formal][$setting]); } } if (count($prefsTemp[$formal]) == 0) { unset($prefsTemp[$formal]); unset($modulesFound[$row['modulename']]); } } foreach ($modulesFound as $name => $true) { $sql = db_query("SELECT modulename, setting, value FROM {$userprefs}\n WHERE modulename = '{$name}'\n AND (setting LIKE 'user_%' OR setting LIKE 'check_%')\n AND userid = '{$session['user']['acctid']}'\n "); while ($row = db_fetch_assoc($sql)) { $prefs["{$row['modulename']}__{$row['setting']}"] = $row['value']; } } $prefsFormat = array_merge_recursive($prefsFormat, $prefsTemp); $prefsFormat = modulehook('prefs-format', $prefsFormat); require_once 'lib/villagenav.php'; villagenav(); addnav('Refresh', 'runmodule.php?module=settings'); addnav('Categories'); foreach (array_keys($prefsFormat) as $int => $name) { addnav($name, "runmodule.php?module=settings&cat=" . rawurlencode($name)); } output("`c`b`i`Q{$category} Settings`b`i`c"); if (httpget('save')) { output("`@`iYour Settings have been saved!`i`n"); } rawoutput("<form action='runmodule.php?module=settings&op=save' method = 'POST'>"); require_once 'lib/showform.php'; showform($prefsFormat[$category], $prefs); rawoutput(sprintf("<input type='hidden' name='oldvalues' value='%s' />", json_encode($prefs))); rawoutput("<input type='hidden' name='return' value='{$category}' />"); rawoutput("</form>"); rawoutput("<script type='text/javascript'>\n document.getElementsByName('template')[0].onchange = function () {\n var index = this.selectedIndex;\n var selection = this.children[index].value;\n document.cookie = 'template=' + selection + ';expires=86400';\n }\n\n </script>"); addnav('', 'runmodule.php?module=settings&op=save'); break; } page_footer(); }
protected function saveVardefs($basepath, $installDefPrefix, $relationshipName, $vardefs) { mkdir_recursive("{$basepath}/vardefs/"); $GLOBALS['log']->debug(get_class($this) . "->saveVardefs(): vardefs =" . print_r($vardefs, true)); foreach ($vardefs as $moduleName => $definitions) { // find this module's Object name - the object name, not the module name, is used as the key in the vardefs... if (isset($GLOBALS['beanList'][$moduleName])) { $module = get_module_info($moduleName); $object = $module->object_name; } else { $object = $moduleName; } $filename = "{$basepath}/vardefs/{$moduleName}.php"; foreach ($definitions as $definition) { $GLOBALS['log']->debug(get_class($this) . "->saveVardefs(): saving the following to {$filename}" . print_r($definition, true)); write_array_to_file('dictionary["' . $object . '"]["fields"]["' . $definition['name'] . '"]', $definition, $filename, 'a'); } $installDefs[$moduleName] = array('from' => "{$installDefPrefix}/relationships/vardefs/{$moduleName}.php", 'to_module' => $moduleName); } $GLOBALS['log']->debug(get_class($this) . "->saveVardefs(): installDefs =" . print_r($installDefs, true)); return $installDefs; }
// Default tabbed config to true if (!isset($prefs['tabconfig'])) { $prefs['tabconfig'] = 1; } // Okay, allow modules to add prefs one at a time. // We are going to do it this way to *ensure* that modules don't conflict // in namespace. $sql = "SELECT modulename FROM " . db_prefix("modules") . " WHERE infokeys LIKE '%|prefs|%' AND active=1 ORDER BY modulename"; $result = db_query($sql); $everfound = 0; $foundmodules = array(); $msettings = array(); $mdata = array(); while ($row = db_fetch_assoc($result)) { $module = $row['modulename']; $info = get_module_info($module); if (count($info['prefs']) <= 0) { continue; } $tempsettings = array(); $tempdata = array(); $found = 0; while (list($key, $val) = each($info['prefs'])) { $isuser = preg_match("/^user_/", $key); $ischeck = preg_match("/^check_/", $key); if (is_array($val)) { $v = $val[0]; $x = explode("|", $v); $val[0] = $x[0]; $x[0] = $val; } else {
/** * action map_markers * Google Maps - Output the Map Markers */ function action_map_markers() { header_remove('X-Frame-Options'); $this->view = 'map_markers'; // Define globals for use in the view. $this->bean->map_center = array(); $this->bean->map_markers = array(); $this->bean->map_markers_groups = array(); $this->bean->custom_markers = array(); $this->bean->custom_areas = array(); // Create New Sugar_Smarty Object $this->sugarSmarty = new Sugar_Smarty(); $this->sugarSmarty->assign("mod_strings", $GLOBALS['mod_strings']); $this->sugarSmarty->assign("app_strings", $GLOBALS['app_strings']); $this->sugarSmarty->assign('app_list_strings', $GLOBALS['app_list_strings']); $this->sugarSmarty->assign('moduleListSingular', $GLOBALS['app_list_strings']['moduleListSingular']); $this->sugarSmarty->assign('moduleList', $GLOBALS['app_list_strings']['moduleList']); //echo '<pre>'; //var_dump($_REQUEST); // Related Map Record Defines the Map if (!empty($_REQUEST['record']) || !empty($_REQUEST['relate_id']) && !empty($_REQUEST['relate_module']) || !empty($_REQUEST['quick_address']) && !empty($_REQUEST['display_module'])) { // If map 'record' then define map details from current module. if (@is_guid($_REQUEST['record'])) { // Get the map object $map = get_module_info($GLOBALS['currentModule']); $map->retrieve($_REQUEST['record']); // Define map variables $map_parent_type = $map->parent_type; $map_parent_id = $map->parent_id; $map_module_type = $map->module_type; $map_unit_type = $map->unit_type; $map_distance = $map->distance; } else { if (@(is_guid($_REQUEST['relate_id']) && !empty($_REQUEST['relate_module']))) { // Define map variables $map_parent_type = $_REQUEST['relate_module']; $map_parent_id = $_REQUEST['relate_id']; $map_module_type = !empty($_REQUEST['display_module']) ? $_REQUEST['display_module'] : $_REQUEST['relate_module']; $map_distance = !empty($_REQUEST['distance']) ? $_REQUEST['distance'] : $this->settings['map_default_distance']; $map_unit_type = !empty($_REQUEST['unit_type']) ? $_REQUEST['unit_type'] : $this->settings['map_default_unit_type']; } else { if (!empty($_REQUEST['quick_address']) && !empty($_REQUEST['display_module'])) { // Define map variables / No Parent $map_parent_type = null; $map_parent_id = null; $map_module_type = !empty($_REQUEST['display_module']) ? $_REQUEST['display_module'] : $_REQUEST['relate_module']; $map_distance = !empty($_REQUEST['distance']) ? $_REQUEST['distance'] : $this->settings['map_default_distance']; $map_unit_type = !empty($_REQUEST['unit_type']) ? $_REQUEST['unit_type'] : $this->settings['map_default_unit_type']; } } } // Define display object, note - 'Accounts_Members' is a special display type $this->display_object = $map_module_type == 'Accounts_Members' ? get_module_info('Accounts') : get_module_info($map_module_type); $mod_strings_display = return_module_language($GLOBALS['current_language'], $this->display_object->module_name); $mod_strings_display = array_merge($mod_strings_display, $GLOBALS['mod_strings']); // If relate module/id object if (!empty($map_parent_type) && !empty($map_parent_id)) { // Define relate objects $this->relate_object = get_module_info($map_parent_type); $this->relate_object->retrieve($map_parent_id); $mod_strings_related = return_module_language($GLOBALS['current_language'], $this->relate_object->module_name); $mod_strings_related = array_merge($mod_strings_related, $GLOBALS['mod_strings']); // Get the Relate object Assoc Data $where_conds = $this->relate_object->table_name . ".id = '" . $map_parent_id . "'"; $query = $this->relate_object->create_new_list_query("" . $this->relate_object->table_name . ".assigned_user_id", $where_conds, array(), array(), 0, '', false, $this->relate_object, false); //var_dump($query); $relate_result = $this->bean->db->query($query); $relate = $this->bean->db->fetchByAssoc($relate_result); // Add Relate (Center Point) Marker $this->bean->map_center = $this->getMarkerData($map_parent_type, $relate, true, $mod_strings_related); // Define Center Point $center_lat = $this->relate_object->jjwg_maps_lat_c; $center_lng = $this->relate_object->jjwg_maps_lng_c; } else { // Geocode 'quick_address' $aInfo = $this->bean->getGoogleMapsGeocode($_REQUEST['quick_address'], false, true); // If not status 'OK', then fail here and exit. Note: Inside of iFrame if (!empty($aInfo['status']) && $aInfo['status'] != 'OK' && preg_match('/[A-Z\\_]/', $aInfo['status'])) { echo '<br /><br /><div><b>' . $GLOBALS['mod_strings']['LBL_MAP_LAST_STATUS'] . ': ' . $aInfo['status'] . '</b></div><br /><br />'; exit; } //var_dump($aInfo); // Define Marker Data $aInfo['name'] = $_REQUEST['quick_address']; $aInfo['id'] = 0; $aInfo['module'] = $map_module_type == 'Accounts_Members' ? 'Accounts' : $map_module_type; $aInfo['address'] = $_REQUEST['quick_address']; $aInfo['jjwg_maps_address_c'] = $_REQUEST['quick_address']; $aInfo['jjwg_maps_lat_c'] = $aInfo['lat']; $aInfo['jjwg_maps_lng_c'] = $aInfo['lng']; $this->bean->map_center = $this->getMarkerData($map_parent_type, $aInfo, true); // Define Center Point $center_lat = $aInfo['lat']; $center_lng = $aInfo['lng']; } //var_dump($aInfo); // Define $x and $y expressions $x = '(69.1*((' . $this->display_object->table_name . '_cstm.jjwg_maps_lat_c)-(' . $center_lat . ')))'; $y = '(53.0*((' . $this->display_object->table_name . '_cstm.jjwg_maps_lng_c)-(' . $center_lng . ')) * COS((' . $center_lat . ')/57.1))'; $calc_distance_expression = 'SQRT(' . $x . '*' . $x . '+' . $y . '*' . $y . ')'; if (strtolower($map_unit_type) == 'km' || strtolower($map_unit_type) == 'kilometer') { $calc_distance_expression .= '*1.609'; // 1 mile = 1.609 km } // Find the Items to Display // Assume there is no address at 0,0; it's in the Atlantic Ocean! $where_conds = "(" . $this->display_object->table_name . "_cstm.jjwg_maps_lat_c != 0 OR " . "" . $this->display_object->table_name . "_cstm.jjwg_maps_lng_c != 0) " . " AND " . "(" . $this->display_object->table_name . "_cstm.jjwg_maps_geocode_status_c = 'OK')" . " AND " . "(" . $calc_distance_expression . " < " . $map_distance . ")"; $query = $this->display_object->create_new_list_query('display_object_distance', $where_conds, array(), array(), 0, '', false, $this->display_object, false); // Add the disply_object_distance into SELECT list $query = str_replace('SELECT ', 'SELECT (' . $calc_distance_expression . ') AS display_object_distance, ', $query); if ($map_module_type == 'Contacts') { // Contacts - Account Name $query = str_replace(' FROM contacts ', ' ,accounts.name AS account_name, accounts.id AS account_id FROM contacts ', $query); $query = str_replace(' FROM contacts ', ' FROM contacts LEFT JOIN accounts_contacts ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0 LEFT JOIN accounts ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 ', $query); } elseif ($map_module_type == 'Opportunities') { // Opps - Account Name $query = str_replace(' FROM opportunities ', ' ,accounts.name AS account_name, accounts.id AS account_id FROM opportunities ', $query); $query = str_replace(' FROM opportunities ', ' FROM opportunities LEFT JOIN accounts_opportunities ON opportunities.id=accounts_opportunities.opportunity_id and accounts_opportunities.deleted = 0 LEFT JOIN accounts ON accounts_opportunities.account_id=accounts.id AND accounts.deleted=0 ', $query); } elseif ($map_module_type == 'Accounts_Members') { // 'Accounts_Members' is a special display type $query = str_replace(' AND accounts.deleted=0', ' AND accounts.deleted=0 AND accounts.parent_id = \'' . $this->bean->db->quote($map_parent_id) . '\'', $query); } //var_dump($query); $display_result = $this->bean->db->limitQuery($query, 0, $this->settings['map_markers_limit']); while ($display = $this->bean->db->fetchByAssoc($display_result)) { if (!empty($map_distance) && !empty($display['id'])) { $marker_data_module_type = $map_module_type == 'Accounts_Members' ? 'Accounts' : $map_module_type; $marker_data = $this->getMarkerData($marker_data_module_type, $display, false, $mod_strings_display); if (!empty($marker_data)) { $this->bean->map_markers[] = $marker_data; } } } //var_dump($this->bean->map_markers); // Next define the Custom Markers and Areas related to this Map // Define relate and display objects from the necessary classes (utils.php) @($markers_object = get_module_info('jjwg_Markers')); @($areas_object = get_module_info('jjwg_Areas')); // Relationship Names: jjwg_maps_jjwg_areas and jjwg_maps_jjwg_markers // Find the Related Beans: Maps to Markers if (@(is_object($markers_object) && is_object($map))) { $related_custom_markers = $map->get_linked_beans('jjwg_maps_jjwg_markers', 'jjwg_Markers'); if ($related_custom_markers) { foreach ($related_custom_markers as $marker_bean) { $marker_data = $this->getMarkerDataCustom($marker_bean); if (!empty($marker_data)) { $this->bean->custom_markers[] = $marker_data; } } } } // Find the Related Beans: Maps to Areas if (@(is_object($areas_object) && is_object($map))) { $related_custom_areas = $map->get_linked_beans('jjwg_maps_jjwg_areas', 'jjwg_Areas'); if ($related_custom_areas) { foreach ($related_custom_areas as $area_bean) { $area_data = $this->getAreaDataCustom($area_bean); if (!empty($area_data)) { $this->bean->custom_areas[] = $area_data; } } } } // Map Target List (ProspectLists) } elseif (!empty($_REQUEST['list_id'])) { $this->bean->map_markers = array(); $this->display_object = get_module_info('ProspectLists'); // Use the Export Query if (!empty($_REQUEST['list_id'])) { $this->display_object->retrieve($_REQUEST['list_id']); if ($this->display_object->id == $_REQUEST['list_id']) { $prospect_list_object = $this->display_object; $list_id = $this->display_object->id; } } if (!empty($list_id)) { $list_modules = array('Accounts', 'Contacts', 'Leads', 'Users', 'Prospects'); $temp_marker_groups = array(); foreach ($list_modules as $display_module) { $this->display_object = get_module_info($display_module); $mod_strings_display = return_module_language($GLOBALS['current_language'], $this->display_object->module_name); $mod_strings_display = array_merge($mod_strings_display, $GLOBALS['mod_strings']); // Find the Items to Display // Assume there is no address at 0,0; it's in the Atlantic Ocean! $where_conds = "(" . $this->display_object->table_name . "_cstm.jjwg_maps_lat_c != 0 OR " . "" . $this->display_object->table_name . "_cstm.jjwg_maps_lng_c != 0) " . " AND " . "(" . $this->display_object->table_name . "_cstm.jjwg_maps_geocode_status_c = 'OK')"; $query = $this->display_object->create_new_list_query('', $where_conds, array(), array(), 0, '', false, $this->display_object, false); if ($display_module == 'Contacts') { // Contacts - Account Name $query = str_replace(' FROM contacts ', ' ,accounts.name AS account_name, accounts.id AS account_id FROM contacts ', $query); $query = str_replace(' FROM contacts ', ' FROM contacts LEFT JOIN accounts_contacts ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0 LEFT JOIN accounts ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 ', $query); } // Add List JOIN $query = str_replace(' FROM ' . $this->display_object->table_name . ' ', ' FROM ' . $this->display_object->table_name . ' ' . 'LEFT JOIN prospect_lists_prospects ON prospect_lists_prospects.related_id = ' . $this->display_object->table_name . '.id AND prospect_lists_prospects.deleted=0 ' . 'LEFT JOIN prospect_lists ON prospect_lists_prospects.prospect_list_id = prospect_lists.id AND prospect_lists.deleted=0 ', $query); // Restrict WHERE to related type and $list_id $query .= ' AND prospect_lists_prospects.related_type = \'' . $this->display_object->module_name . '\' AND ' . 'prospect_lists.id = \'' . $this->bean->db->quote($list_id) . '\''; //var_dump($query); $display_result = $this->bean->db->limitQuery($query, 0, $this->settings['map_markers_limit']); $display_type_found = false; while ($display = $this->bean->db->fetchByAssoc($display_result)) { if (!empty($display['id'])) { $marker_data = $this->getMarkerData($display_module, $display, false, $mod_strings_display); $marker_data['group'] = $GLOBALS['app_list_strings']['moduleList'][$display_module]; if (!empty($marker_data)) { $this->bean->map_markers[] = $marker_data; } $display_type_found = true; } } if ($display_type_found) { $temp_marker_groups[] = $GLOBALS['app_list_strings']['moduleList'][$display_module]; } } $this->bean->map_markers_groups = $temp_marker_groups; } // Map Records } elseif (!empty($_REQUEST['uid']) || !empty($_REQUEST['current_post'])) { if (in_array($_REQUEST['display_module'], $this->settings['valid_geocode_modules'])) { $display_module = $_REQUEST['display_module']; } else { $display_module = 'Accounts'; } if ($_REQUEST['current_post'] == 'session') { $current_post = $_SESSION['jjwg_Maps']['current_post']; } else { $current_post = $_REQUEST['current_post']; } $query = ''; $selected_query = ''; $records = array(); $order_by = ''; $this->display_object = get_module_info($display_module); $mod_strings_display = return_module_language($GLOBALS['current_language'], $this->display_object->module_name); $mod_strings_display = array_merge($mod_strings_display, $GLOBALS['mod_strings']); if (!empty($_REQUEST['uid'])) { // Several records selected or this page $records = explode(',', $_REQUEST['uid']); } elseif (!empty($current_post)) { // Select all records (advanced search) $search_array = generateSearchWhere($display_module, $current_post); //var_dump($search_array); if (!empty($search_array['where'])) { // Related Field Bug: Get relate/link patched 'where' and 'join' @($ret_array = create_export_query_relate_link_patch($display_module, $search_array['searchFields'], $search_array['where'])); if (!empty($ret_array['join'])) { @($selected_query = $this->display_object->create_export_query($order_by, $ret_array['where'], $ret_array['join'])); } else { @($selected_query = $this->display_object->create_export_query($order_by, $ret_array['where'])); } // SugarOnDemand JOIN Bug: If $ret_array['join'] is not included in query, force it in! if (strpos($ret_array['join'], $selected_query) === false) { $selected_query = str_replace(' where ', $ret_array['join'] . ' where ', $selected_query); } // Avoiding subquery. Let's just record the record ID's for later $selected_result = $this->bean->db->limitQuery($selected_query, 0, $this->settings['map_markers_limit']); while ($display = $this->bean->db->fetchByAssoc($selected_result)) { $records[] = $display['id']; } } } //var_dump($records); // Find the Items to Display // Assume there is no address at 0,0; it's in the Atlantic Ocean! $where_conds = "(" . $this->display_object->table_name . "_cstm.jjwg_maps_lat_c != 0 OR " . "" . $this->display_object->table_name . "_cstm.jjwg_maps_lng_c != 0) " . " AND " . "(" . $this->display_object->table_name . "_cstm.jjwg_maps_geocode_status_c = 'OK')"; $query = $this->display_object->create_new_list_query('', $where_conds, array(), array(), 0, '', false, $this->display_object, false); if ($display_module == 'Contacts') { // Contacts - Account Name $query = str_replace(' FROM contacts ', ' ,accounts.name AS account_name, accounts.id AS account_id FROM contacts ', $query); $query = str_replace(' FROM contacts ', ' FROM contacts LEFT JOIN accounts_contacts ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0 LEFT JOIN accounts ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 ', $query); } elseif ($display_module == 'Opportunities') { // Opps - Account Name $query = str_replace(' FROM opportunities ', ' ,accounts.name AS account_name, accounts.id AS account_id FROM opportunities ', $query); $query = str_replace(' FROM opportunities ', ' FROM opportunities LEFT JOIN accounts_opportunities ON opportunities.id=accounts_opportunities.opportunity_id and accounts_opportunities.deleted = 0 LEFT JOIN accounts ON accounts_opportunities.account_id=accounts.id AND accounts.deleted=0 ', $query); } //var_dump($query); $display_result = $this->bean->db->limitQuery($query, 0, $this->settings['map_markers_limit']); $this->bean->map_markers = array(); while ($display = $this->bean->db->fetchByAssoc($display_result)) { if (!empty($search_array['where'])) { // Select all records (advanced search) with where clause if (in_array($display['id'], $records)) { $this->bean->map_markers[] = $this->getMarkerData($display_module, $display, false, $mod_strings_display); } } elseif (!empty($_REQUEST['uid'])) { // Several records selected or this page selected if (in_array($display['id'], $records)) { $this->bean->map_markers[] = $this->getMarkerData($display_module, $display, false, $mod_strings_display); } } else { // All $this->bean->map_markers[] = $this->getMarkerData($display_module, $display, false, $mod_strings_display); } } } // Sort marker groups for the view sort($this->bean->map_markers_groups); // Set display object for later use $this->bean->display_object = $this->display_object; // Get Prospect List Array Dropdown $list = get_module_info('ProspectLists'); $list_query = $list->create_list_query('prospect_lists.name', '1=1', 0); $list_result = $list->db->query($list_query); $list_array = array(); while ($alist = $list->db->fetchByAssoc($list_result)) { if (!empty($alist['name']) && !empty($alist['id'])) { $list_array[$alist['id']] = $alist['name']; } } $this->bean->list_array = $list_array; }
function install_module($module, $force = true) { global $mostrecentmodule, $session; $name = $session['user']['name']; if (!$name) { $name = '`@System`0'; } require_once "lib/sanitize.php"; if (modulename_sanitize($module) != $module) { output("Error, module file names can only contain alpha numeric characters and underscores before the trailing .php`n`nGood module names include 'testmodule.php', 'joesmodule2.php', while bad module names include, 'test.module.php' or 'joes module.php'`n"); return false; } else { // If we are forcing an install, then whack the old version. if ($force) { $sql = "DELETE FROM " . db_prefix("modules") . " WHERE modulename='{$module}'"; db_query($sql); } // We want to do the inject so that it auto-upgrades any installed // version correctly. if (injectmodule($module, true)) { // If we're not forcing and this is already installed, we are done if (!$force && is_module_installed($module)) { return true; } $info = get_module_info($module); //check installation requirements if (!module_check_requirements($info['requires'])) { output("`\$Module could not installed -- it did not meet its prerequisites.`n"); return false; } else { $keys = "|" . join(array_keys($info), "|") . "|"; $sql = "INSERT INTO " . db_prefix("modules") . " (modulename,formalname,moduleauthor,active,filename,installdate,installedby,category,infokeys,version,download,description) VALUES ('{$mostrecentmodule}','" . addslashes($info['name']) . "','" . addslashes($info['author']) . "',0,'{$mostrecentmodule}.php','" . date("Y-m-d H:i:s") . "','" . addslashes($name) . "','" . addslashes($info['category']) . "','{$keys}','" . addslashes($info['version']) . "','" . addslashes($info['download']) . "', '" . addslashes($info['description']) . "')"; db_query($sql); $fname = $mostrecentmodule . "_install"; if (isset($info['settings']) && count($info['settings']) > 0) { foreach ($info['settings'] as $key => $val) { if (is_array($val)) { $x = explode("|", $val[0]); } else { $x = explode("|", $val); } if (isset($x[1])) { $x[1] = trim($x[1]); set_module_setting($key, $x[1]); debug("Setting {$key} to default {$x[1]}"); } } } if ($fname() === false) { return false; } output("`^Module installed. It is not yet active.`n"); invalidatedatacache("inject-{$mostrecentmodule}"); massinvalidate("moduleprepare"); return true; } } else { output("`\$Module could not be injected."); output("Module not installed."); output("This is probably due to the module file having a parse error or not existing in the filesystem.`n"); return false; } } }
function __construct($subpanelName, $moduleName) { $GLOBALS['log']->debug(get_class($this) . "->__construct({$subpanelName} , {$moduleName})"); $this->_subpanelName = $subpanelName; $this->_moduleName = $moduleName; $module = BeanFactory::getBean($moduleName); // BEGIN ASSERTIONS if (empty($module)) { sugar_die(get_class($this) . ": Modulename {$moduleName} is not a Deployed Module"); } // END ASSERTIONS $this->historyPathname = 'custom/history/modules/' . $moduleName . '/subpanels/' . $subpanelName . '/' . self::HISTORYFILENAME; $this->_history = new History($this->historyPathname); require_once 'include/SubPanel/SubPanelDefinitions.php'; // retrieve the definitions for all the available subpanels for this module from the subpanel $spd = new SubPanelDefinitions($module); // Get the lists of fields already in the subpanel and those that can be added in // Get the fields lists from an aSubPanel object describing this subpanel from the SubPanelDefinitions object $this->_viewdefs = array(); $this->_fielddefs = array(); $this->_language = ''; if (!empty($spd->layout_defs)) { if (array_key_exists(strtolower($subpanelName), $spd->layout_defs['subpanel_setup'])) { //First load the original defs from the module folder $originalSubpanel = $spd->load_subpanel($subpanelName, false, true); $this->_fullFielddefs = $originalSubpanel ? $originalSubpanel->get_list_fields() : array(); $this->_mergeFielddefs($this->_fielddefs, $this->_fullFielddefs); $this->_aSubPanelObject = $spd->load_subpanel($subpanelName); // now check if there is a restored subpanel in the history area - if there is, then go ahead and use it if (file_exists($this->historyPathname)) { // load in the subpanelDefOverride from the history file $GLOBALS['log']->debug(get_class($this) . ": loading from history"); require $this->historyPathname; $this->_viewdefs = $layout_defs; } else { $this->_viewdefs = $this->_aSubPanelObject->get_list_fields(); } // don't attempt to access the template_instance property if our subpanel represents a collection, as it won't be there - the sub-sub-panels get this value instead if (!$this->_aSubPanelObject->isCollection()) { $this->_language = $this->_aSubPanelObject->template_instance->module_dir; } // Retrieve a copy of the bean for the parent module of this subpanel - so we can find additional fields for the layout $subPanelParentModuleName = $this->_aSubPanelObject->get_module_name(); $beanListLower = array_change_key_case($GLOBALS['beanList']); if (!empty($subPanelParentModuleName) && isset($beanListLower[strtolower($subPanelParentModuleName)])) { $subPanelParentModule = get_module_info($subPanelParentModuleName); // Run through the preliminary list, keeping only those fields that are valid to include in a layout foreach ($subPanelParentModule->field_defs as $key => $def) { $key = strtolower($key); if (AbstractMetaDataParser::validField($def)) { if (!isset($def['label'])) { $def['label'] = $def['name']; } $this->_fielddefs[$key] = $def; } } } $this->_mergeFielddefs($this->_fielddefs, $this->_viewdefs); } } }
} } $install_status = get_module_install_status(); $uninstalled = $install_status['uninstalledmodules']; reset($uninstalled); $invalidmodule = array("version" => "", "author" => "", "category" => "Invalid Modules", "download" => "", "description" => "", "invalid" => true); while (list($key, $modulename) = each($uninstalled)) { $row = array(); //test if the file is a valid module or a lib file/whatever that got in, maybe even malcode that does not have module form $modulenamelower = strtolower($modulename); $file = strtolower(file_get_contents("modules/{$modulename}.php")); if (strpos($file, $modulenamelower . "_getmoduleinfo") === false || strpos($file, $modulenamelower . "_install") === false || strpos($file, $modulenamelower . "_uninstall") === false) { //here the files has neither do_hook nor getinfo, which means it won't execute as a module here --> block it + notify the admin who is the manage modules section $moduleinfo = array_merge($invalidmodule, array("name" => $modulename . ".php " . appoencode(translate_inline("(`\$Invalid Module! Contact Author or check file!`0)")))); } else { $moduleinfo = get_module_info($modulename); } //end of testing $row['installed'] = false; $row['active'] = false; $row['category'] = $moduleinfo['category']; $row['modulename'] = $modulename; $row['formalname'] = $moduleinfo['name']; $row['description'] = $moduleinfo['description']; $row['moduleauthor'] = $moduleinfo['author']; $row['invalid'] = isset($moduleinfo['invalid']) ? $moduleinfo['invalid'] : false; if (!array_key_exists($row['category'], $all_modules)) { $all_modules[$row['category']] = array(); } $all_modules[$row['category']][$row['modulename']] = $row; }
<?php // translator ready // addnews ready // mail ready define("ALLOW_ANONYMOUS", true); define("OVERRIDE_FORCED_NAV", true); require_once "lib/http.php"; require_once "common.php"; require_once "lib/dump_item.php"; require_once "lib/modules.php"; require_once "lib/villagenav.php"; if (injectmodule(httpget('module'), httpget('admin') ? true : false)) { $info = get_module_info(httpget('module')); if (!isset($info['allowanonymous'])) { $allowanonymous = false; } else { $allowanonymous = $info['allowanonymous']; } if (!isset($info['override_forced_nav'])) { $override_forced_nav = false; } else { $override_forced_nav = $info['override_forced_nav']; } do_forced_nav($allowanonymous, $override_forced_nav); $starttime = getmicrotime(); $fname = $mostrecentmodule . "_run"; tlschema("module-{$mostrecentmodule}"); $fname(); $endtime = getmicrotime(); if ($endtime - $starttime >= 1.0 && $session['user']['superuser'] & SU_DEBUG_OUTPUT) {
function search_filter_rel_info(&$focus, $tar_rel_module, $relationship_name) { $rel_list = array(); foreach ($focus->relationship_fields as $rel_key => $rel_value) { if ($rel_value == $relationship_name) { $temp_bean = get_module_info($tar_rel_module); echo $focus->{$rel_key}; $temp_bean->retrieve($focus->{$rel_key}); if ($temp_bean->id != "") { $rel_list[] = $temp_bean; return $rel_list; } } } return $rel_list; //end function search_filter_rel_info }
/** * Set module visibility in all courses * @param int $moduleId id of the module * @param bool $visibility true for visible, false for invisible * @return array( backlog, boolean ) * backlog object * boolean true if suceeded, false otherwise * @todo remove the need of the Backlog and use Exceptions instead */ function set_module_visibility($moduleId, $visibility) { $backlog = new Backlog(); $success = true; $tbl = claro_sql_get_main_tbl(); $moduleInfo = get_module_info($moduleId); $tool_id = get_course_tool_id($moduleInfo['label']); $sql = "SELECT `code` FROM `" . $tbl['course'] . "`"; $course_list = claro_sql_query_fetch_all($sql); $default_visibility = false; foreach ($course_list as $course) { if (false === set_module_visibility_in_course($tool_id, $course['code'], $visibility)) { $success = false; $backlog->failure(get_lang('Cannot change module visibility in %course', array('%course' => $course['code']))); break; } } return array($backlog, $success); }
/** * Define Maps Address * * Address Relationship Notes: * Account(address) * Contact(address) * Lead(address) * Taget/Prospect(address) * Opportunity to Account(address) * Case 'account_id' to Account(address) * or Case to Account(address) * Project to Account(address) * or Project to Opportunity to Account(address) * Meeting - based on Flex Relate * * @param $object_name signular object name * @param $display fetched row */ function defineMapsAddress($object_name, $display) { $address = false; $fields = false; $parent = null; $parent_type = ''; $parent_id = ''; $GLOBALS['log']->debug(__METHOD__ . ' START'); $GLOBALS['log']->debug(__METHOD__ . ' $object_name: ' . $object_name); $GLOBALS['log']->debug(__METHOD__ . ' $display: ' . print_r($display, true)); // Field naming is different in some modules. // Some modules do not have an address, so a related account needs to be found first. if ($object_name == 'Account') { $address = $this->defineMapsFormattedAddress($display, $this->settings['geocode_modules_to_address_type']['Accounts']); } elseif ($object_name == 'Contact') { $address = $this->defineMapsFormattedAddress($display, $this->settings['geocode_modules_to_address_type']['Contacts']); } elseif ($object_name == 'Lead') { $address = $this->defineMapsFormattedAddress($display, $this->settings['geocode_modules_to_address_type']['Leads']); } elseif ($object_name == 'Prospect') { $address = $this->defineMapsFormattedAddress($display, $this->settings['geocode_modules_to_address_type']['Prospects']); } elseif ($object_name == 'User') { $address = $this->defineMapsFormattedAddress($display, $this->settings['geocode_modules_to_address_type']['Users']); } elseif ($object_name == 'Opportunity') { // Find Account - Assume only one related Account $query = "SELECT accounts.*, accounts_cstm.* FROM accounts LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c " . " LEFT JOIN accounts_opportunities ON accounts.id = accounts_opportunities.account_id AND accounts_opportunities.deleted = 0 " . " WHERE accounts.deleted = 0 AND accounts_opportunities.opportunity_id = '" . $display['id'] . "'"; $GLOBALS['log']->debug(__METHOD__ . ' Opportunity to Account'); $result = $this->db->limitQuery($query, 0, 1); $fields = $this->db->fetchByAssoc($result); if (!empty($fields)) { $address = $this->defineMapsFormattedAddress($fields, $this->settings['geocode_modules_to_address_type']['Opportunities']); } } elseif (in_array($object_name, array('aCase', 'Case'))) { // Find Account from Case (account_id field) $query = "SELECT accounts.*, accounts_cstm.* FROM accounts LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c " . " WHERE accounts.deleted = 0 AND id = '" . $display['account_id'] . "'"; $GLOBALS['log']->debug(__METHOD__ . ' Case to Account'); $result = $this->db->limitQuery($query, 0, 1); $fields = $this->db->fetchByAssoc($result); // If Account is not found; Find many to many Account - Assume only one related Account if (empty($fields)) { $query = "SELECT accounts.*, accounts_cstm.* FROM accounts LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c " . " LEFT JOIN accounts_cases ON accounts.id = accounts_cases.account_id AND accounts_cases.deleted = 0 " . " WHERE accounts.deleted = 0 AND accounts_cases.case_id = '" . $display['id'] . "'"; $GLOBALS['log']->debug(__METHOD__ . ' Case to Accounts'); $result = $this->db->limitQuery($query, 0, 1); $fields = $this->db->fetchByAssoc($result); } if (!empty($fields)) { $address = $this->defineMapsFormattedAddress($fields, $this->settings['geocode_modules_to_address_type']['Cases']); } } elseif ($object_name == 'Project') { // Check relationship from Project to Account - Assume only one related Account $query = "SELECT accounts.*, accounts_cstm.* FROM accounts LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c " . " LEFT JOIN projects_accounts ON accounts.id = projects_accounts.account_id AND projects_accounts.deleted = 0 " . " WHERE accounts.deleted = 0 AND projects_accounts.project_id = '" . $display['id'] . "'"; $GLOBALS['log']->debug(__METHOD__ . ' Project to Account'); $result = $this->db->limitQuery($query, 0, 1); $fields = $this->db->fetchByAssoc($result); if (empty($fields)) { // Find Opportunity - Assuming that the Project was created from an Opportunity (Closed Won) Detial View $query = "SELECT opportunities.*, opportunities_cstm.* FROM opportunities LEFT JOIN opportunities_cstm ON opportunities.id = opportunities_cstm.id_c " . " LEFT JOIN projects_opportunities ON opportunities.id = projects_opportunities.opportunity_id AND projects_opportunities.deleted = 0 " . " WHERE opportunities.deleted = 0 AND projects_opportunities.project_id = '" . $display['id'] . "'"; $GLOBALS['log']->debug(__METHOD__ . ' Project to Opportunity'); $result = $this->db->limitQuery($query, 0, 1); $opportunity = $this->db->fetchByAssoc($result); // Find Account - Assume only one related Account for the Opportunity $query = "SELECT accounts.*, accounts_cstm.* FROM accounts LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c " . " LEFT JOIN accounts_opportunities ON accounts.id = accounts_opportunities.account_id AND accounts_opportunities.deleted = 0 " . " WHERE accounts.deleted = 0 AND accounts_opportunities.opportunity_id = '" . $opportunity['id'] . "'"; $GLOBALS['log']->debug(__METHOD__ . ' Opportunity to Account'); $result = $this->db->limitQuery($query, 0, 1); $fields = $this->db->fetchByAssoc($result); } if (!empty($fields)) { $address = $this->defineMapsFormattedAddress($fields, $this->settings['geocode_modules_to_address_type']['Project']); } } elseif ($object_name == 'Meeting') { // Find Meeting - Flex Relate Fields: meetings.parent_type and meetings.parent_id $query = "SELECT meetings.*, meetings_cstm.* FROM meetings LEFT JOIN meetings_cstm ON meetings.id = meetings_cstm.id_c " . " WHERE meetings.deleted = 0 AND meetings.id = '" . $display['id'] . "'"; $GLOBALS['log']->debug(__METHOD__ . ' Meeting'); $result = $this->db->limitQuery($query, 0, 1); $meeting = $this->db->fetchByAssoc($result); $parent_type = $meeting['parent_type']; $parent_id = $meeting['parent_id']; $GLOBALS['log']->debug(__METHOD__ . ' Meeting $parent_type: ' . $parent_type); $GLOBALS['log']->debug(__METHOD__ . ' Meeting $parent_id: ' . $parent_id); // If the parent_type is valid module to geocode if (in_array($parent_type, array_keys($this->settings['valid_geocode_modules'])) && !empty($parent_id) && $parent_type != 'Meeting') { // Define parent object $parent = get_module_info($parent_type); $parent->retrieve($parent_id); $parent->custom_fields->retrieve(); $fields = $parent->fetched_row; $GLOBALS['log']->debug(__METHOD__ . ' Meeting $parent->object_name: ' . $parent->object_name); $GLOBALS['log']->debug(__METHOD__ . ' Meeting $parent->fetched_row: ' . print_r($parent->fetched_row, true)); // Call this defineMapsAddress for parent which will look at other relationships $aInfo = $this->defineMapsAddress($parent->object_name, $parent->fetched_row); // return $aInfo $GLOBALS['log']->debug(__METHOD__ . ' Meeting $address Found $aInfo: ' . print_r($aInfo, true)); return $aInfo; } } // If related account address has already been geocoded if (!empty($address) && $fields['jjwg_maps_geocode_status_c'] == 'OK' && !empty($fields['jjwg_maps_lat_c']) && !empty($fields['jjwg_maps_lng_c'])) { $aInfo = array('address' => $address, 'status' => 'OK', 'lat' => $fields['jjwg_maps_lat_c'], 'lng' => $fields['jjwg_maps_lng_c']); $GLOBALS['log']->debug(__METHOD__ . ' OK Array Found $aInfo: ' . print_r($aInfo, true)); return $aInfo; // elseif return address only - if defined } elseif (!empty($address)) { $aInfo = array('address' => $address); $GLOBALS['log']->debug(__METHOD__ . ' $address Found $aInfo: ' . print_r($aInfo, true)); return $aInfo; } else { return false; } }
$summary = get_lang('Module installation failed'); $dialogBox->error(Backlog_Reporter::report($summary, $details)); } } else { $summary = get_lang('Module installation failed'); $details = get_lang('Module directory not found'); $dialogBox->error(Backlog_Reporter::report($summary, $details)); } } else { $summary = get_lang('Module installation failed'); $details = get_lang('Missing module directory'); $dialogBox->error(Backlog_Reporter::report($summary, $details)); } } if (empty($typeReq) && $module_id) { $moduleInfo = get_module_info($module_id); $typeReq = $moduleInfo['type']; } //---------------------------------- // FIND INFORMATION //---------------------------------- // $moduleTypeList = claro_get_module_types(); // $moduleTypeList = array_merge($moduleTypeList, array_keys($typeLabel)); switch ($typeReq) { case 'applet': $sqlSelectType = " D.`id` AS dock_id, " . "\n" . " D.`name` AS dockname," . "\n"; $sqlJoinType = " LEFT JOIN `" . $tbl_dock . "` AS D " . "\n" . " ON D.`module_id`= M.id " . "\n"; $orderType = ""; break; case 'tool': $sqlSelectType = " CT.`id` AS courseToolId, " . "\n" . " CT.`icon` AS icon," . "\n" . " CT.`script_url` AS script_url," . "\n" . " CT.`def_rank` AS rank," . "\n" . " CT.`def_access` AS visibility," . "\n";
function LeadsJjwg_MapsLogicHook() { $this->jjwg_Maps = get_module_info('jjwg_Maps'); }
function __construct() { $this->jjwg_Maps = get_module_info('jjwg_Maps'); }
protected function getTablename($moduleName) { // Check the moduleName exists in the beanList before calling get_module_info - Activities is the main culprit here if (isset($GLOBALS['beanList'][$moduleName])) { $module = get_module_info($moduleName); return $module->table_name; } return strtolower($moduleName); }
function ProspectsJjwg_MapsLogicHook() { $this->jjwg_Maps = get_module_info('jjwg_Maps'); }
function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name = "") { global $beanList; global $dictionary; $temp_module = get_module_info($base_module); $rel_attribute1_name = $temp_module->field_defs[strtolower($rel_module1_name)]['relationship']; $rel_module1 = $this->get_other_module($rel_attribute1_name, $base_module, $temp_module->db); $rel_module1_bean = get_module_info($rel_module1); if ($rel_module2_name != "") { if ($rel_module2_name == 'ProjectTask') { $rel_module2_name = strtolower($rel_module2_name); } $rel_attribute2_name = $rel_module1_bean->field_defs[strtolower($rel_module2_name)]['relationship']; $rel_module2 = $this->get_other_module($rel_attribute2_name, $rel_module1_bean->module_dir, $rel_module1_bean->db); $rel_module2_bean = get_module_info($rel_module2); return $rel_module2_bean; } else { //no rel_module2, so return rel_module2 bean return $rel_module1_bean; } //end function trace_relationship_module }
addnav("", "modules.php?sorting=shortname&order=" . ($sorting == "shortname" ? !$order : 0)); if (count($uninstmodules) > 0) { $count = 0; $moduleinfo = array(); $sortby = array(); $numberarray = array(); $invalidmodule = array("version" => "", "author" => "", "category" => "", "download" => "", "invalid" => true); foreach ($uninstmodules as $key => $shortname) { //test if the file is a valid module or a lib file/whatever that got in, maybe even malcode that does not have module form $shortnamelower = strtolower($shortname); $file = strtolower(file_get_contents("modules/{$shortname}.php")); if (strpos($file, $shortnamelower . "_getmoduleinfo") === false || strpos($file, $shortnamelower . "_install") === false || strpos($file, $shortnamelower . "_uninstall") === false) { //here the files has neither do_hook nor getinfo, which means it won't execute as a module here --> block it + notify the admin who is the manage modules section $temp = array_merge($invalidmodule, array("name" => $shortname . ".php " . appoencode(translate_inline("(`\$Invalid Module! Contact Author or check file!`0)")))); } else { $temp = get_module_info($shortname); } //end of testing if (!$temp || empty($temp)) { continue; } $temp['shortname'] = $shortname; array_push($moduleinfo, $temp); array_push($sortby, full_sanitize($temp[$sorting])); array_push($numberarray, $count); $count++; } array_multisort($sortby, $order ? SORT_DESC : SORT_ASC, $numberarray, $order ? SORT_DESC : SORT_ASC); for ($a = 0; $a < count($moduleinfo); $a++) { $i = $numberarray[$a]; rawoutput("<tr class='" . ($i % 2 ? "trlight" : "trdark") . "'>");
private static function identifyRelateField($thisModuleName, $sourceModuleName) { $module = get_module_info($thisModuleName); foreach ($module->field_defs as $field) { if ($field['type'] == 'relate' && isset($field['module']) && $field['module'] == $sourceModuleName) { return $field['name']; } } return null; }
function process_by_rel_bean($rel1_module) { $this->rel1_relationship_name = $this->retrieve_by_modules($this->base_module, $rel1_module, $this->db); $this->rel1_module = $rel1_module; $this->rel1_bean = get_module_info($this->rel1_module); //end function process_by_rel_bean }
protected function saveVardefs($basepath, $installDefPrefix, $relationshipName, $vardefs) { mkdir_recursive("{$basepath}/vardefs/"); $GLOBALS['log']->debug(get_class($this) . "->saveVardefs(): vardefs =" . print_r($vardefs, true)); foreach ($vardefs as $moduleName => $definitions) { // find this module's Object name - the object name, not the module name, is used as the key in the vardefs... if (isset($GLOBALS['beanList'][$moduleName])) { $module = get_module_info($moduleName); $object = $module->object_name; } else { $object = $moduleName; } $relName = $moduleName; foreach ($definitions as $definition) { if (!empty($definition['relationship'])) { $relName = $definition['relationship']; break; } } $filename = "{$basepath}/vardefs/{$relName}_{$moduleName}.php"; $out = "<?php\n// created: " . date('Y-m-d H:i:s') . "\n"; foreach ($definitions as $definition) { $GLOBALS['log']->debug(get_class($this) . "->saveVardefs(): saving the following to {$filename}" . print_r($definition, true)); $out .= '$dictionary["' . $object . '"]["fields"]["' . $definition['name'] . '"] = ' . var_export_helper($definition) . ";\n"; } file_put_contents($filename, $out); $installDefs[$moduleName] = array('from' => "{$installDefPrefix}/relationships/vardefs/{$relName}_{$moduleName}.php", 'to_module' => $moduleName); } $GLOBALS['log']->debug(get_class($this) . "->saveVardefs(): installDefs =" . print_r($installDefs, true)); return $installDefs; }
/** * Merge determined bean data into an determined text template, this could be * an email template, expression template, or another type of text with * bean variables in it. * * @global type $beanList * @param type $bean * @param type $template * @param type $component_array * @param type $evaluate * @return type */ public function mergeTemplate($bean, $template, $component_array, $evaluate = false) { global $beanList; $replace_array = array(); $replace_type_array = array(); foreach ($component_array as $module_name => $module_array) { //base module if ($module_name == $bean->module_dir) { foreach ($module_array as $field => $field_array) { if ($field_array['value_type'] == 'href_link') { //Create href link to target record $replacement_value = $this->get_href_link($bean); } if ($field_array['value_type'] == 'future') { if ($evaluate) { $replacement_value = bpminbox_check_special_fields($field_array['name'], $bean, false, array()); } else { $replacement_value = bpminbox_check_special_fields($field_array['name'], $bean, false, array()); } } if ($field_array['value_type'] == 'past') { $replacement_value = bpminbox_check_special_fields($field_array['name'], $bean, true, array()); } $replace_type_array[$field_array['original']] = get_bean_field_type($field_array['name'], $bean); $replace_array[$field_array['original']] = implode(', ', unencodeMultienum($replacement_value)); } } else { //Confirm this is an actual module in the beanlist if (isset($beanList[$module_name]) || isset($bean->field_defs[$module_name])) { ///Build the relationship information using the Relationship handler $rel_handler = $bean->call_relationship_handler("module_dir", true); if (isset($bean->field_defs[$module_name])) { $rel_handler->rel1_relationship_name = $bean->field_defs[$module_name]['relationship']; $rel_module = get_rel_module_name($bean->module_dir, $rel_handler->rel1_relationship_name, $bean->db); $rel_handler->rel1_module = $rel_module; $rel_handler->rel1_bean = get_module_info($rel_module); } else { $rel_handler->process_by_rel_bean($module_name); } foreach ($bean->field_defs as $field => $attribute_array) { if (!empty($attribute_array['relationship']) && $attribute_array['relationship'] == $rel_handler->rel1_relationship_name) { $rel_handler->base_vardef_field = $field; break; } } //obtain the rel_module object $rel_list = $rel_handler->build_related_list("base"); if (!empty($rel_list[0])) { $rel_object = $rel_list[0]; $rel_module_present = true; } else { $rel_module_present = false; } foreach ($module_array as $field => $field_array) { if ($rel_module_present == true) { if ($field_array['value_type'] == 'href_link') { //Create href link to target record $replacement_value = $this->get_href_link($rel_object); } else { //use future always for rel because fetched should always be the same $replacement_value = bpminbox_check_special_fields($field_array['name'], $rel_object, false, array()); } } else { $replacement_value = "Invalid Value"; } $replace_array[$field_array['original']] = implode(', ', unencodeMultienum($replacement_value)); } } } } foreach ($replace_array as $name => $replacement_value) { if ($evaluate) { $replacement_value = str_replace("\n", ' ', $replacement_value); $type = $replace_type_array[$name]['type']; $dbtype = $replace_type_array[$name]['db_type']; //TODO evaluate more types even Ids perhaps $this->logger->info("Field : {$name} , type: '{$type}', DBtype: '{$dbtype}'"); if (($dbtype == 'double' || $dbtype == 'int') && $type != 'currency') { $replacement_value = trim($replacement_value); } elseif ($type == 'currency') { //TODO hardcoded . , should use system currency format $replacement_value = str_replace(",", '', $replacement_value); $replacement_value = str_replace(".", ',', $replacement_value); $replacement_value = floatval($replacement_value); } else { //here $replacement_value must be datatime, time, string datatype values $replacement_value = "'" . $replacement_value . "'"; } } else { $replacement_value = nl2br($replacement_value); } $template = str_replace($name, $replacement_value, $template); } return $template; }
function search_filter_rel_info(&$focus, $tar_rel_module, $relationship_name) { $rel_list = array(); foreach ($focus->relationship_fields as $rel_key => $rel_value) { if ($rel_value == $relationship_name) { $temp_bean = get_module_info($tar_rel_module); // echo $focus->$rel_key; $temp_bean->retrieve($focus->{$rel_key}); if ($temp_bean->id != "") { $rel_list[] = $temp_bean; return $rel_list; } } } foreach ($focus->field_defs as $field_name => $field_def) { //Check if the relationship_name matches a "relate" field if (!empty($field_def['type']) && $field_def['type'] == 'relate' && !empty($field_def['id_name']) && !empty($focus->field_defs[$field_def['id_name']]) && !empty($focus->field_defs[$field_def['id_name']]['relationship']) && $focus->field_defs[$field_def['id_name']]['relationship'] == $relationship_name) { $temp_bean = get_module_info($tar_rel_module); // echo $focus->$field_def['id_name']; $temp_bean->retrieve($focus->{$field_def}['id_name']); if ($temp_bean->id != "") { $rel_list[] = $temp_bean; return $rel_list; } //Check if the relationship_name matches a "link" in a relate field } else { if (!empty($rel_value['link']) && !empty($rel_value['id_name']) && $rel_value['link'] == $relationship_name) { $temp_bean = get_module_info($tar_rel_module); // echo $focus->$rel_value['id_name']; $temp_bean->retrieve($focus->{$rel_value}['id_name']); if ($temp_bean->id != "") { $rel_list[] = $temp_bean; return $rel_list; } } } } // special case for unlisted parent-type relationships if (!empty($focus->parent_type) && $focus->parent_type == $tar_rel_module && !empty($focus->parent_id)) { $temp_bean = get_module_info($tar_rel_module); $temp_bean->retrieve($focus->parent_id); if ($temp_bean->id != "") { $rel_list[] = $temp_bean; return $rel_list; } } return $rel_list; //end function search_filter_rel_info }
$tbl_module = $tbl_name['module']; $tbl_module_info = $tbl_name['module_info']; $tbl_dock = $tbl_name['dock']; //NEEDED LIBRAIRIES require_once get_path('incRepositorySys') . '/lib/module/manage.lib.php'; require_once get_path('incRepositorySys') . '/lib/admin.lib.inc.php'; $undeactivable_tool_array = get_not_deactivable_tool_list(); $htmlHeadXtra[] = "<script type=\"text/javascript\">\nfunction confirmMakeVisible ()\n{\n if (confirm(\" " . clean_str_for_javascript(get_lang("Are you sure you want to make this module visible in all courses ?")) . "\"))\n {return true;}\n else\n {return false;}\n}\nfunction confirmMakeInVisible ()\n{\n if (confirm(\" " . clean_str_for_javascript(get_lang("Are you sure you want to make this module invisible in all courses ?")) . "\"))\n {return true;}\n else\n {return false;}\n}\n</script>"; //---------------------------------- // GET REQUEST VARIABLES //---------------------------------- $cmd = isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : null; $item = isset($_REQUEST['item']) ? $_REQUEST['item'] : 'GLOBAL'; $section_selected = isset($_REQUEST['section']) ? $_REQUEST['section'] : null; $moduleId = isset($_REQUEST['module_id']) ? (int) $_REQUEST['module_id'] : null; $module = get_module_info($moduleId); if (!$module) { claro_die("ERROR: INVALID MODULE ID!!!"); } language::load_module_translation($module['label']); $dockList = get_dock_list($module['type']); $nameTools = get_lang('Module settings'); $noPHP_SELF = true; // FIXME : BAD use of get_lang !!!!! ClaroBreadCrumbs::getInstance()->prepend(get_lang($module['module_name'])); ClaroBreadCrumbs::getInstance()->prepend(get_lang('Module list'), get_path('rootAdminWeb') . 'module/module_list.php?typeReq=' . $module['type']); ClaroBreadCrumbs::getInstance()->prepend(get_lang('Administration'), get_path('rootAdminWeb')); ClaroBreadCrumbs::getInstance()->setCurrent($nameTools); $dialogBox = new dialogBox(); //---------------------------------- // EXECUTE COMMAND