Ejemplo n.º 1
0
 function do_manage($is_show = "")
 {
     global $ttH;
     $err = "";
     //update
     if (isset($ttH->input['do_action'])) {
         $up_id = isset($ttH->input["selected_id"]) ? $ttH->input["selected_id"] : array();
         switch ($ttH->input["do_action"]) {
             case "do_edit":
                 $arr_show_order = isset($ttH->post["show_order"]) ? $ttH->post["show_order"] : array();
                 $arr_is_show = isset($ttH->post["is_show"]) ? $ttH->post["is_show"] : array();
                 $mess = $ttH->lang['global']['edit_success'] . " ID: <strong>";
                 $str_mess = "";
                 for ($i = 0; $i < count($up_id); $i++) {
                     $dup = array();
                     //$dup['show_order'] = $arr_show_order[$up_id[$i]];
                     $dup['is_show'] = $arr_is_show[$up_id[$i]];
                     $ok = $ttH->db->do_update("user", $dup, "user_id=" . $up_id[$i]);
                     if ($ok) {
                         $str_mess .= $str_mess ? ", " : "";
                         $str_mess .= $up_id[$i];
                     } else {
                         $mess .= $ttH->lang["global"]['edit_false'] . " ID: <strong>" . $up_id[$i] . "</strong>";
                     }
                 }
                 $mess .= $str_mess . "</strong>";
                 $err = $ttH->html->html_alert($mess, "success");
                 break;
             case "do_del":
                 if (isset($ttH->input['id'])) {
                     $list_del = $ttH->input['id'];
                 } elseif (isset($ttH->post['selected_id']) && is_array($ttH->post['selected_id'])) {
                     $list_del = @implode(',', $ttH->post['selected_id']);
                 }
                 $err = $this->do_del($list_del);
                 break;
         }
     }
     $p = isset($ttH->input["p"]) ? $ttH->input["p"] : 1;
     $search_date_begin = isset($ttH->input["search_date_begin"]) ? $ttH->input["search_date_begin"] : "";
     $search_date_end = isset($ttH->input["search_date_end"]) ? $ttH->input["search_date_end"] : "";
     $search_group_id = isset($ttH->input["search_group_id"]) ? $ttH->input["search_group_id"] : 0;
     $search_title = isset($ttH->input["search_title"]) ? $ttH->input["search_title"] : "";
     $where = " where user_id>0 ";
     $ext = "";
     if ($search_date_begin || $search_date_end) {
         $tmp1 = @explode("/", $search_date_begin);
         $time_begin = @mktime(0, 0, 0, $tmp1[1], $tmp1[0], $tmp1[2]);
         $tmp2 = @explode("/", $search_date_end);
         $time_end = @mktime(23, 59, 59, $tmp2[1], $tmp2[0], $tmp2[2]);
         $where .= " AND (date_create BETWEEN {$time_begin} AND {$time_end} ) ";
         $ext .= "&date_begin=" . $search_date_begin . "&date_end=" . $search_date_end;
     }
     if (!empty($search_group_id)) {
         $where .= " and group_id='" . $search_group_id . "' ";
         $ext .= "&search_group_id=" . $search_group_id;
     }
     if (!empty($search_title)) {
         $where .= " and (\r\r\n\t\t\t\tuser_id='{$search_title}' \r\r\n\t\t\t\tor username like '%{$search_title}%'\r\r\n\t\t\t\tor nickname like '%{$search_title}%'\r\r\n\t\t\t\tor email like '%{$search_title}%'\r\r\n\t\t\t\tor address like '%{$search_title}%'\r\r\n\t\t\t) ";
         $ext .= "&search_title=" . $search_title;
     }
     $num_total = 0;
     $res_num = $ttH->db->query("select user_id from user " . $where . " ");
     $num_total = $ttH->db->num_rows($res_num);
     $n = $ttH->conf["n_list"] ? $ttH->conf["n_list"] : 30;
     $num_pages = ceil($num_total / $n);
     if ($p > $num_pages) {
         $p = $num_pages;
     }
     if ($p < 1) {
         $p = 1;
     }
     $start = ($p - 1) * $n;
     $link_action = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub);
     //Sort
     $arr_title = array("user_id" => array("title" => $ttH->lang["global"]["id"], "link" => $link_action . "&p=" . $p . $ext . "&sort=user_id-desc", "class" => ""), "username" => array("title" => $ttH->lang["user"]["username"], "link" => $link_action . "&p=" . $p . $ext . "&sort=username-desc", "class" => ""), "nickname" => array("title" => $ttH->lang["user"]["nickname"], "link" => $link_action . "&p=" . $p . $ext . "&sort=nickname-desc", "class" => ""), "is_show" => array("title" => $ttH->lang["user"]["status"], "link" => $link_action . "&p=" . $p . $ext . "&sort=is_show-desc", "class" => ""), "date_create" => array("title" => $ttH->lang["global"]["date_create"], "link" => $link_action . "&p=" . $p . $ext . "&sort=date_create-desc", "class" => ""));
     $sort = isset($ttH->input["sort"]) ? $ttH->input["sort"] : "";
     if ($sort) {
         $arr_allow_sort = array(1 => "asc", 2 => "desc");
         $tmp = explode("-", $sort);
         if (array_key_exists($tmp[0], $arr_title) && in_array($tmp[1], $arr_allow_sort)) {
             $order_tmp = $tmp[0] == "user_id" ? "a.user_id" : $tmp[0];
             $where .= " order by " . $order_tmp . " " . $tmp[1];
             $arr_title[$tmp[0]]["class"] = $tmp[1];
             $arr_title[$tmp[0]]["link"] = $link_action . "&p=" . $p . $ext . "&sort=" . $tmp[0] . "-" . $arr_allow_sort[3 - array_search($tmp[1], $arr_allow_sort)];
         } else {
             $sort = "";
         }
     }
     if ($sort == "") {
         $where .= " order by date_create DESC";
     }
     //End sort
     //Title row
     foreach ($arr_title as $k => $v) {
         $class = $v["class"] ? " class='" . $v["class"] . "'" : "";
         $data["f_" . $k] = '<a href="' . $v["link"] . '" ' . $class . '>' . $v["title"] . '</a>';
     }
     //End title row
     $sql = "select * from user " . $where . " limit {$start},{$n}";
     //echo $sql;
     $nav = $ttH->admin->admin_paginate($link_action, $num_total, $n, $ext, $p);
     $result = $ttH->db->query($sql);
     $i = 0;
     $html_row = "";
     if ($num = $ttH->db->num_rows($result)) {
         while ($row = $ttH->db->fetch_row($result)) {
             $i++;
             $row["link_edit"] = $ttH->admin->get_link_admin($this->modules, $this->action, "edit", array("id" => $row['user_id']));
             $row["link_trash"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_trash", "id" => $row['user_id']));
             $row["link_restore"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_restore", "id" => $row['user_id']));
             $row["link_del"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_del", "id" => $row['user_id']));
             $row["status"] = status_info($row["is_show"]);
             $row['is_show'] = list_status("is_show[" . $row['user_id'] . "]", $row['is_show'], "  onchange=\"do_check (" . $row['user_id'] . ")\" style=\"width:100%;\"");
             $ttH->temp_act->assign('row', $row);
             $ttH->temp_act->parse("manage.row_item");
         }
     } else {
         $ttH->temp_act->assign('row', array("mess" => $ttH->lang["global"]["no_have_data"]));
         $ttH->temp_act->parse("manage.row_empty");
     }
     $data['html_row'] = $html_row;
     $data['nav'] = $nav;
     $data['err'] = $err;
     $data['link_action_search'] = $link_action;
     $data['link_action'] = $link_action . "&p=" . $p . $ext;
     $data['search_date_begin'] = $search_date_begin;
     $data['search_date_end'] = $search_date_end;
     $data['search_title'] = $search_title;
     $ttH->temp_act->assign('data', $data);
     $ttH->temp_act->parse("manage");
     return $ttH->temp_act->text("manage");
 }
Ejemplo n.º 2
0
<?php

if (!isset($_GET['action'])) {
    die;
}
import('model/status.php');
if ($_GET['action'] == 'delete') {
    remove_status($_POST['id'] * 1, true);
} elseif ($_GET['action'] == 'post') {
    if (user() && posted('content')) {
        if (trim($_POST['content'])) {
            post_status($_POST['content'], 'say');
        }
    }
} elseif ($_GET['action'] == 'fetch') {
    die(json_encode(list_status($_GET['start'] * 1, $_GET['limit'] * 1)));
} elseif ($_GET['action'] == 'querynew') {
    $id = $_GET['id'] * 1;
    if ($id < last_post_id()) {
        die('new');
    }
    die('none');
}
Ejemplo n.º 3
0
function dde_conf($form_name)
{
    global $l, $protectedPost, $protectedGet, $pages_refs, $infos_status;
    if ($_SESSION['OCS']['CONFIGURATION']['TELEDIFF_WK'] == 'YES') {
        //sous onglets
        if ($infos_status['NIV_BIS'] != '') {
            $conf_value['GENERAL'] = $l->g(107);
            $conf_value['GUI'] = $l->g(84);
        }
        $conf_value['STATUS'] = $l->g(1095);
        //$conf_value['ADMIN']='Administration';
        onglet($conf_value, $form_name, "conf", 7);
        if ($protectedPost['Valid'] == $l->g(103)) {
            $etat = verif_champ();
            if ($etat == "") {
                $MAJ = update_default_value($protectedPost);
            } else {
                $msg = "";
                foreach ($etat as $name => $value) {
                    $msg .= $name . " " . $l->g(759) . " " . $value . "<br>";
                }
                msg_error($msg);
            }
        }
        if (!isset($protectedPost['conf']) or $protectedPost['conf'] == "GENERAL") {
            pageTELEDIFF_WK($form_name);
        }
        if ($protectedPost['conf'] == "GUI") {
            //mise a jour des données demandée par l'utilisateur
            if ($protectedPost['Valid_fields_x'] != "") {
                //si la mise a jour est limitée à certain champs
                if (isset($protectedPost['DEFAULT_FIELD'])) {
                    $fields = explode(',', $protectedPost['DEFAULT_FIELD']);
                } else {
                    $fields = array('type', 'field', 'lbl', 'must_completed', 'value', 'restricted', 'link_status');
                    //si le type est TEXTAREA, il faut aussi changer le type de la colonne en longtext
                    if ($protectedPost['type'] == 1) {
                        $type_modif = "longtext";
                    } else {
                        $type_modif = "varchar(255)";
                    }
                    $sql_modify_type = 'ALTER TABLE downloadwk_pack change 
									fields_%1$s  
									fields_%1$s ' . $type_modif . ' default null;';
                    $arg = array($protectedPost['FIELDS']);
                    mysql2_query_secure($sql_modify_type, $_SESSION['OCS']["writeServer"], $arg);
                    //echo $sql_modify_type;
                }
                //création de la requête
                $sql_update = 'UPDATE downloadwk_fields 
										set ';
                $arg = array();
                foreach ($fields as $key => $value) {
                    $sql_update .= $value . "='%s' ,";
                    $arg[] = $protectedPost[$value];
                }
                $sql_update = substr($sql_update, 0, -1) . "where id='%s'";
                $arg[] = $protectedPost['FIELDS'];
                mysql2_query_secure($sql_update, $_SESSION['OCS']["writeServer"], $arg);
                //print_r
                //echo $sql_update;
            }
            $sql_service = "select id,field,value,lbl,default_field \n\t\t\t\t\t\t\t  FROM downloadwk_tab_values";
            $resultSERV = mysql2_query_secure($sql_service, $_SESSION['OCS']["readServer"]);
            $List_tab[] = '';
            while ($item = mysql_fetch_object($resultSERV)) {
                $lbl = define_lbl($item->lbl, $item->default_field);
                $List_tab[$item->id] = $lbl;
            }
            $name_field = array("TAB");
            //$oblig_field['INFO_VALID']=$name_field['INFO_VALID'];
            $tab_name = array($l->g(1097) . ":");
            $type_field = array(2);
            $value_field = array($List_tab);
            if (isset($protectedPost['TAB']) and $protectedPost['TAB'] != 0) {
                $sql_service = "select id,lbl,default_field \n\t\t\t\t\t\t\t\t  FROM downloadwk_fields \n\t\t\t\t\t\t\t\t  where TAB='%s'";
                $arg = array($protectedPost['TAB']);
                $resultSERV = mysql2_query_secure($sql_service, $_SESSION['OCS']["readServer"], $arg);
                $List_fields[] = '';
                while ($item = mysql_fetch_object($resultSERV)) {
                    $lbl = define_lbl($item->lbl, $item->default_field);
                    $List_fields[$item->id] = $lbl;
                    $default_field[$item->id] = $item->default_field;
                }
                array_push($name_field, "FIELDS");
                array_push($tab_name, $l->g(1096) . ":");
                array_push($type_field, 2);
                array_push($value_field, $List_fields);
            }
            $tab_typ_champ = show_field($name_field, $type_field, $value_field);
            $tab_typ_champ[0]['COMMENT_BEHING'] = "<a href=# onclick=window.open(\"index.php?" . PAG_INDEX . "=" . $pages_refs['ms_admin_management'] . "&head=1&admin=tab&value=TAB&form=" . $form_name . "\",\"admin_management\",\"location=0,status=0,scrollbars=0,menubar=0,resizable=0,width=550,height=450\")><img src=image/plus.png></a>";
            $tab_typ_champ[0]['RELOAD'] = $form_name;
            $tab_typ_champ[1]['RELOAD'] = $form_name;
            $tab_typ_champ[1]['COMMENT_BEHING'] = "<a href=# onclick=window.open(\"index.php?" . PAG_INDEX . "=" . $pages_refs['ms_admin_management'] . "&head=1&admin=fields&value=" . $protectedPost['TAB'] . "&form=" . $form_name . "\",\"admin_management\",\"location=0,status=0,scrollbars=0,menubar=0,resizable=0,width=700,height=650\")><img src=image/plus.png></a>";
            tab_modif_values($tab_name, $tab_typ_champ, $tab_hidden, $title = "", $comment = "", $name_button = "modif", $showbutton = false, $form_name = 'NO_FORM');
            if (isset($protectedPost['FIELDS']) and $protectedPost['FIELDS'] != 0) {
                echo "<br>";
                $sql_status = "SELECT id,lbl FROM downloadwk_statut_request";
                $res_status = mysql2_query_secure($sql_status, $_SESSION['OCS']["readServer"]);
                $status['0'] = $l->g(454);
                while ($val_status = mysql_fetch_array($res_status)) {
                    $status[$val_status['id']] = $val_status['lbl'];
                }
                //print_r($status);
                $list_type = array('TEXT', 'TEXTAREA', 'SELECT', 'SHOW DATA', 'PASSWORD', 'CHECKBOX', 'LIST', 'HIDDEN', 'BLOB (FILE)', 'LINK LIST', 'TABLE');
                $yes_no = array($l->g(454), $l->g(455));
                $sql_detailField = "select type,field,lbl,must_completed,\n\t\t\t\t\t\t\t\t\t\tvalue,restricted,link_status \n\t\t\t\t\t\t\t\t\t  FROM downloadwk_fields \n\t\t\t\t\t\t\t\t\t  where id='%s' and tab='%s' ";
                $arg = array($protectedPost['FIELDS'], $protectedPost['TAB']);
                $result_detailField = mysql2_query_secure($sql_detailField, $_SESSION['OCS']["readServer"], $arg);
                $item_detailField = mysql_fetch_object($result_detailField);
                //if there is no result or more than 1, don't show update table
                $num_row = mysql_numrows($result_detailField);
                if ($num_row == 1) {
                    $protectedPost['type'] = $item_detailField->type;
                    $protectedPost['must_completed'] = $item_detailField->must_completed;
                    $protectedPost['restricted'] = $item_detailField->restricted;
                    $protectedPost['link_status'] = $item_detailField->link_status;
                    $name_field = array('type', 'field', 'lbl', 'must_completed', 'value', 'restricted', 'link_status');
                    $tab_name = array($l->g(1071) . ':', $l->g(1098) . ':', $l->g(1063) . ':', $l->g(1064) . ':', $l->g(1099) . ':', $l->g(1065) . ':', $l->g(1066) . ':');
                    if ($default_field[$protectedPost['FIELDS']]) {
                        $title = $l->g(1101);
                        //$showbutton=false;
                        $type_field = array(3, 3, 3, 3, 0, 3, 3, 7);
                        $value_field = array($list_type[$item_detailField->type], $item_detailField->field, $l->g($item_detailField->lbl), $yes_no[$item_detailField->must_completed], $item_detailField->value, $yes_no[$item_detailField->restricted], $status[$item_detailField->link_status], 'value');
                        if ($item_detailField->field == "STATUS") {
                            $type_field[4] = 2;
                            unset($status[0]);
                            $value_field[4] = $status;
                            $protectedPost['value'] = $item_detailField->value;
                        }
                        $name_field[7] = 'DEFAULT_FIELD';
                        $tab_name[7] = '';
                    } else {
                        $title = "";
                        //$showbutton=true;
                        $type_field = array(2, 0, 0, 2, 0, 2, 2);
                        $value_field = array($list_type, $item_detailField->field, $item_detailField->lbl, $yes_no, $item_detailField->value, $yes_no, $status);
                    }
                    $tab_typ_champ = show_field($name_field, $type_field, $value_field);
                    tab_modif_values($tab_name, $tab_typ_champ, $tab_hidden, $title, $comment = "", $name_button = "fields", $showbutton = true, $form_name = 'NO_FORM');
                }
            }
        } elseif ($protectedPost['conf'] == "STATUS") {
            //mise à jour des valeurs de statuts
            if ($protectedPost['Valid_fields_x'] != '') {
                if (trim($protectedPost['lbl']) != '') {
                    $sql_update = "UPDATE downloadwk_statut_request\n\t\t\t\t\t\t\t\t\t\tset LBL='%s' ,  ACTIF='%s'\n\t\t\t\t\t\t\t\t\t\twhere ID='%s'";
                    $arg = array($protectedPost['lbl'], $protectedPost['actif'], $protectedPost['id']);
                    mysql2_query_secure($sql_update, $_SESSION['OCS']["writeServer"], $arg);
                    msg_success($l->g(1121));
                } else {
                    msg_error($l->g(988));
                }
            }
            $infos_status = list_status(false);
            $name_field = array("STATUS");
            $tab_name = array($l->g(1100) . ":");
            $type_field = array(2);
            $value_field = array($infos_status['STAT']);
            if (isset($protectedPost['STATUS']) and $protectedPost['STATUS'] != 0) {
                //delete old post if you change status
                if (isset($protectedPost['OLD_STATUS']) and $protectedPost['OLD_STATUS'] != $protectedPost['STATUS']) {
                    unset($protectedPost['actif'], $protectedPost['lbl'], $protectedPost['name']);
                }
                $yes_no = array($l->g(454), $l->g(455));
                if (!isset($protectedPost['actif'])) {
                    $protectedPost['actif'] = $infos_status['ACTIF'][$protectedPost['STATUS']];
                }
                if (!isset($protectedPost['lbl'])) {
                    $protectedPost['lbl'] = $infos_status['STAT_BIS'][$protectedPost['STATUS']];
                }
                if (!isset($protectedPost['name'])) {
                    $protectedPost['name'] = $infos_status['NIV'][$protectedPost['STATUS']];
                }
                $protectedPost['id'] = $protectedPost['STATUS'];
                array_push($name_field, 'actif', 'id', 'lbl', 'name', 'OLD_STATUS');
                array_push($tab_name, $l->g(1102) . ':', $l->g(1103) . ':', $l->g(1063) . ':', $l->g(1064) . ':', '');
                array_push($type_field, 2, 3, 0, 3, 7);
                array_push($value_field, $yes_no, $protectedPost['id'], $protectedPost['lbl'], $protectedPost['name'], $protectedPost['STATUS']);
                $showbutton = true;
            } else {
                $showbutton = false;
            }
            $tab_typ_champ = show_field($name_field, $type_field, $value_field);
            $tab_typ_champ[0]['RELOAD'] = $form_name;
            tab_modif_values($tab_name, $tab_typ_champ, $tab_hidden, $title, $comment = "", $name_button = "fields", $showbutton, $form_name = 'NO_FORM');
        }
    }
}
// code is always made freely available.
// Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
//====================================================================================
/*
 * workflow for Teledeploy 
 * 
 */
require_once 'require/function_telediff_wk.php';
//TELEDIFF_WK
$activate = option_conf_activate('TELEDIFF_WK');
if ($activate) {
    if (isset($protectedPost['MODIF']) and $protectedPost['MODIF'] != null) {
        $protectedPost['onglet'] = 2;
    }
    //print_r($protectedPost);
    $infos_status = list_status();
    if ($infos_status['NIV_BIS'] == "") {
        msg_warning($l->g(1089));
    } else {
        //define tab
        $data_on[1] = $l->g(1072);
        $data_on[2] = $l->g(1073);
    }
    if ($_SESSION['OCS']['CONFIGURATION']['TELEDIFF_WK'] == 'YES') {
        $data_on[4] = $l->g(107);
    }
    $form_name = "admins";
    echo open_form($form_name);
    if (isset($data_on)) {
        onglet($data_on, $form_name, "onglet", 4);
        $table_name = $form_name;