示例#1
0
文件: google.php 项目: ayaou/Zuha
 function __construct()
 {
     if (defined('__USERS_CONNECT_APPS')) {
         extract(__USERS_CONNECT_APPS);
         $this->googleClientId = !empty($googleClientId) ? $googleClientId : null;
         $this->googleClientAPIKey = !empty($googleClientAPIKey) ? $googleClientAPIKey : null;
         $this->googleClientSecret = !empty($googleClientSecret) ? $googleRedirectUri : null;
         $this->googleRedirectUri = !empty($googleRedirectUri) ? $googleRedirectUri : null;
         $this->twitterClientAPIKey = !empty($twitterClientAPIKey) ? $twitterClientAPIKey : null;
         $this->twitterClientSecret = !empty($twitterClientSecret) ? $twitterClientAPIKey : null;
     }
     // Or set the database path from here if you need to use any constants
     parent::__construct();
     // check for parent::__construct() and call it if it exists
     $this->google['user'] = $this->googleClientId;
     // APP.'plugins'.DS.'cities'.DS.'cities.sqlite.db';
 }
 public function view_graphNew($id)
 {
     //For nodes and children
     $array = array();
     $dbclass = new DATABASE_CONFIG();
     $conn = $dbclass->getConnection();
     //Requirements----------------
     $fetch = mysql_query("SELECT * FROM entities where problem_map_id = {$id} and type = 'requirement'");
     while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
         $e = new ProblemMapRank();
         $e->id = $row['id'];
         $e->decomposition_id = $row['decomposition_id'];
         $e->name = $row['name'];
         $e->type = $row['type'];
         $e->current_decomposition = $row['current_decomposition'];
         $e->problem_map_id = $row['problem_map_id'];
         $array[] = $e;
     }
     //User Scenario----------------
     $fetch = mysql_query("SELECT * FROM entities where problem_map_id = {$id} and type = 'usescenario'");
     while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
         $e = new ProblemMapRank();
         $e->id = $row['id'];
         $e->decomposition_id = $row['decomposition_id'];
         $e->name = $row['name'];
         $e->type = $row['type'];
         $e->current_decomposition = $row['current_decomposition'];
         $e->problem_map_id = $row['problem_map_id'];
         $array[] = $e;
     }
     //Functions----------------
     $fetch = mysql_query("SELECT * FROM entities where problem_map_id = {$id} and type = 'function'");
     while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
         $e = new ProblemMapRank();
         $e->id = $row['id'];
         $e->decomposition_id = $row['decomposition_id'];
         $e->name = $row['name'];
         $e->type = $row['type'];
         $e->current_decomposition = $row['current_decomposition'];
         $e->problem_map_id = $row['problem_map_id'];
         $array[] = $e;
     }
     //Artifacts----------------
     $fetch = mysql_query("SELECT * FROM entities where problem_map_id = {$id} and type = 'artifact'");
     while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
         $e = new ProblemMapRank();
         $e->id = $row['id'];
         $e->decomposition_id = $row['decomposition_id'];
         $e->name = $row['name'];
         $e->type = $row['type'];
         $e->current_decomposition = $row['current_decomposition'];
         $e->problem_map_id = $row['problem_map_id'];
         $array[] = $e;
     }
     //Behaviors----------------
     $fetch = mysql_query("SELECT * FROM entities where problem_map_id = {$id} and type = 'behavior'");
     while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
         $e = new ProblemMapRank();
         $e->id = $row['id'];
         $e->decomposition_id = $row['decomposition_id'];
         $e->name = $row['name'];
         $e->type = $row['type'];
         $e->current_decomposition = $row['current_decomposition'];
         $e->problem_map_id = $row['problem_map_id'];
         $array[] = $e;
     }
     //Issues----------------
     $fetch = mysql_query("SELECT * FROM entities where problem_map_id = {$id} and type = 'issue'");
     while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
         $e = new ProblemMapRank();
         $e->id = $row['id'];
         $e->decomposition_id = $row['decomposition_id'];
         $e->name = $row['name'];
         $e->type = $row['type'];
         $e->current_decomposition = $row['current_decomposition'];
         $e->problem_map_id = $row['problem_map_id'];
         $array[] = $e;
     }
     foreach ($array as $e) {
         foreach ($array as $tmp) {
             if ($tmp->decomposition_id != null) {
                 if ($e->current_decomposition != null) {
                     if ($tmp->decomposition_id == $e->current_decomposition) {
                         $e->children1[] = $tmp->name;
                     }
                 }
             }
         }
     }
     //For links
     $linkFetch = mysql_query("SELECT * FROM links where problem_map_id = {$id}");
     while ($row = mysql_fetch_array($linkFetch, MYSQL_ASSOC)) {
         foreach ($array as $e) {
             if ($row['from_entity_id'] == $e->id) {
                 foreach ($array as $tmp) {
                     if ($tmp->id == $row['to_entity_id']) {
                         $e->thelinks[] = $tmp->name;
                     }
                 }
             }
         }
     }
     $outPutJson = json_encode($array);
     file_put_contents('problemMapStructure.json', $outPutJson);
     $this->log_entry($id, "ProblemMapsController, view_graph_2, " . $id);
     // retrieve the problem map and set it to a variable accessible in the view
     $ProblemMap = $this->ProblemMap->findById($id);
     $this->set(compact('ProblemMap'));
     // this is for JSON and XML requests.
     $this->set('_serialize', array('ProblemMap'));
 }