PHP Method User::getDepartmentIds, codiad Code Examples

This page contains top rated real world PHP examples of method User::getDepartmentIds from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: display_profile.php Project: nikosv/openeclass
0
                $tool_content .= "</div>
                        </div> <!-- end of col-xs-6 -->
                    </div> <!-- end of row -->
                </div> <!-- end of col-xs-12 profile-pers-info -->
            </div> <!-- end of pers_info row -->";
    if (!empty($userdata->description)) {
        $tool_content .= "<div id='profile-about-me' class='row'>
                            <div class='col-xs-12 col-md-10 col-md-offset-2 profile-pers-info'>
                            <h4>$langProfileAboutMe</h4><div>
                                ".standard_text_escape($userdata->description)."</div></div></div>";
    }
        $tool_content .= "
    <div id='profile-departments' class='row'>
        <div class='col-xs-12 col-md-10 col-md-offset-2 profile-pers-info'>            
            <div><span class='tag'>$langHierarchyNode : </span>";
            $departments = $user->getDepartmentIds($id);
                $i = 1;
                foreach ($departments as $dep) {
                    $br = ($i < count($departments)) ? '<br/>' : '';
                    $tool_content .= $tree->getFullPath($dep) . $br;
                    $i++;
                }
        $tool_content .= "</div>
            <div>
                <span class='tag'>$langProfileMemberSince : </span><span class='tag-value'>$userdata->registered_at</span>
            </div>
        </div>
    </div>";
