Beispiel #1
0
        }
        $enabled = trim(GETPOST('AGENDA_EXT_ENABLED_' . $id . '_' . $i, 'alpha'));
        if (!empty($src) && !dol_is_url($src)) {
            setEventMessage($langs->trans("ErrorParamMustBeAnUrl"), 'errors');
            $error++;
            $errorsaved++;
            break;
        }
        $tabparam['AGENDA_EXT_NAME_' . $id . '_' . $i] = $name;
        $tabparam['AGENDA_EXT_SRC_' . $id . '_' . $i] = $src;
        $tabparam['AGENDA_EXT_COLOR_' . $id . '_' . $i] = $color;
        $tabparam['AGENDA_EXT_ENABLED_' . $id . '_' . $i] = $enabled;
        $i++;
    }
    if (!$error) {
        $result = dol_set_user_param($db, $conf, $fuser, $tabparam);
        if (!$result > 0) {
            $error++;
        }
    }
    if (!$error) {
        $db->commit();
        setEventMessage($langs->trans("SetupSaved"));
    } else {
        $db->rollback();
        if (empty($errorsaved)) {
            setEventMessage($langs->trans("Error"), 'errors');
        }
    }
}
/*
Beispiel #2
0
 /**
  *  Save order of boxes for area and user
  *
  *  @param	DoliDB	$db				Database handler
  *  @param	string	$zone       	Name of area (0 for Homepage, ...)
  *  @param  string  $boxorder   	List of boxes with correct order 'A:123,456,...-B:789,321...'
  *  @param  int     $userid     	Id of user
  *  @return int                   	<0 if KO, >= 0 if OK
  */
 static function saveboxorder($db, $zone, $boxorder, $userid = 0)
 {
     global $conf;
     $error = 0;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     dol_syslog(get_class() . "::saveboxorder zone=" . $zone . " userid=" . $userid);
     if (!$userid || $userid == 0) {
         return 0;
     }
     $user = new User($db);
     $user->id = $userid;
     $db->begin();
     // Save parameters to say user has a dedicated setup
     $tab = array();
     $confuserzone = 'MAIN_BOXES_' . $zone;
     $tab[$confuserzone] = 1;
     if (dol_set_user_param($db, $conf, $user, $tab) < 0) {
         $error = $db->lasterror();
         $db->rollback();
         return -3;
     }
     // Delete all lines
     $sql = "DELETE FROM " . MAIN_DB_PREFIX . "boxes";
     $sql .= " WHERE entity = " . $conf->entity;
     $sql .= " AND fk_user = "******" AND position = " . $zone;
     dol_syslog(get_class() . "::saveboxorder", LOG_DEBUG);
     $result = $db->query($sql);
     if ($result) {
         $colonnes = explode('-', $boxorder);
         foreach ($colonnes as $collist) {
             $part = explode(':', $collist);
             $colonne = $part[0];
             $list = $part[1];
             dol_syslog(get_class() . "::saveboxorder column=" . $colonne . ' list=' . $list);
             $i = 0;
             $listarray = explode(',', $list);
             foreach ($listarray as $id) {
                 if (is_numeric($id)) {
                     //dol_syslog("aaaaa".count($listarray));
                     $i++;
                     $ii = sprintf('%02d', $i);
                     $sql = "INSERT INTO " . MAIN_DB_PREFIX . "boxes";
                     $sql .= "(box_id, position, box_order, fk_user, entity)";
                     $sql .= " values (";
                     $sql .= " " . $id . ",";
                     $sql .= " " . $zone . ",";
                     $sql .= " '" . $colonne . $ii . "',";
                     $sql .= " " . $userid . ",";
                     $sql .= " " . $conf->entity;
                     $sql .= ")";
                     dol_syslog(get_class() . "::saveboxorder", LOG_DEBUG);
                     $result = $db->query($sql);
                     if ($result < 0) {
                         $error++;
                         break;
                     }
                 }
             }
         }
         if ($error) {
             $error = $db->error();
             $db->rollback();
             return -2;
         } else {
             $db->commit();
             return 1;
         }
     } else {
         $error = $db->lasterror();
         $db->rollback();
         dol_syslog(get_class() . "::saveboxorder " . $error);
         return -1;
     }
 }
