public function doAction()
 {
     $this->generateAuthURL();
     //pay a little query to avoid to fetch 5000 rows
     $this->data = $jobData = getJobData($this->jid, $this->password);
     $wStruct = new WordCount_Struct();
     $wStruct->setIdJob($this->jid);
     $wStruct->setJobPassword($this->password);
     $wStruct->setNewWords($jobData['new_words']);
     $wStruct->setDraftWords($jobData['draft_words']);
     $wStruct->setTranslatedWords($jobData['translated_words']);
     $wStruct->setApprovedWords($jobData['approved_words']);
     $wStruct->setRejectedWords($jobData['rejected_words']);
     if ($jobData['status'] == Constants_JobStatus::STATUS_ARCHIVED || $jobData['status'] == Constants_JobStatus::STATUS_CANCELLED) {
         //this job has been archived
         $this->job_archived = true;
         $this->job_owner_email = $jobData['job_owner'];
     }
     $this->job_stats = CatUtils::getFastStatsForJob($wStruct);
     $proj = getProject($jobData['id_project']);
     $this->project_status = $proj[0];
     /**
      * Retrieve information about job errors
      * ( Note: these information are fed by the revision process )
      * @see setRevisionController
      */
     $jobQA = new Revise_JobQA($this->jid, $this->password, $wStruct->getTotal());
     $jobQA->retrieveJobErrorTotals();
     $jobVote = $jobQA->evalJobVote();
     $this->totalJobWords = $wStruct->getTotal();
     $this->qa_data = $jobQA->getQaData();
     $this->qa_overall_text = $jobVote['minText'];
     $this->qa_overall_avg = $jobVote['avg'];
     $this->qa_equivalent_class = $jobVote['equivalent_class'];
 }
Esempio n. 2
0
function forceProject()
{
    if (!getProject() instanceof Project) {
        redirect("/pg/");
    }
    return getProject();
}
 public function doAction()
 {
     $this->generateAuthURL();
     //pay a little query to avoid to fetch 5000 rows
     $this->jobData = $jobData = getJobData($this->jid, $this->password);
     $wStruct = new WordCount_Struct();
     $wStruct->setIdJob($this->jid);
     $wStruct->setJobPassword($this->password);
     $wStruct->setNewWords($jobData['new_words']);
     $wStruct->setDraftWords($jobData['draft_words']);
     $wStruct->setTranslatedWords($jobData['translated_words']);
     $wStruct->setApprovedWords($jobData['approved_words']);
     $wStruct->setRejectedWords($jobData['rejected_words']);
     if ($jobData['status'] == Constants_JobStatus::STATUS_ARCHIVED || $jobData['status'] == Constants_JobStatus::STATUS_CANCELLED) {
         //this job has been archived
         $this->job_archived = true;
         $this->job_owner_email = $jobData['job_owner'];
     }
     $tmp = CatUtils::getEditingLogData($this->jid, $this->password);
     $this->data = $tmp[0];
     $this->stats = $tmp[1];
     $this->job_stats = CatUtils::getFastStatsForJob($wStruct);
     $proj = getProject($jobData['id_project']);
     $this->project_status = $proj[0];
 }
Esempio n. 4
0
 /**
  * When Called it perform the controller action to retrieve/manipulate data
  *
  * @return mixed
  */
 function doAction()
 {
     if (count($this->errors) > 0) {
         return null;
     }
     //get job language and data
     //Fixed Bug: need a specific job, because we need The target Language
     //Removed from within the foreach cycle, the job is always the same...
     $jobData = $this->jobInfo = getJobData($this->jobID, $this->jobPass);
     $pCheck = new AjaxPasswordCheck();
     //check for Password correctness
     if (empty($jobData) || !$pCheck->grantJobAccessByJobData($jobData, $this->jobPass)) {
         $msg = "Error : wrong password provided for download \n\n " . var_export($_POST, true) . "\n";
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
         return null;
     }
     $projectData = getProject($jobData['id_project']);
     $source = $jobData['source'];
     $target = $jobData['target'];
     $tmsService = new TMSService();
     /**
      * @var $tmx SplTempFileObject
      */
     $this->tmx = $tmsService->exportJobAsTMX($this->jobID, $this->jobPass, $source, $target);
     $this->fileName = $projectData[0]['name'] . "-" . $this->jobID . ".tmx";
 }
Esempio n. 5
0
 public function __construct($name, $desc, $usage)
 {
     $this->project = getProject();
     $this->name = $name;
     $this->desc = $desc;
     $this->usage = $usage;
     $this->executor = new CommandExecutor($this);
 }
Esempio n. 6
0
/**
 * @return Project
 */
function forceProject()
{
    $project = getProject();
    if (!$project instanceof Project) {
        redirect("/pg/");
    }
    return $project;
}
Esempio n. 7
0
function printProjectPage($projectID)
{
    $project = getProject($projectID);
    echo '<h1 class="page_title_withside">' . $project['project_name'] . '</h1>';
    echo '<div class="page_content">';
    echo '<div class="img_right"><img src="' . getProjectImage($project['project_id']) . '"></img></div>';
    echo $project['project_page'];
    echo '</div>';
    echo '<div class="page_content">';
    echo '<h1>Blog Posts About this Project</h1>';
    echo '<p>Blog posts tagged as "' . getTagName($project['project_tag']) . '" refer to this project. Click below to see all of the blog posts about ' . $project['project_name'] . '.</p>';
    echo '<h3>Blog Posts Tagged in <a class="dark_red" href="/blog/tag/' . $project['project_tag'] . '">' . getTagName($project['project_tag']) . ' (' . $project['project_tag'] . ')</a></h3>';
    echo '</div>';
}
Esempio n. 8
0
 public function controllerDoAction()
 {
     //pay a little query to avoid to fetch 5000 rows
     $this->jobData = getJobData($this->jid, $this->password);
     $this->job_stats = $this->getFastStatsForJob();
     if ($this->jobData['status'] == Constants_JobStatus::STATUS_ARCHIVED || $this->jobData == Constants_JobStatus::STATUS_CANCELLED) {
         //this job has been archived
         $this->job_archived = true;
         $this->job_owner_email = $this->jobData['job_owner'];
     }
     if (self::$start_id == -1) {
         self::$start_id = $this->jobData['job_first_segment'];
     }
     //TODO: portare dentro il codice
     try {
         $tmp = $this->getEditLogData();
         $this->data = $tmp[0];
         $this->pagination = $tmp[2];
         foreach ($this->data as $i => $dataRow) {
             /**
              * @var $dataRow EditLog_EditLogSegmentClientStruct
              */
             $this->data[$i] = $dataRow->toArray();
         }
         $this->stats = $tmp[1];
         $proj = getProject($this->jobData['id_project']);
         $this->project_status = $proj[0];
         $__langStatsDao = new LanguageStats_LanguageStatsDAO(Database::obtain());
         $maxDate = $__langStatsDao->getLastDate();
         $languageSearchObj = new LanguageStats_LanguageStatsStruct();
         $languageSearchObj->date = $maxDate;
         $languageSearchObj->source = $this->data[0]['job_source'];
         $languageSearchObj->target = $this->data[0]['job_target'];
         $this->languageStatsData = $__langStatsDao->read($languageSearchObj);
         $this->languageStatsData = $this->languageStatsData[0];
     } catch (Exception $exn) {
         if ($exn->getCode() == -1) {
             $this->jobEmpty = true;
         }
     }
 }
