Ejemplo n.º 1
0
    protected function _create_home()
    {
        if (_button()) {
            $v = $this->__(array('codigo', 'nombre', 'apellido', 'direccion', 'edad', 'sexo', 'email', 'telefono', 'identificacion', 'status', 'carne', 'carne_auto' => 0));
            /*
            padre_nombre
            padre_apellido
            
            madre_nombre
            madre_apellido
            
            encargado_nombre
            encargado_apellido
            encargado_profesion
            encargado_labora
            encargando_labora_direccion
            
            encargado_identificacion
            encargado_emergencia
            */
            $sql = 'INSERT INTO _students' . _build_array('INSERT', $v);
            $v['id'] = _sql_nextid($sql);
            if ($v['carne_auto']) {
                $v['carne'] = date('Y') . $v['id'];
                $sql = 'UPDATE _students SET carne = ?
					WHERE id_alumno = ?';
                _sql(sql_filter($sql, $v['carne'], $v['id']));
            }
            $sql_insert = '';
            // TODO: Build query
            $sql = 'INSERT INTO _registrations' . _build_array('INSERT', '');
        }
        $sql = 'SELECT grade_id, grade_name
			FROM _grades
			WHERE grade_status = 1
			ORDER BY grade_order';
        $grades = _rowset($sql);
        foreach ($grades as $i => $row) {
            if (!$i) {
                _style('grades');
            }
            _style('grades.row', array('GRADE_ID' => $row['grade_id'], 'GRADE_NAME' => $row['grade_name']));
        }
        $sql = 'SELECT section_id, section_name
			FROM _sections
			WHERE section_grade = 1';
        $sections = _rowset($sql);
        foreach ($sections as $i => $row) {
            if (!$i) {
                _style('sections');
            }
            _style('sections.row', array('SECTION_ID' => $row['section_id'], 'SECTION_NAME' => $row['section_name']));
        }
        return;
    }