Beispiel #3
0
            $tabparam["MAIN_LANG_DEFAULT"] = '';
        }
        if ($_POST["check_SIZE_LISTE_LIMIT"] == "on") {
            $tabparam["MAIN_SIZE_LISTE_LIMIT"] = $_POST["main_size_liste_limit"];
        } else {
            $tabparam["MAIN_SIZE_LISTE_LIMIT"] = '';
        }
        if ($_POST["check_MAIN_THEME"] == "on") {
            $tabparam["MAIN_THEME"] = $_POST["main_theme"];
        } else {
            $tabparam["MAIN_THEME"] = '';
        }
        $tabparam["MAIN_SEARCHFORM_CONTACT"] = $_POST["main_searchform_contact"];
        $tabparam["MAIN_SEARCHFORM_SOCIETE"] = $_POST["main_searchform_societe"];
        $tabparam["MAIN_SEARCHFORM_PRODUITSERVICE"] = $_POST["main_searchform_produitservice"];
        $result = dol_set_user_param($db, $conf, $object, $tabparam);
        header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
        exit;
    }
}
/*
 * View
 */
llxHeader();
$head = user_prepare_head($object);
$title = $langs->trans("User");
if ($action == 'edit') {
    print '<form method="post" action="' . $_SERVER["PHP_SELF"] . '">';
    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
    print '<input type="hidden" name="action" value="update">';
    print '<input type="hidden" name="id" value="' . $id . '">';
Beispiel #4
0
    /**
     *      Save order of boxes for area and user
     *
     *      @param      string     $zone       Name of area (0 for Homepage, ...)
     *      @param      string     $boxorder   List of boxes with correct order 'A:123,456,...-B:789,321...'
     *      @param      int        $userid     Id of user
     *      @return     int                    <0 if KO, >= 0 if OK
     */
	function saveboxorder($zone,$boxorder,$userid=0)
	{
		global $conf;

		require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");

		dol_syslog("InfoBoxes::saveboxorder zone=".$zone." user="******"DELETE FROM ".MAIN_DB_PREFIX."boxes";
		$sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def";
		$sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid";
		$sql.= " AND ".MAIN_DB_PREFIX."boxes_def.entity = ".$conf->entity;
		$sql.= " AND ".MAIN_DB_PREFIX."boxes.fk_user = "******" AND ".MAIN_DB_PREFIX."boxes.position = ".$zone;

		dol_syslog("InfoBox::saveboxorder sql=".$sql);
		$result = $this->db->query($sql);
		if ($result)
		{
			$colonnes=explode('-',$boxorder);
			foreach ($colonnes as $collist)
			{
				$part=explode(':',$collist);
				$colonne=$part[0];
				$list=$part[1];
				dol_syslog('InfoBox::saveboxorder column='.$colonne.' list='.$list);

				$i=0;
				$listarray=explode(',',$list);
				foreach ($listarray as $id)
				{
					if (is_numeric($id))
					{
						//dol_syslog("aaaaa".count($listarray));
						$i++;
						$ii=sprintf('%02d',$i);
						$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes";
						$sql.= "(box_id, position, box_order, fk_user)";
						$sql.= " values (";
						$sql.= " ".$id.",";
						$sql.= " ".$zone.",";
						$sql.= " '".$colonne.$ii."',";
						$sql.= " ".$userid;
						$sql.= ")";

						dol_syslog("InfoBox::saveboxorder sql=".$sql);
						$result = $this->db->query($sql);
						if ($result < 0)
						{
							$error++;
							break;
						}
					}
				}
			}
			if ($error)
			{
				$this->error=$this->db->error();
				$this->db->rollback();
				return -2;
			}
			else
			{
				$this->db->commit();
				return 1;
			}
		}
		else
		{
			$this->error=$this->db->lasterror();
			$this->db->rollback();
			dol_syslog("InfoBox::saveboxorder ".$this->error);
			return -1;
		}
	}