function app_installer_json(&$vars) { extract($vars); if (!class_exists('Services_JSON')) { lib_include('json'); } $json = new Services_JSON(); $apps_list = array(); if (isset($GLOBALS['PATH']['apps'])) { foreach ($GLOBALS['PATH']['apps'] as $k => $v) { if ($k != 'omb') { $apps_list[$k] = $k; } } } // apps_list = physical apps on this host $sources = environment('remote_sources'); $remote_list = array(); // remote_list = all not-installed apps on remote sources foreach ($sources as $name => $url) { $url = "http://" . $url . "&p=" . urlencode($request->uri); $curl = curl_init($url); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $result = false; $result = curl_exec($curl); if ($result) { $data = mb_unserialize($result); foreach ($data as $appname => $appdata) { $remote_list[$appname] = $appname; } } curl_close($curl); } $i = $Identity->find(get_app_id()); while ($s = $i->NextChild('settings')) { if ($s->name == 'app' && in_array($s->value, $apps_list)) { $apps_list = drop_array_element($apps_list, $s->value); } } $i = $Identity->find(get_app_id()); while ($s = $i->NextChild('settings')) { if ($s->name == 'app' && in_array($s->value, $remote_list)) { $remote_list = drop_array_element($remote_list, $s->value); } } $all_apps = array_merge($apps_list, $remote_list); header("Content-Type: application/javascript"); print $json->encode($all_apps); exit; }
function register($table) { trigger_before('register', $this, $this); global $db; if (!isset($this->table)) { $this->table = $table; } if (!isset($this->access_list)) { $this->access_list = array(); } if (!isset($this->relations)) { $this->relations = array(); } if (!isset($this->allowed_methods)) { $this->allowed_methods = array('get', 'post', 'put', 'delete'); } if (!isset($this->field_array)) { $this->field_array = $db->get_fields($this->table); } if (array_key_exists('entry_id', $this->field_array)) { $this->has_metadata = true; } else { $this->has_metadata = false; } $this->hidden = false; if (count($this->field_array) > 0) { $this->exists = true; } else { $this->exists = false; } if (isset($this->field_array[$this->table . "_primary_key"])) { $this->set_primary_key($this->field_array[$this->table . "_primary_key"]); $this->field_array = drop_array_element($this->field_array, $this->table . "_primary_key"); } if (!in_array($this->table, array('db_sessions'))) { $this->save(); } foreach ($this->relations as $table => $vals) { //$this->field_array[$field] $custom_class = classify($table); if (class_exists($custom_class)) { if ($table != 'entries') { if (isset($db->tables[$table])) { $obj =& $db->tables[$table]; } else { $obj = new $custom_class(); } if (array_key_exists('target_id', $obj->field_array)) { if (array_key_exists('entry_id', $this->field_array)) { $k = 'entry_id'; $fk = $table . '.target_id'; $this->relations[$table]['col'] = $k; $this->relations[$table]['fkey'] = $fk; } } } } } }