Ejemplo n.º 2
0
    protected function _create_home()
    {
        global $core, $user;
        if (_button() && is_ghost()) {
            $v = $this->__(array('cat' => 1, 'ticket_group' => 0, 'ticket_title', 'ticket_text', 'ticket_username', 'attachments'));
            $t_contact = $user->v();
            if (f($v['ticket_username']) && _auth_get('ticket_create_admin')) {
                if (!preg_match('#^([a-z0-9\\_\\-]+)$#is', $v['ticket_username'])) {
                    $this->_error('#SIGN_LOGIN_ERROR');
                }
                $sql = 'SELECT *
					FROM _members
					WHERE user_username = ?
						AND user_id <> 1
						AND user_active = 1';
                if (!($t_contact = _fieldrow(sql_filter($sql, $v['ticket_username'])))) {
                    $this->_error('#SIGN_LOGIN_ERROR');
                }
            }
            if (!($ticket_status = $core->cache_load('ticket_status_default'))) {
                $sql = 'SELECT status_id
					FROM _tickets_status
					WHERE status_default = 1';
                $ticket_status = $core->cache_store(_field($sql, 'status_id', 0));
            }
            $v2 = array('code' => substr(md5(unique_id()), 0, 8), 'childs' => 0, 'parent' => 0, 'deleted' => 0, 'lastreply' => (int) $user->time, 'group' => $v['ticket_group'], 'contact' => $t_contact['user_id'], 'aby' => 0, 'cat' => $v['cat'], 'status' => $ticket_status, 'start' => (int) $user->time, 'end' => 0, 'ip' => $user->i_ip, 'title' => $v['ticket_title'], 'text' => $v['ticket_text']);
            $sql = 'INSERT INTO _tickets' . _build_array('INSERT', prefix('ticket', $v2));
            $v['ticket_id'] = _sql_nextid($sql);
            $v = array_merge($v, $v2);
            if (f($v['attachments'])) {
                $attachments = explode(',', $v['attachments']);
                $location = XFS . 'space/f/';
                if (@is_dir($location)) {
                    @(include XFS . 'core/upload.php');
                    $upload = new upload();
                    $umask = umask(0);
                    $i = 0;
                    foreach ($attachments as $row) {
                        if (@file_exists($location . $row)) {
                            $extension = _extension($row);
                            if (preg_match('/\\.(' . $upload->ext_blacklist . ')$/', strtolower($row))) {
                                $extension = 'txt';
                            }
                            $filepath = _filename('_' . $v['code'] . '_' . $i, $extension);
                            @rename($location . $row, $location . $filepath);
                            $upload->chmod($location . $filepath);
                            $insert_attach = array('ticket' => $v['ticket_id'], 'name' => $filepath, 'mime' => mime_content_type($location . $filepath), 'extension' => $extension, 'size' => filesize($location . $filepath), 'checksum' => md5_file($location . $filepath), 'downloads' => 0, 'time' => time());
                            $sql = 'INSERT INTO _tickets_attach' . _build_array('INSERT', prefix('attach', $insert_attach));
                            _sql($sql);
                            $i++;
                        }
                    }
                    @umask($umask);
                }
            }
            if ($v['parent']) {
                $sql = 'UPDATE _tickets SET ticket_childs = ticket_childs + 1
					WHERE ticket_id = ?';
                _sql(sql_filter($sql, $v['ticket_parent']));
            }
            if (f($v['ticket_username'])) {
                $insert_note = array('ticket_id' => (int) $v['ticket_id'], 'user_id' => $user->v('user_id'), 'note_text' => _lang('TICKET_CREATE_STAFF'), 'note_time' => time(), 'note_cc' => 1);
                $sql = 'INSERT INTO _tickets_notes' . _build_array('INSERT', $insert_note);
                _sql($sql);
            }
            $sql = 'SELECT group_name, group_email
				FROM _groups
				WHERE group_id = ?';
            $d_group = _fieldrow(sql_filter($sql, $v['ticket_group']));
            $ticket_subject = entity_decode($d_group['group_name'] . ' [#' . $v['code'] . ']: ' . $v['ticket_title']);
            $ticket_message = entity_decode($v['text']);
            $sql = 'SELECT m.user_email
				FROM _groups_members gm, _members m
				WHERE gm.member_group = ?
					AND gm.member_mod = ?
					AND gm.member_uid = m.user_id
				ORDER BY m.user_email';
            $group_members = _rowset(sql_filter($sql, $v['group'], 1), false, 'user_email');
            //
            // Common email notification
            require_once XFS . 'core/emailer.php';
            $emailer = new emailer();
            $emailer_vars = array('USERNAME' => $t_contact['user_username'], 'FULLNAME' => entity_decode(_fullname($t_contact)), 'SUBJECT' => entity_decode($v['ticket_title']), 'MESSAGE' => $ticket_message, 'TICKET_URL' => _link($this->m(), array('x1' => 'view', 'code' => $v['code'])));
            $email_from = $d_group['group_email'] . '@' . $core->v('domain');
            $user_template = 'ticket_' . $d_group['group_email'];
            //
            // Notify ticket creator
            $emailer->from($email_from);
            $emailer->set_subject($ticket_subject);
            $emailer->use_template($user_template);
            $emailer->email_address($t_contact['user_email']);
            $emailer->set_decode(true);
            $emailer->assign_vars($emailer_vars);
            $emailer->send();
            $emailer->reset();
            //
            // Notify group mods
            $emailer->from($email_from);
            $emailer->use_template('ticket_tech');
            $emailer->set_subject($ticket_subject);
            foreach ($group_members as $i => $row) {
                $method = !$i ? 'email_address' : 'cc';
                $emailer->{$method}($row);
            }
            $emailer->set_decode(true);
            $emailer->assign_vars($emailer_vars);
            $emailer->send();
            $emailer->reset();
            return $this->e(_link($this->m(), array('x1' => 'view', 'code' => $v['code'])));
        }
        $sql = 'SELECT group_id, group_name
			FROM _groups
			ORDER BY group_name';
        _rowset_style($sql, 'groups');
        $sql = 'SELECT cat_id, cat_name
			FROM _tickets_cat
			WHERE cat_id > 0
				AND cat_group IN (??)
			GROUP BY cat_name
			ORDER BY cat_group, cat_name';
        if (!($cat = _rowset_style(sql_filter($sql, $user->auth_groups()), 'cat', 'cat'))) {
            _style('no_cat');
        }
        return v_style(array('CHANGE_USER' => sprintf(_lang('TICKET_CHANGE_USER'), _fullname($user->v()))));
    }
Ejemplo n.º 3
0
    protected function _groups_create()
    {
        gfatal();
        global $core;
        $v = $this->__(array('g_name', 'g_email', 'g_mod', 'g_color'));
        if (!f($v['g_name']) || !f($v['g_email']) || !f($v['g_mod'])) {
            $this->_error('#FIELD_IS_EMPTY');
        }
        $sql = 'SELECT group_id
			FROM _groups
			WHERE group_name = ?';
        if (_fieldrow(sql_filter($sql, $v['g_name']))) {
            $this->_error('#GROUP_NAME_EXISTS');
        }
        $sql = 'SELECT group_id
			FROM _groups
			WHERE group_email = ?';
        if (_fieldrow(sql_filter($sql, $v['g_email']))) {
            $this->_error('#GROUP_EMAIL_EXISTS');
        }
        $mod_list = array_map('trim', explode(',', $v['g_mod']));
        array_unshift($mod_list, 'addquotes');
        $sql = 'SELECT user_id
			FROM _members
			WHERE user_username IN (??)
			ORDER BY user_username';
        if (!($mods_list = _rowset(sql_filter($sql, _implode(',', $mod_list)), false, 'user_id'))) {
            $this->_error('#USER_UNKNOWN');
        }
        $sql_insert = array('name' => $v['g_name'], 'email' => $v['g_email'], 'color' => $v['g_color']);
        $sql = 'INSERT INTO _groups' . _build_array('INSERT', prefix('group', $sql_insert));
        $group_id = _sql_nextid($sql);
        foreach ($mods_list as $row) {
            $sql_insert = array('group' => $group_id, 'uid' => $row, 'mod' => 1);
            $sql = 'INSERT INTO _groups_members' . _build_array('INSERT', prefix('member', $sql_insert));
            _sql($sql);
        }
        $core->cache_unload();
        return $this->e('~OK');
    }