コード例 #1
0
ファイル: proposals.php プロジェクト: edwinraycom/vals-soc
function renderProposal($proposal, $target = 'none', $follow_action = 'show')
{
    //A proposal consists of: fields = array('proposal_id', 'owner_id', 'org_id', 'inst_id',
    //'supervisor_id', 'pid', 'solution_short', 'solution_long', 'state',);
    $propid = $proposal->proposal_id;
    $buttons = '';
    if (Users::isStudent() && Groups::isOwner(_PROPOSAL_OBJ, $propid) && $proposal->state != 'published') {
        $delete_action = "onclick='if(confirm(\"" . t('Are you sure you want to delete this proposal?') . "\")){ajaxCall(\"proposal\", \"delete\", " . "{type: \"proposal\", proposal_id: {$propid}, target: \"{$target}\"}, \"refreshTabs\", \"json\", " . "[\"proposal\", \"{$target}\", \"proposal\", \"\", \"{$follow_action}\"]);}'";
        $edit_action = "onclick='ajaxCall(\"proposal\", \"edit\", {type: \"proposal\", proposal_id: {$propid}, target: " . "\"{$target}\", format:\"html\"}, \"formResult\", \"html\", [\"{$target}\", \"proposal\"]);'";
        $buttons .= "<div class='totheright' id='proposal_buttons'><input type='button' value='" . t('edit') . "' {$edit_action}/>";
        $buttons .= "<input type='button' value='" . t('delete') . "' {$delete_action}/></div>";
    }
    $content = "<div id='msg_{$target}'></div>\r\n\t{$buttons}" . "<h1>" . ($proposal->title ? $proposal->title : Proposal::getDefaultName('', $proposal)) . " (" . renderDefaultField('state', $proposal) . ")</h1>\r\n\r\n\t<div id='personalia'>\r\n\t<h3>Parties involved</h3>\r\n\t\t<ul>\r\n\t\t\t<li>" . t('Supervisor') . ": " . renderDefaultField('supervisor_name', $proposal, 'supervisor_user_name') . "</i>" . "<li>" . t('Mentor') . ": " . renderDefaultField('mentor_name', $proposal, 'mentor_user_name') . "</i>" . "<li>" . t('Student') . ": " . renderDefaultField('student_name', $proposal, 'name') . "</i>" . "<li>" . t('Institute') . ": " . renderDefaultField('i_name', $proposal) . "</i>" . "<li>" . t('Organisation') . ": " . renderDefaultField('o_name', $proposal) . "</i>" . "</ul>\r\n\t</div>" . "<div id='project'>\r\n\t\t" . t('Project') . ": " . $proposal->pr_title . "\r\n\t</div>" . "<div id='proposal_text'>\r\n\t\t<h3>" . t('Solution Summary') . "</h3>\r\n\t\t" . renderDefaultField('solution_short', $proposal) . "<br/>" . "<a href='javascript:void(0)' data='off' onclick='makeVisible(\"solution_{$propid}\");'>" . t('more') . "</a>" . "\r\n\t\t\t<div id='solution_{$propid}' class='invisible'>\r\n\t\t\t<h3>Solution</h3>\r\n\t\t\t" . renderDefaultField('solution_long', $proposal) . "\r\n\t\t\t</div>\r\n\t</div>";
    module_load_include('inc', 'vals_soc', 'includes/ui/comments/threaded_comments');
    $content .= initComments($propid, _PROPOSAL_OBJ);
    return $content;
}
コード例 #2
0
function renderProject($project = '', $target = '', $inline = FALSE, $all_can_edit = _VALS_SOC_MENTOR_ACCESS_ALL)
{
    if (!$project) {
        return t('I cannot show this project. It seems empty.');
    }
    if (is_object($project)) {
        $project = objectToArray($project);
    } else {
        //It is NOT an object, so: array
    }
    $key_name = Groups::keyField(_PROJECT_OBJ);
    $id = $project[$key_name];
    $type = _PROJECT_OBJ;
    $role = getRole();
    $content = "<div class=\"totheright\">";
    if (_STUDENT_TYPE == getRole()) {
        $content .= "<br/><br/><input type='button' onclick=\"getProposalFormForProject(" . $project['pid'] . ")\" value='.t( 'Submit proposal for this project').'/>";
    }
    $is_inproject_organisation = Groups::isAssociate(_PROJECT_OBJ, $id);
    //If not inline and either owner or mentor and mentors allowed to edit...
    if (!$inline && ($all_can_edit && $is_inproject_organisation || Groups::isOwner(_PROJECT_OBJ, $id))) {
        $delete_action = "onclick='if(confirm(\"" . t('Are you sure you want to delete this project?') . "\")){ajaxCall(\"project\", \"delete\", {type: \"{$type}\", id: {$id}, target: \"{$target}\"}, \"refreshTabs\", \"json\", [\"{$type}\", \"{$target}\", \"project\"]);}'";
        $edit_action = "onclick='ajaxCall(\"project\", \"edit\", {type: \"{$type}\", id: {$id}, target: \"{$target}\"}, \"formResult\", \"html\", [\"{$target}\", \"project\"]);'";
        $content .= "<input type='button' value='" . t('edit') . "' {$edit_action}/>";
        $content .= "<input type='button' value='" . t('delete') . "' {$delete_action}/>";
    }
    $content .= "</div>";
    $content .= "<h2>" . $project['title'] . "</h2>";
    if ($is_inproject_organisation) {
        $content .= "<h3>Statistics</h3>";
        $content .= "<p>Number of student views: " . $project['views'] . "<BR>" . "Number of times marked by a student: " . $project['likes'] . "</p>";
    }
    $content .= '<p>' . $project['description'] . '</p>';
    if ($project['url']) {
        $content .= '<p>' . tt('More information can be found at %1$s', "<a href='{$project['url']}'> {$project['url']}</a>") . '</p>';
    }
    if (!$inline) {
        if (getRole() != _ANONYMOUS_TYPE) {
            module_load_include('inc', 'vals_soc', 'includes/ui/comments/threaded_comments');
            $content .= initComments($id, _PROJECT_OBJ);
        }
    }
    return $content;
}
コード例 #3
0
        }
        break;
    case 'view':
        $type = altSubValue($_POST, 'type', 'comment');
        $id = altSubValue($_POST, 'id');
        $target = altSubValue($_POST, 'target', '');
        if (!($id && $type && $target)) {
            die(t('There are missing arguments. Please inform the administrator of this mistake.'));
        }
        $post = ThreadedComments::getInstance()->getPostById($id);
        if (!$post) {
            echo tt('The post for this %1$s cannot be found', t_type($type));
        } else {
            $entity_id = $post['entity_id'];
            $entity_type = $post['entity_type'];
            $threaded_comments = new ThreadUIBuilder($entity_id, $entity_type);
            echo $threaded_comments->renderSingleComment($post);
        }
        break;
    case 'viewall':
        if (getRole() != _ANONYMOUS_TYPE) {
            $type = altSubValue($_GET, 'type');
            $id = altSubValue($_GET, 'id');
            module_load_include('inc', 'vals_soc', 'includes/ui/comments/threaded_comments');
            $content = initComments($id, $type);
            echo $content;
        }
        break;
    default:
        echo "No such action: " . $_GET['action'];
}