コード例 #1
0
    public function is_user_id_allowed_to_view_drama($user_id, Oedipus_Drama $drama)
    {
        $user = NULL;
        $drama_id = $drama->get_id();
        if (InputValidation_NumberValidator::validate_database_id($user_id)) {
            $dbh = DB::m();
            $user_id = mysql_real_escape_string($user_id, $dbh);
            $query = <<<SQL
SELECT
\tcount(user_id) AS count
FROM
\toedipus_users_allowed_to_view_drama_links
WHERE
\toedipus_users_allowed_to_view_drama_links.user_id = {$user_id}
\tAND
\toedipus_users_allowed_to_view_drama_links.drama_id = {$drama_id}
SQL;
            $result = mysql_query($query, $dbh);
            if ($row = mysql_fetch_assoc($result)) {
                if ($row['count'] == 1) {
                    return TRUE;
                }
                return FALSE;
            }
        }
    }
コード例 #2
0
 public static function get_view_page_url(Oedipus_Drama $drama = NULL)
 {
     if (isset($drama)) {
         #			$url = new HTMLTags_URL();
         #			$url->set_file('/dramas/'. $drama->get_unique_name());
         #//                        $url->set_get_variable('oo-page', 1);
         #//                        $url->set_get_variable('page-class', 'Oedipus_DramaEditorPage');
         #
         #//                        $url->set_get_variable('drama_unique_name', );
         return PublicHTML_URLHelper::get_oo_page_url('Oedipus_DramaPage', array('drama_id' => $drama->get_id()));
         return $url;
     } else {
         return PublicHTML_URLHelper::get_oo_page_url('Oedipus_DramaPage');
     }
 }
コード例 #3
0
 /**
  *
  * URLs
  *
  */
 public static function get_drama_page_url_for_drama(Oedipus_Drama $drama)
 {
     return self::get_drama_page_url_for_drama_id($drama->get_id());
 }
コード例 #4
0
    public function add_table(Oedipus_Drama $drama, $table_name)
    {
        // ADD TABLE TO DATABASE
        $drama_id = $drama->get_id();
        $dbh = DB::m();
        $sql = <<<SQL
INSERT INTO
\toedipus_tables
SET
\tname = '{$table_name}',
\tdrama_id = {$drama_id},
\tadded = NOW()
SQL;
        //                print_r($sql);exit;
        $result = mysql_query($sql, $dbh);
        $table_id = mysql_insert_id($dbh);
        // ADD DEFAULT ACTOR tO DATABASE
        $actor_name = 'First Actor';
        $actor_color = 'red';
        $sql2 = <<<SQL
INSERT INTO
\toedipus_actors
SET
\tname = '{$actor_name}',
\tcolor = '{$actor_color}',
\ttable_id = {$table_id},
\tadded = NOW()
SQL;
        //                print_r($sql);exit;
        $result2 = mysql_query($sql2, $dbh);
        $actor_id = mysql_insert_id($dbh);
        $actor = new Oedipus_Actor($actor_id, $actor_name, $actor_color);
        $actors = array();
        $actors[] = $actor;
        foreach ($actors as $actor) {
            // ADD DEFAULT stated_intention tO DATABASE
            $stated_intention_position = '1';
            $stated_intention_doubt = '';
            $sql3 = <<<SQL
INSERT INTO
\toedipus_stated_intentions
SET
\tposition = '{$stated_intention_position}',
\tdoubt = '{$stated_intention_doubt}'
SQL;
            //                print_r($sql);exit;
            $result3 = mysql_query($sql3, $dbh);
            $stated_intention_id = mysql_insert_id($dbh);
            // ADD DEFAULT option tO DATABASE
            $option_name = 'First Option';
            $sql4 = <<<SQL
INSERT INTO
\toedipus_options
SET
\tname = '{$option_name}',
\tactor_id = {$actor_id},
\tstated_intention_id = {$stated_intention_id},
\tadded = NOW()
SQL;
            //                print_r($sql);exit;
            $result4 = mysql_query($sql4, $dbh);
            $option_id = mysql_insert_id($dbh);
            $stated_intention = new Oedipus_StatedIntention($stated_intention_id, $stated_intention_position, $stated_intention_doubt);
            $actors_option = new Oedipus_Option($option_id, $option_name, $stated_intention);
            $actor->add_option($actors_option);
        }
        // Create default positions
        foreach ($actors as $actor) {
            foreach ($actor->get_options() as $option) {
                $positions = array();
                foreach ($actors as $position_actor) {
                    // ADD DEFAULT position tO DATABASE
                    $position_position = '1';
                    $position_doubt = '';
                    $option_id = $option->get_id();
                    $actor_id = $position_actor->get_id();
                    $sql5 = <<<SQL
INSERT INTO
\toedipus_positions
SET
\tposition = '{$position_position}',
\tdoubt = '{$position_doubt}',
\toption_id = {$option_id},
\tactor_id = {$actor_id}
SQL;
                    //                                                        print_r($sql5);exit;
                    $result5 = mysql_query($sql5, $dbh);
                    $position_id = mysql_insert_id($dbh);
                    $positions[$position_actor->get_name()] = new Oedipus_Position($position_id, $position_position, $position_doubt, $position_actor);
                }
                $option->add_positions($positions);
            }
        }
        $table = new Oedipus_Table($table_id, $drama_id, $table_name, $actors);
        //                print_r($table);exit;
        //
        // Update Drama Object with new Table
        //                $drama->add_table($table);
        return $table;
    }