Example #1
0
     $sql = "UPDATE `{$dbScheduler}` SET params = '{$CONFIG['closure_delay']}' WHERE action = 'CloseIncidents' LIMIT 1";
     mysql_query($sql);
     if (mysql_error()) {
         trigger_error(mysql_error(), E_USER_WARNING);
         echo "<p><strong>FAILED:</strong> {$sql}</p>";
         $upgradeok = FALSE;
     } else {
         echo "<p><strong>OK:</strong> {$sql}</p>";
     }
 }
 //add trigger to users, NOTE we do user 1(admin's) in the schema
 $sql = "SELECT id FROM `{$dbUsers}` WHERE id > 1";
 if ($result = @mysql_query($sql)) {
     echo '<p>Adding default triggers to existing users.</p>';
     while ($row = mysql_fetch_row($result)) {
         setup_user_triggers($row->id);
     }
 }
 //add the triggers for var_notify users from above
 if (is_array($assign_notify_users)) {
     echo '<p>Replacing "Notify on reassign" option with triggers</p>';
     foreach ($assign_notify_users as $assign_user) {
         $sql = "INSERT INTO `{$dbTriggers}`(triggerid, userid, action, template, checks) ";
         $sql .= "VALUES('TRIGGER_INCIDENT_ASSIGNED', '{$assign_user}', 'ACTION_EMAIL', 'EMAIL_INCIDENT_REASSIGNED_USER_NOTIFY', '{userstatus} ==  {$assign_user}')";
         mysql_query($sql);
         if (mysql_error()) {
             trigger_error(mysql_error(), E_USER_ERROR);
         }
     }
 }
 //fix the visibility for KB articles
Example #2
0
        if (mysql_error()) {
            trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
        }
        $newuserid = mysql_insert_id();
        // Create permissions (set to none)
        $sql = "SELECT * FROM `{$dbPermissions}`";
        $result = mysql_query($sql);
        if (mysql_error()) {
            trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING);
        }
        while ($perm = mysql_fetch_object($result)) {
            $psql = "INSERT INTO `{$dbUserPermissions}` (userid, permissionid, granted) ";
            $psql .= "VALUES ('{$newuserid}', '{$perm->id}', 'false')";
            mysql_query($psql);
            if (mysql_error()) {
                trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
            }
        }
        if (!$result) {
            echo "<p class='error'>{$strAdditionFail}</p>\n";
        } else {
            setup_user_triggers($newuserid);
            trigger('TRIGGER_NEW_USER', array('userid' => $newuserid));
            html_redirect("manage_users.php#userid{$newuserid}");
        }
        clear_form_data('add_user');
        clear_form_errors('add_user');
    } else {
        html_redirect($_SERVER['PHP_SELF'], FALSE);
    }
}
Example #3
0
 /**
  * Adds a user to SiT! this performs a number of checks to ensure uniqueness and mandertory details are present
  *
  * @return mixed int for user ID if sucessful else FALSE
  * @author Paul Heaney
  */
 function add()
 {
     global $CONFIG, $now;
     $this->style = $CONFIG['default_interface_style'];
     $this->startdate = $now;
     if (empty($this->source)) {
         $this->source = 'sit';
     }
     if (empty($this->password)) {
         $this->password = generate_password(16);
     }
     $toReturn = FALSE;
     $sql = "SELECT * FROM `{$GLOBALS['dbUsers']}` WHERE username = '******'";
     $result = mysql_query($sql);
     if (mysql_error()) {
         trigger_error(mysql_error(), E_USER_WARNING);
     }
     if (mysql_num_rows($result) != 0) {
         // Already exists
         trigger_error($GLOBALS['strUsernameNotUnique'], E_USER_ERROR);
         $toReturn = FALSE;
     } else {
         // Insert
         $sql = "INSERT INTO `{$GLOBALS['dbUsers']}` (username, password, realname, roleid, ";
         $sql .= "groupid, title, email, phone, mobile, fax, status, var_style, ";
         $sql .= "holiday_entitlement, user_startdate, lastseen, user_source) ";
         $sql .= "VALUES ('{$this->username}', MD5('{$this->password}'), '{$this->realname}', '{$this->roleid}', ";
         $sql .= "'{$this->group->id}', '{$this->jobtitle}', '{$this->email}', '{$this->phone}', '{$this->mobile}', '{$this->fax}', ";
         $sql .= "{$this->status}, '{$this->style}', ";
         $sql .= "'{$this->holiday_entitlement}', '{$this->startdate}', 0, '{$this->source}')";
         $result = mysql_query($sql);
         if (mysql_error()) {
             trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
             $toReturn = false;
         }
         $toReturn = mysql_insert_id();
         if ($toReturn != FALSE) {
             // Create permissions (set to none)
             $sql = "SELECT * FROM `{$GLOBALS['dbPermissions']}`";
             $result = mysql_query($sql);
             if (mysql_error()) {
                 trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING);
             }
             while ($perm = mysql_fetch_object($result)) {
                 $psql = "INSERT INTO `{$GLOBALS['dbUserPermissions']}` (userid, permissionid, granted) ";
                 $psql .= "VALUES ('{$toReturn}', '{$perm->id}', 'false')";
                 mysql_query($psql);
                 if (mysql_error()) {
                     trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
                 }
             }
             setup_user_triggers($toReturn);
             trigger('TRIGGER_NEW_USER', array('userid' => $toReturn));
         }
     }
     return $toReturn;
 }