//render custom profile fields content
$tool_content .= render_profile_fields_content(array('user_id' => $id));
$tool_content .= "</div>
Example #2
Show file File: multiedituser.php Project: nikosv/openeclass
0
                $subs = $user->getDepartmentIds($uid);
            }

            $count = 0;
            foreach ($subs as $key => $id) {
                $terms[] = $id;
                validateNode($id, isDepartmentAdmin());
                $count++;
            }

            $pref = ($c) ? 'a' : 'user';
            $criteria[] = $pref . '.id = user_department.user';
            $criteria[] = 'department IN (' . implode(', ', array_fill(0, $count, '?s')) . ')';
        }

        if (isset($_POST['move_submit'])) {
            $criteria[] = 'department = ?d';
            $terms[] = $dep;
        }

        $qry_criteria = (count($criteria)) ? implode(' AND ', $criteria) : '';
        // end filter/criteria

        if (!empty($c)) {
            $qry_base = " FROM user AS a LEFT JOIN course_user AS b ON a.id = b.user_id $depqryadd WHERE b.course_id = ?d ";
            array_unshift($terms, $c);
            if ($qry_criteria) {
                $qry_base .= ' AND ' . $qry_criteria;
            }
            $qry = "SELECT DISTINCT a.username " . $qry_base . " ORDER BY a.username ASC";
        } elseif ($search == 'no_login') {
            $qry_base = " FROM user LEFT JOIN loginout ON user.id = loginout.id_user $depqryadd WHERE loginout.id_user IS NULL ";
            if ($qry_criteria) {
                $qry_base .= ' AND ' . $qry_criteria;
            }
            $qry = "SELECT DISTINCT username " . $qry_base . ' ORDER BY username ASC';
        } else {
            $qry_base = ' FROM user' . $depqryadd;
            if ($qry_criteria) {
                $qry_base .= ' WHERE ' . $qry_criteria;
            }
            $qry = 'SELECT DISTINCT username ' . $qry_base . ' ORDER BY username ASC';
        }

        Database::get()->queryFunc($qry
                , function($users) use(&$usernames) {
            $usernames .= $users->username . "\n";
        }, $terms);
    }

    $tool_content .= action_bar(array(
            array('title' => $langBack,
                'url' => "index.php",
                'icon' => 'fa-reply',
                'level' => 'primary-label')));

    if (isset($_POST['activate_submit'])) {
        $infoText = $langActivateUserInfo;
        $monthsField = "
                <div class='form-group'>
                    <label class='col-sm-2 control-label' for='months-id'>$langActivateMonths:</label>
                    <div class='col-sm-9'>
                        <input name='months' id='months-id' class='form-control' type='number' min='1' step='1' value='6'>
                    </div>
                </div>";
        $confirm = '';
    } elseif (isset($_POST['move_submit'])) {
        $nodePickerParams = array(
            'defaults' => $dep,
            'multiple' => false);
        if (isDepartmentAdmin()) {
            $nodePickerParams['allowables'] = $user->getDepartmentIds($uid);
Example #3
Show file File: multideluser.php Project: kostastzo/openeclass
0
 $criteria[] = 'email LIKE ?s';
 $terms[] = '%' . $email . '%';
 if ($search == 'inactive') {
     $criteria[] = 'expires_at < ' . DBHelper::timeAfter();
 }
 // Department search
 $depqryadd = '';
 $dep = isset($_POST['department']) ? intval($_POST['department']) : 0;
 if ($dep || isDepartmentAdmin()) {
     $depqryadd = ', user_department';
     $subs = array();
     if ($dep) {
         $subs = $tree->buildSubtrees(array($dep));
     } else {
         if (isDepartmentAdmin()) {
             $subs = $user->getDepartmentIds($uid);
         }
     }
     $count = 0;
     foreach ($subs as $key => $id) {
         $terms[] = $id;
         validateNode($id, isDepartmentAdmin());
         $count++;
     }
     $pref = $c ? 'a' : 'user';
     $criteria[] = $pref . '.user.id = user_department.user';
     $criteria[] = 'department IN (' . array_fill(0, $count, '?s') . ')';
 }
 $qry_criteria = count($criteria) ? implode(' AND ', $criteria) : '';
 // end filter/criteria
 if (!empty($c)) {
Example #4
Show file File: infocours.php Project: kostastzo/openeclass
0
    if (isDepartmentAdmin()) {
        $olddeps = $course->getDepartmentIds($cId);
        foreach ($departments as $depId) {
            if (!in_array($depId, $olddeps)) {
                validateNode(intval($depId), true);
            }
        }
        foreach ($olddeps as $depId) {
            if (!in_array($depId, $departments)) {
                validateNode($depId, true);
            }
        }
    }
    // Update query
    Database::get()->query("UPDATE course SET title = ?s,\n                    prof_names = ?s\n                    WHERE code = ?s", $_POST['title'], $_POST['titulary'], $_GET['c']);
    $course->refresh($cId, $departments);
    $tool_content .= "<div class='alert alert-success'>{$langModifDone}</div>";
} else {
    $row = Database::get()->querySingle("SELECT course.code AS code, course.title AS title, course.prof_names AS prof_name, course.id AS id\n                                            FROM course\n                                           WHERE course.code = ?s", $_GET['c']);
    $tool_content .= "<div class='form-wrapper'>\n\t<form role='form' class='form-horizontal' action='" . $_SERVER['SCRIPT_NAME'] . "?c=" . q($_GET['c']) . "' method='post' onsubmit='return validateNodePickerForm();'>\n\t<fieldset>\n        <div class='form-group'>\n\t    <label for='Faculty' class='col-sm-2 control-label'>{$langFaculty}:</label>\n            <div class='col-sm-10'>";
    if (isDepartmentAdmin()) {
        list($js, $html) = $tree->buildCourseNodePicker(array('defaults' => $course->getDepartmentIds($row->id), 'allowables' => $user->getDepartmentIds($uid)));
    } else {
        list($js, $html) = $tree->buildCourseNodePicker(array('defaults' => $course->getDepartmentIds($row->id)));
    }
    $head_content .= $js;
    $tool_content .= $html;
    $tool_content .= "</div></div>";
    $tool_content .= "<div class='form-group'>\n            <label for='fcode' class='col-sm-2 control-label'>{$langCode}</label>\n            <div class='col-sm-10'>\n                <input type='text' class='form-control' name='fcode' id='fcode' value='{$row->code}' size='60' />\n            </div>\n        </div>\n        <div class='form-group'>\n            <label for='title' class='col-sm-2 control-label'>{$langCourseTitle}:</label>\n            <div class='col-sm-10'>\n\t\t<input type='text' class='form-control' name='title' id='title' value='" . q($row->title) . "' size='60' />\n\t    </div>\n        </div>\n        <div class='form-group'>\n            <label for='titulary' class='col-sm-2 control-label'>{$langTeachers}:</label>\n            <div class='col-sm-10'>\n\t\t<input type='text' class='form-control' name='titulary' id='titulary' value='" . q($row->prof_name) . "' size='60' />\n\t    </div>\n        </div>\n        <div class='form-group'>\n            <div class='col-sm-10 col-sm-offset-4'>\n                <input class='btn btn-primary' type='submit' name='submit' value='{$langModify}'>\n            </div>\n        </div>\n        </fieldset>\n\t</form>\n        </div>";
}
draw($tool_content, 3, null, $head_content);
Example #5
Show file File: search_user.php Project: nikosv/openeclass
0
$am = isset($_GET['am']) ? $_GET['am'] : '';
$verified_mail = isset($_GET['verified_mail']) ? intval($_GET['verified_mail']) : 3;
$user_type = isset($_GET['user_type']) ? intval($_GET['user_type']) : '';
$auth_type = isset($_GET['auth_type']) ? intval($_GET['auth_type']) : '';
$email = isset($_GET['email']) ? mb_strtolower(trim($_GET['email'])) : '';
$reg_flag = isset($_GET['reg_flag']) ? intval($_GET['reg_flag']) : '';
$user_registered_at = isset($_GET['user_registered_at']) ? $_GET['user_registered_at'] : '';

if (isset($_GET['department'])) {
    $depts_defaults = array('params' => 'name="department"', 'tree' => array('0' => $langAllFacultes), 'multiple' => false, 'defaults' => array_map('intval', $_GET['department']));
} else {
    $depts_defaults = array('params' => 'name="department"', 'tree' => array('0' => $langAllFacultes), 'multiple' => false);
}

if (isDepartmentAdmin()) {
    $allowables = array('allowables' => $user->getDepartmentIds($uid));
    $depts_defaults = array_merge($depts_defaults, $allowables);
}

// Display Actions Toolbar
$tool_content .= action_bar(array(
            array('title' => $langAllUsers,
                'url' => "listusers.php?search=yes",
                'icon' => 'fa-search',
                'level' => 'primary-label'),
            array('title' => $langInactiveUsers,
                'url' => "listusers.php?search=inactive",
                'icon' => 'fa-search',
                'level' => 'primary-label'),
            array('title' => $langBack,
                'url' => "index.php",
Example #6
Show file File: searchcours.php Project: kostastzo/openeclass
0
            break;
        case "3":
            $typeSel[0] = "selected";
            break;
        default:
            $typeSel[-1] = "selected";
            break;
    }
}
$tool_content .= "<div class='form-group'>\n        <label for='formsearchtype' class='col-sm-2 control-label'>{$langCourseVis}:</label>\n        <div class='col-sm-10'>\n          <select class='form-control' name='formsearchtype'>\n           <option value='-1' " . @$typeSel[-1] . ">{$langAllTypes}</option>\n           <option value='2' " . @$typeSel[2] . ">{$langTypeOpen}</option>\n           <option value='1' " . @$typeSel[1] . ">{$langTypeRegistration}</option>\n           <option value='0' " . @$typeSel[0] . ">{$langTypeClosed}</option>\n           <option value='3' " . @$typeSel[3] . ">{$langCourseInactiveShort}</option>\n          </select>\n        </div>\n      </div>";
$reg_flag_data = array();
$reg_flag_data[1] = $langAfter;
$reg_flag_data[2] = $langBefore;
$tool_content .= "<div class='form-group'><label class='col-sm-2 control-label'>{$langCreationDate}:</label>";
$tool_content .= "<div class='col-sm-5'>" . selection($reg_flag_data, 'reg_flag', $reg_flag, 'class="form-control"') . "</div>";
$tool_content .= "<div class='col-sm-5'>";
$tool_content .= "<input class='form-control' id='id_date' name='date' type='text' value='{$date}' data-date-format='dd-mm-yyyy' placeholder='{$langCreationDate}'>                    \n                </div>";
$tool_content .= "</div>";
$tool_content .= "<div class='form-group'><label class='col-sm-2 control-label'>{$langFaculty}:</label>";
$tool_content .= "<div class='col-sm-10'>";
if (isDepartmentAdmin()) {
    list($js, $html) = $tree->buildNodePicker(array('params' => 'name="formsearchfaculte"', 'tree' => array('0' => $langAllFacultes), 'useKey' => "id", 'multiple' => false, 'allowables' => $user->getDepartmentIds($uid)));
} else {
    list($js, $html) = $tree->buildNodePicker(array('params' => 'name="formsearchfaculte"', 'tree' => array('0' => $langAllFacultes), 'useKey' => "id", 'multiple' => false));
}
$head_content .= $js;
$tool_content .= $html;
$tool_content .= "</div></div>";
$tool_content .= "<div class='form-group'>\n                    <div class='col-sm-10 col-sm-offset-2'>\n                        <input class='btn btn-primary' type='submit' name='search_submit' value='{$langSearch}'>\n                        <a href='index.php' class='btn btn-default'>{$langCancel}</a>        \n                    </div>\n      </div>";
$tool_content .= "</fieldset></form></div>";
draw($tool_content, 3, null, $head_content);
Example #7
Show file File: index.php Project: kostastzo/openeclass
0
         case '10':
             $course_license = 10;
             break;
         default:
             $course_license = 0;
             break;
     }
 }
 // disable visibility if it is opencourses certified
 if (get_config('opencourses_enable') && $isOpenCourseCertified) {
     $_POST['formvisible'] = '2';
 }
 $departments = isset($_POST['department']) ? $_POST['department'] : array();
 $deps_valid = true;
 foreach ($departments as $dep) {
     if (get_config('restrict_teacher_owndep') && !$is_admin && !in_array($dep, $user->getDepartmentIds($uid))) {
         $deps_valid = false;
     }
 }
 //===================course format and start and finish date===============
 //check if there is a start and finish date if weekly selected
 if ($_POST['view_type'] || $_POST['start_date'] || $_POST['finish_date']) {
     if (!$_POST['start_date']) {
         //if no start date do not allow weekly view and show alert message
         $view_type = 'units';
         $_POST['start_date'] = '0000-00-00';
         $_POST['finish_date'] = '0000-00-00';
         $noWeeklyMessage = 1;
     } else {
         //if there is start date create the weeks from that start date
         //Number of the previous week records for this course
Example #8
Show file File: edituser.php Project: nikosv/openeclass
0
            list($js, $html) = $tree->buildUserNodePicker(array('defaults' => $user->getDepartmentIds($u)));
        }
        $head_content .= $js;
        $tool_content .= $html;
        $tool_content .= "</div></div>
        <div class='form-group'>
          <label class='col-sm-2 control-label'>$langProperty:</label>
          <div class='col-sm-10'>";
        if ($info->status == USER_GUEST) { // if we are guest user do not display selection
            $tool_content .= selection(array(USER_GUEST => $langGuest), 'newstatus', intval($info->status), "class='form-control'");
        } else {
            $tool_content .= selection(array(USER_TEACHER => $langTeacher,
                USER_STUDENT => $langStudent), 'newstatus', intval($info->status), "class='form-control'");
        }
        $tool_content .= "</div></div>";
        $reg_date = DateTime::createFromFormat("Y-m-d H:i:s", $info->registered_at);
        $exp_date = DateTime::createFromFormat("Y-m-d H:i:s", $info->expires_at);
        $tool_content .= "<div class='form-group'>
                <label class='col-sm-2 control-label'>$langRegistrationDate:</label>
                <div class='col-sm-10'>" . $reg_date->format("d-m-Y H:i") . "</div>
            </div>
         <div class='input-append date form-group' id='user_date_expires_at' data-date='" . $exp_date->format("d-m-Y H:i") . "' data-date-format='dd-mm-yyyy'>
         <label class='col-sm-2 control-label'>$langExpirationDate: </label>
            <div class='col-xs-10 col-sm-9'>
                <input class='form-control' name='user_date_expires_at' type='text' value='" . $exp_date->format("d-m-Y H:i") . "'>
            </div>
        <div class='col-xs-2 col-sm-1'>
            <span class='add-on'><i class='fa fa-times'></i></span>
            <span class='add-on'><i class='fa fa-calendar'></i></span>
        </div>
         </div>
        <div class='form-group'>
          <label class='col-sm-2 control-label'>$langUserID: </label>
          <div class='col-sm-10'>$u</div>
        </div>
        <div class='form-group'>
          <label class='col-sm-2 control-label'>$langUserWhitelist</label>
          <div class='col-sm-10'><textarea rows='6' cols='60' name='user_upload_whitelist'>" . q($info->whitelist) . "</textarea></div>
        </div>";
        //show custom profile fields input
        if ($info->status != USER_GUEST) {
            $tool_content .= render_profile_fields_form(array('origin' => 'admin_edit_profile', 'user_id' => $u));
        }
        $tool_content .= "<input type='hidden' name='u' value='$u' />
        <input type='hidden' name='u_submitted' value='1' />
        <input type='hidden' name='registered_at' value='" . $info->registered_at . "' />
        <div class='col-sm-offset-2 col-sm-10'>
	    <input class='btn btn-primary' type='submit' name='submit_edituser' value='$langModify' />
        </div>
        </fieldset>
        </form>
        </div>";
        $sql = Database::get()->queryArray("SELECT a.code, a.title, a.id, a.visible, DATE(b.reg_date) AS reg_date, b.status
                            FROM course AS a
                            JOIN course_department ON a.id = course_department.course
                            JOIN hierarchy ON course_department.department = hierarchy.id
                            LEFT JOIN course_user AS b ON a.id = b.course_id
                            WHERE b.user_id = ?s ORDER BY b.status, hierarchy.name", $u);

        // user is registered to courses
        if (count($sql) > 0) {
            $tool_content .= "<h4>$langStudentParticipation</h4>
                    <div class='table-responsive'>
                    <table class='table-default'>
                    <tr>
                    <th class='text-left'>$langCode</th>
                    <th class='text-left'>$langLessonName</th>
                    <th>$langCourseRegistrationDate</th>
                    <th>$langProperty</th>
                    <th>$langActions</th>
                    </tr>";
            foreach ($sql as $logs) {
                if ($logs->visible == COURSE_INACTIVE) {
                    $tool_content .= "<tr class='not_visible'>";
                }
                $tool_content .= "<td><a href='{$urlServer}courses/$logs->code/'>" . q($logs->code) . "</a></td>
                        <td>" . q($logs->title) . "</td><td align='center'>";
                if ($logs->reg_date == '0000-00-00') {
                    $tool_content .= $langUnknownDate;
                } else {
                    $tool_content .= " " . nice_format($logs->reg_date) . " ";
                }
                $tool_content .= "</td><td class='text-center'>";
                if ($logs->status == USER_TEACHER) {
                    $tool_content .= $langTeacher;
                    $tool_content .= "</td><td align='center'>---</td></tr>\n";
                } else {
                    if ($logs->status == USER_STUDENT) {
                        $tool_content .= $langStudent;
                    } else {
                        $tool_content .= $langVisitor;
                    }
                    $tool_content .= "</td><td class='text-center'>" .
                            icon('fa-ban', $langUnregCourse, "unreguser.php?u=$u&amp;c=$logs->id") . "</tr>";
                }
            }
            $tool_content .= "</table></div>";
        } else {
            $tool_content .= "<div class='alert alert-warning'>$langNoStudentParticipation</div>";
        }
    } else { // if the form was submitted then update user

        // get the variables from the form and initialize them
        $fname = isset($_POST['fname']) ? $_POST['fname'] : '';
        $lname = isset($_POST['lname']) ? $_POST['lname'] : '';
        // trim white spaces in the end and in the beginning of the word
        $username = isset($_POST['username']) ?$_POST['username'] : '';
        $email = isset($_POST['email']) ? mb_strtolower(trim($_POST['email'])) : '';
        $phone = isset($_POST['phone']) ? $_POST['phone'] : '';
        $am = isset($_POST['am']) ? $_POST['am'] : '';
        $departments = isset($_POST['department']) ? $_POST['department'] : 'NULL';
        $newstatus = isset($_POST['newstatus']) ? $_POST['newstatus'] : 'NULL';
        $registered_at = isset($_POST['registered_at']) ? $_POST['registered_at'] : '';
        if (isset($_POST['user_date_expires_at'])) {
            $expires_at = DateTime::createFromFormat("d-m-Y H:i", $_POST['user_date_expires_at']);
            $user_expires_at = $expires_at->format("Y-m-d H:i");
            $user_date_expires_at = $expires_at->format("d-m-Y H:i");
        }

        $user_upload_whitelist = isset($_POST['user_upload_whitelist']) ? $_POST['user_upload_whitelist'] : '';
        $user_exist = FALSE;
        // check if username is free
        if (Database::get()->querySingle("SELECT username FROM user
                                           WHERE id <> ?d AND
                                                 username = ?s", $u, $username)) {
            $user_exist = TRUE;
        }
        
        //check for validation errors in custom profile fields
        $cpf_check = cpf_validate_format();
        
        // check if there are empty fields
        if (empty($fname) or empty($lname) or empty($username) or cpf_validate_required_edituser() === false) {
            Session::Messages($langFieldsMissing, 'alert-danger');
            redirect_to_home_page('modules/admin/edituser.php?u=' . $u);
        } elseif (isset($user_exist) and $user_exist == true) {
            Session::Messages($langUserFree, 'alert-danger');
            redirect_to_home_page('modules/admin/edituser.php?u=' . $u);
        } elseif ($cpf_check[0] === false) {
            $cpf_error_str = '';
            unset($cpf_check[0]);
            foreach ($cpf_check as $cpf_error) {
                $cpf_error_str .= $cpf_error;
            }
            $tool_content .= "<div class='alert alert-danger'>$cpf_error_str <br>
                                <a href='$_SERVER[SCRIPT_NAME]'>$langAgain</a></div";
            draw($tool_content, 3, null, $head_content);
            exit();
        }

        if ($registered_at > $user_expires_at) {
            Session::Messages($langExpireBeforeRegister, 'alert-warning');
        }

        // email cannot be verified if there is no mail saved
        if (empty($email) and $verified_mail) {
            $verified_mail = 2;
        }

        // if depadmin then diff new/old deps and if new or deleted deps are out of juristinction, then error
        if (isDepartmentAdmin()) {
            $olddeps = $user->getDepartmentIds(intval($u));
Example #9
Show file File: profile.php Project: kostastzo/openeclass
0
            break;
        case EMAIL_VERIFIED:
            $message = icon('fa-check', $langMailVerificationYesU);
            break;
        case EMAIL_UNVERIFIED:
            $link = "<a href = '../auth/mail_verify_change.php?from_profile=TRUE'>{$langHere}</a>.";
            $message = "<div class='alert alert-warning'>{$langMailNotVerified} {$link}</div>";
        default:
            break;
    }
    $tool_content .= "<div class='form-group'><label for='mailstatus' class='col-sm-2 control-label'>{$langVerifiedMail}</label>\n                        {$message}</div>";
}
if (!get_config('restrict_owndep')) {
    $tool_content .= "<div class='form-group'><label for='faculty' class='col-sm-2 control-label'>{$langFaculty}:</label>";
    $tool_content .= "<div class='col-sm-10'>";
    list($js, $html) = $tree->buildUserNodePicker(array('defaults' => $userObj->getDepartmentIds($uid)));
    $head_content .= $js;
    $tool_content .= $html;
    $tool_content .= "</div></div>";
}
$tool_content .= "<div class='form-group'><label for='language' class='col-sm-2 control-label'>{$langLanguage}:</label>\n                      <div class='col-sm-10'>" . lang_select_options('userLanguage', "class='form-control'") . "</div>\n                  </div>";
if ($icon) {
    $message_pic = $langReplacePicture;
    $picture = profile_image($uid, IMAGESIZE_SMALL) . "&nbsp;&nbsp;";
    $delete = '&nbsp;' . icon('fa-times', $langDelete, '#', 'id="delete"') . '&nbsp;';
} else {
    $picture = $delete = '';
    $message_pic = $langAddPicture;
}
$tool_content .= "<div class='form-group'>\n        <label for='picture' class='col-sm-2 control-label'>{$message_pic}</label>\n            <div class='col-sm-10'><span>{$picture}{$delete}</span><input type='file' name='userimage' size='30'></div>\n        </div>\n        <div class='form-group'>      \n          <label for='desription' class='col-sm-2 control-label'>{$langDescription}:</label>\n          <div class='col-sm-10'>" . rich_text_editor('desc_form', 5, 20, $desc_form) . "</div>\n        </div>\n        <div class='col-sm-offset-2 col-sm-10'>        \n          <input class='btn btn-primary' type='submit' name='submit' value='{$langSubmit}'>\n          <a href='display_profile.php' class='btn btn-default'>{$langCancel}</a>\n        </div>      \n      </fieldset>\n      </form>\n      </div>";
draw($tool_content, 1, null, $head_content);
Example #10
Show file File: create_course.php Project: kostastzo/openeclass
0
</script>
hContent;
register_posted_variables(array('title' => true, 'password' => true, 'prof_names' => true));
if (empty($prof_names)) {
    $prof_names = "{$_SESSION['givenname']} {$_SESSION['surname']}";
}
$departments = isset($_POST['department']) ? $_POST['department'] : array();
$deps_valid = true;
foreach ($departments as $dep) {
    if (get_config('restrict_teacher_owndep') && !$is_admin && !in_array($dep, $user->getDepartmentIds($uid))) {
        $deps_valid = false;
    }
}
// Check if the teacher is allowed to create in the departments he chose
if (!$deps_valid) {
    $tool_content .= "<div class='alert alert-danger'>{$langCreateCourseNotAllowedNode}</div>\n                    <p class='pull-right'><a class='btn btn-default' href='{$_SERVER['PHP_SELF']}'>{$langBack}</a></p>";
    draw($tool_content, 1, null, $head_content);
    exit;
}
// display form
if (!isset($_POST['create_course'])) {
    $allow_only_defaults = get_config('restrict_teacher_owndep') && !$is_admin ? true : false;
    list($js, $html) = $tree->buildCourseNodePicker(array('defaults' => $user->getDepartmentIds($uid), 'allow_only_defaults' => $allow_only_defaults));
    $head_content .= $js;
    foreach ($license as $id => $l_info) {
        if ($id and $id < 10) {
            $cc_license[$id] = $l_info['title'];
        }
    }
    $tool_content .= "\n<div class='form-wrapper'>\n    <form class='form-horizontal' role='form' method='post' name='createform' action='{$_SERVER['SCRIPT_NAME']}' onsubmit=\"return validateNodePickerForm() && checkrequired(this, 'title', 'prof_names');\">\n        <fieldset>\n            <div class='form-group'>\n                <label for='title' class='col-sm-2 control-label'>{$langTitle}:</label>\n                <div class='col-sm-10'>\n                  <input name='title' id='title' type='text' class='form-control' id='exerciseTitle' value='" . q($title) . "' placeholder='{$langTitle}'>\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='dialog-set-value' class='col-sm-2 control-label'>{$langFaculty}:</label>\n                <div class='col-sm-10'>\n                  {$html}\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='prof_names' class='col-sm-2 control-label'>{$langTeachers}:</label>\n                <div class='col-sm-10'>\n                      <input class='form-control' type='text' name='prof_names' id='prof_names' value='" . q($prof_names) . "'>\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='localize' class='col-sm-2 control-label'>{$langLanguage}:</label>\n                <div class='col-sm-10'>\n                      " . lang_select_options('localize', "class='form-control'") . "\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='description' class='col-sm-2 control-label'>{$langDescrInfo} <small>{$langOptional}</small>:</label>\n                <div class='col-sm-10'>\n                      " . rich_text_editor('description', 4, 20, @$description) . "\n                </div>\n            </div>\n            <div class='form-group'>\n                <label class='col-sm-2 control-label'>{$langCourseFormat}:</label>\n                <div class='col-sm-10'>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='view_type' value='simple' id='simple'>\n                        {$langCourseSimpleFormat}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='view_type' value='units' id='units' checked>\n                        {$langWithCourseUnits}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='view_type' value='weekly' id='weekly'>\n                        {$langCourseWeeklyFormat}\n                      </label>\n                    </div>                         \n                </div>\n            </div>\n            <div class='form-group' id='weeklyDates'>\n                <div class='col-sm-10 col-sm-offset-2'>\n                      {$langStartDate} <input class='dateInForm form-control' type='text' name='start_date' value='' readonly>\n                </div>\n                <div class='col-sm-10 col-sm-offset-2'>\n                      {$langDuration} <input class='dateInForm form-control' type='text' name='finish_date' value='' readonly>\n                </div>                \n            </div>\n            <div class='form-group'>\n                <label class='col-sm-2 control-label'>{$langOpenCoursesLicense}:</label>\n                <div class='col-sm-10'>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='l_radio' value='0' checked>\n                        {$license[0]['title']}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='l_radio' value='10'>\n                        {$license[10]['title']}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input id='cc_license' type='radio' name='l_radio' value='cc'>\n                        {$langCMeta['course_license']}\n                      </label>\n                    </div>                         \n                </div>\n            </div>\n            <div class='form-group' id='cc'>\n                <div class='col-sm-10 col-sm-offset-2'>\n                      " . selection($cc_license, 'cc_use', "", 'class="form-control"') . "\n                </div>              \n            </div>\n            <div class='form-group'>\n                <label for='localize' class='col-sm-2 control-label'>{$langAvailableTypes}:</label>\n                <div class='col-sm-10'>\n                    <div class='radio'>\n                      <label>\n                        <input id='courseopen' type='radio' name='formvisible' value='2' checked>\n                        <img src='{$themeimg}/lock_open.png' alt='{$langOpenCourse}' title='{$langOpenCourse}' width='16'>&nbsp;{$langOpenCourse}\n                        <span class='help-block'><small>{$langPublic}</small></span>\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input id='coursewithregistration' type='radio' name='formvisible' value='1'>\n                        <img src='{$themeimg}/lock_registration.png' alt='{$m['legrestricted']}' title='{$m['legrestricted']}' width='16'>&nbsp;{$m['legrestricted']}\n                        <span class='help-block'><small>{$langPrivOpen}</small></span>\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input id='courseclose' type='radio' name='formvisible' value='0'>\n                        <img src='{$themeimg}/lock_closed.png' alt='{$langClosedCourse}' title='{$langClosedCourse}' width='16'>&nbsp;{$langClosedCourse}\n                        <span class='help-block'><small>{$langClosedCourseShort}</small></span>\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input id='courseinactive' type='radio' name='formvisible' value='3'>\n                        <img src='{$themeimg}/lock_inactive.png' alt='{$langInactiveCourse}' title='{$langInactiveCourse}' width='16'>&nbsp;{$langInactiveCourse}\n                        <span class='help-block'><small>{$langCourseInactiveShort}</small></span>\n                      </label>\n                    </div>                   \n                </div>\n                <div class='form-group'>\n                    <label for='coursepassword' class='col-sm-2 control-label'>{$langOptPassword}:</label>\n                    <div class='col-sm-10'>\n                          <input class='form-control' id='coursepassword' type='text' name='password' value='" . @q($password) . "' class='FormData_InputText' autocomplete='off'>\n                    </div>\n                </div>\n                <div class='form-group'>\n                    <div class='col-sm-10 col-sm-offset-2'>\n                          <input class='btn btn-primary' type='submit' name='create_course' value='" . q($langCourseCreate) . "'>\n                          <a href='{$urlServer}main/portfolio.php' class='btn btn-default'>{$langCancel}</a>\n                    </div>\n                </div>                 \n            </div>\n            <div class='text-right'><small>{$langFieldsOptionalNote}</small></div>\n        </fieldset>\n    </form>\n</div>";
} else {
    // create the course and the course database
Example #11
Show file File: multireguser.php Project: kostastzo/openeclass
0
    if (!empty($unparsed_lines)) {
        $tool_content .= "<p><b>{$langErrors}</b></p><pre>" . q($unparsed_lines) . "</pre>";
    }
    $tool_content .= "<table class='table-default'><tr><th>{$langSurname}</th><th>{$langName}</th><th>e-mail</th><th>{$langPhone}</th><th>{$langAm}</th><th>username</th><th>password</th></tr>\n";
    foreach ($new_users_info as $n) {
        $tool_content .= "<tr><td>" . q($n[1]) . "</td><td>" . q($n[2]) . "</td><td>" . q($n[3]) . "</td><td>" . q($n[4]) . "</td><td>" . q($n[5]) . "</td><td>" . q($n[6]) . "</td><td>" . q($n[7]) . "</td></tr>\n";
    }
    $tool_content .= "</table>";
} else {
    Database::get()->queryFunc("SELECT id, name FROM hierarchy WHERE allow_course = true ORDER BY name", function ($n) use(&$facs) {
        $facs[$n->id] = $n->name;
    });
    $access_options = array(ACCESS_PRIVATE => $langProfileInfoPrivate, ACCESS_PROFS => $langProfileInfoProfs, ACCESS_USERS => $langProfileInfoUsers);
    $tool_content .= "<div class='alert alert-info'>{$langMultiRegUserInfo}</div>\n        <div class='form-wrapper'>\n        <form class='form-horizontal' role='form' method='post' action='{$_SERVER['SCRIPT_NAME']}' onsubmit='return validateNodePickerForm();' >\n        <fieldset>        \n        <div class='form-group'>\n            <label for='fields' class='col-sm-3 control-label'>{$langMultiRegFields}:</label>\n            <div class='col-sm-9'>\n                <input class='form-control' id='fields' type='text' name='fields' value='first last id email phone'>\n            </div>\n        </div>\n        <div class='form-group'>\n            <label for='user_info' class='col-sm-3 control-label'>{$langUsersData}:</label>\n            <div class='col-sm-9'>\n                <textarea class='auth_input form-control' name='user_info' id='user_info' rows='10'></textarea>\n            </div>\n        </div>\n        <div class='form-group'>\n            <label for='type' class='col-sm-3 control-label'>{$langMultiRegType}:</label>\n            <div class='col-sm-9'>\n                <select class='form-control' name='type' id='type'>\n                    <option value='stud'>{$langsOfStudents}</option>\n                    <option value='prof'>{$langOfTeachers}</option>\n                </select>\n            </div>\n        </div>\n        <div class='form-group'>\n            <label for='prefix' class='col-sm-3 control-label'>{$langMultiRegPrefix}:</label>\n            <div class='col-sm-9'>\n                <input class='form-control' type='text' name='prefix' id='prefix' value='user'>\n            </div>\n        </div>\n        <div class='form-group'>\n        <label class='col-sm-3 control-label'>{$langFaculty}:</label>\n            <div class='col-sm-9'>";
    if (isDepartmentAdmin()) {
        list($js, $html) = $tree->buildUserNodePicker(array('params' => 'name="facid[]"', 'allowables' => $user->getDepartmentIds($uid)));
    } else {
        list($js, $html) = $tree->buildUserNodePicker(array('params' => 'name="facid[]"'));
    }
    $head_content .= $js;
    $tool_content .= $html;
    $tool_content .= "</div>\n        </div>\n        <div class='form-group'>\n            <label for='am' class='col-sm-3 control-label'>{$langAm}:</label>\n            <div class='col-sm-9'>\n                <input class='form-control' type='text' name='am' id='am'>\n            </div>\n        </div>\n        <div class='form-group'>\n        <label for='lang' class='col-sm-3 control-label'>{$langLanguage}:</label>\n            <div class='col-sm-9'>" . lang_select_options('lang', 'class="form-control"') . "</div>\n        </div>\n        <div class='form-group'>\n        <label for='email_public' class='col-sm-3 control-label'>{$langEmail}</label>\n            <div class='col-sm-9'>" . selection($access_options, 'email_public', ACCESS_PRIVATE, 'class="form-control"') . "</div>\n        </div>\n        <div class='form-group'>\n        <label for='am_public' class='col-sm-3 control-label'>{$langAm}</label>\n            <div class='col-sm-9'>" . selection($access_options, 'am_public', ACCESS_PRIVATE, 'class="form-control"') . "</div>\n        </div>\n        <div class='form-group'>\n        <label for='phone_public' class='col-sm-3 control-label'>{$langPhone}</label>\n            <div class='col-sm-9'>" . selection($access_options, 'phone_public', ACCESS_PRIVATE, 'class="form-control"') . "</div>\n        </div>\n        <div class='form-group'>\n        <label for='send_mail' class='col-sm-3 control-label'>{$langInfoMail}</label>\n            <div class='col-sm-9'>\n                <div class='checkbox'>\n                    <label>\n                        <input name='send_mail' id='send_mail' type='checkbox'> {$langMultiRegSendMail}\n                    </label>\n                </div>            \n            </div>\n        </div>\n        <div class='form-group'>\n            <div class='col-sm-9 col-sm-offset-3'>\n                <input class='btn btn-primary' type='submit' name='submit' value='{$langSubmit}'>\n                <a class='btn btn-default' href='index.php'>{$langCancel}</a>\n            </div>\n        </div>       \n        </fieldset>\n        </form>\n        </div>";
}
draw($tool_content, 3, null, $head_content);
function create_user($status, $uname, $password, $surname, $givenname, $email, $departments, $am, $phone, $lang, $send_mail, $email_public, $phone_public, $am_public)
{
    global $charset, $langAsProf, $langYourReg, $siteName, $langDestination, $langYouAreReg, $langSettings, $langPass, $langAddress, $langIs, $urlServer, $langProblem, $administratorName, $administratorSurname, $langManager, $langTel, $langEmail, $emailhelpdesk, $profsuccess, $usersuccess, $user;
    if ($status == 1) {
        $message = $profsuccess;
        $type_message = $langAsProf;
    } else {
Example #12
Show file File: multireguser.php Project: nikosv/openeclass
0
         $tool_content .= selection($auth_m, "auth_methods_form", '', "class='form-control'");
         $tool_content .= "</div></div>";
     }
     
     $tool_content .= "<div class='form-group'>
         <label for='prefix' class='col-sm-3 control-label'>$langMultiRegPrefix:</label>
         <div class='col-sm-9'>
             <input class='form-control' type='text' name='prefix' id='prefix' value='user'>
         </div>
     </div>
     <div class='form-group'>
     <label class='col-sm-3 control-label'>$langFaculty:</label>
         <div class='col-sm-9'>";
 if (isDepartmentAdmin()) {
     list($js, $html) = $tree->buildUserNodePicker(array('params' => 'name="facid[]"',
         'allowables' => $user->getDepartmentIds($uid)));
 } else {
     list($js, $html) = $tree->buildUserNodePicker(array('params' => 'name="facid[]"'));
 }
 $head_content .= $js;
 $tool_content .= $html;
 $tool_content .= "</div>
     </div>
     <div class='form-group'>
         <label for='am' class='col-sm-3 control-label'>$langAm:</label>
         <div class='col-sm-9'>
             <input class='form-control' type='text' name='am' id='am'>
         </div>
     </div>
     <div class='form-group'>
     <label for='lang' class='col-sm-3 control-label'>$langLanguage:</label>
Example #13
Show file File: newuseradmin.php Project: kostastzo/openeclass
0
     $title = $langInsertUserInfo;
 } else {
     $pageName = $langProfReg;
     $title = $langNewProf;
 }
 $tool_content .= "<div class='form-wrapper'>\n        <form class='form-horizontal' role='form' action='{$_SERVER['SCRIPT_NAME']}' method='post' onsubmit='return validateNodePickerForm();'>\n        <fieldset>\n        <div class='form-group'>\n        <label for='Name' class='col-sm-2 control-label'>{$langName}:</label>\n            <div class='col-sm-10'>\n              <input class='form-control' id='Name' type='text' name='givenname_form' value='" . q($pn) . "' placeholder='{$langName}'>\n            </div>\n        </div>\n        <div class='form-group'>\n        <label for='Sur' class='col-sm-2 control-label'>{$langSurname}:</label>\n            <div class='col-sm-10'>\n              <input class='form-control' id='Sur' type='text' name='surname_form' value='" . q($ps) . "' placeholder='{$langSurname}'>\n            </div>\n        </div>\n        <div class='form-group'>\n        <label for='Username' class='col-sm-2 control-label'>{$langUsername}:</label>\n            <div class='col-sm-10'>\n                <input class='form-control' id='Username' type='text' name='uname' value='" . q($pu) . "' autocomplete='off' placeholder='{$langUsername}'>\n            </div>\n        </div>\n        <div class='form-group'>\n        <label for='passsword' class='col-sm-2 control-label'>{$langPass}:</label>\n            <div class='col-sm-10'>\n              <input class='form-control' type='text' name='password' value='" . genPass() . "' id='password' autocomplete='off'  placeholder='{$langPass}'/><span id='result'></span>\n            </div>\n        </div>\n        <div class='form-group'>\n        <label for='email' class='col-sm-2 control-label'>{$langEmail}:</label>\n            <div class='col-sm-10'>\n              <input class='form-control' id='email' type='text' name='email_form' value='" . q($pe) . "' palceholder='{$langEmail}'>\n            </div>\n        </div>\n        <div class='form-group'>\n          <label for='emailverified' class='col-sm-2 control-label'>{$langEmailVerified}:</label>\n            <div class='col-sm-10'>";
 $verified_mail_data = array(0 => $m['pending'], 1 => $m['yes'], 2 => $m['no']);
 if (isset($pv)) {
     $tool_content .= selection($verified_mail_data, "verified_mail_form", $pv, "class='form-control'");
 } else {
     $tool_content .= selection($verified_mail_data, "verified_mail_form", '', "class='form-control'");
 }
 $tool_content .= "</div></div>\n        <div class='form-group'>\n        <label for='phone' class='col-sm-2 control-label'>{$langPhone}:</label>\n            <div class='col-sm-10'>            \n                <input class='form-control' id='phone' type='text' name='phone' value='" . q($pphone) . "' placeholder='{$langPhone}'>\n            </div>\n        </div>\n        <div class='form-group'>\n        <label for='faculty' class='col-sm-2 control-label'>{$langFaculty}:</label>\n            <div class='col-sm-10'>";
 $depid = isset($pt) ? $pt : null;
 if (isDepartmentAdmin()) {
     list($js, $html) = $tree->buildNodePicker(array('params' => 'name="department"', 'defaults' => $depid, 'tree' => null, 'useKey' => 'id', 'where' => "AND node.allow_user = true", 'multiple' => false, 'allowables' => $user->getDepartmentIds($uid)));
 } else {
     list($js, $html) = $tree->buildNodePicker(array('params' => 'name="department"', 'defaults' => $depid, 'tree' => null, 'useKey' => 'id', 'where' => "AND node.allow_user = true", 'multiple' => false));
 }
 $head_content .= $js;
 $tool_content .= $html;
 $tool_content .= "</div></div>\n        <div class='form-group'>\n        <label for='am' class='col-sm-2 control-label'>{$langAm}:</label>\n           <div class='col-sm-10'>\n               <input class='form-control' id='am' type='text' name='am' value='" . q($pam) . "' placeholder='{$langOptional}'>\n           </div>\n        </div>\n        <div class='form-group'>\n        <label for='lang' class='col-sm-2 control-label'>{$langLanguage}:</label>\n        <div class='col-sm-10'>";
 $tool_content .= lang_select_options('language', "class='form-control'", $language);
 $tool_content .= "</div></div>";
 if (isset($_GET['id'])) {
     @($tool_content .= "<div class='form-group'><label for='comments' class='col-sm-2 control-label'>{$langComments}</label>\n                                <div class='col-sm-10'>" . q($pcom) . "</div>\n                            </div>\n                            <div class='form-group'><label for='date' class='col-sm-2 control-label'>{$langDate}</label>\n                                <div class='col-sm-10'>" . q($pdate) . "</div></div>");
     $tool_content .= "<input type='hidden' name='rid' value='{$id}' />";
 }
 $tool_content .= "<div class='col-sm-offset-2 col-sm-10'>                   \n                            <input class='btn btn-primary' type='submit' name='submit' value='{$langRegistration}'>\n                        </div>              \n        <input type='hidden' name='pstatus' value='{$pstatus}' />\n        <input type='hidden' name='auth' value='1' />\n        </fieldset>\n        </form>\n        </div>";
 if ($pstatus == 5) {
     $reqtype = '?type=user';
Example #14
Show file File: hierarchy.php Project: nikosv/openeclass
0
    $options = array('codesuffix' => true, 'defaults' => $user->getDepartmentIds($uid), 'allow_only_defaults' => (!$is_admin));
    $joptions = json_encode($options);

    $head_content .= <<<hContent
<script type="text/javascript">
/* <![CDATA[ */

$(function() {
            
    $( "#js-tree" ).jstree({
        "plugins" : ["sort", "contextmenu"],
        "core" : {
            "data" : {
                "url" : "{$urlAppend}modules/hierarchy/nodes.php",
                "type" : "POST",
                "data" : function(node) {
                    return { "id" : node.id, "options" : $joptions };
                }
            },
            "multiple" : false,
            "themes" : {
                "name" : "proton",
                "dots" : true,
                "icons" : false
            }
        },
        "sort" : function (a, b) {
            priorityA = this.get_node(a).li_attr.tabindex;
            priorityB = this.get_node(b).li_attr.tabindex;

            if (priorityA == priorityB) {
                return (this.get_text(a) > this.get_text(b)) ? 1 : -1;
            } else {
                return (priorityA < priorityB) ? 1 : -1;
            }
        },
        "contextmenu": {
            "select_node" : true,
            "items" : customMenu
        }
    })
    .delegate("a", "click.jstree", function (e) { 
        $("#js-tree").jstree("show_contextmenu", e.currentTarget); 
    });

});

function customMenu(node) {

    var items = {
        editItem: {
            label: "$langEdit",
            action: function (obj) { document.location.href='?action=edit&id=' + node.id; }
        },
        deleteItem: {
            label: "$langDelete",
            action: function (obj) { if (confirm('$langConfirmDelete')) document.location.href='?action=delete&id=' + node.id; }
        }
    };

    if (node.a_attr.class == 'nosel') {
        delete items.editItem;
        delete items.deleteItem;
    }

    return items;
}

/* ]]> */
</script>
hContent;

    $tool_content .= "<tr><td colspan='" . ($maxdepth + 4) . "'><div id='js-tree'></div></td></tr></table>";
}
// Add a new node
elseif (isset($_GET['action']) && $_GET['action'] == 'add') {
    if (isset($_POST['add'])) {
        $code = $_POST['code'];

        $names = array();
        foreach ($session->active_ui_languages as $key => $langcode) {
            $n = (isset($_POST['name-' . $langcode])) ? $_POST['name-' . $langcode] : null;
            if (!empty($n)) {
                $names[$langcode] = $n;
            }
        }

        $name = serialize($names);

        $allow_course = (isset($_POST['allow_course'])) ? 1 : 0;
        $allow_user = (isset($_POST['allow_user'])) ? 1 : 0;
        $order_priority = (isset($_POST['order_priority']) && !empty($_POST['order_priority'])) ? intval($_POST['order_priority']) : 'null';
        // Check for empty fields
        if (empty($names)) {
            $tool_content .= "<div class='alert alert-danger'>" . $langEmptyNodeName . "</div><br>";
            $tool_content .= action_bar(array(
                array('title' => $langReturnToAddNode,
                    'url' => $_SERVER['SCRIPT_NAME'] . "?a=1",
                    'icon' => 'fa-reply',
                    'level' => 'primary-label')));
        }
        // Check for greek letters
        elseif (!empty($code) && !preg_match("/^[A-Z0-9a-z_-]+$/", $code)) {
            $tool_content .= "<div class='alert alert-danger'>" . $langGreekCode . "</div><br>";
            $tool_content .= action_bar(array(
                array('title' => $langReturnToAddNode,
                    'url' => $_SERVER['SCRIPT_NAME'] . "?a=1",
                    'icon' => 'fa-reply',
                    'level' => 'primary-label')));
        } else {
            // OK Create the new node
            $pid = intval($_POST['parentid']);
            validateParentId($pid, isDepartmentAdmin());
            $tree->addNode($name, $tree->getNodeLft($pid), $code, $allow_course, $allow_user, $order_priority);
            $tool_content .= "<div class='alert alert-success'>" . $langAddSuccess . "</div>";
        }
    } else {
        // Display form for new node information
        $tool_content .= "<div class='form-wrapper'>
            <form role='form' class='form-horizontal' method=\"post\" action=\"" . $_SERVER['SCRIPT_NAME'] . "?action=add\" onsubmit=\"return validateNodePickerForm();\">
            <fieldset>
            <div class='form-group'>
                <label class='col-sm-3 control-label'>$langNodeCode1:</label>
                <div class='col-sm-9'>
                    <input class='form-control' type='text' name='code' placeholder='$langCodeFaculte2'>
                </div>
            </div>";
            $i = 0;
            foreach ($session->active_ui_languages as $key => $langcode) {
                $tool_content .= "<div class='form-group'>
                        <label class='col-sm-3 control-label'>$langNodeName:</label>";
                $tdpre = ($i >= 0) ? "<div class='col-sm-9'>" : '';
                $placeholder = "$langFaculte2 (" . $langNameOfLang[langcode_to_name($langcode)] . ")";
                $tool_content .= $tdpre . "<input class='form-control' type='text' name='name-" . $langcode . "' placeholder='$placeholder'></div></div>";
                $i++;
            }

        $tool_content .= "<div class='form-group'>
                        <label class='col-sm-3 control-label'>$langNodeParent:</label>
                        <div class='col-sm-9'>";
        list($js, $html) = $tree->buildNodePicker(array('params' => 'name="parentid"', 'tree' => array('0' => 'Top'), 'multiple' => false, 'defaults' => $user->getDepartmentIds($uid), 'allow_only_defaults' => (!$is_admin)));
Example #15
Show file File: mailtoprof.php Project: nikosv/openeclass
0
$navigation[] = array('url' => 'index.php', 'name' => $langAdmin);

// Display link back to index.php
$tool_content .= action_bar(array(
    array('title' => $langBack,
        'url' => "index.php",
        'icon' => 'fa-reply',
        'level' => 'primary-label')));
/* * ***************************************************************************
  MAIN BODY
 * **************************************************************************** */
// Send email after form post
if (isset($_POST['submit']) && ($_POST['body_mail'] != '') && ($_POST['submit'] == $langSend)) {

    if (isDepartmentAdmin()) {
        $depwh = ' user_department.department IN (' . implode(', ', $user->getDepartmentIds($uid)) . ') ';
    }

    // where we want to send the email ?
    if ($_POST['sendTo'] == '0') { // All users
        if (isDepartmentAdmin()) {
            $sql = Database::get()->queryArray("SELECT email, id FROM user, user_department WHERE user.id = user_department.user AND " . $depwh);
        } else {
            $sql = Database::get()->queryArray("SELECT email, id FROM user");
        }
    } elseif ($_POST['sendTo'] == "1") { // Only professors
        if (isDepartmentAdmin()) {
            $sql = Database::get()->queryArray("SELECT email, id FROM user, user_department WHERE user.id = user_department.user 
                                                                AND user.status = " . USER_TEACHER . " AND " . $depwh);
        } else {
            $sql = Database::get()->queryArray("SELECT email, id FROM user where status = " . USER_TEACHER . "");
Example #16
Show file File: listcours.php Project: kostastzo/openeclass
0
 }
 if (isset($_GET['reg_flag']) and !empty($_GET['date'])) {
     $query .= ' AND created ' . ($_GET['reg_flag'] == 1 ? '>=' : '<=') . ' ?s';
     $date_created_at = DateTime::createFromFormat("d-m-Y H:i", $_GET['date']);
     $terms[] = $date_created_at->format("Y-m-d H:i:s");
 }
 // Datatables internal search
 $filter_terms = array();
 if (!empty($_GET['sSearch'])) {
     $filter_query = ' AND (title LIKE ?s OR prof_names LIKE ?s)';
     $filter_terms[] = '%' . $_GET['sSearch'] . '%';
     $filter_terms[] = '%' . $_GET['sSearch'] . '%';
 } else {
     $filter_query = '';
 }
 $query .= isDepartmentAdmin() ? ' AND course_department.department IN (' . implode(', ', $user->getDepartmentIds($uid)) . ') ' : '';
 // sorting
 $extra_query = "ORDER BY course.title " . ($_GET['sSortDir_0'] == 'desc' ? 'DESC' : '');
 // pagination
 if ($limit > 0) {
     $extra_query .= " LIMIT ?d, ?d";
     $extra_terms = array($offset, $limit);
 } else {
     $extra_terms = array();
 }
 $sql = Database::get()->queryArray("SELECT DISTINCT course.code, course.title, course.prof_names, course.visible, course.id\n                               FROM course, course_department, hierarchy\n                              WHERE course.id = course_department.course\n                                AND hierarchy.id = course_department.department\n                                    {$query} {$filter_query} {$extra_query}", $terms, $filter_terms, $extra_terms);
 $all_results = Database::get()->querySingle("SELECT COUNT(*) as total FROM course, course_department, hierarchy\n                                                WHERE course.id = course_department.course\n                                                AND hierarchy.id = course_department.department\n                                                {$query}", $terms)->total;
 $filtered_results = Database::get()->querySingle("SELECT COUNT(*) as total FROM course, course_department, hierarchy\n                                                WHERE course.id = course_department.course\n                                                AND hierarchy.id = course_department.department\n                                                {$query} {$filter_query}", $terms, $filter_terms)->total;
 $data['iTotalRecords'] = $all_results;
 $data['iTotalDisplayRecords'] = $filtered_results;
 $data['aaData'] = array();
Example #17
Show file File: init.php Project: nikosv/openeclass
0
     $status = USER_TEACHER;
 } else {
     $stat = Database::get()->querySingle("SELECT status FROM course_user\n                                                           WHERE user_id = ?d AND\n                                                           course_id = ?d", $uid, $course_id);
     if ($stat) {
         $status = $stat->status;
     } else {
         // the department manager has rights to the courses of his department(s)
         if ($is_departmentmanage_user && $is_usermanage_user && !$is_power_user && !$is_admin && isset($course_code)) {
             require_once 'include/lib/hierarchy.class.php';
             require_once 'include/lib/course.class.php';
             require_once 'include/lib/user.class.php';
             $treeObj = new Hierarchy();
             $courseObj = new Course();
             $userObj = new User();
             $atleastone = false;
             $subtrees = $treeObj->buildSubtrees($userObj->getDepartmentIds($uid));
             $depIds = $courseObj->getDepartmentIds($course_id);
             foreach ($depIds as $depId) {
                 if (in_array($depId, $subtrees)) {
                     $atleastone = true;
                     break;
                 }
             }
             if ($atleastone) {
                 $status = 1;
                 $is_course_admin = true;
                 $_SESSION['courses'][$course_code] = USER_DEPARTMENTMANAGER;
             }
         }
     }
 }
Example #18
Show file File: hierarchy.php Project: kostastzo/openeclass
0
        list($js, $html) = $tree->buildNodePicker(array('params' => 'name="nodelft"', 'tree' => array('0' => 'Top'), 'useKey' => 'lft', 'multiple' => false, 'defaults' => $user->getDepartmentIds($uid), 'allow_only_defaults' => !$is_admin));
        $head_content .= $js;
        $tool_content .= $html;
        $tool_content .= "<span class='help-block'><small>{$langNodeParent2}</small></span>\n        </div></div>\n        <div class='form-group'>\n          <label class='col-sm-3 control-label'>{$langNodeAllowCourse}:</label>\n            <div class='col-sm-9'>\n                  <input type='checkbox' name='allow_course' value='1' checked='checked'><span class='help-block'><small>{$langNodeAllowCourse2}</small></span>\n          </div>\n        </div>\n        <div class='form-group'>\n        <label class='col-sm-3 control-label'>{$langNodeAllowUser}</label>\n          <div class='col-sm-9'>\n              <input type='checkbox' name='allow_user' value='1' checked='checked'><span class='help-block'><small>{$langNodeAllowUser2}</small></span>\n          </div>\n        </div>\n        <div class='form-group'>\n        <label class='col-sm-3 control-label'>{$langNodeOrderPriority}</label>      \n          <div class='col-sm-9'>\n              <input type='text' name='order_priority'><span class='help-block'><small>{$langNodeOrderPriority2}</small></span>\n          </div>\n        </div>\n        <div class='form-group'>\n          <div class='col-sm-10 col-sm-offset-2'>\n              <input class='btn btn-primary' type='submit' name='add' value='" . $langAdd . "' />\n          </div>\n        </div>\n        </fieldset>\n        </form>\n        </div>";
    }
} elseif (isset($_GET['action']) and $_GET['action'] == 'delete') {
    $id = intval($_GET['id']);
    validateNode($id, isDepartmentAdmin());
    // locate the lft and rgt of the node we want to delete
    $node = Database::get()->querySingle("SELECT lft, rgt from hierarchy WHERE id = ?d", $id);
    if ($node !== false) {
        // locate the subtree of the node we want to delete. the subtree contains the node itself
        $subres = Database::get()->queryArray("SELECT id FROM hierarchy WHERE lft BETWEEN ?d AND ?d", intval($node->lft), intval($node->rgt));
        $c = 0;
        // for each subtree node, check if it has belonging children (courses, users)
        foreach ($subres as $subnode) {
            $c += Database::get()->querySingle("SELECT COUNT(*) AS count FROM course_department WHERE department = ?d", intval($subnode->id))->count;
            $c += Database::get()->querySingle("SELECT COUNT(*) AS count FROM user_department WHERE department = ?d", intval($subnode->id))->count;
        }
        if ($c > 0) {
            // The node cannot be deleted
            $tool_content .= "<div class='alert alert-danger'>{$langNodeProErase}<br >{$langNodeNoErase}</div>";
        } else {
            // The node can be deleted
            $tree->deleteNode($id);
            $tool_content .= "<div class='alert alert-success'>{$langNodeErase}</div>";
        }
    }
} elseif (isset($_GET['action']) and $_GET['action'] == 'edit') {
    $id = intval($_REQUEST['id']);
    validateNode($id, isDepartmentAdmin());
    if (isset($_POST['edit'])) {
        // Check for empty fields
        $names = array();
        foreach ($session->active_ui_languages as $key => $langcode) {
            $n = isset($_POST['name-' . $langcode]) ? $_POST['name-' . $langcode] : null;
            if (!empty($n)) {
                $names[$langcode] = $n;
            }
        }
        $name = serialize($names);
        $code = $_POST['code'];
        $allow_course = isset($_POST['allow_course']) ? 1 : 0;
        $allow_user = isset($_POST['allow_user']) ? 1 : 0;
        $order_priority = isset($_POST['order_priority']) && !empty($_POST['order_priority']) ? intval($_POST['order_priority']) : 'null';
        if (empty($name)) {
            $tool_content .= "<div class='alert alert-danger'>" . $langEmptyNodeName . "<br>";
            $tool_content .= action_bar(array(array('title' => $langReturnToEditNode, 'url' => $_SERVER['SCRIPT_NAME'] . "?action=edit&amp;id={$id}", 'icon' => 'fa-reply', 'level' => 'primary-label')));
        } else {
            // OK Update the node
            validateParentLft(intval($_POST['nodelft']), isDepartmentAdmin());
            $tree->updateNode($id, $name, intval($_POST['nodelft']), intval($_POST['lft']), intval($_POST['rgt']), intval($_POST['parentLft']), $code, $allow_course, $allow_user, $order_priority);
            $tool_content .= "<div class='alert alert-success'>{$langEditNodeSuccess}</div><br />";
        }
    } else {
        // Get node information
        $id = intval($_GET['id']);
        $mynode = Database::get()->querySingle("SELECT name, lft, rgt, code, allow_course, allow_user, order_priority FROM hierarchy WHERE id = ?d", $id);
        $parentLft = $tree->getParent($mynode->lft, $mynode->rgt);
        $check_course = $mynode->allow_course == 1 ? " checked=1 " : '';
        $check_user = $mynode->allow_user == 1 ? " checked=1 " : '';
        // Display form for edit node information
        $tool_content .= "<div class='form-wrapper'>\n        <form role='form' class='form-horizontal' method='post' action='" . $_SERVER['SCRIPT_NAME'] . "?action=edit' onsubmit='return validateNodePickerForm();'>\n        <fieldset>\n        <div class='form-group'>\n            <label class='col-sm-3 control-label'>{$langNodeCode1}:</label>\n            <div class='col-sm-9'>\n                <input type='text' name='code' value='" . q($mynode->code) . "' />&nbsp;<i>" . $langCodeFaculte2 . "</i>\n            </div>\n        </div>";
        $is_serialized = false;
        $names = @unserialize($mynode->name);
        if ($names !== false) {
            $is_serialized = true;
        }
        $i = 0;
        foreach ($session->active_ui_languages as $key => $langcode) {
            $n = $is_serialized && isset($names[$langcode]) ? $names[$langcode] : '';
            if (!$is_serialized && $key == 0) {
                $n = $mynode->name;
            }
            $tool_content .= "<div class='form-group'>\n                     <label class='col-sm-3 control-label'>{$langNodeName}:</label>";
            $tdpre = $i >= 0 ? "<div class='col-sm-9'>" : '';
            $placeholder = "{$langFaculte2} (" . $langNameOfLang[langcode_to_name($langcode)] . ")";
            $tool_content .= $tdpre . "<input type='text' name='name-" . q($langcode) . "' value='" . q($n) . "' placeholder='{$placeholder}'></div></div>";
            $i++;
        }
        $tool_content .= "<div class='form-group'>\n                        <label class='col-sm-3 control-label'>{$langNodeParent}:</label>\n                        <div class='col-sm-9'>";
        if ($is_admin) {
            list($js, $html) = $tree->buildNodePicker(array('params' => 'name="nodelft"', 'defaults' => $parentLft->lft, 'exclude' => $id, 'tree' => array('0' => 'Top'), 'useKey' => 'lft', 'multiple' => false));
        } else {
            list($js, $html) = $tree->buildNodePicker(array('params' => 'name="nodelft"', 'defaults' => $parentLft->lft, 'exclude' => $id, 'tree' => array('0' => 'Top'), 'useKey' => 'lft', 'multiple' => false, 'allowables' => $user->getDepartmentIds($uid)));
Example #19
Show file File: create_course.php Project: nikosv/openeclass
0
hContent;

register_posted_variables(array('title' => true, 'password' => true, 'prof_names' => true));
if (empty($prof_names)) {
    $prof_names = "$_SESSION[givenname] $_SESSION[surname]";
}

// departments and validation
$allow_only_defaults = get_config('restrict_teacher_owndep') && !$is_admin;
$allowables = array();
if ($allow_only_defaults) {
    // Method: getDepartmentIdsAllowedForCourseCreation
    // fetches only specific tree nodes, not their sub-children
    //$user->getDepartmentIdsAllowedForCourseCreation($uid);
    // the code below searches for the allow_course flag in the user's department subtrees
    $userdeps = $user->getDepartmentIds($uid);
    $subs = $tree->buildSubtreesFull($userdeps);
    foreach ($subs as $node) {
        if (intval($node->allow_course) === 1) {
            $allowables[] = $node->id;
        }
    }
}
$departments = isset($_POST['department']) ? $_POST['department'] : array();
$deps_valid = true;

foreach ($departments as $dep) {
    if ($allow_only_defaults && !in_array($dep, $allowables)) {
        $deps_valid = false;
        break;
    }
Example #20
Show file File: auth.inc.php Project: nikosv/openeclass
0
function shib_cas_login($type) {
    global $surname, $givenname, $email, $status, $language, $session,
        $urlServer, $is_admin, $is_power_user, $is_usermanage_user,
        $is_departmentmanage_user, $langUserAltAuth, $langRegistrationDenied;

    $alt_auth_stud_reg = get_config('alt_auth_stud_reg');

    if ($alt_auth_stud_reg == 2) {
        $autoregister = TRUE;
    } else {
        $autoregister = FALSE;
    }

    if ($type == 'shibboleth') {
        $uname = $_SESSION['shib_uname'];
        $email = $_SESSION['shib_email'];
        $shib_surname = $_SESSION['shib_surname'];
        $shibsettings = Database::get()->querySingle("SELECT auth_settings FROM auth WHERE auth_id = 6");
        if ($shibsettings) {
            if ($shibsettings->auth_settings != 'shibboleth' and $shibsettings->auth_settings != '') {
                $shibseparator = $shibsettings->auth_settings;
            }
            if (strpos($shib_surname, $shibseparator)) {
                $temp = explode($shibseparator, $shib_surname);
                $givenname = $temp[0];
                $surname = $temp[1];
            }
        }
    } elseif ($type == 'cas') {
        $uname = $_SESSION['cas_uname'];
        $surname = $_SESSION['cas_surname'];
        $givenname = $_SESSION['cas_givenname'];
        $email = isset($_SESSION['cas_email']) ? $_SESSION['cas_email'] : '';
        $am = isset($_SESSION['cas_userstudentid']) ? $_SESSION['cas_userstudentid'] : '';
    }

    // Attributes passed to login_hook()
    $attributes = array();
    if (isset($_SESSION['cas_attributes'])) {
        foreach ($_SESSION['cas_attributes'] as $name => $value) {
            $attributes[strtolower($name)] = $value;
        }
    }

    // user is authenticated, now let's see if he is registered also in db
    if (get_config('case_insensitive_usernames')) {
        $sqlLogin = "COLLATE utf8_general_ci = ?s";
    } else {
        $sqlLogin = "COLLATE utf8_bin = ?s";
    }
    $info = Database::get()->querySingle("SELECT id, surname, username, password, givenname, status, email, lang, verified_mail
						FROM user WHERE username $sqlLogin", $uname);

    if ($info) {
        // if user found
        if ($info->password != $type) {
            // has different auth method - redirect to home page
            unset($_SESSION['shib_uname']);
            unset($_SESSION['shib_email']);
            unset($_SESSION['shib_surname']);
            unset($_SESSION['cas_uname']);
            unset($_SESSION['cas_email']);
            unset($_SESSION['cas_surname']);
            unset($_SESSION['cas_givenname']);
            unset($_SESSION['cas_userstudentid']);
            Session::Messages($langUserAltAuth, 'alert-danger');
            redirect_to_home_page();
        } else {
            // don't force email address from CAS/Shibboleth.
            // user might prefer a different one
            if (!empty($info->email)) {
                $email = $info->email;
            }

            $userObj = new User();

            $options = login_hook(array(
                'user_id' => $info->id,
                'attributes' => $attributes,
                'status' => $info->status,
                'departments' => $userObj->getDepartmentIds($info->id),
                'am' => $am));

            if (!$options['accept']) {
                foreach (array_keys($_SESSION) as $key) {
                    unset($_SESSION[$key]);
                }
                Session::Messages($langRegistrationDenied, 'alert-warning');
                redirect_to_home_page();
            }

            $status = $options['status'];

            // update user information
            Database::get()->query("UPDATE user SET surname = ?s, givenname = ?s, email = ?s,
                                           status = ?d WHERE id = ?d",
                                        $surname, $givenname, $email, $status, $info->id);

            $userObj->refresh($info->id, $options['departments']);
            user_hook($_SESSION['uid']);

            // check for admin privileges
            $admin_rights = get_admin_rights($info->id);
            if ($admin_rights == ADMIN_USER) {
                $is_active = 1;   // admin user is always active
                $_SESSION['is_admin'] = 1;
                $is_admin = 1;
            } elseif ($admin_rights == POWER_USER) {
                $_SESSION['is_power_user'] = 1;
                $is_power_user = 1;
            } elseif ($admin_rights == USERMANAGE_USER) {
                $_SESSION['is_usermanage_user'] = 1;
                $is_usermanage_user = 1;
            } elseif ($admin_rights == DEPARTMENTMANAGE_USER) {
                $_SESSION['is_departmentmanage_user'] = 1;
                $is_departmentmanage_user = 1;
            }
            $_SESSION['uid'] = $info->id;
            if (isset($_SESSION['langswitch'])) {
                $language = $_SESSION['langswitch'];
            } else {
                $language = $info->lang;
            }
        }
    } elseif ($autoregister and !(get_config('am_required') and empty($am))) {
        // if user not found and autoregister enabled, create user
	    $verified_mail = EMAIL_UNVERIFIED;
    	if (isset($_SESSION['cas_email'])) {
    	    $verified_mail = EMAIL_VERIFIED;
    	} else { // redirect user to mail_verify_change.php
	    	$_SESSION['mail_verification_required'] = 1;
        }

        $options = login_hook(array(
            'user_id' => null,
            'attributes' => $attributes,
            'am' => $am));

        if (!$options['accept']) {
            foreach (array_keys($_SESSION) as $key) {
                unset($_SESSION[$key]);
            }
            Session::Messages($langRegistrationDenied, 'alert-warning');
            redirect_to_home_page();
        }
        $status = $options['status'];
        $_SESSION['uid'] = Database::get()->query("INSERT INTO user
                    SET surname = ?s, givenname = ?s, password = ?s,
                        username = ?s, email = ?s, status = ?d, lang = ?s,
                        am = ?s, verified_mail = ?d,
                        registered_at = " . DBHelper::timeAfter() . ",
                        expires_at = " . DBHelper::timeAfter(get_config('account_duration')) . ",
                        whitelist = ''",
                $surname, $givenname, $type, $uname, $email, $status,
                $language, $options['am'], $verified_mail)->lastInsertID;
        $userObj = new User();
        $userObj->refresh($_SESSION['uid'], $options['departments']);
        user_hook($_SESSION['uid']);
    } else {
        // user not registered, automatic registration disabled
        // redirect to registration screen
        foreach (array_keys($_SESSION) as $key) {
            unset($_SESSION[$key]);
        }
        session_destroy();
        redirect_to_home_page('modules/auth/registration.php');
        exit;
    }

    $_SESSION['uname'] = $uname;
    $_SESSION['surname'] = $surname;
    $_SESSION['givenname'] = $givenname;
    $_SESSION['email'] = $email;
    $_SESSION['status'] = $status;
    //$_SESSION['is_admin'] = $is_admin;
    $_SESSION['shib_user'] = 1; // now we are shibboleth user

    Database::get()->query("INSERT INTO loginout (loginout.id_user, loginout.ip, loginout.when, loginout.action)
					VALUES ($_SESSION[uid], '$_SERVER[REMOTE_ADDR]', " . DBHelper::timeAfter() . ", 'LOGIN')");
    $session->setLoginTimestamp();
    if (get_config('email_verification_required') and
            get_mail_ver_status($_SESSION['uid']) == EMAIL_VERIFICATION_REQUIRED) {
        $_SESSION['mail_verification_required'] = 1;
        // init.php is already loaded so redirect from here
        redirect_to_home_page('modules/auth/mail_verify_change.php');
    }
}