Exemplo n.º 1
0
     if ($sql_op->insert('biblio_author', $data)) {
         echo '<script type="text/javascript">';
         echo 'alert(\'' . __('Author succesfully updated!') . '\');';
         echo 'parent.setIframeContent(\'authorIframe\', \'' . MODULES_WEB_ROOT_DIR . 'bibliography/iframe_author.php?biblioID=' . $data['biblio_id'] . '\');';
         echo '</script>';
     } else {
         utility::jsAlert(__('Author FAILED to Add. Please Contact System Administrator') . "\n" . $sql_op->error);
     }
 } else {
     if (isset($_POST['authorID']) and !empty($_POST['authorID'])) {
         // add to current session
         $_SESSION['biblioAuthor'][$_POST['authorID']] = array($_POST['authorID'], intval($_POST['level']));
     } else {
         if ($author_name and empty($_POST['authorID'])) {
             // check author
             $author_id = checkAuthor($author_name);
             if ($author_id !== false) {
                 $last_id = $author_id;
             } else {
                 // adding new author
                 $data['author_name'] = $author_name;
                 $data['authority_type'] = $_POST['type'];
                 $data['input_date'] = date('Y-m-d');
                 $data['last_update'] = date('Y-m-d');
                 // insert new author to author master table
                 $sql_op->insert('mst_author', $data);
                 $last_id = $sql_op->insert_id;
             }
             $_SESSION['biblioAuthor'][$last_id] = array($last_id, intval($_POST['level']));
         }
     }
function BraftonArticleImporter()
{
    $errors = new BraftonErrorReport(variable_get('brafton_api_key'), variable_get('brafton_api_root'), (bool) variable_get('brafton_debug_mode'));
    //Gathers feed type, Api and Video Keys, and archive file information from the Brafton module settings page.
    $import_list = array();
    $feed_type = variable_get('brafton_feed_type');
    $is_api = variable_get('brafton_api_key');
    $is_archive = variable_get('brafton_archive_file');
    $overwrite = variable_get('brafton_overwrite');
    $is_published = variable_get('brafton_published');
    $counter = 0;
    //Define default fields for b_news type_url_form_media
    if ($is_api || $is_archive) {
        //Loads the date and overwrite settings.
        $date = get_date_setting();
        //Loads the article objects from the feed into an array.
        $article_array = load_article_array($is_archive);
        //Loops through the article array
        foreach ($article_array as $value) {
            //Checks to see if the article already exists.  If it does not, a new node is created of type b_news.  If it does, then depending upon the overwrite settings the existing node is either loaded, or we iterate to the next article in the feed
            $id = $value->getId();
            $check = check_if_article_exists($id);
            if (!empty($check) && $overwrite == 1) {
                $nid = key($check['node']);
                $node = node_load($nid);
            } elseif (empty($check)) {
                $node = new stdClass();
            } else {
                continue;
            }
            //Gets an array of image information from the feed.
            $image = get_image_attributes($value);
            //Gets the article categories as an array of valid and unique term ids.
            $categories = set_article_categories($value, 'b_news');
            //Instantiation of each article component as a field in the node object.
            $node->status = $is_published == 1 ? 0 : 1;
            $types = array('body' => 'body', 'image' => 'field_brafton_image', 'tax' => 'field_brafton_term');
            if (variable_get('brafton_existing_type') != 'b_news') {
                $types['body'] = variable_get('brafton_custom_body');
                $types['image'] = variable_get('brafton_custom_image');
                $types['tax'] = variable_get('brafton_custom_taxonomy');
            }
            $node->type = variable_get('brafton_existing_type');
            $node->language = LANGUAGE_NONE;
            $node->title = $value->getHeadline();
            $import_list['title'][] = $node->title;
            $node->uid = checkAuthor(variable_get('brafton_author'), $value->getByLine());
            //$nodestatus = 1;
            $node->created = strtotime($value->{$date}());
            $node->updated = $node->created;
            $node->promote = 0;
            $node->sticky = 0;
            $node->comment = variable_get('brafton_comments');
            $node->{$types['body']}[$node->language][0] = array('value' => $value->getText(), 'summary' => $value->getExtract(), 'format' => 'full_html');
            if ($image) {
                $node->{$types['image']}[$node->language][0] = (array) system_retrieve_file($image['url'], NULL, TRUE, FILE_EXISTS_REPLACE);
                $node->{$types['image']}[$node->language][0]['alt'] = $image['alt'];
                $node->{$types['image']}[$node->language][0]['title'] = $image['title'];
            }
            if (field_info_instance('node', 'field_brafton_id', $node->type) == NULL) {
                $brafton_id_field = array('field_name' => 'field_brafton_id', 'entity_type' => 'node', 'bundle' => $node->type, 'display' => array('default' => array('label' => 'hidden', 'type' => 'hidden')));
                field_create_instance($brafton_id_field);
            }
            $node->field_brafton_id[$node->language][0]['value'] = $id;
            //Setting the article pause cta text
            //ensure categories don't get added twice
            $cats = false;
            $oldcats;
            if ($overwrite && isset($node->{$types['tax']}[$node->language])) {
                $oldcats = $node->{$types['tax']}[$node->language];
                $cats = true;
            }
            foreach ($categories as $category) {
                if ($cats) {
                    foreach ($oldcats as $oldcat) {
                        if ($oldcat['tid'] != $category) {
                            $node->{$types['tax']}[$node->language][]['tid'] = $category;
                        }
                    }
                } else {
                    $node->{$types['tax']}[$node->language][]['tid'] = $category;
                }
            }
            //end category code
            node_save($node);
            var_dump($node);
            taxonomy_node_insert($node);
            $nid = $node->nid;
            $alias = drupal_get_path_alias("node/" . $nid);
            $counter++;
            ++$errors->level;
        }
    }
    $import_list['counter'] = $counter;
    return $import_list;
}
Exemplo n.º 3
0
                    $errorArray[] = "Book not found at this location.";
                }
            }
        } else {
            $abort = true;
            $errorArray[] = "Book id not received by server.";
        }
    } else {
        $abort = true;
        $errorArray[] = "You must be logged in as the author to edit a book's table of contents.";
    }
    if ($abort) {
        return false;
    }
}
checkAuthor('books', 'info_working', $book->id);
//Data exists and user signed in valid
if (!$abort) {
    //Validate user input
    //Validate book author
    if ($book->id === 'newBook') {
        $book->author === $_SESSION['username'];
    } else {
        if ($book->author === $bookInfo['_source']['author']) {
        } else {
            $abort = true;
            $errorArray[] = "Book author submitted does not match author in database.";
        }
    }
    //Verify title exists, is gte than 1 and less than 140 characters
    if ($book->title != '') {
Exemplo n.º 4
0
                $abort = true;
                $errorArray[] = "Book not found at this location.";
            }
        } else {
            $abort = true;
            $errorArray[] = "Book id not received by server.";
        }
    } else {
        $abort = true;
        $errorArray[] = "You must be logged in as the author to edit a book's table of contents.";
    }
    if ($abort) {
        return false;
    }
}
checkAuthor('books', 'info_working', $glossary->bookId);
//Data exists and user signed in valid
if (!$abort) {
    //Remove uneccesary data to be sent
    $bookId = $glossary->bookId;
    $action = $glossary->action;
    unset($glossary->action);
    //Remove any invalid keys
    $validKeys = (object) array('terms' => '');
    $glossary = (object) array_intersect_key(get_object_vars($glossary), get_object_vars($validKeys));
    //Validate data
    //Sample data:
    /*
    {  
    	"7f678ckwnt":{  
    	  "text":"Lorem ipsum",
Exemplo n.º 5
0
                $abort = true;
                $errorArray[] = "Book not found at this location.";
            }
        } else {
            $abort = true;
            $errorArray[] = "Book id not received by server.";
        }
    } else {
        $abort = true;
        $errorArray[] = "You must be logged in as the author to edit a book's table of contents.";
    }
    if ($abort) {
        return false;
    }
}
checkAuthor('books', 'info_working', $references->bookId);
//Data exists and user signed in valid
if (!$abort) {
    //Remove uneccesary data to be sent
    $pageId = $references->pageId;
    $action = $references->action;
    $refs = $references->refs;
    //Validate data
    //Sample data:
    /*
    {  
    	"7f678ckwnt":{  
    	  "desc":[  
    	     "Nullam dictum felis eu pede mollis pretium. Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis tellus, vitae iaculis lacus elit id tortor. Fusce fermentum odio nec arcu. Fusce commodo aliquam arcu. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.",
    	     "Cursus lacinia erat. Maecenas vestibulum mollis diam. Donec vitae orci sed dolor rutrum auctor. Ut non enim eleifend felis pretium feugiat. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit."
    	  ],
Exemplo n.º 6
0
                $abort = true;
                $errorArray[] = "Page not found at this location.";
            }
        } else {
            $abort = true;
            $errorArray[] = "Page id not received by server.";
        }
    } else {
        $abort = true;
        $errorArray[] = "You must be logged in as the author to edit a page.";
    }
    if ($abort) {
        return false;
    }
}
checkAuthor('books', 'pages', $data->id);
if (!$abort) {
    $widgets = [];
    $reviewsWidget = "";
    //Validate widgets
    foreach ($data->widgets as $key => $widget) {
        //print_r($data->widgets);
        //echo "<br><br>";
        switch ($widget->type) {
            case "contentgroup":
                $widgets[] = processContentGroup($widget);
                break;
            case "header1":
                $widgets[] = processHeader1($widget);
                break;
            case "textBox":