Esempio n. 9
0
function getProjectsContent($path)
{
    global $title;
    include 'blog.php';
    $action = array_shift($path);
    if ($action == "") {
        $title = "Projects" . $title;
        $content = '<h1>Projects</h1><p>Below is a list of personal (and maybe some group) projects that I thought deserved their own page. Feel free to contact me (see the footer) if you\'de like to know more about a certain project or endeavor.</p>';
        $content .= '<p class="subtitle">The following projects are listed in order of their most recent blog post activity.</p>';
        foreach (fetchProjects() as $project) {
            $content .= getProjectSummary($project);
        }
        return $content;
    } else {
        $project = fetchProject($action);
        if ($project == null) {
            return get404();
        } else {
            $title = $project['name'] . " (Project)" . $title;
            return getProject($project);
        }
    }
    return "<h1>Projects</h1>";
}
Esempio n. 10
0
 require 'lib.php';
 require_once 'database.ini';
 //If project id is a number
 if (is_numeric($project_id_input)) {
     //Get all of the stories, epics and attachments from pivotal API
     $raw_data = getStories(PT_TOKEN, $project_id_input);
     $epics_raw_data = getEpics(PT_TOKEN, $project_id_input);
     $attachments_raw_data = getAttachments(PT_TOKEN, $project_id_input);
     //if the pivotal story contains a field named 'error' (leads to error message)
     if (!isset($raw_data["error"]) || !isset($epics_raw_data["error"]) || !isset($attachments_raw_data["error"])) {
         $connection = connectToDb();
         $history_id_check = getHistoryId($connection, $project_id_input);
         //If the project already exists, perform update
         if ($history_id_check == NULL) {
             //Get project name
             $project_data = getProject(PT_TOKEN, $project_id_input);
             if ($connection == true) {
                 try {
                     //Make an entry in the history table
                     insertIntoHistory($connection, $project_data["id"], $project_data["name"]);
                     $latest_history_sql = 'SELECT MAX(history.id) FROM history;';
                     //Send the sql command
                     $latest_history_id = $connection->query($latest_history_sql);
                     //Get the data from the PDO object
                     $latest_history_id = $latest_history_id->fetch(PDO::FETCH_ASSOC);
                     //Insert data into the database
                     $history_id = $latest_history_id["MAX(history.id)"];
                     insertDataIntoDb($raw_data, $connection, $project_data["name"], $latest_history_id["MAX(history.id)"]);
                     echo '<div class="row text-center h2 alert alert-success" role="alert">' . htmlspecialchars($project_data["name"]) . ' added to the database!</div>';
                     //Inserting into the epics table
                     insertEpicDataIntoDb($epics_raw_data, $connection, $latest_history_id["MAX(history.id)"]);
Esempio n. 11
0
function common_projektneStrane()
{
    //debug mod aktivan
    global $userid, $user_nastavnik, $user_student, $conf_files_path, $user_siteadmin;
    $predmet = intval($_REQUEST['predmet']);
    $ag = intval($_REQUEST['ag']);
    $projekat = intval($_REQUEST['projekat']);
    $action = $_REQUEST['action'];
    //for project page only:
    $section = $_REQUEST['section'];
    $subaction = $_REQUEST['subaction'];
    $id = intval($_REQUEST['id']);
    //editing links, rss....
    if ($user_student && !$user_siteadmin) {
        $actualProject = getActualProjectForUserInPredmet($userid, $predmet, $ag);
        if ($actualProject[id] != $projekat) {
            //user is not in this project in this predmet...hijack attempt?
            zamgerlog("projektne strane: korisnik nije na projektu {$projekat} (pp{$predmet}, ag{$ag})", 3);
            zamgerlog2("nije na projektu", $projekat);
            return;
        }
    }
    $params = getPredmetParams($predmet, $ag);
    $project = getProject($projekat);
    $members = fetchProjectMembers($project[id]);
    if ($params[zakljucani_projekti] == 0) {
        zamgerlog("projektne strane: jos nisu otvorene! (pp{$predmet}, ag{$ag})", 3);
        zamgerlog2("svi projekti su jos otkljucani", $predmet, $ag);
        return;
    }
    if ($user_student && !$user_siteadmin) {
        $linkPrefix = "?sta=student/projekti&akcija=projektnastranica&projekat={$projekat}&predmet={$predmet}&ag={$ag}";
    } elseif ($user_nastavnik) {
        $linkPrefix = "?sta=nastavnik/projekti&akcija=projektna_stranica&projekat={$projekat}&predmet={$predmet}&ag={$ag}";
    } else {
        return;
    }
    ?>
  
     <h2><?php 
    echo filtered_output_string($project[naziv]);
    ?>
</h2>
     <div class="links">
            <ul class="clearfix">
            	<li><a href="<?php 
    echo $linkPrefix;
    ?>
">Početna strana</a></li>
            	<li><a href="<?php 
    echo $linkPrefix . "&section=info";
    ?>
">Informacije o projektu</a></li>
                <li><a href="<?php 
    echo $linkPrefix . "&section=links";
    ?>
">Korisni linkovi</a></li>
                <li><a href="<?php 
    echo $linkPrefix . "&section=rss";
    ?>
">RSS feedovi</a></li>
                <li><a href="<?php 
    echo $linkPrefix . "&section=bl";
    ?>
">Članci</a></li>
                <li><a href="<?php 
    echo $linkPrefix . "&section=file";
    ?>
">Fajlovi</a></li>
                <li class="last"><a href="<?php 
    echo $linkPrefix . "&section=bb";
    ?>
">Grupa za diskusiju</a></li>
            </ul>   
     </div>	
    <?php 
    if (!isset($section)) {
        //display project start page
        ?>
  	    <div id="mainWrapper" class="clearfix">
			<div id="leftBlocks">
                <div class="blockRow clearfix">
                     <div class="block" id="latestPosts">
                        <a class="blockTitle" href="<?php 
        echo $linkPrefix . "&section=bb";
        ?>
" title="Grupa za diskusiju">Najnoviji postovi</a>
                        <div class="items">
                        <?php 
        $latestPosts = fetchLatestPostsForProject($project[id], 4);
        foreach ($latestPosts as $post) {
            ?>
                            <div class="item">
                                <span class="date"><?php 
            echo date('d.m H:i  ', mysql2time($post[vrijeme]));
            ?>
</span>
                                <a href="<?php 
            echo $linkPrefix . "&section=bb&subaction=view&tid={$post['tema']}#p{$post['id']}";
            ?>
" title="<?php 
            echo $post['naslov'];
            ?>
" target="_blank"><?php 
            $maxLen = 100;
            $len = strlen($post[naslov]);
            echo filtered_output_string(substr($post['naslov'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</a>
                                <span class="author"> - <?php 
            echo filtered_output_string($post[osoba][prezime] . ' ' . $post[osoba][ime]);
            ?>
</span>
                                <div class="desc"><?php 
            $maxLen = 200;
            $len = strlen($post[tekst]);
            echo filtered_output_string(substr($post['tekst'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</div><!--desc-->
                            </div><!--item-->	
                        <?php 
        }
        ?>
                        
                        
                        </div><!--items-->
                    </div><!--block-->
                    
                    
                </div><!--blockRow-->
                
                <div class="blockRow clearfix">
                     <div class="block" id="latestArticles">
                        <a class="blockTitle" href="<?php 
        echo $linkPrefix . "&section=bl";
        ?>
" title="Članci">Najnoviji članci</a>
                        <div class="items">
                        <?php 
        $latestArticles = fetchArticlesForProject($project[id], 0, 4);
        foreach ($latestArticles as $article) {
            $author = getAuthorOfArticle($article[id]);
            ?>
                            <div class="item">
                                <span class="date"><?php 
            echo date('d.m H:i  ', mysql2time($article[vrijeme]));
            ?>
</span>
                                <a href="<?php 
            echo $linkPrefix . "&section=bl&subaction=view&id={$article['id']}";
            ?>
" title="<?php 
            echo $article['naslov'];
            ?>
" target="_blank"><?php 
            $maxLen = 100;
            $len = strlen($article[naslov]);
            echo filtered_output_string(substr($article['naslov'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</a>
                                <span class="author"> - <?php 
            echo filtered_output_string($author[prezime] . ' ' . $author[ime]);
            ?>
</span>
                                <div class="desc"><?php 
            $maxLen = 200;
            $len = strlen($article[tekst]);
            echo filtered_output_string(substr($article['tekst'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</div><!--desc-->
                            </div><!--item-->	
                        <?php 
        }
        ?>
                        
                        
                        </div><!--items-->
                    </div><!--block-->
                    
                    
                </div><!--blockRow-->

            </div><!--leftBlocks-->
            <div id="rightBlocks" class="clearfix">
            	<div class="blockRow">
                    <div class="block" id="latestLinks">
                        <a class="blockTitle" href="<?php 
        echo $linkPrefix . "&section=links";
        ?>
" title="Korisni linkovi">Korisni linkovi</a>
                        <div class="items">
                       
        <?php 
        //get latest entries
        $links = fetchLinksForProject($project[id], 0, 4);
        foreach ($links as $link) {
            $url = $link[url];
            $scheme = parse_url($url);
            $scheme = $scheme['scheme'];
            if ($scheme == '') {
                //only www part
                $url = 'http://' . $url;
            }
            $maxLen = 150;
            $len = strlen($link[naziv]);
            if ($len > $maxLen) {
                echo '...';
            }
            $author = getAuthorOfLink($link[id]);
            ?>
                            <div class="item">
                                <a href="<?php 
            echo $url;
            ?>
" title="<?php 
            echo $link['naziv'];
            ?>
" target="_blank"><?php 
            $maxLen = 35;
            $len = strlen($link[naziv]);
            echo filtered_output_string(substr($link['naziv'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</a>
                                <span class="author"> - <?php 
            echo filtered_output_string($author[prezime] . ' ' . $author[ime]);
            ?>
</span>
        <?php 
            if ($link[opis] != '') {
                ?>
                   
                                <div class="desc"><?php 
                $maxLen = 200;
                $len = strlen($link[opis]);
                echo filtered_output_string(substr($link['opis'], 0, $maxLen - 1));
                if ($len > $maxLen) {
                    echo '...';
                }
                ?>
</div><!--desc-->
        <?php 
            }
            ?>
                 
                            </div><!--item-->   		
        <?php 
        }
        //foreach
        ?>
     
                        </div><!--items-->   
                    </div><!--block--> 
				</div><!--blockRow-->            
            	<div class="blockRow">
                    <div class="block" id="latestRSS">
                        <a class="blockTitle" href="<?php 
        echo $linkPrefix . "&section=rss";
        ?>
" title="RSS feedovi">RSS feedovi</a>
                        <div class="items">
                       
        <?php 
        //get latest entries
        $links = fetchRSSForProject($project[id], 0, 4);
        foreach ($links as $link) {
            $url = $link[url];
            $scheme = parse_url($url);
            $scheme = $scheme['scheme'];
            if ($scheme == '') {
                //only www part
                $url = 'http://' . $url;
            }
            $maxLen = 150;
            $len = strlen($link[naziv]);
            if ($len > $maxLen) {
                echo '...';
            }
            $author = getAuthorOfRSS($link[id]);
            ?>
                            <div class="item">
                                <a href="<?php 
            echo $url;
            ?>
" title="<?php 
            echo $link['naziv'];
            ?>
" target="_blank"><?php 
            $maxLen = 35;
            $len = strlen($link[naziv]);
            echo filtered_output_string(substr($link['naziv'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</a>
                                <span class="author"> - <?php 
            echo filtered_output_string($author[prezime] . ' ' . $author[ime]);
            ?>
</span>
        <?php 
            if ($link[opis] != '') {
                ?>
                   
                                <div class="desc"><?php 
                $maxLen = 200;
                $len = strlen($link[opis]);
                echo filtered_output_string(substr($link['opis'], 0, $maxLen - 1));
                if ($len > $maxLen) {
                    echo '...';
                }
                ?>
</div><!--desc-->
        <?php 
            }
            ?>
                 
                            </div><!--item-->   		
        <?php 
        }
        //foreach
        ?>
     
                        </div><!--items-->   
                    </div><!--block-->
                </div><!--blockRow-->  
            	<div class="blockRow">
                    <div class="block" id="latestFiles">
                        <a class="blockTitle" href="<?php 
        echo $linkPrefix . "&section=file";
        ?>
" title="Fajlovi">Fajlovi</a>
                        <div class="items">
                       
        <?php 
        //get latest entries
        $files = fetchFilesForProjectLatestRevisions($project[id], 0, 4);
        foreach ($files as $file) {
            $author = getAuthorOfFile($file[id]);
            ?>
                            <div class="item">
                                <span class="date"><?php 
            echo date('d.m H:i  ', mysql2time($file[vrijeme]));
            ?>
</span>
                                <a href="<?php 
            echo "index.php?sta=common/attachment&tip=projekat&projekat={$projekat}&id={$file['id']}";
            ?>
" title="<?php 
            echo $file['filename'];
            ?>
" ><?php 
            $maxLen = 100;
            $len = strlen($file[filename]);
            echo filtered_output_string(substr($file['filename'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</a>
                                <span class="author"> - <?php 
            echo filtered_output_string($author[prezime] . ' ' . $author[ime]);
            ?>
</span>
                               
                            </div><!--item-->	
        <?php 
        }
        //foreach
        ?>
     
                        </div><!--items-->   
                    </div><!--block-->
                </div><!--blockRow-->            
                          
            </div><!--rightBlocks-->
        </div><!--mainWrapper-->    
    <?php 
    } else {
        if ($section == 'info') {
            // display project info
            ?>
    	<h2>Informacije o projektu</h2>

<table class="projekti" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <th width="200" align="left" valign="top" scope="row">Naziv</th>
    <td width="490" align="left" valign="top"><?php 
            echo filtered_output_string($project['naziv']);
            ?>
</td>
  </tr>
  <tr>
    <th width="200" align="left" valign="top" scope="row">Prijavljeni studenti</th>
    <td width="490" align="left" valign="top">
    	<?php 
            if (empty($members)) {
                echo 'Nema prijavljenih studenata.';
            } else {
                ?>
        <ul>
        <?php 
                foreach ($members as $member) {
                    ?>
        	<li><?php 
                    echo filtered_output_string($member[prezime] . ' ' . $member[ime] . ', ' . $member[brindexa]);
                    ?>
</li>
		<?php 
                }
                ?>
        </ul>	
		<?php 
            }
            ?>
    
    </td>
  </tr>
  <tr>
    <th width="200" align="left" valign="top" scope="row">Opis</th>
    <td width="490" align="left" valign="top"><?php 
            echo filtered_output_string($project['opis']);
            ?>
</td>
  </tr>
</table>
    
     
    <?php 
        } elseif ($section == 'links') {
            //links management
            $linkPrefix .= '&section=links';
            ?>
<h2>Korisni linkovi</h2>
 <div class="links" id="link">
    <ul class="clearfix">
        <li><a href="<?php 
            echo $linkPrefix;
            ?>
">Lista linkova</a></li>
        <li><a href="<?php 
            echo $linkPrefix . "&subaction=add";
            ?>
">Novi link</a></li>
    </ul>   
</div>	

    <?php 
            if (!isset($subaction)) {
                $rowsPerPage = 20;
                $pageNum = 1;
                if (isset($_REQUEST['page'])) {
                    $pageNum = $_REQUEST['page'];
                }
                // counting the offset
                $offset = ($pageNum - 1) * $rowsPerPage;
                //display links for this project, with links to edit and delete
                $links = fetchLinksForProject($project[id], $offset, $rowsPerPage);
                foreach ($links as $link) {
                    if (isUserAuthorOfLink($link[id], $userid)) {
                        ?>
<div class="links" id="link">
    <ul class="clearfix">
        <li><a href="<?php 
                        echo $linkPrefix . "&subaction=edit&id={$link['id']}";
                        ?>
">Uredi</a></li>
        <li><a href="<?php 
                        echo $linkPrefix . "&subaction=del&id={$link['id']}";
                        ?>
">Briši</a></li>
    </ul>   
</div>	
	<?php 
                    }
                    //if user is author of this item
                    ?>

<table class="linkovi" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <th width="200" align="left" valign="top" scope="row">URL</th>
    <td width="490" align="left" valign="top">
    <?php 
                    $url = $link[url];
                    $scheme = parse_url($url);
                    $scheme = $scheme['scheme'];
                    if ($scheme == '') {
                        //only www part
                        $url = 'http://' . $url;
                    }
                    ?>
<a href="<?php 
                    echo $url;
                    ?>
" title="<?php 
                    echo $link['naziv'];
                    ?>
" target="_blank"><?php 
                    echo filtered_output_string($link[naziv]);
                    ?>
</a>   
    </td>
  </tr>
 <?php 
                    if ($link['opis'] != '') {
                        ?>
  <tr>
    <th width="200" align="left" valign="top" scope="row">Opis</th>
    <td width="490" align="left" valign="top"><?php 
                        echo filtered_output_string($link['opis']);
                        ?>
</td>
  </tr>
  <?php 
                    }
                    //opis
                    ?>
</table>
    <?php 
                }
                //foreach link
                $numrows = getCountLinksForProject($project[id]);
                $maxPage = ceil($numrows / $rowsPerPage);
                $self = $linkPrefix;
                if ($maxPage > 0) {
                    echo "<span class=\"newsPages\">";
                    if ($pageNum > 1) {
                        $page = $pageNum - 1;
                        $prev = " <a href=\"{$self}&page={$page}\">[Prethodna]</a> ";
                        $first = " <a href=\"{$self}&page=1\">[Prva]</a> ";
                    }
                    if ($pageNum < $maxPage) {
                        $page = $pageNum + 1;
                        $next = " <a href=\"{$self}&page={$page}\">[Sljedeća]</a> ";
                        $last = " <a href=\"{$self}&page={$maxPage}\">[Zadnja]</a> ";
                    }
                    echo $first . $prev . " Strana <strong>{$pageNum}</strong> od ukupno <strong>{$maxPage}</strong> " . $next . $last;
                    echo "</span>";
                    //newsPages span
                }
            } else {
                if ($subaction == 'add') {
                    if (!isset($_REQUEST['submit'])) {
                        ?>
						 <h3>Novi link</h3>
				<?php 
                        print genform("POST", "addForm");
                        ?>
						
						<div id="formDiv">
							Polja sa * su obavezna. <br />
							
                            <div class="row">
								<span class="label">Naziv *</span>
								<span class="formw"><input name="naziv" type="text" id="naziv" size="70" /></span> 
							</div>
	
							<div class="row">
								<span class="label">URL *</span>
								<span class="formw"><input name="url" type="text" id="url" size="70" /></span> 
							</div>
							<div class="row">
								<span class="label">Opis</span>
								<span class="formw"><textarea name="opis" cols="60" rows="15" wrap="physical" id="opis"></textarea></span>
							</div> 
							
							<div class="row">	
								<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
							</div>
						
						</div><!--formDiv-->
						</form>
							
	<?php 
                    } else {
                        $errorText = formProcess_links('add');
                        if ($errorText == '') {
                            nicemessage('Novi link uspješno dodan.');
                            zamgerlog("dodao link na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("dodao link na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'edit') {
                    if (!isUserAuthorOfLink($id, $userid)) {
                        return;
                    }
                    //edit item
                    if (!isset($_REQUEST['submit'])) {
                        $entry = getLink($id);
                        ?>
					 <h3>Uredi link</h3>
				<?php 
                        print genform("POST", "editForm");
                        ?>
                	
					<div id="formDiv">
						Polja sa * su obavezna. <br />
						
						<div class="row">
							<span class="label">Naziv *</span>
							<span class="formw"><input name="naziv" type="text" id="naziv" size="70" value="<?php 
                        echo $entry['naziv'];
                        ?>
" /></span> 
						</div>

						<div class="row">
							<span class="label">URL *</span>
							<span class="formw"><input name="url" type="text" id="url" size="70" value="<?php 
                        echo $entry['url'];
                        ?>
" /></span> 
						</div>
						<div class="row">
							<span class="label">Opis</span>
							<span class="formw"><textarea name="opis" cols="60" rows="15" wrap="physical" id="opis"><?php 
                        echo $entry['opis'];
                        ?>
</textarea></span>
						</div> 
						
						<div class="row">	
							<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
						</div>
					
					</div><!--formDiv-->
					</form>
							
						
		<?php 
                    } else {
                        $errorText = formProcess_links('edit');
                        if ($errorText == '') {
                            nicemessage('Uspješno ste uredili link.');
                            zamgerlog("uredio link na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("uredio link na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            //an error occured trying to process the form
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'del') {
                    if (!isUserAuthorOfLink($id, $userid)) {
                        return;
                    }
                    //delete item
                    if (isset($id) && is_int($id) && $id > 0) {
                        if (!isset($_REQUEST['c'])) {
                            echo "Da li ste sigurni da zelite obrisati ovaj link?<br />";
                            echo '<a href="' . $linkPrefix . '&subaction=del&id=' . $id . '&c=true">Da</a> | <a href="' . $linkPrefix . '">Odustani</a>';
                        } else {
                            if ($_REQUEST['c'] == 'true') {
                                //delete the record
                                if (deleteLink($id)) {
                                    nicemessage('Uspješno ste obrisali link.');
                                    zamgerlog("obrisao link na projektu {$projekat} (pp{$predmet})", 2);
                                    zamgerlog2("obrisao link na projektu", $projekat);
                                    $link = $linkPrefix;
                                } else {
                                    niceerror('Doslo je do greske prilikom brisanja linka. Molimo kontaktirajte administratora.');
                                    $link = "javascript:history.back();";
                                }
                                nicemessage('<a href="' . $link . '">Povratak.</a>');
                            }
                        }
                        //else isset c get parameter
                    }
                    //id is okay
                }
                //subaction == del
            }
            //subaction set
        } elseif ($section == 'rss') {
            //links management
            $linkPrefix .= '&section=rss';
            ?>
<h2>RSS feedovi</h2>
 <div class="links clearfix" id="rss">
    <ul>
        <li><a href="<?php 
            echo $linkPrefix;
            ?>
">Lista RSS feedova</a></li>
        <li><a href="<?php 
            echo $linkPrefix . "&subaction=add";
            ?>
">Novi RSS feed</a></li>
    </ul>   
</div>	

    <?php 
            if (!isset($subaction)) {
                $rowsPerPage = 20;
                $pageNum = 1;
                if (isset($_REQUEST['page'])) {
                    $pageNum = $_REQUEST['page'];
                }
                // counting the offset
                $offset = ($pageNum - 1) * $rowsPerPage;
                //display links for this project, with links to edit and delete
                $feeds = fetchRSSForProject($project[id], $offset, $rowsPerPage);
                foreach ($feeds as $link) {
                    if (isUserAuthorOfRSS($link[id], $userid)) {
                        ?>
<div class="links clearfix" id="rss">
    <ul>
        <li><a href="<?php 
                        echo $linkPrefix . "&subaction=edit&id={$link['id']}";
                        ?>
">Uredi</a></li>
        <li><a href="<?php 
                        echo $linkPrefix . "&subaction=del&id={$link['id']}";
                        ?>
">Briši</a></li>
    </ul>   
</div>	
	<?php 
                    }
                    //if user is author of this item
                    ?>
<table class="rss" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <th width="200" align="left" valign="top" scope="row">URL</th>
    <td width="490" align="left" valign="top">
    <?php 
                    $url = $link[url];
                    $scheme = parse_url($url);
                    $scheme = $scheme['scheme'];
                    if ($scheme == '') {
                        //only www part
                        $url = 'http://' . $url;
                    }
                    ?>
<a href="<?php 
                    echo $url;
                    ?>
" title="<?php 
                    echo $link['naziv'];
                    ?>
" target="_blank"><?php 
                    echo filtered_output_string($link[naziv]);
                    ?>
</a>   
    </td>
  </tr>
 <?php 
                    if ($link['opis'] != '') {
                        ?>
  <tr>
    <th width="200" align="left" valign="top" scope="row">Opis</th>
    <td width="490" align="left" valign="top"><?php 
                        echo filtered_output_string($link['opis']);
                        ?>
</td>
  </tr>
 <?php 
                    }
                    //opis
                    ?>

 <tr>
 	<td colspan="2">
 	<?php 
                    global $conf_files_path;
                    //Ukljucimo koristenje globalne varijable koja pokazuje na privatni direktorij sa datotekama koji nije dostupan preko weba
                    $hashfromURL = hash("md5", $url);
                    $cachefile = "";
                    //Provjeri postojanost $conf_files_path/cache/rss direktorija
                    if (file_exists($conf_files_path . "/cache")) {
                        if (!file_exists($conf_files_path . "/cache/rss")) {
                            mkdir($conf_files_path . "/cache/rss");
                        }
                        $cachefile = $conf_files_path . "/cache/rss/" . $hashfromURL . ".html";
                    } else {
                        if (mkdir($conf_files_path . "/cache")) {
                            if (mkdir($conf_files_path . "/cache/rss/")) {
                                $cachefile = $conf_files_path . "/cache/rss/" . $hashfromURL . ".html";
                            }
                        }
                    }
                    $cachetime = 5 * 60;
                    //5 minuta TODO:Pri deployment-u povecati na sat-dva.
                    //Serviraj is kesha ako je mladji od $cachetime
                    if (file_exists($cachefile) && time() - filemtime($cachefile) < $cachetime) {
                        include $cachefile;
                        print "RSS ucitan iz kesha!";
                    } else {
                        //Ucitaj RSS ponovo
                        $XMLfilename = $url;
                        //Pocni dump buffera
                        ob_start();
                        include "lib/rss2html.php";
                        //HTML parsiran sadrzaj RSS-a
                        //Otvori kesh fajl za pisanje
                        $fp = fopen($cachefile, 'w');
                        //Sacuvaj sadrzaj izlaznog buffer-a u fajl
                        fwrite($fp, ob_get_contents());
                        //zatvori fajl
                        fclose($fp);
                        //Posalji izlaz na browser
                        ob_end_flush();
                        print "RSS osvjezen - feed ponovo ucitan!";
                    }
                    ?>
 	</td>
</tr>
 
</table>
    <?php 
                }
                //foreach link
                $numrows = getCountRSSForProject($project[id]);
                $maxPage = ceil($numrows / $rowsPerPage);
                $self = $linkPrefix;
                if ($maxPage > 0) {
                    echo "<span class=\"newsPages\">";
                    if ($pageNum > 1) {
                        $page = $pageNum - 1;
                        $prev = " <a href=\"{$self}&page={$page}\">[Prethodna]</a> ";
                        $first = " <a href=\"{$self}&page=1\">[Prva]</a> ";
                    }
                    if ($pageNum < $maxPage) {
                        $page = $pageNum + 1;
                        $next = " <a href=\"{$self}&page={$page}\">[Sljedeća]</a> ";
                        $last = " <a href=\"{$self}&page={$maxPage}\">[Zadnja]</a> ";
                    }
                    echo $first . $prev . " Strana <strong>{$pageNum}</strong> od ukupno <strong>{$maxPage}</strong> " . $next . $last;
                    echo "</span>";
                    //newsPages span
                }
            } else {
                if ($subaction == 'add') {
                    if (!isset($_REQUEST['submit'])) {
                        ?>
						 <h3>Novi RSS feed</h3>
				<?php 
                        print genform("POST", "addForm");
                        ?>
						
						<div id="formDiv">
							Polja sa * su obavezna. <br />
							
                            <div class="row">
								<span class="label">Naziv *</span>
								<span class="formw"><input name="naziv" type="text" id="naziv" size="70" /></span> 
							</div>
	
							<div class="row">
								<span class="label">URL *</span>
								<span class="formw"><input name="url" type="text" id="url" size="70" /></span> 
							</div>
							<div class="row">
								<span class="label">Opis</span>
								<span class="formw"><textarea name="opis" cols="60" rows="15" wrap="physical" id="opis"></textarea></span>
							</div> 
							
							<div class="row">	
								<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
							</div>
						
						</div><!--formDiv-->
						</form>
							
	<?php 
                    } else {
                        $errorText = formProcess_rss('add');
                        if ($errorText == '') {
                            nicemessage('Novi RSS feed uspješno dodan.');
                            zamgerlog("dodao novi rss feed na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("dodao rss feed na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'edit') {
                    if (!isUserAuthorOfRSS($id, $userid)) {
                        return;
                    }
                    //edit item
                    if (!isset($_REQUEST['submit'])) {
                        $entry = getRSS($id);
                        ?>
					 <h3>Uredi RSS feed</h3>
				<?php 
                        print genform("POST", "editForm");
                        ?>
                	
					<div id="formDiv">
						Polja sa * su obavezna. <br />
						
						<div class="row">
							<span class="label">Naziv *</span>
							<span class="formw"><input name="naziv" type="text" id="naziv" size="70" value="<?php 
                        echo $entry['naziv'];
                        ?>
" /></span> 
						</div>

						<div class="row">
							<span class="label">URL *</span>
							<span class="formw"><input name="url" type="text" id="url" size="70" value="<?php 
                        echo $entry['url'];
                        ?>
" /></span> 
						</div>
						<div class="row">
							<span class="label">Opis</span>
							<span class="formw"><textarea name="opis" cols="60" rows="15" wrap="physical" id="opis"><?php 
                        echo $entry['opis'];
                        ?>
</textarea></span>
						</div> 
						
						<div class="row">	
							<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
						</div>
					
					</div><!--formDiv-->
					</form>
							
						
		<?php 
                    } else {
                        $errorText = formProcess_rss('edit');
                        if ($errorText == '') {
                            nicemessage('Uspješno ste uredili RSS feed.');
                            zamgerlog("uredio rss feed na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("uredio rss feed na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            //an error occured trying to process the form
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'del') {
                    if (!isUserAuthorOfRSS($id, $userid)) {
                        return;
                    }
                    //delete item
                    if (isset($id) && is_int($id) && $id > 0) {
                        if (!isset($_REQUEST['c'])) {
                            echo "Da li ste sigurni da zelite obrisati ovaj RSS feed?<br />";
                            echo '<a href="' . $linkPrefix . '&subaction=del&id=' . $id . '&c=true">Da</a> | <a href="' . $linkPrefix . '">Odustani</a>';
                        } else {
                            if ($_REQUEST['c'] == 'true') {
                                //delete the record
                                if (deleteRSS($id)) {
                                    nicemessage('Uspješno ste obrisali RSS feed.');
                                    zamgerlog("obrisao rss feed na projektu {$projekat} (pp{$predmet})", 2);
                                    zamgerlog2("obrisao rss feed na projektu", $projekat);
                                    $link = $linkPrefix;
                                } else {
                                    niceerror('Doslo je do greske prilikom brisanja RSS feeda. Molimo kontaktirajte administratora.');
                                    $link = "javascript:history.back();";
                                }
                                nicemessage('<a href="' . $link . '">Povratak.</a>');
                            }
                        }
                        //else isset c get parameter
                    }
                    //id is okay
                }
                //subaction == del
            }
            //subaction set
        } elseif ($section == 'bl') {
            //links management
            $linkPrefix .= '&section=bl';
            ?>
<h2>Članci</h2>
 <div class="links clearfix" id="bl">
    <ul>
        <li><a href="<?php 
            echo $linkPrefix;
            ?>
">Lista članaka</a></li>
        <li><a href="<?php 
            echo $linkPrefix . "&subaction=add";
            ?>
">Novi članak</a></li>
    </ul>   
</div>	
    <?php 
            if (!isset($subaction)) {
                $rowsPerPage = 20;
                $pageNum = 1;
                if (isset($_REQUEST['page'])) {
                    $pageNum = $_REQUEST['page'];
                }
                // counting the offset
                $offset = ($pageNum - 1) * $rowsPerPage;
                $articles = fetchArticlesForProject($project[id], $offset, $rowsPerPage);
                foreach ($articles as $article) {
                    ?>
    
   <div class="article_summary clearfix">
   	<?php 
                    if (!empty($article[slika])) {
                        ?>
    	<div class="imgCont">
        	<a href="<?php 
                        echo "index.php?sta=common/articleImageDownload&projekat={$projekat}&predmet={$predmet}&ag={$ag}&a={$article['id']}&u={$article['osoba']}&i={$article['slika']}";
                        ?>
" target="_blank">
    			<img src="<?php 
                        echo "index.php?sta=common/articleImageDownload&projekat={$projekat}&predmet={$predmet}&ag={$ag}&a={$article['id']}&u={$article['osoba']}&i={$article['slika']}";
                        ?>
" />
        	</a>
        </div>
	<?php 
                    }
                    ?>
    	<div class="contentCont" <?php 
                    if (empty($article[slika])) {
                        echo 'style="margin-left: 0;"';
                    }
                    ?>
>
            <h1>
                <a href="<?php 
                    echo $linkPrefix . "&subaction=view&id={$article['id']}";
                    ?>
" 
                title="<?php 
                    echo $article['naslov'];
                    ?>
"><?php 
                    echo filtered_output_string($article['naslov']);
                    ?>
                </a>
            </h1>
            <div class="details">
        <?php 
                    $author = getAuthorOfArticle($article[id]);
                    ?>
                Autor: <?php 
                    echo filtered_output_string($author[ime] . ' ' . $author[prezime]);
                    ?>
<br />
                Datum: <?php 
                    echo date('d.m.Y', strtotime($article[vrijeme]));
                    ?>
            </div><!--details-->
   <?php 
                    if (isUserAuthorOfArticle($article[id], $userid) == true) {
                        ?>
	
            <div class="buttons">
                <a href="<?php 
                        echo $linkPrefix . "&subaction=edit&id={$article['id']}";
                        ?>
" title="Uredi ovaj članak">Uredi</a> | 
                <a href="<?php 
                        echo $linkPrefix . "&subaction=del&id={$article['id']}";
                        ?>
" title="Briši ovaj članak">Briši</a>
            </div><!--buttons-->	
	<?php 
                    }
                    ?>

<div class="text">
                                <?php 
                    $len = strlen($article[tekst]);
                    if (!empty($article[slika])) {
                        $maxLen = 400;
                    } else {
                        $maxLen = 800;
                    }
                    echo filtered_output_string(substr($article['tekst'], 0, $maxLen - 1));
                    if ($len > $maxLen) {
                        echo '...';
                    }
                    ?>
            </div><!--text-->
        </div><!--contentCont-->
   </div><!--article_summary--> 
    
    <?php 
                }
                //foreach article
                $numrows = getCountArticlesForProject($project[id]);
                $maxPage = ceil($numrows / $rowsPerPage);
                $self = $linkPrefix;
                if ($maxPage > 0) {
                    echo "<span class=\"newsPages\">";
                    if ($pageNum > 1) {
                        $page = $pageNum - 1;
                        $prev = " <a href=\"{$self}&page={$page}\">[Prethodna]</a> ";
                        $first = " <a href=\"{$self}&page=1\">[Prva]</a> ";
                    }
                    if ($pageNum < $maxPage) {
                        $page = $pageNum + 1;
                        $next = " <a href=\"{$self}&page={$page}\">[Sljedeća]</a> ";
                        $last = " <a href=\"{$self}&page={$maxPage}\">[Zadnja]</a> ";
                    }
                    echo $first . $prev . " Strana <strong>{$pageNum}</strong> od ukupno <strong>{$maxPage}</strong> " . $next . $last;
                    echo "</span>";
                    //newsPages span
                }
            } else {
                if ($subaction == 'view') {
                    $article = getArticle($id);
                    if (empty($article)) {
                        zamgerlog("projektne strane: nepostojeci clanak sa IDom {$id}, projekat {$projekat} (pp{$predmet}, ag{$ag})", 3);
                        zamgerlog2("nepostojeci clanak na projektu", $id, $projekat);
                        return;
                    }
                    ?>
		
	   <div class="article_full clearfix">
			<div class="contentCont clearfix">
				<h1>
					<a href="<?php 
                    echo $linkPrefix . "?subaction=view&id={$article['id']}";
                    ?>
" 
					title="<?php 
                    echo $article['naslov'];
                    ?>
"><?php 
                    echo filtered_output_string($article['naslov']);
                    ?>
					</a>
				</h1>
				<div class="details">
			<?php 
                    $author = getAuthorOfArticle($article[id]);
                    ?>
					Autor: <?php 
                    echo filtered_output_string($author[ime] . ' ' . $author[prezime]);
                    ?>
<br />
					Datum: <?php 
                    echo date('d.m.Y', strtotime($article[vrijeme]));
                    ?>
				</div><!--details-->
	   <?php 
                    if (isUserAuthorOfArticle($article[id], $userid) == true) {
                        ?>
	
				<div class="buttons">
					<a href="<?php 
                        echo $linkPrefix . "&subaction=edit&id={$article['id']}";
                        ?>
" title="Uredi ovaj članak">Uredi</a> | 
					<a href="<?php 
                        echo $linkPrefix . "&subaction=del&id={$article['id']}";
                        ?>
" title="Briši ovaj članak">Briši</a>
				</div><!--buttons-->	
		<?php 
                    }
                    ?>
		<?php 
                    if (!empty($article[slika])) {
                        ?>
			<div class="imgCont">
            	<a href="<?php 
                        echo "index.php?sta=common/articleImageDownload&projekat={$projekat}&predmet={$predmet}&ag={$ag}&a={$article['id']}&u={$article['osoba']}&i={$article['slika']}";
                        ?>
" target="_blank">
            		<img src="<?php 
                        echo "index.php?sta=common/articleImageDownload&projekat={$projekat}&predmet={$predmet}&ag={$ag}&a={$article['id']}&u={$article['osoba']}&i={$article['slika']}";
                        ?>
" />
                </a>     
            </div>
	  <?php 
                    }
                    ?>
				<div class="text"><?php 
                    echo filtered_output_string($article['tekst']);
                    ?>
</div><!--text-->
			</div><!--contentCont-->
	   </div><!--article_full--> 
       <a id="backLink" href="<?php 
                    echo $linkPrefix;
                    ?>
">Povratak na listu članaka</a>

		
		<?php 
                } elseif ($subaction == 'add') {
                    if (!isset($_REQUEST['submit'])) {
                        ?>
	
    		
				 <h3>Novi članak</h3>
				<?php 
                        print genform("POST", "addForm\" enctype=\"multipart/form-data\" ");
                        ?>
                
                <div id="formDiv">
                	Polja sa * su obavezna. <br />
                
                	<div class="row">
                        <span class="label">Naslov *</span>
                        <span class="formw"><input name="naslov" type="text" id="naslov" size="70" /></span> 
                  	</div>
                    <div class="row">
                        <span class="label">Tekst</span>
                        <span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"></textarea></span>
                   	</div> 
                   
                    <div class="row">
                        <span class="label">Slika</span>
                        <span class="formw">
                            <input name="image" type="file" id="image" size="60" />
                        </span><br /><br />
                        Dozvoljeni tipovi slike: jpg, jpeg, gif, png <br />
                    </div> 
                    
                    <div class="row">	
                      	<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
                    </div>
                
                </div><!--formDiv-->
               
                </form>
                
			
	<?php 
                    } else {
                        $errorText = formProcess_bl('add');
                        if ($errorText == '') {
                            nicemessage('Novi članak uspješno dodan.');
                            zamgerlog("dodao novi clanak na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("dodao clanak na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'edit') {
                    if (!isUserAuthorOfArticle($id, $userid)) {
                        return;
                    }
                    //edit item
                    if (!isset($_REQUEST['submit'])) {
                        $entry = getArticle($id);
                        ?>
				 <h3>Uredi članak</h3>
				<?php 
                        print genform("POST", "editForm\" enctype=\"multipart/form-data\" ");
                        ?>
				
				<div id="formDiv">
					Polja sa * su obavezna. <br />
				
					<div class="row">
						<span class="label">Naslov *</span>
						<span class="formw"><input name="naslov" type="text" id="naslov" size="70" value="<?php 
                        echo $entry['naslov'];
                        ?>
" /></span> 
					</div>
					<div class="row">
						<span class="label">Tekst</span>
						<span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"><?php 
                        echo $entry['tekst'];
                        ?>
</textarea></span>
					</div> 

<?php 
                        if ($entry['slika'] != '') {
                            //if the image exists, display it
                            ?>
				   <div class="row">
						<span class="label">Trenutna slika</span>
						<span class="formw"><img src="<?php 
                            echo "index.php?sta=common/articleImageDownload&projekat={$projekat}&predmet={$predmet}&ag={$ag}&a={$article['id']}&u={$entry['osoba']}&i={$entry['slika']}";
                            ?>
" />
						</span>
				   </div> 
				   
				   <div class="row">
						<span class="label">Briši sliku</span>
						<span class="formw"><input name="delete" type="checkbox" id="delete" value="delete" /></span>
				   </div> 
			   
<?php 
                        }
                        //if image is present
                        ?>
					<div class="row">
					  <span class="label"><?php 
                        if ($entry['slika'] != '') {
                            echo "ILI: Zamijeni sliku";
                        } else {
                            echo "Slika";
                        }
                        ?>
</span>
						<span class="formw">
							<input name="image" type="file" id="image" size="50" />
						</span><br /><br />
						Dozvoljeni tipovi slike: jpg, jpeg, gif, png <br />
					</div>                         
					
					<div class="row">	
						<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
					</div>
				
				</div><!--formDiv-->
				
				
				</form>
				
				
<?php 
                    } else {
                        $errorText = formProcess_bl('edit');
                        if ($errorText == '') {
                            nicemessage('Uspješno ste uredili članak.');
                            zamgerlog("uredio clanak na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("uredio clanak na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            //an error occured trying to process the form
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'del') {
                    //delete item
                    if (isset($id) && is_int($id) && $id > 0) {
                        if (isUserAuthorOfArticle($id, $userid) == false) {
                            return;
                        }
                        if (!isset($_REQUEST['c'])) {
                            echo "Da li ste sigurni da zelite obrisati ovaj članak? <br />";
                            echo '<a href="' . $linkPrefix . '&amp;subaction=del&amp;id=' . $id . '&amp;c=true">Da</a> | <a href="' . $linkPrefix . '">Odustani</a>';
                        } else {
                            if ($_REQUEST['c'] == 'true') {
                                //delete the record
                                if (deleteArticle($id)) {
                                    nicemessage('Uspješno ste obrisali članak.');
                                    zamgerlog("obrisao clanak na projektu {$projekat} (pp{$predmet})", 2);
                                    zamgerlog2("obrisao clanak na projektu", $projekat);
                                    $link = $linkPrefix;
                                } else {
                                    niceerror('Došlo je do greske prilikom brisanja članka. Molimo kontaktirajte administratora.');
                                    $link = "javascript:history.back();";
                                }
                                nicemessage('<a href="' . $link . '">Povratak.</a>');
                            }
                        }
                        //else isset c get parameter
                    }
                    //id is okay
                }
                //subaction == del
            }
            //subaction set
        } elseif ($section == 'file') {
            //files management
            $linkPrefix .= '&section=file';
            ?>
<h2>Fajlovi</h2>
 <div class="links clearfix" id="rss">
    <ul>
        <li><a href="<?php 
            echo $linkPrefix;
            ?>
">Lista fajlova</a></li>
        <li><a href="<?php 
            echo $linkPrefix . "&subaction=add";
            ?>
">Novi fajl</a></li>
    </ul>   
</div>	

    <?php 
            if (!isset($subaction)) {
                $rowsPerPage = 20;
                $pageNum = 1;
                if (isset($_REQUEST['page'])) {
                    $pageNum = $_REQUEST['page'];
                }
                // counting the offset
                $offset = ($pageNum - 1) * $rowsPerPage;
                //display files for this project, with links to edit and delete
                $files = fetchFilesForProjectAllRevisions($project[id], $offset, $rowsPerPage);
                ?>
<table class="files_table" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th scope="col" class="creation_date">Datum kreiranja</th>
    <th scope="col" class="author">Autor</th>
    <th scope="col" class="revision">Revizija</th>
    <th scope="col" class="name">Naziv</th>
    <th scope="col" class="filesize">Veličina</th>
    <th scope="col" class="options">Opcije</th>
  </tr>
	<?php 
                foreach ($files as $file) {
                    $lastRevisionId = 0;
                    $firstRevisionId = count($file) > 0 ? count($file) - 1 : 0;
                    $author = getAuthorOfFile($file[$lastRevisionId][id]);
                    ?>
				
    <tr>
    	<td class="creation_date"><?php 
                    echo date('d.m.Y H:i:s', mysql2time($file[$lastRevisionId][vrijeme]));
                    ?>
</td><!--vrijeme-->
    	<td class="author"><?php 
                    echo filtered_output_string($author['ime'] . ' ' . $author['prezime']);
                    ?>
</td><!--author-->
        <td class="revision">v<?php 
                    echo $file[$lastRevisionId][revizija];
                    ?>
</td><!--revizija-->
        <td class="filename"><?php 
                    if (count($file) > 1) {
                        ?>
		<a href="#" onclick="toggleFileRevisions('file_<?php 
                        echo $file[$lastRevisionId][id];
                        ?>
_revisions')"><?php 
                        echo filtered_output_string($file[$lastRevisionId][filename]);
                        ?>
</a>		
   	<?php 
                    } else {
                        ?>
    	<?php 
                        echo filtered_output_string($file[$lastRevisionId][filename]);
                        ?>
    <?php 
                    }
                    ?>
        </td><!--filename-->
        <td class="filesize"><?php 
                    $lokacijafajlova = "{$conf_files_path}/projekti/fajlovi/{$projekat}/" . $file[$lastRevisionId][osoba] . "/" . $file[$lastRevisionId][filename] . '/v' . $file[$lastRevisionId][revizija] . '/';
                    $filepath = $lokacijafajlova . $file[$lastRevisionId][filename];
                    $filesize = filesize($filepath);
                    echo nicesize($filesize);
                    ?>
        </td><!--filesize-->
        <td class="options">
			<a href="<?php 
                    echo 'index.php?sta=common/attachment' . "&tip=projekat&projekat={$projekat}&id=" . $file[$lastRevisionId][id];
                    ?>
">Snimi</a>        
	<?php 
                    if (isUserAuthorOfFile($file[$lastRevisionId][id], $userid)) {
                        ?>
           <a href="<?php 
                        echo $linkPrefix . "&subaction=edit&id=" . $file[$firstRevisionId]['id'];
                        ?>
">Uredi</a>
           <a href="<?php 
                        echo $linkPrefix . "&subaction=del&id=" . $file[$firstRevisionId]['id'];
                        ?>
">Briši</a>
	<?php 
                    }
                    //if user is author of this item
                    ?>
        </td><!--options-->
    </tr><!--file_leading-->
    <?php 
                    if (count($file) > 1) {
                        for ($i = 1; $i < count($file); $i++) {
                            $revision = $file[$i];
                            $author = getAuthorOfFile($revision[id]);
                            ?>
            <tr class="file_<?php 
                            echo $file[$lastRevisionId][id];
                            ?>
_revisions" style="display: none;" id="file_revisions">
                <td class="creation_date"><?php 
                            echo date('d.m.Y H:i:s', mysql2time($revision[vrijeme]));
                            ?>
</td><!--vrijeme-->
                <td class="author"><?php 
                            echo filtered_output_string($author['ime'] . ' ' . $author['prezime']);
                            ?>
</td><!--author-->
                <td class="revision">v<?php 
                            echo $revision[revizija];
                            ?>
</td><!--revizija-->
                <td class="filename"><?php 
                            echo filtered_output_string($revision[filename]);
                            ?>
</td><!--filename-->
                <td class="filesize"><?php 
                            $lokacijafajlova = "{$conf_files_path}/projekti/fajlovi/{$projekat}/" . $revision[osoba] . "/" . $revision[filename] . '/v' . $revision[revizija] . '/';
                            $filepath = $lokacijafajlova . $revision[filename];
                            $filesize = filesize($filepath);
                            echo nicesize($filesize);
                            ?>
                </td><!--filesize-->
                <td class="options">
                    <a href="<?php 
                            echo 'index.php?sta=common/attachment' . "&tip=projekat&projekat={$projekat}&id=" . $revision[id];
                            ?>
">Snimi</a>        
                </td><!--options-->
            </tr><!--file_revision-->	
    <?php 
                        }
                        //foreach revision
                    }
                    //if count files > 1
                }
                //foreach file
                ?>
    </table>
<!--files_table-->
<?php 
                $numrows = getCountFilesForProjectWithoutRevisions($project[id]);
                $maxPage = ceil($numrows / $rowsPerPage);
                $self = $linkPrefix;
                if ($maxPage > 0) {
                    echo "<span class=\"newsPages\">";
                    if ($pageNum > 1) {
                        $page = $pageNum - 1;
                        $prev = " <a href=\"{$self}&page={$page}\">[Prethodna]</a> ";
                        $first = " <a href=\"{$self}&page=1\">[Prva]</a> ";
                    }
                    if ($pageNum < $maxPage) {
                        $page = $pageNum + 1;
                        $next = " <a href=\"{$self}&page={$page}\">[Sljedeća]</a> ";
                        $last = " <a href=\"{$self}&page={$maxPage}\">[Zadnja]</a> ";
                    }
                    echo $first . $prev . " Strana <strong>{$pageNum}</strong> od ukupno <strong>{$maxPage}</strong> " . $next . $last;
                    echo "</span>";
                    //newsPages span
                }
                ?>
    <script type="text/javascript">
		function getElementsByClassName( strClassName, obj ) 
		{
			var ar = arguments[2] || new Array();
			var re = new RegExp("\\b" + strClassName + "\\b", "g");
		
			if ( re.test(obj.className) ) 
			{
				ar.push( obj );
			}
			for ( var i = 0; i < obj.childNodes.length; i++ )
				getElementsByClassName( strClassName, obj.childNodes[i], ar );
			
			return ar;
		}
		
		function toggleFileRevisions(divID)
		{
			 var aryClassElements = getElementsByClassName( divID, document.body );
			for ( var i = 0; i < aryClassElements.length; i++ ) 
			{
				if (aryClassElements[i].style.display == '')
					aryClassElements[i].style.display = 'none';
				else
					aryClassElements[i].style.display = '';	
			}
		}
	
	</script>
    <?php 
            } else {
                if ($subaction == 'add') {
                    if (!isset($_REQUEST['submit'])) {
                        ?>
						 <h3>Novi fajl</h3>
				<?php 
                        print genform("POST", "addForm\" enctype=\"multipart/form-data\" ");
                        ?>
						
						<div id="formDiv">
							Polja sa * su obavezna. <br />
							<b>Limit za upload je 20MB.</b> <br />
                            <div class="row">
                                <span class="label">Fajl *</span>
                                <span class="formw">
                                    <input name="filename" type="file" id="filename" size="60" />
                                    <input type="hidden" name="MAX_FILE_SIZE" value="20971520">
                                </span>
                            </div> 
                            
							<div class="row">	
								<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
							</div>
						
						</div><!--formDiv-->
						</form>
							
	<?php 
                    } else {
                        $errorText = formProcess_file('add');
                        if ($errorText == '') {
                            nicemessage('Novi fajl uspješno dodan.');
                            zamgerlog("dodao novi fajl na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("dodao fajl na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'edit') {
                    if (!isUserAuthorOfFile($id, $userid)) {
                        return;
                    }
                    if (!isThisFileFirstRevision($id)) {
                        return;
                    }
                    //edit item
                    if (!isset($_REQUEST['submit'])) {
                        $entry = getFileFirstRevision($id);
                        $lastRevisionEntry = getFileLastRevision($id);
                        ?>
					 <h3>Uredi fajl</h3>
				<?php 
                        print genform("POST", "editForm\" enctype=\"multipart/form-data\" ");
                        ?>
					
					<div id="formDiv">
						Polja sa * su obavezna. <br />
						<b>Limit za upload je 20MB.</b> <br />							
					   <div class="row">
							<span class="label">Trenutni fajl</span>
							<span class="formw"><a href="<?php 
                        echo 'index.php?sta=common/attachment' . "&tip=projekat&projekat={$projekat}&id=" . $lastRevisionEntry[id];
                        ?>
" >
								<?php 
                        echo filtered_output_string($lastRevisionEntry[filename]);
                        ?>
							</a>
							</span>
					   </div> 

						<div class="row">
						  <span class="label">Zamijeni fajl</span>
							<span class="formw">
								<input name="filename" type="file" id="filename" size="50" />
								<input type="hidden" name="MAX_FILE_SIZE" value="20971520">
							</span>
						</div>                         
						<div class="row">	
							<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
						</div>
					
					</div><!--formDiv-->
					</form>
	
		<?php 
                    } else {
                        $errorText = formProcess_file('edit');
                        if ($errorText == '') {
                            nicemessage('Uspješno ste uredili fajl.');
                            zamgerlog("uredio fajl na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("uredio fajl na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            //an error occured trying to process the form
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'del') {
                    if (!isUserAuthorOfFile($id, $userid)) {
                        return;
                    }
                    if (!isThisFileFirstRevision($id)) {
                        return;
                    }
                    //delete item
                    if (isset($id) && is_int($id) && $id > 0) {
                        if (!isset($_REQUEST['c'])) {
                            echo "Da li ste sigurni da zelite obrisati ovaj fajl? Obrisacete sve revizije fajla sa servera.<br />";
                            echo '<a href="' . $linkPrefix . '&subaction=del&id=' . $id . '&c=true">Da</a> | <a href="' . $linkPrefix . '">Odustani</a>';
                        } else {
                            if ($_REQUEST['c'] == 'true') {
                                //delete the record
                                if (deleteFile($id)) {
                                    nicemessage('Uspješno ste obrisali fajl.');
                                    zamgerlog("obrisao fajl na projektu {$projekat} (pp{$predmet})", 2);
                                    zamgerlog2("obrisao fajl na projektu", $projekat);
                                    $link = $linkPrefix;
                                } else {
                                    niceerror('Doslo je do greske prilikom brisanja fajla. Molimo kontaktirajte administratora.');
                                    $link = "javascript:history.back();";
                                }
                                nicemessage('<a href="' . $link . '">Povratak.</a>');
                            }
                        }
                        //else isset c get parameter
                    }
                    //id is okay
                }
                //subaction == del
            }
            //subaction set
        } elseif ($section == 'bb') {
            //links management
            $linkPrefix .= '&section=bb';
            ?>
<h2>Grupa za diskusiju</h2>
 <div class="links clearfix" id="bl">
    <ul>
        <li><a href="<?php 
            echo $linkPrefix;
            ?>
">Lista tema</a></li>
        <li><a href="<?php 
            echo $linkPrefix . "&subaction=add";
            ?>
">Nova tema</a></li>
    </ul>   
</div>	
    <?php 
            if (!isset($subaction)) {
                $rowsPerPage = 20;
                $pageNum = 1;
                if (isset($_REQUEST['page'])) {
                    $pageNum = $_REQUEST['page'];
                }
                // counting the offset
                $offset = ($pageNum - 1) * $rowsPerPage;
                $threads = fetchThreadsForProject($project[id], $offset, $rowsPerPage);
                $numrows = getCountThreadsForProject($project[id]);
                ?>
<div id="threadList">
	<div class="threadRow caption clearfix">
        <div class="threadInfo">
        	<div class="views">Pregleda</div><!--views-->
        	<div class="lastReply">Zadnji odgovor</div><!--lastReply-->
            <div class="replies">Odgovora</div><!--replies-->
        </div><!--threadInfo-->
    	<div class="title">Teme (<?php 
                echo $numrows;
                ?>
)</div><!--title-->		
    </div><!--threadRow caption-->
    <?php 
                foreach ($threads as $key => $thread) {
                    ?>
	<div class="threadRow clearfix<?php 
                    if ($key % 2) {
                        echo ' pattern';
                    }
                    ?>
">
        <div class="threadInfo">
        	<div class="views"><?php 
                    echo intval($thread[pregleda]);
                    ?>
</div><!--views-->
        	<div class="lastReply"><?php 
                    echo date('d.m.Y H:i:s', mysql2time($thread[zadnji_post][vrijeme]));
                    ?>
<br /><?php 
                    echo filtered_output_string($thread[zadnji_post][osoba][prezime] . ' ' . $thread[zadnji_post][osoba][ime]);
                    ?>
</div><!--lastReply-->
            <div class="replies"><?php 
                    echo intval($thread[broj_odgovora]);
                    ?>
</div><!--replies-->
        </div><!--threadInfo-->
    	<div class="title"><a href="<?php 
                    echo $linkPrefix . "&subaction=view&tid={$thread['id']}";
                    ?>
" title="<?php 
                    echo $thread['naslov'];
                    ?>
"><?php 
                    echo filtered_output_string($thread[naslov]);
                    ?>
</a></div><!--title-->
        <div class="author"><?php 
                    echo filtered_output_string($thread[prvi_post][osoba][prezime] . ' ' . $thread[prvi_post][osoba][ime]);
                    ?>
</div><!--author-->		
    </div><!--threadRow caption-->
    <?php 
                }
                //foreach thread
                ?>
</div><!--threadList-->
    <?php 
                $maxPage = ceil($numrows / $rowsPerPage);
                $self = $linkPrefix;
                if ($maxPage > 0) {
                    echo "<span class=\"newsPages\">";
                    if ($pageNum > 1) {
                        $page = $pageNum - 1;
                        $prev = " <a href=\"{$self}&page={$page}\">[Prethodna]</a> ";
                        $first = " <a href=\"{$self}&page=1\">[Prva]</a> ";
                    }
                    if ($pageNum < $maxPage) {
                        $page = $pageNum + 1;
                        $next = " <a href=\"{$self}&page={$page}\">[Sljedeća]</a> ";
                        $last = " <a href=\"{$self}&page={$maxPage}\">[Zadnja]</a> ";
                    }
                    echo $first . $prev . " Strana <strong>{$pageNum}</strong> od ukupno <strong>{$maxPage}</strong> " . $next . $last;
                    echo "</span>";
                    //newsPages span
                }
            } else {
                if ($subaction == 'view') {
                    $tid = intval($_REQUEST[tid]);
                    $thread = getThreadAndPosts($tid);
                    if (empty($thread)) {
                        zamgerlog("projektne strane: nepostojeci thread sa IDom {$id}, projekat {$projekat} (pp{$predmet}, ag{$ag})", 3);
                        zamgerlog2("nepostojeci thread na projektu", $id, $projekat);
                        return;
                    }
                    incrementThreadViewCount($thread[id]);
                    ?>
    <div id="fullThread">
    <?php 
                    foreach ($thread[posts] as $post) {
                        ?>
				
		<div class="post"><a name="p<?php 
                        echo $post[id];
                        ?>
">
        	<div id="post_<?php 
                        echo $post[id];
                        ?>
_header" class="header clearfix" onclick="toggleShowPost('post_<?php 
                        echo $post[id];
                        ?>
')">
                <div class="buttons">
                	<a href="<?php 
                        echo $linkPrefix . "&subaction=add&tid={$post['tema']}&id={$post['id']}";
                        ?>
" title="Odgovori na ovaj post">Odgovori</a>
    <?php 
                        if (isUserAuthorOfPost($post[id], $userid) == true) {
                            ?>
    				| <a href="<?php 
                            echo $linkPrefix . "&subaction=edit&tid={$post['tema']}&id={$post['id']}";
                            ?>
" title="Uredi vlastiti post">Uredi</a>
    				| <a href="<?php 
                            echo $linkPrefix . "&subaction=del&tid={$post['tema']}&id={$post['id']}";
                            ?>
" title="Obriši vlastiti post">Obriši</a>		
    <?php 
                        }
                        ?>
                </div>
                <div class="maininfo">
                	<div class="date"><?php 
                        echo date('d.m.Y H:i:s', mysql2time($post[vrijeme]));
                        ?>
</div>
                    <div class="author"><?php 
                        echo filtered_output_string($post[osoba][prezime] . ' ' . $post[osoba][ime]);
                        ?>
</div> - 
                    <div class="title"><?php 
                        echo filtered_output_string($post[naslov]);
                        ?>
</div>
                </div>
            </div><!--header-->
            <div class="text" id="post_<?php 
                        echo $post[id];
                        ?>
_text"><?php 
                        echo filtered_output_string($post[tekst]);
                        ?>
</div><!--text-->

        </div><!--post-->				
					
	<?php 
                    }
                    //foreach post
                    ?>
    
    
    </div><!--fullThread-->
        <script type="text/javascript">
		function toggleShowPost(divID)
		{
			header = document.getElementById(divID + '_header');
			text = document.getElementById(divID + '_text');
			if (text.style.display == 'block' || text.style.display == '')
			{
				text.style.display = 'none';
				header.style.backgroundColor = '#F5F5F5';
				header.style.color = 'black';
			}
			else
			{
				text.style.display = 'block';
				header.style.backgroundColor = '#EEEEEE';
			}	
				
		}
	
		</script>
	
    <?php 
                } elseif ($subaction == 'add') {
                    $threadID = intval($_REQUEST['tid']);
                    if ($threadID <= 0) {
                        $thread = false;
                    } else {
                        $thread = true;
                    }
                    if ($thread == true) {
                        $postInfo = getPostInfoForThread($threadID, $id);
                        $extendedThreadInfo = array();
                        getExtendedInfoForThread($threadID, $extendedThreadInfo);
                        if (empty($postInfo)) {
                            zamgerlog("projektne strane: odgovor na nepostojeci post {$id}, projekat {$projekat} (pp{$predmet})", 3);
                            zamgerlog2("odgovor na nepostojeci post na projektu", $id, $projekat);
                            return;
                        }
                    }
                    if (!isset($_REQUEST['submit'])) {
                        ?>
	
    		
				 <h3><?php 
                        if ($thread == true) {
                            echo 'Novi odgovor';
                        } else {
                            echo 'Nova tema';
                        }
                        ?>
</h3>
				<?php 
                        print genform("POST", "addForm");
                        ?>
                <?php 
                        if ($thread == true) {
                            ?>
 
					<input type="hidden" name="tid" value="<?php 
                            echo $threadID;
                            ?>
"  />
				<?php 
                        }
                        ?>
                <div id="formDiv">
                	Polja sa * su obavezna. <br />
                
                	<div class="row">
                        <span class="label">Naslov *</span>
                        <span class="formw"><input name="naslov" type="text" id="naslov" size="70" <?php 
                        if ($thread == true) {
                            ?>
 value="RE: <?php 
                            echo $extendedThreadInfo['naslov'];
                            ?>
"<?php 
                        }
                        ?>
/></span> 
                  	</div>
                    <div class="row">
                        <span class="label">Tekst *</span>
                        <span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"></textarea></span>
                   	</div> 
                                      
                    <div class="row">	
                      	<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
                    </div>
                
                </div><!--formDiv-->
               
                </form>
               
	<?php 
                    } else {
                        $errorText = formProcess_bb('add', $thread, $threadID);
                        if ($errorText == '') {
                            if ($thread == true) {
                                nicemessage('Novi odgovor uspješno dodan.');
                                zamgerlog("dodao novi odgovor na diskusiju ID {$threadID}, projekat {$projekat} (pp{$predmet})", 2);
                                zamgerlog2("dodao odgovor na diskusiju", $threadID, $projekat);
                            } else {
                                nicemessage('Nova tema uspješno dodana.');
                                zamgerlog("dodao novu temu na projektu {$projekat} (pp{$predmet})", 2);
                                zamgerlog2("dodao temu na projektu", $projekat);
                            }
                            if (!empty($_REQUEST[tid])) {
                                $link = $linkPrefix . "&subaction=view&tid={$_REQUEST['tid']}";
                            } else {
                                $link = $linkPrefix;
                            }
                        } else {
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'edit') {
                    //edit item
                    if (isUserAuthorOfPost($id, $userid) == false) {
                        zamgerlog("pokusava urediti post {$id} a nije autor, projekat {$projekat} (pp{$predmet})", 3);
                        zamgerlog2("pokusava urediti post a nije autor", $id, $projekat);
                        return;
                    }
                    $threadID = intval($_REQUEST[tid]);
                    if ($threadID <= 0) {
                        zamgerlog("pokusava urediti nepostojeci post {$id}, projekat {$projekat} (pp{$predmet})", 3);
                        zamgerlog2("pokusava urediti nepostojeci post", $id, $projekat);
                        return;
                    }
                    if (!isset($_REQUEST['submit'])) {
                        $entry = getPost($id);
                        if (empty($entry)) {
                            zamgerlog("pokusava urediti nepostojeci post {$id}, projekat {$projekat} (pp{$predmet})", 3);
                            zamgerlog2("pokusava urediti nepostojeci post", $id, $projekat);
                            return;
                        }
                        ?>
				 <h3>Uredi post</h3>
				<?php 
                        print genform("POST", "editForm");
                        ?>
				<div id="formDiv">
					Polja sa * su obavezna. <br />
				
					<div class="row">
						<span class="label">Naslov *</span>
						<span class="formw"><input name="naslov" type="text" id="naslov" size="70" value="<?php 
                        echo $entry['naslov'];
                        ?>
" /></span> 
					</div>
					<div class="row">
						<span class="label">Tekst *</span>
						<span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"><?php 
                        echo $entry['tekst'];
                        ?>
</textarea></span>
					</div> 
					
					<div class="row">	
						<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
					</div>
				
				</div><!--formDiv-->
				
				
				</form>
				
				
<?php 
                    } else {
                        $errorText = formProcess_bb('edit', $thread, $threadID);
                        if ($errorText == '') {
                            nicemessage('Uspješno ste uredili post.');
                            zamgerlog("uredio vlastiti BB post {$id}, projekat {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("uredio vlastiti post", $id, $projekat);
                            $link = $linkPrefix . "&subaction=view&tid={$_REQUEST['tid']}";
                        } else {
                            //an error occured trying to process the form
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'del') {
                    //delete item
                    if (isset($id) && is_int($id) && $id > 0) {
                        if (isUserAuthorOfPost($id, $userid) == false) {
                            zamgerlog("pokusava izbrisati post {$id} a nije autor, projekat {$projekat} (pp{$predmet})", 3);
                            zamgerlog2("pokusava izbrisati post a nije autor", $id, $projekat);
                            return;
                        }
                        $threadID = intval($_REQUEST[tid]);
                        if ($threadID <= 0) {
                            zamgerlog("pokusava izbrisati nepostojeci post {$id}, projekat {$projekat} (pp{$predmet})", 3);
                            zamgerlog2("pokusava izbrisati nepostojeci post", $id, $projekat);
                            return;
                        }
                        if (!isset($_REQUEST['c'])) {
                            echo "Da li ste sigurni da zelite obrisati ovaj post? <br />";
                            echo '<a href="' . $linkPrefix . '&amp;subaction=del&tid=' . $threadID . '&id=' . $id . '&amp;c=true">Da</a> | <a href="' . $linkPrefix . '">Odustani</a>';
                        } else {
                            if ($_REQUEST['c'] == 'true') {
                                //delete the record
                                if (deletePost($id)) {
                                    nicemessage('Uspješno ste obrisali post.');
                                    zamgerlog("obrisao post na projektu {$projekat} (pp{$predmet})", 2);
                                    zamgerlog2("obrisao post na projektu", $projekat);
                                    if (getCountPostsInThread($threadID) > 0) {
                                        $link = $linkPrefix . "&subaction=view&tid={$_REQUEST['tid']}";
                                    } else {
                                        $link = $linkPrefix;
                                    }
                                } else {
                                    niceerror('Došlo je do greske prilikom brisanja posta. Molimo kontaktirajte administratora.');
                                    $link = "javascript:history.back();";
                                }
                                nicemessage('<a href="' . $link . '">Povratak.</a>');
                            }
                        }
                        //else isset c get parameter
                    }
                    //id is okay
                }
                //subaction == del
            }
            //subaction set
        }
        //section == bb (forum)
    }
    //else - section is set
}
Esempio n. 12
0
    function getWeeksTime($time, $user_id)
    {
        $colname_rsTimesheet = "-1";
        if (isset($user_id)) {
            $colname_rsTimesheet = get_magic_quotes_gpc() ? $user_id : addslashes($user_id);
        }
        $query_rsTimesheet = sprintf("SELECT * FROM procentris_timesheet WHERE user_id = %s", $colname_rsTimesheet);
        $rsTimesheet = mysql_query($query_rsTimesheet) or die(mysql_error());
        $row_rsTimesheet = mysql_fetch_assoc($rsTimesheet);
        $totalRows_rsTimesheet = mysql_num_rows($rsTimesheet);
        $today = getdate($time);
        $chkdate = $today['weekday'];
        $chkdate2 = strtolower($chkdate);
        $arr = getDays($time);
        $fromdate = $arr['monday']['year'] . "-" . $arr['monday']['mon'] . "-" . $arr['monday']['mday'];
        $todate = $arr['sunday']['year'] . "-" . $arr['sunday']['mon'] . "-" . $arr['sunday']['mday'];
        //$fromdate = $arr[$chkdate2]['year']."-".$arr[$chkdate2]['mon']."-".$arr[$chkdate2]['mday'];
        //$todate = $arr[$chkdate2]['year']."-".$arr[$chkdate2]['mon']."-".$arr[$chkdate2]['mday'];
        $category = getCategory($user_id, $fromdate, $todate);
        if ($category) {
            $result = '<table border=1 cellspacing=0 cellpadding=2>';
            $result .= '<tr><td colspan=10 align=center>' . $today['mday'] . ' ' . $today['month'] . ', ' . $today['year'] . '</td></tr>';
            $result .= '<tr><td align=left><b>Client</b></td><td align=left><b>Project</b></td><td align=left><b>Task</b></td>';
            foreach ($arr as $key => $value) {
                $result .= '<td align=left><b>' . substr(ucfirst($key), 0, 3) . '</b></td>';
            }
            $result .= '</tr>';
            foreach ($category as $categoryKey => $categoryValue) {
                $categorycnt[$categoryValue] = 1;
                $project = getProject($user_id, $categoryKey, $fromdate, $todate);
                if ($project) {
                    foreach ($project as $projectKey => $projectValue) {
                        $projectcnt[$projectValue] = 1;
                        $task = getTask($user_id, $categoryKey, $projectKey, $fromdate, $todate);
                        if ($task) {
                            $j = 0;
                            foreach ($task as $taskKey => $taskValue) {
                                if ($categorycnt[$categoryValue] == 1) {
                                    $result .= '<tr>
													<td align=left>' . $categoryValue . '</td>';
                                } else {
                                    $result .= '<td align=left>&nbsp;</td>';
                                }
                                $categorycnt[$categoryValue]++;
                                if ($projectcnt[$projectValue] == 1) {
                                    $result .= '<td align=left>' . $projectValue . '</td>';
                                } else {
                                    $result .= '<td align=left>&nbsp;</td>';
                                }
                                $projectcnt[$projectValue]++;
                                $result .= '<td align=left>' . $taskValue . '</td>';
                                $i = 0;
                                $totalh[$j] = 0;
                                foreach ($arr as $key => $value) {
                                    $timetaken[$i] = getTime($user_id, $categoryKey, $projectKey, $taskKey, $arr[$key]['year'] . "-" . $arr[$key]['mon'] . "-" . $arr[$key]['mday']);
                                    if (number_format($timetaken[$i], 2) == "0.00") {
                                        $taketime = "&nbsp;";
                                    } else {
                                        $taketime = number_format($timetaken[$i], 2);
                                    }
                                    $result .= '<td align=right>' . $taketime . '</td>';
                                    $totalv[$key] += $timetaken[$i];
                                    $totalh[$j] += $timetaken[$i];
                                    $i++;
                                }
                                $j++;
                                $result .= '</tr>';
                            }
                        }
                    }
                }
            }
            $result .= '<tr><td align=left>&nbsp;</td><td align=left>&nbsp;</td><td align=right><b>Total:</b></td>';
            foreach ($arr as $key => $value) {
                $grandtotal += $totalv[$key];
                $result .= '<td align=right>' . number_format($totalv[$key], 2) . '</td>';
            }
            $result .= '</tr>';
            $result .= '<tr><td colspan=10 align=center>TOTAL HOURS WORKED THIS WEEK: <b>' . number_format($grandtotal, 2) . '</b></td></tr>';
            $result .= '</table>';
            return $result;
        }
    }
Esempio n. 13
0
}
if (!$users) {
    $users = getFollowers($nick, $connfb);
}
// keys
try {
    $keys = getKeys($nick, null, $client);
} catch (Exception $e) {
    $throttled = true;
    error_log($e->getMessage());
    $keys = getKeys($nick, $conn);
}
// turtle
$rank = getRank($users);
$ledger = getLedger($webid, $conn);
$project = getProject($ledger);
$main = 'http://gitpay.org/' . $user['login'] . '#this';
$githubaccount = 'http://github.com/' . $user['login'];
if ($webid && $webid['bitcoin']) {
    $bitcoin = $webid['bitcoin'];
}
if ($webid && $webid['preferredURI']) {
    $preferredURI = $webid['preferredURI'];
}
$turtle = getTurtle($user, $webid, $users, $keys);
insertKeys($keys, $nick, $conn);
writeTurtle($turtle);
if (!empty($_SESSION['login'])) {
    activateUser('https://gitpay.org/' . $_SESSION['login'] . '#this', $conn);
}
$active = getActive('https://gitpay.org/' . $nick . '#this', $conn);
Esempio n. 14
0
<?php

require_once 'settings.php';
if ($_SERVER['REQUEST_METHOD'] == "GET") {
    if (!empty($_GET['id'])) {
        echo json_encode(getProject($_GET['id']));
    } else {
        echo json_encode(getProjects());
    }
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
    // $json = file_get_contents('php://input');
    // if($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] == 'PUT') {
    // 	//This is an UPDATE call
    // 	if(!empty($json))
    // 		return json_encode(updatePrice());
    // }
    // elseif($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] == 'DELETE') {
    // 	//This is a DELETE call
    // 	// die($json);
    // 	if(!empty($_GET['id'] && !empty($_GET['quantity'])))
    // 		return json_encode(deletePriceFromQuantity($_GET['id'], $_GET['quantity']));
    // }
    // else {
    // 	//This is an ADD call
    // 	if(!empty($json))
    // 		return json_encode(addPrice());
    // }
}
function getProject($id)
{
Esempio n. 15
0
function getProject()
{
    $pc = new projectController();
    $api = new apiController();
    if (isset($_GET)) {
        if (!isset($_GET["api_key"])) {
            return json_encode(["err" => "Specify API_KEY"]);
        } else {
            if (!isset($_GET["project"])) {
                return json_encode(["err" => "Specify PROJECT"]);
            } else {
                $project = $_GET["project"];
                $apikey = $_GET["api_key"];
                if ($api->checkKey($apikey)) {
                    $pr = $pc->getProjectDataFull($project);
                    if (!is_bool($pr)) {
                        return json_encode($pr);
                    } else {
                        return json_encode(["err" => "Project not found!"]);
                    }
                } else {
                    return json_encode(["err" => "Incorrect key."]);
                }
            }
        }
    } else {
        return json_encode(["err" => "No arguments found."]);
    }
}
echo getProject();
Esempio n. 16
0
/*
 * pmt.mcpe.me
 *
 * Copyright (C) 2015 PEMapModder
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * @author PEMapModder
 */
use pg\lib\Project;
include_once __DIR__ . "/utils.php";
if (getProject() instanceof Project) {
    redirect(".");
    die;
}
if (!isset($_POST["name"], $_POST["version"], $_POST["authors"], $_POST["website"])) {
    redirect(".");
    die;
}
try {
    $project = new Project($_POST["name"], $_POST["version"], preg_split("/[ \t]*,[ \t]*/", $_POST["authors"], -1, PREG_SPLIT_NO_EMPTY));
    $project->getDesc()->website = $_POST["website"];
} catch (Exception $e) {
    header("Location: .?err=" . urlencode("Error: {$e->getMessage()}"));
    die;
}
setProject($project);
Esempio n. 17
0
 function item_action()
 {
     $id = trim($_GET['id']);
     $project = getProject($id);
     include template('project_item');
 }
Esempio n. 18
0
 public function doAction()
 {
     try {
         $this->_checkData();
     } catch (Exception $e) {
         if ($e->getCode() == -1) {
             Utils::sendErrMailReport($e->getMessage());
         }
         Log::doLog($e->getMessage());
         return $e->getCode();
     }
     //check tag mismatch
     //get original source segment, first
     $segment = getSegment($this->id_segment);
     //compare segment-translation and get results
     $check = new QA($segment['segment'], $this->translation);
     $check->performConsistencyCheck();
     if ($check->thereAreWarnings()) {
         $err_json = $check->getWarningsJSON();
         $translation = $this->translation;
     } else {
         $err_json = '';
         $translation = $check->getTrgNormalized();
     }
     /*
      * begin stats counter
      *
      * It works good with default InnoDB Isolation level
      *
      * REPEATABLE-READ offering a row level lock for this id_segment
      *
      */
     $db = Database::obtain();
     $db->begin();
     $old_translation = getCurrentTranslation($this->id_job, $this->id_segment);
     //        $old_version = ( empty( $old_translation['translation_date'] ) ? '0' : date_create( $old_translation['translation_date'] )->getTimestamp() );
     //        if( $this->client_target_version != $old_version ){
     //            $this->result[ 'errors' ][ ] = array( "code" => -102, "message" => "Translation version mismatch" );
     //            $db->rollback();
     //            return false;
     //        }
     //if volume analysis is not enabled and no translation rows exists
     //create the row
     if (!INIT::$VOLUME_ANALYSIS_ENABLED && empty($old_translation['status'])) {
         $_Translation = array();
         $_Translation['id_segment'] = (int) $this->id_segment;
         $_Translation['id_job'] = (int) $this->id_job;
         $_Translation['status'] = Constants_TranslationStatus::STATUS_NEW;
         $_Translation['segment_hash'] = $segment['segment_hash'];
         $_Translation['translation'] = $segment['segment'];
         $_Translation['standard_word_count'] = $segment['raw_word_count'];
         $_Translation['serialized_errors_list'] = '';
         $_Translation['suggestion_position'] = 0;
         $_Translation['warning'] = false;
         $_Translation['translation_date'] = date("Y-m-d H:i:s");
         $res = addTranslation($_Translation);
         if ($res < 0) {
             $this->result['errors'][] = array("code" => -101, "message" => "database errors");
             $db->rollback();
             return $res;
         }
         /*
          * begin stats counter
          *
          */
         $old_translation = $_Translation;
     }
     $_Translation = array();
     $_Translation['id_segment'] = $this->id_segment;
     $_Translation['id_job'] = $this->id_job;
     $_Translation['status'] = $this->status;
     $_Translation['time_to_edit'] = $this->time_to_edit;
     $_Translation['translation'] = preg_replace('/[ \\t\\n\\r\\0\\x0A\\xA0]+$/u', '', $translation);
     $_Translation['serialized_errors_list'] = $err_json;
     $_Translation['suggestion_position'] = $this->chosen_suggestion_index;
     $_Translation['warning'] = $check->thereAreWarnings();
     $_Translation['translation_date'] = date("Y-m-d H:i:s");
     /**
      * when the status of the translation changes, the auto propagation flag
      * must be removed
      */
     if ($_Translation['translation'] != $old_translation['translation'] || $this->status == Constants_TranslationStatus::STATUS_TRANSLATED || $this->status == Constants_TranslationStatus::STATUS_APPROVED) {
         $_Translation['autopropagated_from'] = 'NULL';
     }
     $res = CatUtils::addSegmentTranslation($_Translation);
     if (!empty($res['errors'])) {
         $this->result['errors'] = $res['errors'];
         $msg = "\n\n Error addSegmentTranslation \n\n Database Error \n\n " . var_export(array_merge($this->result, $_POST), true);
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
         $db->rollback();
         return -1;
     }
     if (INIT::$DQF_ENABLED && !empty($this->jobData['dqf_key']) && $_Translation['status'] == Constants_TranslationStatus::STATUS_TRANSLATED) {
         $dqfSegmentStruct = DQF_DqfSegmentStruct::getStruct();
         if ($old_translation['suggestion'] == null) {
             $dqfSegmentStruct->target_segment = "";
             $dqfSegmentStruct->tm_match = 0;
         } else {
             $dqfSegmentStruct->target_segment = $old_translation['suggestion'];
             $dqfSegmentStruct->tm_match = $old_translation['suggestion_match'];
         }
         $dqfSegmentStruct->task_id = $this->id_job;
         $dqfSegmentStruct->segment_id = $this->id_segment;
         $dqfSegmentStruct->source_segment = $segment['segment'];
         $dqfSegmentStruct->new_target_segment = $_Translation['translation'];
         $dqfSegmentStruct->time = $_Translation['time_to_edit'];
         //            $dqfSegmentStruct->mtengine = $this->jobData['id_mt_engine'];
         $dqfSegmentStruct->mt_engine_version = 1;
         try {
             $dqfQueueHandler = new Analysis_DqfQueueHandler();
             $dqfQueueHandler->createSegment($dqfSegmentStruct);
         } catch (Exception $exn) {
             $msg = $exn->getMessage() . "\n\n" . $exn->getTraceAsString();
             Log::doLog($msg);
             Utils::sendErrMailReport($msg);
         }
     }
     $propagateToTranslated = true;
     //for the moment, this is set explicitely
     if ($this->propagate == false) {
         $propagateToTranslated = false;
     }
     //propagate translations
     $TPropagation = array();
     //Warning: this value will NOT be used to update values,
     //but to exclude current segment from auto-propagation
     $_idSegment = $this->id_segment;
     $propagateToTranslated ? $TPropagation['status'] = $this->status : null;
     $TPropagation['id_job'] = $this->id_job;
     $TPropagation['translation'] = $translation;
     $TPropagation['autopropagated_from'] = $this->id_segment;
     $TPropagation['serialized_errors_list'] = $err_json;
     $TPropagation['warning'] = $check->thereAreWarnings();
     //        $TPropagation[ 'translation_date' ]       = date( "Y-m-d H:i:s" );
     $TPropagation['segment_hash'] = $old_translation['segment_hash'];
     $propagationTotal = array();
     if ($propagateToTranslated && in_array($this->status, array(Constants_TranslationStatus::STATUS_TRANSLATED, Constants_TranslationStatus::STATUS_APPROVED, Constants_TranslationStatus::STATUS_REJECTED))) {
         try {
             $propagationTotal = propagateTranslation($TPropagation, $this->jobData, $_idSegment, $propagateToTranslated);
         } catch (Exception $e) {
             $msg = $e->getMessage() . "\n\n" . $e->getTraceAsString();
             Log::doLog($msg);
             Utils::sendErrMailReport($msg);
         }
     }
     //Recount Job Totals
     $old_wStruct = new WordCount_Struct();
     $old_wStruct->setIdJob($this->id_job);
     $old_wStruct->setJobPassword($this->password);
     $old_wStruct->setNewWords($this->jobData['new_words']);
     $old_wStruct->setDraftWords($this->jobData['draft_words']);
     $old_wStruct->setTranslatedWords($this->jobData['translated_words']);
     $old_wStruct->setApprovedWords($this->jobData['approved_words']);
     $old_wStruct->setRejectedWords($this->jobData['rejected_words']);
     $old_wStruct->setIdSegment($this->id_segment);
     //redundant, this is made into WordCount_Counter::updateDB
     $old_wStruct->setOldStatus($old_translation['status']);
     $old_wStruct->setNewStatus($this->status);
     //redundant because the update is made only where status = old status
     if ($this->status != $old_translation['status']) {
         //cambiato status, sposta i conteggi
         $old_count = !is_null($old_translation['eq_word_count']) ? $old_translation['eq_word_count'] : $segment['raw_word_count'];
         //if there is not a row in segment_translations because volume analysis is disabled
         //search for a just created row
         $old_status = !empty($old_translation['status']) ? $old_translation['status'] : Constants_TranslationStatus::STATUS_NEW;
         $counter = new WordCount_Counter($old_wStruct);
         $counter->setOldStatus($old_status);
         $counter->setNewStatus($this->status);
         $newValues = array();
         $newValues[] = $counter->getUpdatedValues($old_count);
         foreach ($propagationTotal as $__pos => $old_value) {
             $counter->setOldStatus($old_value['status']);
             $counter->setNewStatus($this->status);
             $newValues[] = $counter->getUpdatedValues($old_value['total']);
         }
         try {
             $newTotals = $counter->updateDB($newValues);
         } catch (Exception $e) {
             $this->result['errors'][] = array("code" => -101, "message" => "database errors");
             //                Log::doLog("Lock: Transaction Aborted. " . $e->getMessage() );
             //                $x1 = explode( "\n" , var_export( $old_translation, true) );
             //                Log::doLog("Lock: Translation status was " . implode( " ", $x1 ) );
             $db->rollback();
             return $e->getCode();
         }
     } else {
         $newTotals = $old_wStruct;
     }
     $job_stats = CatUtils::getFastStatsForJob($newTotals);
     $project = getProject($this->jobData['id_project']);
     $project = array_pop($project);
     $job_stats['ANALYSIS_COMPLETE'] = $project['status_analysis'] == Constants_ProjectStatus::STATUS_DONE || $project['status_analysis'] == Constants_ProjectStatus::STATUS_NOT_TO_ANALYZE ? true : false;
     $file_stats = array();
     $this->result['stats'] = $job_stats;
     $this->result['file_stats'] = $file_stats;
     $this->result['code'] = 1;
     $this->result['data'] = "OK";
     $this->result['version'] = date_create($_Translation['translation_date'])->getTimestamp();
     /* FIXME: added for code compatibility with front-end. Remove. */
     $_warn = $check->getWarnings();
     $warning = $_warn[0];
     /* */
     $this->result['warning']['cod'] = $warning->outcome;
     if ($warning->outcome > 0) {
         $this->result['warning']['id'] = $this->id_segment;
     } else {
         $this->result['warning']['id'] = 0;
     }
     //strtoupper transforms null to "" so check for the first element to be an empty string
     if (!empty($this->split_statuses[0]) && !empty($this->split_num)) {
         /* put the split inside the transaction if they are present */
         $translationStruct = TranslationsSplit_SplitStruct::getStruct();
         $translationStruct->id_segment = $this->id_segment;
         $translationStruct->id_job = $this->id_job;
         $translationStruct->target_chunk_lengths = array('len' => $this->split_chunk_lengths, 'statuses' => $this->split_statuses);
         $translationDao = new TranslationsSplit_SplitDAO(Database::obtain());
         $result = $translationDao->update($translationStruct);
     }
     $db->commit();
     if ($job_stats['TRANSLATED_PERC'] == '100') {
         $update_completed = setJobCompleteness($this->id_job, 1);
     }
     if (@$update_completed < 0) {
         $msg = "\n\n Error setJobCompleteness \n\n " . var_export($_POST, true);
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
     }
 }
function deletePicture($data)
{
    //checks if requests needed are present and not empty
    $dataNeeded = array("username", "password", "projectID", "file");
    if (checkData($data, $dataNeeded)) {
        //checks if user provided exists
        $results = login($data);
        if ($results["meta"]["ok"] === true) {
            //error getting goal
            $results = getProject($data["projectID"]);
            if ($results["count"] > 0) {
                //update database
                $db = new pdodb();
                $query = "DELETE FROM PortfolioProjectImage WHERE ProjectID = :projectID AND File = :file;";
                $bindings = array(":projectID" => $data["projectID"], ":file" => $data["file"]);
                $results = $db->query($query, $bindings);
                //if update was ok
                if ($results["count"] > 0) {
                    //checks if file exists to delete the picture
                    if (file_exists($data["file"])) {
                        unlink($data["file"]);
                    }
                    $results["meta"]["ok"] = true;
                    $results["rows"]["file"] = $data["file"];
                } else {
                    //check if database provided any meta data if so problem with executing query
                    if (!isset($results["meta"])) {
                        $results["meta"]["ok"] = false;
                    }
                }
            }
        }
    } else {
        $results["meta"] = dataNotProvided($dataNeeded);
    }
    return $results;
}
Esempio n. 20
0
<a href="/admin/projects">&lt;&lt;&lt; Back to Project Management</a><br><br>
<form action="/admin/newproject" method="post">
<table>
    <tr><td>Name:</td><td><input type="text" name="name"></td></tr>
    <tr><td>ID:</td><td><input type="text" name="id"></td></tr>
    <tr><td>Tag:</td><td><input type="text" name="tag"></td></tr>
    <tr><td>Description:</td><td><textarea name="description"></textarea></td></tr>
    <tr><td>Page:</td><td><textarea name="page"></textarea></td></tr>
</table>
<br>
<input type="submit" value="Create">
</form>
<?php 
    } else {
        if ($second_resource === "edit") {
            $project = getProject($third_resource);
            ?>

<a href="/admin/projects">&lt;&lt;&lt; Back to Project Management</a><br><br>
<form action="/admin/editproject" method="post">
<table>
    <tr><td>Name:</td><td><input type="text" name="name" value="<?php 
            echo $project['project_name'];
            ?>
"></td></tr>
    <tr><td>ID:</td><td><input type="text" name="id" value="<?php 
            echo $project['project_id'];
            ?>
"></td></tr>
    <tr><td>Tag:</td><td><input type="text" name="tag" value="<?php 
            echo $project['project_tag'];
Esempio n. 21
0
#get all the est logged to a pooject that have a basecamp id and returns array with basecamp as key and id as value
 	$finder = new AMP_User_Profile(AMP_Registry::getDbcon());
	$items = $finder->find(array('modin'=>'63','custom1'=>$gtdProj));
	$out = array();
 	foreach ($items as $item) {
		if ($item->getData('custom8')){
			$out[$item->getData('custom8')] = $item->getData('id');

		}
	}
 	return $out;

}	


sync_project(getProject('114'));

#$time_entries = getBasecampHours('2513159');
#AMP_dump($time_entries->{'time-entry'}]);
#echo $time_entries->time
#$time =  $time_entries->{'time-entry'};
#    $x=0;
#    AMP_dump($time);
#foreach( $time as $item){
#echo $item->date.'<br>x';
#$x++;
#}



Esempio n. 22
0
<?php

global $jw_googlefonts;
$twWebinkFonts = array();
if (function_exists('getProject') && function_exists('getProjectFonts')) {
    $jw_webink_projects = getProject('', '');
    foreach ($jw_webink_projects as $jw_webink_project) {
        $jw_webink_projectfonts = getProjectFonts('', $jw_webink_project->GUID);
        if ($jw_webink_projectfonts) {
            foreach ($jw_webink_projectfonts as $jw_webink_font) {
                $twWebinkFonts[$jw_webink_font->PSName] = $jw_webink_font->Name;
            }
        }
    }
}
$jw_googlefonts = array_merge($twWebinkFonts, $jw_googlefonts);
function page()
{
    $rResult = mysql_query("SELECT \tproject_id,\r\n                            \t\t\t\tweek_day_id,\r\n                            \t\t\t\tTIME_FORMAT(start,'%H:%i') AS `start`,\r\n                            \t\t\t\tTIME_FORMAT(end,'%H:%i') AS `end`,\r\n                            \t\t\t\tTIME_FORMAT(start,'%H') AS `startH`,\r\n                            \t\t\t\tTIME_FORMAT(end,'%H') AS `endH`\r\n                \t\t\t\t   FROM `work_graphic`\r\n                \t\t\t\t   WHERE id='{$_REQUEST['id']}' AND work_graphic.actived=1");
    $res = mysql_fetch_array($rResult);
    $rResult1 = mysql_query(" SELECT  id,\r\n                                            TIME_FORMAT(break_start,'%H:%i') AS break_start,\r\n                                            TIME_FORMAT(break_end,'%H:%i') AS break_end,\r\n                                            TIME_FORMAT(break_start,'%H') AS `startH`,\r\n                                            TIME_FORMAT(break_end,'%H') AS `endH`\r\n                                    FROM `week_graphic_break`\r\n                                    WHERE week_graphic_id = '{$_REQUEST['id']}' AND actived = 1");
    $data = '
        	<div id="dialog-form">
        		<fieldset >
        	    	<legend >ძირითადი ინფორმაცია</legend>
        	    	<table class="dialog-form-table">
        	            <tr>
        					<td style="width: 200px;"><label for="">პროექტი</label></td>
        	                <td ><label for="">კვირის დღე</label></td>
        				</tr>
        	            <tr>
        					<td style="width: 200px;"><select id="project_id" style="width:150px;">' . getProject($res[project_id]) . '</select></td>
        					<td ><select id="wday" style="width:150px;">' . getWday($res[week_day_id]) . '</select></td>
        				</tr>
        				<tr>
        					<td style="width: 200px;"><label for="">მუშაობის დასაწყისი</label></td>
        					<td ><label for="">მუშაობის დასასრული</label></td>
        				</tr>
        			    <tr>
        					<td id="pasteStart"><input id="start" style="width:145px;" 	type="text" value="' . $res[start] . '" /></td>
        					<td id="pasteEnd"><input id="end"   style="width:145px;"  type="text" value="' . $res[end] . '" /></td>
        				</tr>
        			</table>';
    if ($res[endH] != '') {
        $data .= '<script>        					    
            					    $("#start,#end").timepicker({
                            	        hourMax: ' . $res[endH] . ',
                            	        hourMin: ' . $res[startH] . ',
                            	        minuteMax: 55,
                            	        minuteMin: 00,
                            	        stepMinute: 5,
                            	        minuteGrid: 10,
                            	        hourGrid: 3,
                            	        dateFormat: "",
                            	        timeFormat: "HH:mm"
                            	    });
                            	    </script>';
    }
    $data .= '<table class="dialog-form-table" id="pasteTable">';
    $i = 1;
    while ($res1 = mysql_fetch_array($rResult1)) {
        $data .= '<tr>
                	                    <td style="width: 200px;"><label for="">შესვენება იწყება (' . $i . ')</label></td>
                	                    <td ><label for="">შესვენება მთავრდება (' . $i . ')</label></td>
                	                  </tr>
        	                          <tr>
        	                           <td><input class="breakStart' . $i . '" my_id' . $i . '="' . $res1[id] . '" style="width:145px;" type="text" value="' . $res1[break_start] . '" /></td>
                	                   <td><input class="breakEnd' . $i . '" style="width:145px;" type="text" value="' . $res1[break_end] . '" /></td>
                	                  </tr>
                	                       <script>
	        $(".breakStart' . $i . ',.breakEnd' . $i . '").timepicker({
    	        hourMax: ' . $res1[endH] . ',
    	        hourMin: ' . $res1[startH] . ',
    	        minuteMax: 55,
    	        minuteMin: 00,
    	        stepMinute: 5,
    	        minuteGrid: 10,
    	        hourGrid: 3,
    	        dateFormat: "",
    	        timeFormat: "HH:mm"
	        });
	        </script>';
        $i++;
    }
    $data .= '</table>
        		</fieldset >
        	</div>
        <input type="hidden" id="id" value=' . $_REQUEST[id] . '>';
    return $data;
}
Esempio n. 24
0
<link href="<?php 
echo $config['baseurl'];
?>
/assets/css/card.css" type="text/css" rel="stylesheet" />
<?php 
$projectId = intval($_GET['id']);
$statusNames = getStatusNames();
$cardTypes = getCardTypes();
$project = getProject($projectId);
if ($project) {
    $cards = Db::getResult('SELECT * FROM cards WHERE project_id = ?', $projectId);
    ?>
<div id="page-header">
    <h2><?php 
    echo $project['name'];
    ?>
 </h2>
    <div class="add-form-holder">
        <a id="create-card" href="#create-card"  class="ui-link ui-state-default ui-corner-all">
            <span class="ui-icon ui-icon-plusthick"></span>Add New Card
        </a>
        <form id="card-form" name="card-form" onsubmit="return createCard()" class="invisible">
            <label>Card Title</label>
            <input type="text" name="title" id="title" size="70"/>
            <label>type</label>
            <select name="card_type" id="card_type">
                <?php 
    foreach ($cardTypes as $cardType) {
        ?>
                <option value="<?php 
        echo $cardType['id'];
Esempio n. 25
0
//do relevant stuff with path[1]
switch ($path[0]) {
    case "login":
        switch ($method) {
            case "POST":
                $results = login($data);
                break;
            default:
                $results["meta"] = methodNotAllowed($method, $path);
        }
        break;
    case "projects":
        switch ($method) {
            case "GET":
                if (isset($path[1]) && trim($path[1]) !== "") {
                    $results = getProject($path[1]);
                } else {
                    $results = getProjects($data);
                }
                break;
            case "POST":
                $results = addProject($data);
                break;
            case "PATCH":
                if (isset($path[1]) && trim($path[1]) !== "") {
                    $data["projectID"] = $path[1];
                }
                $results = editProject($data);
                break;
            case "DELETE":
                if (isset($path[1]) && trim($path[1]) !== "") {
 private function _getThemlerData($themeName)
 {
     $project = getProject($themeName);
     $this->_checkThemlerRequirements($project, $themeName);
     $isNew = isset($_GET["create_theme"]) ? $_GET["create_theme"] : 'false';
     // for save and publish new theme
     $isActive = _THEME_NAME_ === $themeName || $isNew === 'true' ? 'true' : 'false';
     $base = $this->_adminUrl . '?themeName=' . $themeName . '&ajax=1&controller=AdminAjax&token=' . $this->token . '&action=';
     $templates = $this->_templateHelper->getThemeTemplates($themeName);
     return json_encode(array('themeName' => $themeName, 'templates' => $templates, 'canDuplicateTemplatesConstructors' => $this->_templateHelper->getDuplicatedTemplates(), 'themes' => $this->getThemesInfo(), 'url' => array('admin' => $this->_adminUrl, 'preview' => $templates['home']), 'ajax' => $this->_adminUrl, 'uploadImage' => $base . 'uploadImage', 'uploadTheme' => $base . 'uploadTheme', 'unZip' => $base . 'unZip', 'isActive' => $isActive, 'isNew' => $isNew, 'cmsVersion' => getThemeVersions(), 'cssJsSources' => getThemeCache(getThemeDir($themeName)), 'md5Hashes' => getThemeHashes(getThemeDir($themeName)), 'project' => $project, 'token' => $this->token, 'maxRequestSize' => getMaxRequestSize()));
 }
 foreach ($arr as $key => $value) {
     //$excel .= ucfirst($key)."/".$arr[$key]['mday']." ".$arr[$key]['month']."\t";
     $excel .= substr($arr[$key]['weekday'], 0, 3) . "\t";
     $worksheet->writeString($row, $tmp, substr($arr[$key]['weekday'], 0, 3), $formatboldcenter);
     $tmp++;
 }
 $excel .= "Total\r\n";
 $worksheet->writeString($row, $tmp, "Total", $formatbold);
 $tmp = 0;
 $row++;
 for ($x = 0; $x < 11; $x++) {
     $worksheet->writeString($row, $x, "", $formatborder);
 }
 foreach ($category as $categoryKey => $categoryValue) {
     $categorycnt[$categoryValue] = 1;
     $project = getProject($user_id, $categoryKey, $fromdate, $todate);
     if ($project) {
         foreach ($project as $projectKey => $projectValue) {
             $projectcnt[$projectValue] = 1;
             $task = getTask($user_id, $categoryKey, $projectKey, $fromdate, $todate);
             if ($task) {
                 $j = 0;
                 foreach ($task as $taskKey => $taskValue) {
                     if ($categorycnt[$categoryValue] == 1) {
                         $excel .= $categoryValue;
                         $worksheet->writeString($row, $tmp, $categoryValue, $format1);
                     }
                     $excel .= "\t";
                     $tmp++;
                     $categorycnt[$categoryValue]++;
                     if ($projectcnt[$projectValue] == 1) {
 *
 * Copyright (C) 2015 PEMapModder
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * @author PEMapModder
 */
include_once __DIR__ . "/utils.php";
header("Content-Type: application/json");
if (!isset($_REQUEST["cmd"])) {
    echo json_encode(["status" => false, "error" => "Missing request field"]);
    return;
}
if (getProject() === null) {
    echo json_encode(["status" => false, "error" => "Session timed out"]);
    return;
}
$proj = getProject();
if (!isset($proj->cmds[strtolower($_REQUEST["cmd"])])) {
    echo json_encode(["status" => false, "error" => "Command does not exist"]);
    return;
}
$cmd = $proj->cmds[strtolower($_REQUEST["cmd"])];
$exe = $cmd->executor;
unset($_SESSION["executors"][$exe->getExecutorId()]);
$exe->getContext()->deleteTree();
unset($proj->cmds[strtolower($_REQUEST["cmd"])]);
echo json_encode(["status" => true]);
Esempio n. 29
0
    ?>
    <td><?php 
    echo $returnArray[$key];
    ?>
 hours&nbsp;</td>
	<?php 
}
?>
	<td>&nbsp;</td>
  </tr>
  <?php 
$category = getCategory($_GET['user_id'], $fromdate, $todate);
if ($category) {
    foreach ($category as $categoryKey => $categoryValue) {
        $categorycnt[$categoryValue] = 1;
        $project = getProject($_GET['user_id'], $categoryKey, $fromdate, $todate);
        if ($project) {
            foreach ($project as $projectKey => $projectValue) {
                $projectcnt[$projectValue] = 1;
                $task = getTask($_GET['user_id'], $categoryKey, $projectKey, $fromdate, $todate);
                if ($task) {
                    $j = 0;
                    foreach ($task as $taskKey => $taskValue) {
                        ?>
  <tr>
	<td><?php 
                        if ($categorycnt[$categoryValue] == 1) {
                            echo $categoryValue;
                        }
                        $categorycnt[$categoryValue]++;
                        ?>
Esempio n. 30
0
function loadAlerts()
{
    global $ThisUsername;
    //gain access to the curent username
    global $ThisUsers;
    //gain access to the current user data
    global $ThisSchools;
    //gain access to the current school data
    global $ThisGroups;
    //gain access to the current group data
    global $ThisOrders;
    //gain access to the current order data
    global $ThisProjects;
    //gain access to the current project data
    global $alertHtml;
    //gain access to the alert html variable (end display html)
    global $alertRemovedA;
    //gain access to the array of removed alerts
    global $alertA;
    //gain access to the array of all alerts
    getUser($ThisUsername);
    //load the current user data based upon the user's username
    getSchool($ThisUsers['School Code']);
    //load the current school data for this user
    getGroup($ThisUsers['Group Code']);
    //load the current group data for this user
    getOrder($ThisGroups['Order Code']);
    //load the current order data for this group
    getProject($ThisOrders['Doc Code']);
    //load the current project data for this order
    $userDBAlertsA = explode("&&&", $ThisUsers['Alerts']);
    //split the user alert data string by &&& and store this array
    if (count($userDBAlertsA) == 2) {
        //if this array has two parts, (one &&& seperator)
        $alertRemovedA = explode(",,,", $userDBAlertsA[0]);
        //split the first part by ,,, and make these items the removed alerts (add the user removed alerts)
        addAlerts($userDBAlertsA[1]);
        //and process the other part using the addAlerts function (add the user alerts with respect to the removed alerts)
    }
    addAlerts($ThisSchools['Alerts']);
    //add the school alerts with respect to the removed alerts
    addAlerts($ThisGroups['Alerts']);
    //add the group alerts with respect to the removed alerts
    addAlerts($ThisOrders['Alerts']);
    //add the order alerts with respect to the removed alerts
    addAlerts($ThisProjects['Alerts']);
    //add the project alerts with respect to the removed alerts
    addAlerts("13,,,12,,,0,,,This is an alert! these can be sent to peeples' dashboards! They can be sent per group, school, individual, etc. ! This one should be blueish! Dale and Erik, you can make it look basicly however you want as long as it is stackable in this right pane!");
    //example alert
    addAlerts("23,,,22,,,1,,,Alerts basicly go away forever when you dismiss them.. these are just for testing.. This should be yellow-ish!");
    //example alert
    addAlerts("34,,,33,,,2,,,This one should be red-sih! WARNING! THE WORLD HAS ENDED!");
    //example alert
    $alertHtml = "";
    //set the alert html to be blank
    for ($i = 0; $i < count($alertA); $i++) {
        //for each alert that is to be printed,
        $thisAlertA = $alertA[$i];
        //create a temporary variable to store the data for this alert
        $alertHtml = $alertHtml . '<div class="alert-item-outer color-' . $thisAlertA[2] . '" id="alert-' . $thisAlertA[0] . '"><p align="left">' . $thisAlertA[3] . '</p><p align="right"><a style="color:#606060;" href="#" onclick="dismissAlert(' . "'" . $thisAlertA[0] . "'" . ');">Dismiss</a></p></div>';
        //add this alert
    }
    if ($alertHtml == '') {
        //if no alerts were added
        $alertHtml = '<p style="margin-top:3em;color:#ffffff;font-size: 300%;">No new alerts at this time</p>';
        //display the no new alerts text
    }
}