Esempio n. 1
0
function tpl_list_heading($colname, $format = "<th%s>%s</th>")
{
    global $proj, $page;
    $imgbase = '<img src="%s" alt="%s" />';
    $class = '';
    $html = eL($colname);
    if ($colname == 'comments' || $colname == 'attachments') {
        $html = sprintf($imgbase, $page->get_image(substr($colname, 0, -1)), $html);
    }
    if (Get::val('order') == $colname) {
        $class = ' class="orderby"';
        $sort1 = Get::safe('sort', 'desc') == 'desc' ? 'asc' : 'desc';
        $sort2 = Get::safe('sort2', 'desc');
        $order2 = Get::safe('order2');
        $html .= '&nbsp;&nbsp;' . sprintf($imgbase, $page->get_image(Get::val('sort')), Get::safe('sort'));
    } else {
        $sort1 = 'desc';
        if (in_array($colname, array('project', 'tasktype', 'category', 'openedby', 'assignedto'))) {
            $sort1 = 'asc';
        }
        $sort2 = Get::safe('sort', 'desc');
        $order2 = Get::safe('order');
    }
    $new_order = array('order' => $colname, 'sort' => $sort1, 'order2' => $order2, 'sort2' => $sort2);
    $html = sprintf('<a title="%s" href="%s">%s</a>', eL('sortthiscolumn'), Filters::noXSS(CreateURL('index', $proj->id, null, array_merge($_GET, $new_order))), $html);
    return sprintf($format, $class, $html);
}
Esempio n. 2
0
function SPITFORM($project, $message, $errors)
{
    global $this_user;
    $message = CleanString($message);
    if ($errors) {
        echo "<table class=nogrid\n                     align=center border=0 cellpadding=6 cellspacing=0>\n              <tr>\n                 <th align=center colspan=2>\n                   <font size=+1 color=red>\n                      &nbsp;Oops, please fix the following errors!&nbsp;\n                   </font>\n                 </td>\n              </tr>\n";
        while (list($name, $message) = each($errors)) {
            # XSS prevention.
            $message = CleanString($message);
            echo "<tr>\n                     <td align=right>\n                       <font color=red>{$name}:&nbsp;</font></td>\n                     <td align=left>\n                       <font color=red>{$message}</font></td>\n                  </tr>\n";
        }
        echo "</table><br>\n";
    }
    #
    # Show stuff
    #
    $project->Show();
    $url = CreateURL("resendapproval", $project);
    echo "<br>";
    echo "<table align=center border=1>\n";
    echo "<form action='{$url}' method='post'>\n";
    echo "<tr>\n              <td>Use the text box (70 columns wide) to add a message to the\n                  email notification. </td>\n          </tr>\n";
    echo "<tr>\n             <td align=center class=left>\n                 <textarea name=message rows=15 cols=70></textarea>\n             </td>\n          </tr>\n";
    echo "<tr>\n              <td align=center>\n                  <b><input type='submit' value='Submit' name='submit'></td>\n          </tr>\n          </form>\n          </table>\n";
}
Esempio n. 3
0
function SPITFORM($formfields, $errors)
{
    global $instance, $runidx, $TBDB_ARCHIVE_TAGLEN, $referrer;
    $iid = $instance->id();
    $runid = $instance->GetRunID($runidx);
    echo $instance->RunPageHeader($runidx);
    echo "<br><br><center>\n          Revise Record {$runid} in Instance {$iid} </center><br>\n";
    if ($errors) {
        echo "<table class=nogrid\n                     align=center border=0 cellpadding=6 cellspacing=0>\n              <tr>\n                 <th align=center colspan=2>\n                   <font size=+1 color=red>\n                      &nbsp;Oops, please fix the following errors!&nbsp;\n                   </font>\n                 </td>\n              </tr>\n";
        while (list($name, $message) = each($errors)) {
            # XSS prevention.
            $message = CleanString($message);
            echo "<tr>\n                     <td align=right>\n                       <font color=red>{$name}:&nbsp;</font></td>\n                     <td align=left>\n                       <font color=red>{$message}</font></td>\n                  </tr>\n";
        }
        echo "</table><br>\n";
    }
    # XSS prevention.
    while (list($key, $val) = each($formfields)) {
        $formfields[$key] = CleanString($val);
    }
    $url = CreateURL("record_revise", $instance, "runidx", $runidx);
    echo "<table align=center border=1> \n          <form action='{$url}' method=post>\n";
    if (isset($referrer)) {
        $url = urlencode($referrer);
        echo "<input type=hidden name=referrer value='{$url}'>\n";
    }
    echo "<tr>\n              <td align=center>\n               <b>Please enter a message to be logged\n                       with the revision</b>\n              </td>\n          </tr>\n          <tr>\n              <td align=center class=left>\n                  <textarea name=\"formfields[message]\"\n                    rows=10 cols=70>" . str_replace("\r", "", $formfields["message"]) . "</textarea>\n              </td>\n          </tr>\n";
    echo "<tr>\n              <td align=center>\n                 <b><input type=submit name=submit value='Revise Record'></b>\n              </td>\n          </tr>\n";
    echo "</form>\n          </table>\n";
    echo "<blockquote><blockquote>\n          <ul>\n            <li> This operation will update the end of run archive that was\n                 saved when the run originally completed. The original record\n                 will not be lost, and you can update as many times as you\n                 like.</li>\n          </ul>\n          </blockquote></blockquote>\n";
}
Esempio n. 4
0
 function action_updateproject()
 {
     global $proj, $db, $baseurl;
     if (Post::val('delete_project')) {
         $url = Post::val('move_to') ? CreateURL(array('pm', 'proj' . Post::num('move_to'), 'prefs')) : $baseurl;
         if (Backend::delete_project($proj->id, Post::val('move_to'))) {
             return array(SUBMIT_OK, L('projectdeleted'), $url);
         } else {
             return array(ERROR_INPUT, L('projectnotdeleted'), $url);
         }
     }
     if (!Post::val('project_title')) {
         return array(ERROR_RECOVER, L('emptytitle'));
     }
     $cols = array('project_title', 'theme_style', 'lang_code', 'default_task', 'default_entry', 'intro_message', 'notify_email', 'notify_jabber', 'notify_subject', 'notify_reply', 'feed_description', 'feed_img_url', 'svn_user', 'svn_url', 'svn_password', 'mail_headers');
     $args = array_map('Post_to0', $cols);
     foreach (array('others_view', 'anon_open', 'send_digest', 'anon_view_tasks', 'anon_group', 'comment_closed', 'auto_assign', 'roadmap_field', 'override_user_lang') as $name) {
         $cols[] = $name;
         $args[] = Post::num($name);
     }
     foreach (array('notify_types', 'changelog_reso', 'syntax_plugins') as $name) {
         $cols[] = $name;
         $args[] = implode(' ', (array) Post::val($name));
     }
     // invalidate the cache if necessary
     if (implode(' ', (array) Post::val('syntax_plugins')) != $proj->prefs['syntax_plugins']) {
         $db->execParam('DELETE FROM {cache} WHERE project_id = ?', $proj->id);
     }
     // carefully check the project prefix...
     $prefix = Post::val('project_prefix');
     // already in use?
     $use = $db->x->GetOne('SELECT project_id FROM {projects} WHERE project_prefix = ? AND project_id != ?', null, array($prefix, $proj->id));
     if (Filters::isAlnum($prefix) && $prefix != 'FS' && !$use) {
         $cols[] = 'project_prefix';
         $args[] = $prefix;
     } else {
         return array(ERROR_RECOVER, L('badprefix'));
     }
     $cols[] = 'last_updated';
     $args[] = time();
     $cols[] = 'default_cat_owner';
     $args[] = Flyspray::UserNameToId(Post::val('default_cat_owner'));
     $db->x->autoExecute('{projects}', array_combine($cols, $args), MDB2_AUTOQUERY_UPDATE, sprintf('project_id = %d', $proj->id));
     $db->x->execParam('UPDATE {projects} SET visible_columns = ? WHERE project_id = ?', array(trim(Post::val('visible_columns')), $proj->id));
     return array(SUBMIT_OK, L('projectupdated'));
 }
Esempio n. 5
0
 function action_newtask()
 {
     global $user;
     list($task_id, $token, $ok) = Backend::create_task($_POST);
     // Status and redirect
     if ($ok) {
         $url = CreateURL(array('details', 'task' . $task_id));
         if ($user->isAnon()) {
             $url = CreateURL(array('details', 'task' . $task_id), array('task_token' => $token));
         }
         if (Post::val('more_tasks')) {
             $url = '';
         }
         return array(SUBMIT_OK, L('newtaskadded'), $url);
     } else {
         return array($task_id, $token);
         // create_task will out error info there
     }
 }
Esempio n. 6
0
foreach ($popups as $i => $popup) {
    echo "{$popup}\n";
}
#
# Find all logs associated with this slice.
#
$query_result = DBQueryFatal("select m.logidx,l.logid,l.date_created,m2.metaval " . "  from logfile_metadata as m " . "left join logfiles as l on l.logidx=m.logidx " . "left join logfile_metadata as m2 on " . "      m2.logidx=m.logidx and m2.metakey='Method' " . "where m.metakey='slice_idx' and m.metaval='{$slice_idx}' " . "order by l.date_created asc");
if ($query_result && mysql_num_rows($query_result)) {
    $table = array('#id' => 'logfiles', '#title' => "Log Files", '#headings' => array("idx" => "ID", "method" => "Op", "created" => "Created", "log" => "Link"));
    $rows = array();
    $img = "<img border='0' src='greenball.gif' />";
    while ($row = mysql_fetch_array($query_result)) {
        $logidx = $row["logidx"];
        $logid = $row["logid"];
        $op = $row["metaval"];
        $date = $row["date_created"];
        $url = CreateURL("spewlogfile", "logfile", $logid);
        $row = array("idx" => $logidx, "method" => $op, "created" => $date, "log" => "<a href='{$url}'>{$img}</a>");
        $rows[] = $row;
    }
    list($html, $button) = TableRender($table, $rows);
    echo $html;
    echo "<center>\n            <a href='showslicelogs.php?slice_idx={$slice_idx}&download=1'>\n            Download All Logs</a></center>";
}
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>

 function Show($short = 0, $sortby = "")
 {
     global $TBDBNAME, $TBDOCBASE, $WIKIDOCURL;
     $pid = $this->pid();
     $eid = $this->eid();
     $nodecounts = array();
     # Node counts, by class.
     $query_result = DBQueryFatal("select nt.class,count(*) from reserved as r " . "left join nodes as n on n.node_id=r.node_id " . "left join node_types as nt on n.type=nt.type " . "where pid='{$pid}' and eid='{$eid}' group by nt.class");
     while ($row = mysql_fetch_array($query_result)) {
         $class = $row[0];
         $count = $row[1];
         $nodecounts[$class] = $count;
     }
     $query_result = DBQueryFatal("select e.*, s.archive_idx, pl.slicename, " . "round(e.minimum_nodes+.1,0) as min_nodes, " . "round(e.maximum_nodes+.1,0) as max_nodes " . " from experiments as e " . "left join experiment_stats as s on s.exptidx=e.idx " . "left join plab_slices as pl" . " on e.pid = pl.pid and e.eid = pl.eid " . "where e.pid='{$pid}' and e.eid='{$eid}'");
     if (($exprow = mysql_fetch_array($query_result)) == 0) {
         TBERROR("Experiment {$eid} in project {$pid} is gone!\n", 1);
     }
     $exp_gid = $exprow["gid"];
     $exp_name = $exprow["expt_name"];
     $exp_swapped = $exprow["expt_swapped"];
     $exp_swapuid = $exprow["expt_swap_uid"];
     $exp_end = $exprow["expt_end"];
     $exp_created = $exprow["expt_created"];
     $exp_head = $exprow["expt_head_uid"];
     $exp_swapper = $exprow["swapper_idx"];
     $exp_state = $exprow["state"];
     $exp_shared = $exprow["shared"];
     $exp_path = $exprow["path"];
     $batchmode = $exprow["batchmode"];
     $canceled = $exprow["canceled"];
     $attempts = $exprow["attempts"];
     $expt_locked = $exprow["expt_locked"];
     $priority = $exprow["priority"];
     $swappable = $exprow["swappable"];
     $noswap_reason = $exprow["noswap_reason"];
     $idleswap = $exprow["idleswap"];
     $idleswap_timeout = $exprow["idleswap_timeout"];
     $noidleswap_reason = $exprow["noidleswap_reason"];
     $autoswap = $exprow["autoswap"];
     $autoswap_timeout = $exprow["autoswap_timeout"];
     $idle_ignore = $exprow["idle_ignore"];
     $savedisk = $exprow["savedisk"];
     $swapreqs = $exprow["swap_requests"];
     $lastswapreq = $exprow["last_swap_req"];
     $minnodes = $exprow["min_nodes"];
     $maxnodes = $exprow["max_nodes"];
     $virtnodes = $exprow["virtnode_count"];
     $syncserver = $exprow["sync_server"];
     $mem_usage = $exprow["mem_usage"];
     $cpu_usage = $exprow["cpu_usage"];
     $exp_slice = $exprow["slicename"];
     $linktest_level = $exprow["linktest_level"];
     $linktest_pid = $exprow["linktest_pid"];
     $usemodelnet = $exprow["usemodelnet"];
     $mnet_cores = $exprow["modelnet_cores"];
     $mnet_edges = $exprow["modelnet_edges"];
     $lockdown = $exprow["lockdown"];
     $skipvlans = $exprow["skipvlans"];
     $exptidx = $exprow["idx"];
     $archive_idx = $exprow["archive_idx"];
     $dpdb = $exprow["dpdb"];
     $dpdbname = $exprow["dpdbname"];
     $dpdbpassword = $exprow["dpdbpassword"];
     $uuid = $exprow["eid_uuid"];
     $paniced = $exprow["paniced"];
     $panic_date = $exprow["panic_date"];
     $autoswap_hrs = $autoswap_timeout / 60.0;
     $idleswap_hrs = $idleswap_timeout / 60.0;
     $noswap = "({$noswap_reason})";
     $noidleswap = "({$noidleswap_reason})";
     $autoswap_str = $autoswap_hrs . " hour" . ($autoswap_hrs == 1 ? "" : "s");
     $idleswap_str = $idleswap_hrs . " hour" . ($idleswap_hrs == 1 ? "" : "s");
     if (!($head_user = User::Lookup($exp_head))) {
         TBERROR("Error getting object for user {$exp_head}", 1);
     }
     $showuser_url = CreateURL("showuser", $head_user);
     if (!($swapper = User::Lookup($exp_swapper))) {
         TBERROR("Error getting object for user {$exp_swapper}", 1);
     }
     $swapper_uid = $swapper->uid();
     $swapper_url = CreateURL("showuser", $swapper);
     if ($swappable) {
         $swappable = "Yes";
     } else {
         $swappable = "<b>No</b> {$noswap}";
     }
     if ($idleswap) {
         $idleswap = "Yes (after {$idleswap_str})";
     } else {
         $idleswap = "<b>No</b> {$noidleswap}";
     }
     if ($autoswap) {
         $autoswap = "<b>Yes</b> (after {$autoswap_str})";
     } else {
         $autoswap = "No";
     }
     if ($idle_ignore) {
         $idle_ignore = "<b>Yes</b>";
     } else {
         $idle_ignore = "No";
     }
     if ($savedisk) {
         $savedisk = "<b>Yes</b>";
     } else {
         $savedisk = "No";
     }
     if ($expt_locked) {
         $expt_locked = "({$expt_locked})";
     } else {
         $expt_locked = "";
     }
     $query_result = DBQueryFatal("select cause_desc " . "from experiment_stats as s,errors,causes " . "where s.exptidx = {$exptidx} " . "and errors.cause = causes.cause " . "and s.last_error = errors.session");
     if ($row = mysql_fetch_array($query_result)) {
         $err_cause = $row[0];
     } else {
         $err_cause = '';
     }
     #
     # Generate the table.
     #
     echo "<table align=center border=1>\n";
     if (!$short) {
         $thisurl = CreateURL("showexp", $this);
         echo "<tr>\n                <td>Name: </td>\n                <td class=left><a href='{$thisurl}'>{$eid}</a></td>\n              </tr>\n";
         echo "<tr>\n                <td>Description: </td>\n                <td class=\"left\">{$exp_name}</td>\n              </tr>\n";
         echo "<tr>\n                <td>Project: </td>\n                <td class=\"left\">\n                  <a href='showproject.php3?pid={$pid}'>{$pid}</a></td>\n              </tr>\n";
         echo "<tr>\n                <td>Group: </td>\n                <td class=\"left\">\n                  <a href='showgroup.php3?pid={$pid}&gid={$exp_gid}'>{$exp_gid}</a>\n                </td>\n              </tr>\n";
         if (isset($exp_slice)) {
             echo "<tr>\n                  <td>Planetlab Slice: </td>\n                  <td class=\"left\">{$exp_slice}</td>\n                </tr>\n";
         }
     }
     echo "<tr>\n            <td>Creator: </td>\n            <td class=\"left\">\n              <a href='{$showuser_url}'>{$exp_head}</a></td>\n          </tr>\n";
     if (!$swapper->SameUser($head_user)) {
         echo "<tr>\n                      <td>Swapper: </td>\n                      <td class=\"left\">\n                          <a href='{$swapper_url}'>{$swapper_uid}</a></td>\n                  </tr>\n";
     }
     if (!$short) {
         $instance = TemplateInstance::LookupByExptidx($exptidx);
         if (!is_null($instance)) {
             $guid = $instance->guid();
             $vers = $instance->vers();
             echo "<tr>\n                    <td>Template: </td>\n                    <td class=\"left\">\n                       <a href='template_show.php?guid={$guid}&version={$vers}'>\n                          {$guid}/{$vers}</a>";
             if ($instance->runidx()) {
                 $runidx = $instance->runidx();
                 $runid = $instance->GetRunID($runidx);
                 $url = CreateURL("experimentrun_show", $instance, "runidx", $runidx);
                 echo " (Current Run:\n                       <a href='{$url}'>{$runid}</a>)</td>";
             } else {
                 $runidx = $instance->LastRunIdx();
                 $runid = $instance->GetRunID($runidx);
                 $url = CreateURL("experimentrun_show", $instance, "runidx", $runidx);
                 echo " (Last Run:\n                       <a href='{$url}'>{$runid}</a>)</td>";
             }
             echo "</tr>\n";
         }
         echo "<tr>\n                <td>Created: </td>\n                <td class=\"left\">{$exp_created}</td>\n              </tr>\n";
         if ($exp_swapped) {
             echo "<tr>\n                    <td>Last Swap/Modify: </td>\n                    <td class=\"left\">{$exp_swapped}\n                        (<a href='{$swapper_url}'>{$swapper_uid}</a>)</td>\n                  </tr>\n";
         }
         if (ISADMIN()) {
             echo "<tr>\n                    <td><a href='{$WIKIDOCURL}/Swapping#swapping'>Swappable:</a></td>\n                    <td class=\"left\">{$swappable}</td>\n                  </tr>\n";
         }
         echo "<tr>\n                  <td><a href='{$WIKIDOCURL}/Swapping#idleswap'>Idle-Swap:</a></td>\n                  <td class=\"left\">{$idleswap}</td>\n              </tr>\n";
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/Swapping#autoswap'>Max. Duration:</a></td>\n                <td class=\"left\">{$autoswap}</td>\n              </tr>\n";
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/Swapping#swapstatesave'>Save State:</a></td>\n                <td class=\"left\">{$savedisk}</td>\n              </tr>\n";
         if (ISADMIN()) {
             echo "<tr>\n                    <td>Idle Ignore:</td>\n                    <td class=\"left\">{$idle_ignore}</td>\n                 </tr>\n";
         }
         echo "<tr>\n                <td>Path: </td>\n                <td class=left>{$exp_path}</td>\n              </tr>\n";
         echo "<tr>\n                <td>Status: </td>\n                <td id=exp_state class=\"left\">{$exp_state} {$expt_locked}</td>\n              </tr>\n";
         if ($err_cause) {
             echo "<tr>\n                    <td>Last Error: </td>\n                    <td class=\"left\"><a href=\"showlasterror.php3?pid={$pid}&eid={$eid}\">{$err_cause}</a></td>\n                  </tr>\n";
         }
         if ($paniced) {
             echo "<tr>\n                    <td>Paniced on: </td>\n                    <td class=left>{$panic_date}</td>\n                  </tr>\n";
         }
         if ($linktest_pid) {
             $linktest_running = "<b>(Linktest Running)</b>";
         } else {
             $linktest_running = "";
         }
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/linktest'>" . "Linktest Level</a>: </td>\n                <td class=\"left\">{$linktest_level} {$linktest_running}</td>\n              </tr>\n";
     }
     if (count($nodecounts)) {
         echo "<tr>\n                 <td>Reserved Nodes: </td>\n                 <td class=\"left\">\n";
         while (list($class, $count) = each($nodecounts)) {
             echo "{$count} ({$class}) &nbsp; ";
         }
         echo "   </td>\n              </tr>\n";
     } elseif (!$short) {
         if ($minnodes != "") {
             echo "<tr>\n                      <td>Min/Max Nodes: </td>\n                      <td class=\"left\"><font color=green>\n                          {$minnodes}/{$maxnodes} (estimates)</font></td>\n                  </tr>\n";
         } else {
             echo "<tr>\n                      <td>Minumum Nodes: </td>\n                      <td class=\"left\"><font color=green>Unknown</font></td>\n                  </tr>\n";
         }
         if ($virtnodes) {
             echo "<tr>\n                      <td>Virtual Nodes: </td>\n                      <td class=\"left\"><font>\n                          {$virtnodes}</font></td>\n                  </tr>\n";
         } else {
             echo "<tr>\n                      <td>Virtual Nodes: </td>\n                      <td class=\"left\"><font color=green>Unknown</font></td>\n                  </tr>\n";
         }
     }
     if (!$short) {
         if ($mem_usage || $cpu_usage) {
             echo "<tr>\n                      <td>Mem Usage Est: </td>\n                      <td class=\"left\">{$mem_usage}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>CPU Usage Est: </td>\n                      <td class=\"left\">{$cpu_usage}</td>\n                  </tr>\n";
         }
         $lastact = $this->LastAct();
         $idletime = $this->IdleTime();
         $stale = $this->IdleStale();
         if ($lastact != -1) {
             echo "<tr>\n                      <td>Last Activity: </td>\n                      <td class=\"left\">{$lastact}</td>\n                  </tr>\n";
             if ($stale) {
                 $str = "(stale)";
             } else {
                 $str = "";
             }
             echo "<tr>\n                      <td>Idle Time: </td>\n                      <td class=\"left\">{$idletime} hours {$str}</td>\n                  </tr>\n";
         }
         if (!($swapreqs == "" || $swapreqs == 0)) {
             echo "<tr>\n                      <td>Swap Requests: </td>\n                      <td class=\"left\">{$swapreqs}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last Swap Req.: </td>\n                      <td class=\"left\">{$lastswapreq}</td>\n                  </tr>\n";
         }
         $lockflip = $lockdown ? 0 : 1;
         $lockval = $lockdown ? "Yes" : "No";
         echo "<tr>\n                   <td>Locked Down:</td>\n                   <td>{$lockval} (<a href=toggle.php?pid={$pid}&eid={$eid}" . "&type=lockdown&value={$lockflip}>Toggle</a>)\n                   </td>\n              </tr>\n";
         if (ISADMIN() || STUDLY() || OPSGUY()) {
             $thisflip = $skipvlans ? 0 : 1;
             $flipval = $skipvlans ? "Yes" : "No";
             echo "<tr>\n                       <td>Skip Vlans:</td>\n                       <td>{$flipval} (<a href=toggle.php?pid={$pid}&eid={$eid}" . "&type=skipvlans&value={$thisflip}>Toggle</a>)\n                       </td>\n                      </tr>\n";
         }
     }
     if ($batchmode) {
         echo "<tr>\n                    <td>Batch Mode: </td>\n                    <td class=\"left\">Yes</td>\n                  </tr>\n";
         echo "<tr>\n                    <td>Start Attempts: </td>\n                    <td class=\"left\">{$attempts}</td>\n                  </tr>\n";
     }
     if ($canceled) {
         echo "<tr>\n                 <td>Cancel Flag: </td>\n                 <td class=\"left\">{$canceled}</td>\n              </tr>\n";
     }
     if (!$short) {
         if (ISADMIN()) {
             echo "<tr>\n                        <td>UUID: </td>\n                        <td class=left>{$uuid}</td>\n                      </tr>\n";
         }
         if ($usemodelnet) {
             echo "<tr>\n                      <td>Use Modelnet: </td>\n                      <td class=\"left\">Yes</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Modelnet Phys Core Nodes: </td>\n                      <td class=\"left\">{$mnet_cores}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Modelnet Phys Edge Nodes: </td>\n                      <td class=\"left\">{$mnet_edges}</td>\n                  </tr>\n";
         }
         if (isset($syncserver)) {
             echo "<tr>\n                      <td>Sync Server: </td>\n                      <td class=\"left\">{$syncserver}</td>\n                  </tr>\n";
         }
         if ($dpdb && $dpdbname && $dpdbpassword) {
             echo "<tr>\n                      <td>DataBase Name: </td>\n                      <td class=\"left\">{$dpdbname}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>DataBase User: </td>\n                      <td class=\"left\">E{$exptidx}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>DataBase Password: </td>\n                      <td class=\"left\">{$dpdbpassword}</td>\n                  </tr>\n";
         }
         echo "<tr>\n                  <td>Index: </td>\n                  <td class=\"left\">{$exptidx}";
         if ($archive_idx) {
             echo " ({$archive_idx}) ";
         }
         echo " </td>\n              </tr>\n";
     }
     if (!$short) {
         if ($this->geniflags()) {
             $slice = GeniSlice::Lookup("geni-cm", $uuid);
             if ($slice) {
                 $slice_hrn = $slice->hrn();
                 $slice_urn = $slice->urn();
                 if (ISADMIN()) {
                     $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "cm");
                     echo "<tr>\n                                <td>Geni Slice (CM): </td>\n                                <td class=\"left\">\n                                     <a href='{$url}'>{$slice_urn}</a></td>\n                              </tr>\n";
                 } else {
                     echo "<tr>\n                                <td>Geni Slice (CM): </td>\n                                <td class=\"left\">{$slice_urn}</td>\n                              </tr>\n";
                 }
             }
         } else {
             $slice = GeniSlice::LookupByExperiment("geni-sa", $this);
             if ($slice) {
                 $slice_hrn = $slice->hrn();
                 $slice_urn = $slice->urn();
                 if (ISADMIN()) {
                     $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "sa");
                     echo "<tr>\n                                 <td>Geni Slice (SA): </td>\n                                 <td class=\"left\">\n                                      <a href='{$url}'>{$slice_urn}</a></td>\n                             </tr>\n";
                 } else {
                     echo "<tr>\n                                <td>Geni Slice (SA): </td>\n                                <td class=\"left\">{$slice_urn}</td>\n                              </tr>\n";
                 }
                 $slice = GeniSlice::Lookup("geni-cm", $slice_hrn);
                 if ($slice) {
                     if (ISADMIN()) {
                         $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "cm");
                         echo "<tr>\n                                     <td>Geni Slice (CM): </td>\n                                     <td class=\"left\">\n                                           <a href='{$url}'>{$slice_urn}</a></td>\n                                  </tr>\n";
                     } else {
                         echo "<tr>\n                                    <td>Geni Slice (SA): </td>\n                                    <td class=\"left\">{$slice_urn}</td>\n                                  </tr>\n";
                     }
                 }
             }
         }
     }
     echo "</table>\n";
 }
function SPITFORM($formfields, $errors)
{
    global $form, $fields, $root, $template, $prevsearch, $this_user;
    if ($savedsearches = $root->SavedSearches($this_user)) {
        $action = CreateURL("template_search", $template);
        echo "<script language=JavaScript>\n              function PreviousSearch() {\n                  var index = document.prevsearch.prevselect.selectedIndex;\n                  document.prevsearch.target='_self';\n                  document.prevsearch.action='{$action}' + '&prevsearch=' +\n                     document.prevsearch.prevselect.options[index].value;\n                  document.prevsearch.submit();\n              }\n              </script>\n";
        echo "<form name=prevsearch onsubmit=\"return false;\"\n                    action=foo method=post>\n";
        echo FormRenderSelect("savedsearches", array('#type' => 'select', '#default' => 'Choose a Previous Search', '#options' => $savedsearches, '#name' => 'prevselect', '#javascript' => "onchange=\"PreviousSearch();\""));
        echo "</form>\n";
    }
    if (isset($prevsearch)) {
        #
        # Lets add a primitive mechanism to allow saved search deletion.
        # Add a delete button to the saved search row.
        #
        $fields['save']['#elements']['deletesearch'] = array('#type' => 'image', '#value' => "{$prevsearch}", '#image' => "trash.jpg");
    }
    $fields['submits'] = array('#type' => 'list', '#colspan' => TRUE, '#elements' => array('addclause' => array('#type' => 'submit', '#value' => "Add Clause"), 'search' => array('#type' => 'submit', '#value' => "Search")));
    echo "<center>";
    FormRender($form, $errors, $fields, $formfields);
    echo "</center>";
}
Esempio n. 9
0
 /**
  * Adds a new task
  * @param array $args array containing all task properties. unknown properties will be ignored
  * @access public
  * @return integer the task ID on success
  * @version 1.0
  * @notes $args is POST data, bad..bad user..
  */
 public static function create_task($args)
 {
     global $db, $user, $proj;
     if (!isset($args)) {
         return 0;
     }
     // these are the POST variables that the user MUST send, if one of
     // them is missing or if one of them is empty, then we have to abort
     $requiredPostArgs = array('item_summary', 'project_id');
     //modify: made description not required
     foreach ($requiredPostArgs as $required) {
         if (empty($args[$required])) {
             return 0;
         }
     }
     $notify = new Notifications();
     if ($proj->id != $args['project_id']) {
         $proj = new Project($args['project_id']);
     }
     if (!$user->can_open_task($proj)) {
         return 0;
     }
     // first populate map with default values
     $sql_args = array('project_id' => $proj->id, 'date_opened' => time(), 'last_edited_time' => time(), 'opened_by' => intval($user->id), 'percent_complete' => 0, 'mark_private' => 0, 'supertask_id' => 0, 'closedby_version' => 0, 'closure_comment' => '', 'task_priority' => 2, 'due_date' => 0, 'anon_email' => '', 'item_status' => STATUS_UNCONFIRMED);
     // POST variables the user is ALLOWED to provide
     $allowedPostArgs = array('task_type', 'product_category', 'product_version', 'operating_system', 'task_severity', 'estimated_effort', 'supertask_id', 'item_summary', 'detailed_desc');
     // these POST variables the user is only ALLOWED to provide if he got the permissions
     if ($user->perms('modify_all_tasks')) {
         $allowedPostArgs[] = 'closedby_version';
         $allowedPostArgs[] = 'task_priority';
         $allowedPostArgs[] = 'due_date';
         $allowedPostArgs[] = 'item_status';
     }
     if ($user->perms('manage_project')) {
         $allowedPostArgs[] = 'mark_private';
     }
     // now copy all over all POST variables the user is ALLOWED to provide
     // (but only if they are not empty)
     foreach ($allowedPostArgs as $allowed) {
         if (!empty($args[$allowed])) {
             $sql_args[$allowed] = $args[$allowed];
         }
     }
     // Process the due_date
     if (isset($args['due_date']) && ($due_date = $args['due_date']) || ($due_date = 0)) {
         $due_date = Flyspray::strtotime($due_date);
     }
     $sql_params[] = 'mark_private';
     $sql_values[] = intval($user->perms('manage_project') && isset($args['mark_private']) && $args['mark_private'] == '1');
     $sql_params[] = 'due_date';
     $sql_values[] = $due_date;
     $sql_params[] = 'closure_comment';
     $sql_values[] = '';
     // Process estimated effort
     $estimated_effort = 0;
     if ($proj->prefs['use_effort_tracking'] && isset($sql_args['estimated_effort'])) {
         if (($estimated_effort = effort::EditStringToSeconds($sql_args['estimated_effort'], $proj->prefs['hours_per_manday'], $proj->prefs['estimated_effort_format'])) === FALSE) {
             Flyspray::show_error(L('invalideffort'));
             $estimated_effort = 0;
         }
         $sql_args['estimated_effort'] = $estimated_effort;
     }
     // Token for anonymous users
     $token = '';
     if ($user->isAnon()) {
         if (empty($args['anon_email'])) {
             return 0;
         }
         $token = md5(function_exists('openssl_random_pseudo_bytes') ? openssl_random_pseudo_bytes(32) : uniqid(mt_rand(), true));
         $sql_args['task_token'] = $token;
         $sql_args['anon_email'] = $args['anon_email'];
     }
     // ensure all variables are in correct format
     if (!empty($sql_args['due_date'])) {
         $sql_args['due_date'] = Flyspray::strtotime($sql_args['due_date']);
     }
     if (isset($sql_args['mark_private'])) {
         $sql_args['mark_private'] = intval($sql_args['mark_private'] == '1');
     }
     // split keys and values into two separate arrays
     $sql_keys = array();
     $sql_values = array();
     foreach ($sql_args as $key => $value) {
         $sql_keys[] = $key;
         $sql_values[] = $value;
     }
     /*
              * TODO: At least with PostgreSQL, this has caused the sequence to be
              * out of sync with reality. Must be fixed in upgrade process. Check
              * what's the situation with MySQL. (It's fine, it updates the value even
              * if the column was manually adjusted. Remove this whole block later.)
             $result = $db->Query('SELECT  MAX(task_id)+1
                                     FROM  {tasks}');
             $task_id = $db->FetchOne($result);
             $task_id = $task_id ? $task_id : 1;
     */
     //now, $task_id is always the first element of $sql_values
     #array_unshift($sql_keys, 'task_id');
     #array_unshift($sql_values, $task_id);
     $sql_keys_string = join(', ', $sql_keys);
     $sql_placeholder = $db->fill_placeholders($sql_values);
     $result = $db->Query("INSERT INTO {tasks}\n                                ({$sql_keys_string})\n                         VALUES ({$sql_placeholder})", $sql_values);
     $task_id = $db->Insert_ID();
     Backend::upload_links($task_id);
     // create tags
     if (isset($args['tags'])) {
         $tagList = explode(';', $args['tags']);
         $tagList = array_map('strip_tags', $tagList);
         $tagList = array_map('trim', $tagList);
         $tagList = array_unique($tagList);
         # avoid duplicates for inputs like: "tag1;tag1" or "tag1; tag1<p></p>"
         foreach ($tagList as $tag) {
             if ($tag == '') {
                 continue;
             }
             # old tag feature
             #$result2 = $db->Query("INSERT INTO {tags} (task_id, tag) VALUES (?,?)",array($task_id,$tag));
             # new tag feature. let's do it in 2 steps, it is getting too complicated to make it cross database compatible, drawback is possible (rare) race condition (use transaction?)
             $res = $db->Query("SELECT tag_id FROM {list_tag} WHERE (project_id=0 OR project_id=?) AND tag_name LIKE ? ORDER BY project_id", array($proj->id, $tag));
             if ($t = $db->FetchRow($res)) {
                 $tag_id = $t['tag_id'];
             } else {
                 if ($proj->prefs['freetagging'] == 1) {
                     # add to taglist of the project
                     $db->Query("INSERT INTO {list_tag} (project_id,tag_name) VALUES (?,?)", array($proj->id, $tag));
                     $tag_id = $db->Insert_ID();
                 } else {
                     continue;
                 }
             }
             $db->Query("INSERT INTO {task_tag}(task_id,tag_id) VALUES(?,?)", array($task_id, $tag_id));
         }
     }
     // Log the assignments and send notifications to the assignees
     if (isset($args['rassigned_to']) && is_array($args['rassigned_to'])) {
         // Convert assigned_to and store them in the 'assigned' table
         foreach ($args['rassigned_to'] as $val) {
             $db->Replace('{assigned}', array('user_id' => $val, 'task_id' => $task_id), array('user_id', 'task_id'));
         }
         // Log to task history
         Flyspray::logEvent($task_id, 14, implode(' ', $args['rassigned_to']));
         // Notify the new assignees what happened.  This obviously won't happen if the task is now assigned to no-one.
         $notify->Create(NOTIFY_NEW_ASSIGNEE, $task_id, null, $notify->SpecificAddresses($args['rassigned_to']), NOTIFY_BOTH, $proj->prefs['lang_code']);
     }
     // Log that the task was opened
     Flyspray::logEvent($task_id, 1);
     $result = $db->Query('SELECT  *
                             FROM  {list_category}
                            WHERE  category_id = ?', array($args['product_category']));
     $cat_details = $db->FetchRow($result);
     // We need to figure out who is the category owner for this task
     if (!empty($cat_details['category_owner'])) {
         $owner = $cat_details['category_owner'];
     } else {
         // check parent categories
         $result = $db->Query('SELECT  *
                                 FROM  {list_category}
                                WHERE  lft < ? AND rgt > ? AND project_id  = ?
                             ORDER BY  lft DESC', array($cat_details['lft'], $cat_details['rgt'], $cat_details['project_id']));
         while ($row = $db->FetchRow($result)) {
             // If there's a parent category owner, send to them
             if (!empty($row['category_owner'])) {
                 $owner = $row['category_owner'];
                 break;
             }
         }
     }
     if (!isset($owner)) {
         $owner = $proj->prefs['default_cat_owner'];
     }
     if ($owner) {
         if ($proj->prefs['auto_assign'] && ($args['item_status'] == STATUS_UNCONFIRMED || $args['item_status'] == STATUS_NEW)) {
             Backend::add_to_assignees($owner, $task_id, true);
         }
         Backend::add_notification($owner, $task_id, true);
     }
     // Reminder for due_date field
     if (!empty($sql_args['due_date'])) {
         Backend::add_reminder($task_id, L('defaultreminder') . "\n\n" . CreateURL('details', $task_id), 2 * 24 * 60 * 60, time());
     }
     // Create the Notification
     if (Backend::upload_files($task_id)) {
         $notify->Create(NOTIFY_TASK_OPENED, $task_id, 'files', null, NOTIFY_BOTH, $proj->prefs['lang_code']);
     } else {
         $notify->Create(NOTIFY_TASK_OPENED, $task_id, null, null, NOTIFY_BOTH, $proj->prefs['lang_code']);
     }
     // If the reporter wanted to be added to the notification list
     if (isset($args['notifyme']) && $args['notifyme'] == '1' && $user->id != $owner) {
         Backend::add_notification($user->id, $task_id, true);
     }
     if ($user->isAnon()) {
         $anonuser = array();
         $anonuser[$email] = array('recipient' => $args['anon_email'], 'lang' => $fs->prefs['lang_code']);
         $recipients = array($anonuser);
         $notify->Create(NOTIFY_ANON_TASK, $task_id, $token, $recipients, NOTIFY_EMAIL, $proj->prefs['lang_code']);
     }
     return array($task_id, $token);
 }
Esempio n. 10
0
function pagenums($pagenum, $perpage, $totalcount)
{
    global $proj;
    $pagenum = intval($pagenum);
    $perpage = intval($perpage);
    $totalcount = intval($totalcount);
    // Just in case $perpage is something weird, like 0, fix it here:
    if ($perpage < 1) {
        $perpage = $totalcount > 0 ? $totalcount : 1;
    }
    $pages = ceil($totalcount / $perpage);
    $output = sprintf(eL('page'), $pagenum, $pages);
    if ($totalcount / $perpage > 1) {
        $params = $_GET;
        # unset unneeded params for shorter urls
        unset($params['do']);
        unset($params['project']);
        unset($params['switch']);
        $output .= '<span class="pagenums DoNotPrint">';
        $start = max(1, $pagenum - 4 + min(2, $pages - $pagenum));
        $finish = min($start + 4, $pages);
        if ($start > 1) {
            $url = Filters::noXSS(CreateURL('tasklist', $proj->id, null, array_merge($params, array('pagenum' => 1))));
            $output .= sprintf('<a href="%s">&lt;&lt;%s </a>', $url, eL('first'));
        }
        if ($pagenum > 1) {
            $url = Filters::noXSS(CreateURL('tasklist', $proj->id, null, array_merge($params, array('pagenum' => $pagenum - 1))));
            $output .= sprintf('<a id="previous" accesskey="p" href="%s">&lt; %s</a> - ', $url, eL('previous'));
        }
        for ($pagelink = $start; $pagelink <= $finish; $pagelink++) {
            if ($pagelink != $start) {
                $output .= ' - ';
            }
            if ($pagelink == $pagenum) {
                $output .= sprintf('<strong>%d</strong>', $pagelink);
            } else {
                $url = Filters::noXSS(CreateURL('tasklist', $proj->id, null, array_merge($params, array('pagenum' => $pagelink))));
                $output .= sprintf('<a href="%s">%d</a>', $url, $pagelink);
            }
        }
        if ($pagenum < $pages) {
            $url = Filters::noXSS(CreateURL('tasklist', $proj->id, null, array_merge($params, array('pagenum' => $pagenum + 1))));
            $output .= sprintf(' - <a id="next" accesskey="n" href="%s">%s &gt;</a>', $url, eL('next'));
        }
        if ($finish < $pages) {
            $url = Filters::noXSS(CreateURL('tasklist', $proj->id, null, array_merge($params, array('pagenum' => $pages))));
            $output .= sprintf('<a href="%s"> %s &gt;&gt;</a>', $url, eL('last'));
        }
        $output .= '</span>';
    }
    return $output;
}
Esempio n. 11
0
 /**
  * Adds a new task
  * @param array $args array containing all task properties. unknown properties will be ignored
  * @access public
  * @return integer the task ID on success
  * @version 1.0
  * @notes $args is POST data, bad..bad user..
  */
 public static function create_task($args)
 {
     global $db, $user, $proj;
     $notify = new Notifications();
     if ($proj->id != $args['project_id']) {
         $proj = new Project($args['project_id']);
     }
     if (!$user->can_open_task($proj) || count($args) < 3) {
         return 0;
     }
     if (!(($item_summary = $args['item_summary']) && ($detailed_desc = $args['detailed_desc']))) {
         return 0;
     }
     // Some fields can have default values set
     if (!$user->perms('modify_all_tasks')) {
         $args['closedby_version'] = 0;
         $args['task_priority'] = 2;
         $args['due_date'] = 0;
         $args['item_status'] = STATUS_UNCONFIRMED;
     }
     $param_names = array('task_type', 'item_status', 'product_category', 'product_version', 'closedby_version', 'operating_system', 'task_severity', 'task_priority');
     $sql_values = array(time(), time(), $args['project_id'], $item_summary, $detailed_desc, intval($user->id), 0);
     $sql_params = array();
     foreach ($param_names as $param_name) {
         if (isset($args[$param_name])) {
             $sql_params[] = $param_name;
             $sql_values[] = $args[$param_name];
         }
     }
     // Process the due_date
     if (isset($args['due_date']) && ($due_date = $args['due_date']) || ($due_date = 0)) {
         $due_date = Flyspray::strtotime($due_date);
     }
     $sql_params[] = 'mark_private';
     $sql_values[] = intval($user->perms('manage_project') && isset($args['mark_private']) && $args['mark_private'] == '1');
     $sql_params[] = 'due_date';
     $sql_values[] = $due_date;
     $sql_params[] = 'closure_comment';
     $sql_values[] = '';
     // Token for anonymous users
     $token = '';
     if ($user->isAnon()) {
         $token = md5(function_exists('openssl_random_pseudo_bytes') ? openssl_random_pseudo_bytes(32) : uniqid(mt_rand(), true));
         $sql_params[] = 'task_token';
         $sql_values[] = $token;
         $sql_params[] = 'anon_email';
         $sql_values[] = $args['anon_email'];
     } else {
         $sql_params[] = 'anon_email';
         $sql_values[] = '';
     }
     $sql_params = join(', ', $sql_params);
     // +1 for the task_id column;
     $sql_placeholder = $db->fill_placeholders($sql_values, 1);
     $result = $db->Query('SELECT  MAX(task_id)+1
                             FROM  {tasks}');
     $task_id = $db->FetchOne($result);
     $task_id = $task_id ? $task_id : 1;
     //now, $task_id is always the first element of $sql_values
     array_unshift($sql_values, $task_id);
     $result = $db->Query("INSERT INTO  {tasks}\n                                 ( task_id, date_opened, last_edited_time,\n                                   project_id, item_summary,\n                                   detailed_desc, opened_by,\n                                   percent_complete, {$sql_params} )\n                         VALUES  ({$sql_placeholder})", $sql_values);
     // Log the assignments and send notifications to the assignees
     if (isset($args['rassigned_to']) && is_array($args['rassigned_to'])) {
         // Convert assigned_to and store them in the 'assigned' table
         foreach ($args['rassigned_to'] as $val) {
             $db->Replace('{assigned}', array('user_id' => $val, 'task_id' => $task_id), array('user_id', 'task_id'));
         }
         // Log to task history
         Flyspray::logEvent($task_id, 14, implode(' ', $args['rassigned_to']));
         // Notify the new assignees what happened.  This obviously won't happen if the task is now assigned to no-one.
         $notify->Create(NOTIFY_NEW_ASSIGNEE, $task_id, null, $notify->SpecificAddresses($args['rassigned_to']));
     }
     // Log that the task was opened
     Flyspray::logEvent($task_id, 1);
     $result = $db->Query('SELECT  *
                             FROM  {list_category}
                            WHERE  category_id = ?', array($args['product_category']));
     $cat_details = $db->FetchRow($result);
     // We need to figure out who is the category owner for this task
     if (!empty($cat_details['category_owner'])) {
         $owner = $cat_details['category_owner'];
     } else {
         // check parent categories
         $result = $db->Query('SELECT  *
                                 FROM  {list_category}
                                WHERE  lft < ? AND rgt > ? AND project_id  = ?
                             ORDER BY  lft DESC', array($cat_details['lft'], $cat_details['rgt'], $cat_details['project_id']));
         while ($row = $db->FetchRow($result)) {
             // If there's a parent category owner, send to them
             if (!empty($row['category_owner'])) {
                 $owner = $row['category_owner'];
                 break;
             }
         }
     }
     if (!isset($owner)) {
         $owner = $proj->prefs['default_cat_owner'];
     }
     if ($owner) {
         if ($proj->prefs['auto_assign'] && ($args['item_status'] == STATUS_UNCONFIRMED || $args['item_status'] == STATUS_NEW)) {
             Backend::add_to_assignees($owner, $task_id, true);
         }
         Backend::add_notification($owner, $task_id, true);
     }
     // Reminder for due_date field
     if ($due_date) {
         Backend::add_reminder($task_id, L('defaultreminder') . "\n\n" . CreateURL('details', $task_id), 2 * 24 * 60 * 60, time());
     }
     // Create the Notification
     if (Backend::upload_files($task_id)) {
         $notify->Create(NOTIFY_TASK_OPENED, $task_id, 'files');
     } else {
         $notify->Create(NOTIFY_TASK_OPENED, $task_id);
     }
     // If the reporter wanted to be added to the notification list
     if (isset($args['notifyme']) && $args['notifyme'] == '1' && $user->id != $owner) {
         Backend::add_notification($user->id, $task_id, true);
     }
     if ($user->isAnon()) {
         $notify->Create(NOTIFY_ANON_TASK, $task_id, $token, $args['anon_email'], NOTIFY_EMAIL);
     }
     return array($task_id, $token);
 }
Esempio n. 12
0
if ($conf['general']['output_buffering'] == 'gzip' && extension_loaded('zlib')) {
    // Start Output Buffering and gzip encoding if setting is present.
    ob_start('ob_gzhandler');
} else {
    ob_start();
}
$page = new FSTpl();
// make sure people are not attempting to manually fiddle with projects they are not allowed to play with
if (Req::has('project') && Req::val('project') != 0 && !$user->can_view_project(Req::val('project'))) {
    Flyspray::show_error(L('nopermission'));
    exit;
}
if ($show_task = Get::val('show_task')) {
    // If someone used the 'show task' form, redirect them
    if (is_numeric($show_task)) {
        Flyspray::Redirect(CreateURL('details', $show_task));
    } else {
        Flyspray::Redirect($baseurl . '?string=' . $show_task);
    }
}
if (Flyspray::requestDuplicated()) {
    // Check that this page isn't being submitted twice
    Flyspray::show_error(3);
}
# handle all forms request that modify data
if (Req::has('action')) {
    # enforcing if the form sent the correct anti csrf token
    # only allow token by post
    if (!Post::has('csrftoken')) {
        die('missingtoken');
    } elseif (Post::val('csrftoken') == $_SESSION['csrftoken']) {
Esempio n. 13
0
     }
     $result = $db->Query('SELECT  * FROM {dependencies}
                            WHERE  depend_id = ?', array(Get::val('depend_id')));
     $dep_info = $db->FetchRow($result);
     $db->Query('DELETE FROM {dependencies} WHERE depend_id = ? AND task_id = ?', array(Get::val('depend_id'), $task['task_id']));
     if ($db->AffectedRows()) {
         $notify->Create(NOTIFY_DEP_REMOVED, $dep_info['task_id'], $dep_info['dep_task_id']);
         $notify->Create(NOTIFY_REV_DEP_REMOVED, $dep_info['dep_task_id'], $dep_info['task_id']);
         Flyspray::logEvent($dep_info['task_id'], 24, $dep_info['dep_task_id']);
         Flyspray::logEvent($dep_info['dep_task_id'], 25, $dep_info['task_id']);
         $_SESSION['SUCCESS'] = L('depremovedmsg');
     } else {
         Flyspray::show_error(L('erroronform'));
     }
     //redirect the user back to the right task
     Flyspray::Redirect(CreateURL('details', Get::val('task_id')));
     break;
     // ##################
     // user requesting a password change
     // ##################
 // ##################
 // user requesting a password change
 // ##################
 case 'lostpw.sendmagic':
     // Check that the username exists
     $sql = $db->Query('SELECT * FROM {users} WHERE user_name = ?', array(Post::val('user_name')));
     // If the username doesn't exist, throw an error
     if (!$db->CountRows($sql)) {
         Flyspray::show_error(L('usernotexist'));
         break;
     }
Esempio n. 14
0
# Check permission.
#
if (!$template->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
    USERERROR("You do not have permission to commit experiment template " . "{$guid}/{$vers}!", 1);
}
#
# Confirm
#
if (!isset($confirmed)) {
    PAGEHEADER("Create Template from Instance");
    echo $instance->ExpPageHeader();
    echo "<center><br><font size=+1>\n          Create new Template from instance {$eid} \n             in Template {$guid}/{$vers}?</font>\n";
    $template->Show();
    echo "<br>";
    $instance->Show(0);
    $url = CreateURL("template_commit", $instance);
    echo "<form action='{$url}' method=post>\n";
    echo "<br>\n";
    echo "<br>\n";
    echo "<b><input type=submit name=confirmed value=Confirm></b>\n";
    echo "<b><input type=submit name=canceled value=Cancel></b>\n";
    echo "</form>\n";
    echo "</center>\n";
    PAGEFOOTER();
    return;
}
#
# Avoid SIGPROF in child.
#
set_time_limit(0);
PAGEHEADER("Create Template from Instance");
function SPITFORM($action, $formfields, $errors)
{
    global $template, $metadata, $referrer;
    global $metadata_type;
    $template_guid = $template->guid();
    $template_vers = $template->vers();
    PAGEHEADER("Manage Template Metadata");
    if ($action == "add") {
        echo "<center>";
        echo "<font size=+1>\n                  Attach metadata[<b>1</b>] to your template.</font>";
        echo "</center><br>\n";
    } elseif ($action == "delete") {
        echo "<center>";
        echo "<h3>Are you sure you want to delete this item?</h3>";
        echo "</center><br>\n";
    }
    if ($errors) {
        echo "<table class=nogrid\n                     align=center border=0 cellpadding=6 cellspacing=0>\n              <tr>\n                 <th align=center colspan=2>\n                   <font size=+1 color=red>\n                      &nbsp;Oops, please fix the following errors!&nbsp;\n                   </font>\n                 </td>\n              </tr>\n";
        while (list($name, $message) = each($errors)) {
            echo "<tr>\n                     <td align=right>\n                       <font color=red>{$name}:&nbsp;</font></td>\n                     <td align=left>\n                       <font color=red>{$message}</font></td>\n                  </tr>\n";
        }
        echo "</table><br>\n";
    }
    if ($action == "modify" || $action == "delete") {
        $url = CreateURL("template_metadata", $template, $metadata);
    } else {
        $url = CreateURL("template_metadata", $template);
    }
    if (isset($metadata_type) && $metadata_type != "") {
        $url .= "&metadata_type={$metadata_type}";
    }
    echo "<form action='{$url}&action={$action}' method=post>\n";
    echo "<table align=center border=1>\n";
    if (isset($referrer) && $referrer != "") {
        echo "<input type=hidden name=referrer value='{$referrer}'>";
    }
    #
    # Template GUID and Version. These are read-only fields.
    #
    echo "<tr>\n              <td class='pad4'>Template GUID:</td>\n              <td class='pad4' class=left>\n                  {$template_guid}/{$template_vers}</td>\n";
    echo "</tr>\n";
    if ($action == "modify" || $action == "delete") {
        $metadata_guid = $metadata->guid();
        $metadata_vers = $metadata->vers();
        echo "<tr>\n                  <td class='pad4'>Metadata GUID:</td>\n                  <td class='pad4' class=left>\n                      {$metadata_guid}/{$metadata_vers}</td>\n";
        echo "</tr>\n";
    }
    $readonly_name = $action == "add" ? "" : "readonly";
    $readonly_value = $action == "delete" ? "readonly" : "";
    #
    # Name of the item
    #
    echo "<tr>\n              <td>*Name:<br>\n                  (something short and pithy)</td>\n              <td class=pad4 class=left>\n\t          <input type=text {$readonly_name}\n                         name=\"formfields[name]\"\n                         value=\"" . $formfields["name"] . "\"\n\t                 size=64>\n             </td>\n          </tr>\n";
    echo "<tr>\n              <td colspan=2>\n               Value (use this area to enter the value of your metadata item).\n              </td>\n          </tr>\n          <tr>\n              <td colspan=2 align=center class=left>\n                  <textarea {$readonly_value} name=\"formfields[value]\"\n                    rows=10 cols=80>" . str_replace("\r", "", $formfields["value"]) . "</textarea>\n              </td>\n          </tr>\n";
    if ($action == "modify") {
        $tag = "Modify Metadata";
    } elseif ($action == "delete") {
        $tag = "Delete Metadata";
    } else {
        $tag = "Add Metadata";
    }
    echo "<tr>\n              <td class='pad4' align=center colspan=2>\n                 <b><input type=submit name=submit value='{$tag}'></b>\n              </td>\n         </tr>\n        </form>\n        </table>\n";
    echo "<blockquote><blockquote>\n          <ol>\n            <li> Metadata can be any arbitrary name/value pair that you want\n                 to associate with your template. The name can include\n                 any printable ascii character including spaces, but\n                 not newlines. The value can include any printable ascii\n                 character and my be multiline.\n          </ol>\n          </blockquote></blockquote>\n";
}
Esempio n. 16
0
}
// our own error handler, so that especially notices don't stay unnoticed
if (version_compare(phpversion(), '5.0.0', '>=')) {
    set_error_handler(array('FlysprayDo', 'error'), ini_get('error_reporting'));
} else {
    set_error_handler(array('FlysprayDo', 'error'));
}
$page = new FSTpl();
if (Get::val('opensearch')) {
    $page->finish('opensearch.tpl');
}
if ($show_task = Get::val('show_task')) {
    // If someone used the 'show task' form, redirect them
    $task_id = Flyspray::GetTaskId($show_task);
    if ($task_id) {
        Flyspray::Redirect(CreateURL(array('details', 'task' . $task_id)));
    } else {
        Flyspray::Redirect(Createurl('index', array('string' => $show_task)));
    }
}
if ($proj->id && $user->perms('manage_project')) {
    // Find out if there are any PM requests wanting attention
    $count = $db->x->GetOne('SELECT COUNT(*) FROM {admin_requests} WHERE project_id = ? AND resolved_by = 0', null, array($proj->id));
    $page->assign('pm_pendingreq_num', $count);
}
// Get e-mail addresses of the admins
if ($user->isAnon() && !$fs->prefs['user_notify']) {
    $amails = $db->x->getCol('SELECT email_address
                         FROM {users} u
                    LEFT JOIN {users_in_groups} g ON u.user_id = g.user_id
                        WHERE g.group_id = 1');
Esempio n. 17
0
 function GenerateMsg($type, $task_id, $arg1 = '0', $lang)
 {
     global $db, $fs, $user, $proj;
     // Get the task details
     $task_details = Flyspray::getTaskDetails($task_id);
     if ($task_id) {
         $proj = new Project($task_details['project_id']);
     }
     // Set the due date correctly
     if ($task_details['due_date'] == '0') {
         $due_date = tL('undecided', $lang);
     } else {
         $due_date = formatDate($task_details['due_date']);
     }
     // Set the due version correctly
     if ($task_details['closedby_version'] == '0') {
         $task_details['due_in_version_name'] = tL('undecided', $lang);
     }
     // Get the string of modification
     $notify_type_msg = array(0 => tL('none'), NOTIFY_TASK_OPENED => tL('taskopened', $lang), NOTIFY_TASK_CHANGED => tL('pm.taskchanged', $lang), NOTIFY_TASK_CLOSED => tL('taskclosed', $lang), NOTIFY_TASK_REOPENED => tL('pm.taskreopened', $lang), NOTIFY_DEP_ADDED => tL('pm.depadded', $lang), NOTIFY_DEP_REMOVED => tL('pm.depremoved', $lang), NOTIFY_COMMENT_ADDED => tL('commentadded', $lang), NOTIFY_ATT_ADDED => tL('attachmentadded', $lang), NOTIFY_REL_ADDED => tL('relatedadded', $lang), NOTIFY_OWNERSHIP => tL('ownershiptaken', $lang), NOTIFY_PM_REQUEST => tL('pmrequest', $lang), NOTIFY_PM_DENY_REQUEST => tL('pmrequestdenied', $lang), NOTIFY_NEW_ASSIGNEE => tL('newassignee', $lang), NOTIFY_REV_DEP => tL('revdepadded', $lang), NOTIFY_REV_DEP_REMOVED => tL('revdepaddedremoved', $lang), NOTIFY_ADDED_ASSIGNEES => tL('assigneeadded', $lang));
     // Generate the nofication message
     if (isset($proj->prefs['notify_subject']) && !$proj->prefs['notify_subject']) {
         $proj->prefs['notify_subject'] = '[%p][#%t] %s';
     }
     if (!isset($proj->prefs['notify_subject']) || $type == NOTIFY_CONFIRMATION || $type == NOTIFY_ANON_TASK || $type == NOTIFY_PW_CHANGE || $type == NOTIFY_NEW_USER || $type == NOTIFY_OWN_REGISTRATION) {
         $subject = tL('notifyfromfs', $lang);
     } else {
         $subject = strtr($proj->prefs['notify_subject'], array('%p' => $proj->prefs['project_title'], '%s' => $task_details['item_summary'], '%t' => $task_id, '%a' => $notify_type_msg[$type], '%u' => $user->infos['user_name']));
     }
     $subject = strtr($subject, "\n", '');
     /* -------------------------------
         | List of notification types: |
         | 1. Task opened              |
         | 2. Task details changed     |
         | 3. Task closed              |
         | 4. Task re-opened           |
         | 5. Dependency added         |
         | 6. Dependency removed       |
         | 7. Comment added            |
         | 8. Attachment added         |
         | 9. Related task added       |
         |10. Taken ownership          |
         |11. Confirmation code        |
         |12. PM request               |
         |13. PM denied request        |
         |14. New assignee             |
         |15. Reversed dep             |
         |16. Reversed dep removed     |
         |17. Added to assignees list  |
         |18. Anon-task opened         |
         |19. Password change          |
         |20. New user                 |
         |21. User registration        |
         -------------------------------
        */
     $body = tL('donotreply', $lang) . "\n\n";
     $online = '';
     // {{{ New task opened
     if ($type == NOTIFY_TASK_OPENED) {
         $body .= tL('newtaskopened', $lang) . " \n\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ") \n\n";
         $body .= tL('attachedtoproject', $lang) . ' - ' . $task_details['project_title'] . "\n";
         $body .= tL('summary', $lang) . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('tasktype', $lang) . ' - ' . $task_details['tasktype_name'] . "\n";
         $body .= tL('category', $lang) . ' - ' . $task_details['category_name'] . "\n";
         $body .= tL('status', $lang) . ' - ' . $task_details['status_name'] . "\n";
         $body .= tL('assignedto', $lang) . ' - ' . implode(', ', $task_details['assigned_to_name']) . "\n";
         $body .= tL('operatingsystem', $lang) . ' - ' . $task_details['os_name'] . "\n";
         $body .= tL('severity', $lang) . ' - ' . $task_details['severity_name'] . "\n";
         $body .= tL('priority', $lang) . ' - ' . $task_details['priority_name'] . "\n";
         $body .= tL('reportedversion', $lang) . ' - ' . $task_details['reported_version_name'] . "\n";
         $body .= tL('dueinversion', $lang) . ' - ' . $task_details['due_in_version_name'] . "\n";
         $body .= tL('duedate', $lang) . ' - ' . $due_date . "\n";
         $body .= tL('details', $lang) . ' - ' . $task_details['detailed_desc'] . "\n\n";
         if ($arg1 == 'files') {
             $body .= tL('fileaddedtoo', $lang) . "\n\n";
             $subject .= ' (' . tL('attachmentadded', $lang) . ')';
         }
         $body .= tL('moreinfo', $lang) . "\n";
         $body .= CreateURL('details', $task_id);
         $online .= tL('newtaskopened', $lang) . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
         $online .= tL('attachedtoproject', $lang) . ' - ' . $task_details['project_title'] . ". ";
         $online .= tL('summary', $lang) . ' - ' . $task_details['item_summary'];
     }
     // }}}
     // {{{ Task details changed
     if ($type == NOTIFY_TASK_CHANGED) {
         $translation = array('priority_name' => tL('priority', $lang), 'severity_name' => tL('severity', $lang), 'status_name' => tL('status', $lang), 'assigned_to_name' => tL('assignedto', $lang), 'due_in_version_name' => tL('dueinversion', $lang), 'reported_version_name' => tL('reportedversion', $lang), 'tasktype_name' => tL('tasktype', $lang), 'os_name' => tL('operatingsystem', $lang), 'category_name' => tL('category', $lang), 'due_date' => tL('duedate', $lang), 'percent_complete' => tL('percentcomplete', $lang), 'mark_private' => tL('visibility', $lang), 'item_summary' => tL('summary', $lang), 'detailed_desc' => tL('taskedited', $lang), 'project_title' => tL('attachedtoproject', $lang), 'estimated_effort' => tL('estimatedeffort', $lang));
         $body .= tL('taskchanged', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ': ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
         $online .= tL('taskchanged', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'];
         foreach ($arg1 as $change) {
             if ($change[0] == 'assigned_to_name') {
                 $change[1] = implode(', ', $change[1]);
                 $change[2] = implode(', ', $change[2]);
             }
             if ($change[0] == 'detailed_desc') {
                 $body .= $translation[$change[0]] . ":\n-------\n" . $change[2] . "\n-------\n";
             } else {
                 $body .= $translation[$change[0]] . ': ' . ($change[1] ? $change[1] : '[-]') . ' -> ' . ($change[2] ? $change[2] : '[-]') . "\n";
             }
         }
         $body .= "\n" . tL('moreinfo', $lang) . "\n";
         $body .= CreateURL('details', $task_id);
     }
     // }}}
     // {{{ Task closed
     if ($type == NOTIFY_TASK_CLOSED) {
         $body .= tL('notify.taskclosed', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
         $body .= tL('reasonforclosing', $lang) . ' ' . $task_details['resolution_name'] . "\n";
         if (!empty($task_details['closure_comment'])) {
             $body .= tL('closurecomment', $lang) . ' ' . $task_details['closure_comment'] . "\n\n";
         }
         $body .= tL('moreinfo', $lang) . "\n";
         $body .= CreateURL('details', $task_id);
         $online .= tL('notify.taskclosed', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ Task re-opened
     if ($type == NOTIFY_TASK_REOPENED) {
         $body .= tL('notify.taskreopened', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
         $body .= tL('moreinfo', $lang) . "\n";
         $body .= CreateURL('details', $task_id);
         $online .= tL('notify.taskreopened', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ Dependency added
     if ($type == NOTIFY_DEP_ADDED) {
         $depend_task = Flyspray::getTaskDetails($arg1);
         $body .= tL('newdep', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
         $body .= CreateURL('details', $task_id) . "\n\n\n";
         $body .= tL('newdepis', $lang) . ':' . "\n\n";
         $body .= 'FS#' . $depend_task['task_id'] . ' - ' . $depend_task['item_summary'] . "\n";
         $body .= CreateURL('details', $depend_task['task_id']);
         $online .= tL('newdep', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ Dependency removed
     if ($type == NOTIFY_DEP_REMOVED) {
         $depend_task = Flyspray::getTaskDetails($arg1);
         $body .= tL('notify.depremoved', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
         $body .= CreateURL('details', $task_id) . "\n\n\n";
         $body .= tL('removeddepis', $lang) . ':' . "\n\n";
         $body .= 'FS#' . $depend_task['task_id'] . ' - ' . $depend_task['item_summary'] . "\n";
         $body .= CreateURL('details', $depend_task['task_id']);
         $online .= tL('notify.depremoved', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ Comment added
     if ($type == NOTIFY_COMMENT_ADDED) {
         // Get the comment information
         $result = $db->Query("SELECT comment_id, comment_text\n                               FROM {comments}\n                               WHERE user_id = ?\n                               AND task_id = ?\n                               ORDER BY comment_id DESC", array($user->id, $task_id), '1');
         $comment = $db->FetchRow($result);
         $body .= tL('notify.commentadded', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
         $body .= "----------\n";
         $body .= $comment['comment_text'] . "\n";
         $body .= "----------\n\n";
         if ($arg1 == 'files') {
             $body .= tL('fileaddedtoo', $lang) . "\n\n";
             $subject .= ' (' . tL('attachmentadded', $lang) . ')';
         }
         $body .= tL('moreinfo', $lang) . "\n";
         $body .= CreateURL('details', $task_id) . '#comment' . $comment['comment_id'];
         $online .= tL('notify.commentadded', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ Attachment added
     if ($type == NOTIFY_ATT_ADDED) {
         $body .= tL('newattachment', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
         $body .= tL('moreinfo', $lang) . "\n";
         $body .= CreateURL('details', $task_id);
         $online .= tL('newattachment', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ Related task added
     if ($type == NOTIFY_REL_ADDED) {
         $related_task = Flyspray::getTaskDetails($arg1);
         $body .= tL('notify.relatedadded', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
         $body .= CreateURL('details', $task_id) . "\n\n\n";
         $body .= tL('relatedis', $lang) . ':' . "\n\n";
         $body .= 'FS#' . $related_task['task_id'] . ' - ' . $related_task['item_summary'] . "\n";
         $body .= CreateURL('details', $related_task['task_id']);
         $online .= tL('notify.relatedadded', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ Ownership taken
     if ($type == NOTIFY_OWNERSHIP) {
         $body .= implode(', ', $task_details['assigned_to_name']) . ' ' . tL('takenownership', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n\n";
         $body .= tL('moreinfo', $lang) . "\n";
         $body .= CreateURL('details', $task_id);
         $online .= implode(', ', $task_details['assigned_to_name']) . ' ' . tL('takenownership', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ".";
     }
     // }}}
     // {{{ Confirmation code
     if ($type == NOTIFY_CONFIRMATION) {
         $body .= tL('noticefrom', $lang) . " {$proj->prefs['project_title']}\n\n" . tL('addressused', $lang) . "\n\n" . " {$arg1[0]}index.php?do=register&magic_url={$arg1[1]} \n\n" . tL('username', $lang) . ': ' . $arg1[2] . "\n" . tL('confirmcodeis', $lang) . " {$arg1['3']} \n\n";
         $online = $body;
     }
     // }}}
     // {{{ Pending PM request
     if ($type == NOTIFY_PM_REQUEST) {
         $body .= tL('requiresaction', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
         $body .= tL('moreinfo', $lang) . "\n";
         $body .= CreateURL('details', $task_id);
         $online .= tL('requiresaction', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ PM request denied
     if ($type == NOTIFY_PM_DENY_REQUEST) {
         $body .= tL('pmdeny', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
         $body .= tL('denialreason', $lang) . ':' . "\n";
         $body .= $arg1 . "\n\n";
         $body .= tL('moreinfo', $lang) . "\n";
         $body .= CreateURL('details', $task_id);
         $online .= tL('pmdeny', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ New assignee
     if ($type == NOTIFY_NEW_ASSIGNEE) {
         $body .= tL('assignedtoyou', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
         $body .= tL('moreinfo', $lang) . "\n";
         $body .= CreateURL('details', $task_id);
         $online .= tL('assignedtoyou', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ Reversed dep
     if ($type == NOTIFY_REV_DEP) {
         $depend_task = Flyspray::getTaskDetails($arg1);
         $body .= tL('taskwatching', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
         $body .= CreateURL('details', $task_id) . "\n\n\n";
         $body .= tL('isdepfor', $lang) . ':' . "\n\n";
         $body .= 'FS#' . $depend_task['task_id'] . ' - ' . $depend_task['item_summary'] . "\n";
         $body .= CreateURL('details', $depend_task['task_id']);
         $online .= tL('taskwatching', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ Reversed dep - removed
     if ($type == NOTIFY_REV_DEP_REMOVED) {
         $depend_task = Flyspray::getTaskDetails($arg1);
         $body .= tL('taskwatching', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
         $body .= CreateURL('details', $task_id) . "\n\n\n";
         $body .= tL('isnodepfor', $lang) . ':' . "\n\n";
         $body .= 'FS#' . $depend_task['task_id'] . ' - ' . $depend_task['item_summary'] . "\n";
         $body .= CreateURL('details', $depend_task['task_id']);
         $online .= tL('taskwatching', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ User added to assignees list
     if ($type == NOTIFY_ADDED_ASSIGNEES) {
         $body .= tL('useraddedtoassignees', $lang) . "\n\n";
         $body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
         $body .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
         $body .= CreateURL('details', $task_id);
         $online .= tL('useraddedtoassignees', $lang) . ". ";
         $online .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . ". ";
         $online .= tL('userwho', $lang) . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . "). ";
     }
     // }}}
     // {{{ Anon-task has been opened
     if ($type == NOTIFY_ANON_TASK) {
         $body .= tL('thankyouforbug', $lang) . "\n\n";
         $body .= CreateURL('details', $task_id, null, array('task_token' => $arg1)) . "\n\n";
         $online .= tL('thankyouforbug') . "";
     }
     // }}}
     // {{{ Password change
     if ($type == NOTIFY_PW_CHANGE) {
         $body = tL('magicurlmessage', $lang) . " \n" . "{$arg1[0]}index.php?do=lostpw&magic_url={$arg1['1']}\n\n" . tL('messagefrom', $lang) . $arg1[0];
         $online = $body;
     }
     // } }}
     // {{{ New user
     if ($type == NOTIFY_NEW_USER) {
         $body = tL('newuserregistered', $lang) . " \n\n" . tL('username', $lang) . ': ' . $arg1[1] . "\n" . tL('realname', $lang) . ': ' . $arg1[2] . "\n";
         $online = $body;
         if ($arg1[6]) {
             $body .= tL('password', $lang) . ': ' . $arg1[5] . "\n";
         }
         $body .= tL('emailaddress', $lang) . ': ' . $arg1[3] . "\n";
         $body .= tL('jabberid', $lang) . ':' . $arg1[4] . "\n\n";
         $body .= tL('messagefrom', $lang) . $arg1[0];
     }
     // }}}
     // {{{ New user him/herself
     if ($type == NOTIFY_OWN_REGISTRATION) {
         $body = tL('youhaveregistered', $lang) . " \n\n" . tL('username', $lang) . ': ' . $arg1[1] . "\n" . tL('realname', $lang) . ': ' . $arg1[2] . "\n";
         $online = $body;
         if ($arg1[6]) {
             $body .= tL('password', $lang) . ': ' . $arg1[5] . "\n";
         }
         $body .= tL('emailaddress', $lang) . ': ' . $arg1[3] . "\n";
         $body .= tL('jabberid', $lang) . ':' . $arg1[4] . "\n\n";
         // Add something here to tell the user whether the registration must
         // first be accepted by Administrators or not. And if it had and was
         // rejected, the reason. Check first what happening when requests are
         // either denied or accepted.
         $body .= tL('messagefrom', $lang) . $arg1[0];
     }
     // }}}
     $body .= "\n\n" . tL('disclaimer', $lang);
     return array(Notifications::fixMsgData($subject), Notifications::fixMsgData($body), $online);
 }
Esempio n. 18
0
 function ShowLog()
 {
     $node_id = $this->node_id();
     $query_result = DBQueryFatal("select * from nodelog where node_id='{$node_id}'" . "order by reported");
     if (!mysql_num_rows($query_result)) {
         echo "<br>\n                      <center>\n                       There are no entries in the log for node {$node_id}.\n                      </center>\n";
         return 0;
     }
     echo "<br>\n                  <center>\n                    Log for node {$node_id}.\n                  </center><br>\n";
     echo "<table border=1 cellpadding=2 cellspacing=2 align='center'>\n";
     echo "<tr>\n                 <th>Delete?</th>\n                 <th>Date</th>\n                 <th>ID</th>\n                 <th>Type</th>\n                 <th>Reporter</th>\n                 <th>Entry</th>\n              </tr>\n";
     while ($row = mysql_fetch_array($query_result)) {
         $type = $row["type"];
         $log_id = $row["log_id"];
         $reporter = $row["reporting_uid"];
         $date = $row["reported"];
         $entry = $row["entry"];
         $url = CreateURL("deletenodelog", $this, "log_id", $log_id);
         echo "<tr>\n \t             <td align=center>\n                      <a href='{$url}'>\n                         <img alt='Delete Log Entry' src='redball.gif'>\n                      </a></td>\n                     <td>{$date}</td>\n                     <td>{$log_id}</td>\n                     <td>{$type}</td>\n                     <td>{$reporter}</td>\n                     <td>{$entry}</td>\n                  </tr>\n";
     }
     echo "</table>\n";
 }
Esempio n. 19
0
function tpl_list_heading($colname, $format = "<th%s>%s</th>")
{
    global $proj, $page;
    $imgbase = '<img src="%s" alt="%s" />';
    $class = $colname;
    $html = eL($colname);
    /*
        if ($colname == 'comments' || $colname == 'attachments') {
            $html = sprintf($imgbase, $page->get_image(substr($colname, 0, -1)), $html);
        }
    */
    if ($colname == 'attachments') {
        $html = '<i class="fa fa-paperclip fa-lg" title="' . $html . '"></i>';
    }
    if ($colname == 'comments') {
        $html = '<i class="fa fa-comments fa-lg" title="' . $html . '"></i>';
    }
    if ($colname == 'votes') {
        $html = '<i class="fa fa-star-o fa-lg" title="' . $html . '"></i>';
    }
    if (Get::val('order') == $colname) {
        $class .= ' orderby';
        $sort1 = Get::safe('sort', 'desc') == 'desc' ? 'asc' : 'desc';
        $sort2 = Get::safe('sort2', 'desc');
        $order2 = Get::safe('order2');
        $html .= '&nbsp;&nbsp;' . sprintf($imgbase, $page->get_image(Get::val('sort')), Get::safe('sort'));
    } else {
        $sort1 = 'desc';
        if (in_array($colname, array('project', 'tasktype', 'category', 'openedby', 'assignedto'))) {
            $sort1 = 'asc';
        }
        $sort2 = Get::safe('sort', 'desc');
        $order2 = Get::safe('order');
    }
    $new_order = array('order' => $colname, 'sort' => $sort1, 'order2' => $order2, 'sort2' => $sort2);
    # unneeded params from $_GET for the sort links
    $params = array_merge($_GET, $new_order);
    unset($params['do']);
    unset($params['project']);
    unset($params['switch']);
    $html = sprintf('<a title="%s" href="%s">%s</a>', eL('sortthiscolumn'), Filters::noXSS(CreateURL('tasklist', $proj->id, null, $params)), $html);
    return sprintf($format, ' class="' . $class . '"', $html);
}
Esempio n. 20
0
#
if (!$PUBSUPPORT) {
    USERERROR("Publication support not enabled.");
}
#
# Verify page arguments.
#
$optargs = OptionalPageArguments("submit", PAGEARG_STRING, "idx", PAGEARG_INTEGER, "formfields", PAGEARG_ARRAY);
#
# Standard Testbed Header
#
PAGEHEADER("Submit Publication");
$also_required = array();
$also_required['article'] = array('conf', 'month');
$typelist = array('article', 'phd thesis', 'masters thesis', 'bachelors thesis', 'techreport', 'unpublished', 'talk', 'software', 'service');
$submit_url = isset($idx) ? CreateURL("submitpub", 'idx', $idx) : CreateURL("submitpub");
#
# Make Month List
#
$monthlist = array();
$query_result = DBQueryFatal("select * from emulab_pubs_month_map order by display_order");
while ($r = mysql_fetch_array($query_result)) {
    $monthlist[$r['month']] = $r['month_name'];
}
#
# Make Project List
#
$projectlist = array();
if ($isadmin) {
    $query_result = DBQueryFatal("select pid from projects order by pid");
} else {
Esempio n. 21
0
     if (!$id) {
         $id = Req::val('user_id');
     }
     $theuser = new User($id, $proj);
     if ($theuser->isAnon()) {
         Flyspray::show_error(5, true, null, $_SESSION['prev_page']);
     }
     $page->assign('theuser', $theuser);
 case 'cat':
 case 'editgroup':
     // yeah, utterly stupid, is changed in 1.0 already
     if (Req::val('area') == 'editgroup') {
         $group_details = Flyspray::getGroupDetails(Req::num('id'));
         if (!$group_details || $group_details['project_id'] != $proj->id) {
             Flyspray::show_error(L('groupnotexist'));
             Flyspray::Redirect(CreateURL('pm', 'groups', $proj->id));
         }
         $page->uses('group_details');
     }
 case 'groups':
 case 'newuser':
 case 'newuserbulk':
 case 'editallusers':
     $page->assign('groups', Flyspray::ListGroups());
 case 'userrequest':
     $sql = $db->Query("SELECT  *\n                             FROM  {admin_requests}\n                            WHERE  request_type = 3 AND project_id = 0 AND resolved_by = 0\n                         ORDER BY  time_submitted ASC");
     $page->assign('pendings', $db->fetchAllArray($sql));
 case 'newproject':
 case 'os':
 case 'prefs':
 case 'resolution':
Esempio n. 22
0
                                 WHERE g.group_id = uig.group_id AND uig.user_id = ? AND project_id = ?', array($uid, $proj->id));
             if ($db->CountRows($sql)) {
                 $oldid = $db->FetchOne($sql);
                 $db->Query('UPDATE {users_in_groups} SET group_id = ? WHERE user_id = ? AND group_id = ?', array(Post::val('group_id'), $uid, $oldid));
             } else {
                 $db->Query('INSERT INTO {users_in_groups} (group_id, user_id) VALUES(?, ?)', array(Post::val('group_id'), $uid));
             }
         }
     }
     if (Post::val('delete_group') && Post::val('group_id') != '1') {
         $db->Query('DELETE FROM {groups} WHERE group_id = ?', Post::val('group_id'));
         if (Post::val('move_to')) {
             $db->Query('UPDATE {users_in_groups} SET group_id = ? WHERE group_id = ?', array(Post::val('move_to'), Post::val('group_id')));
         }
         $_SESSION['SUCCESS'] = L('groupupdated');
         Flyspray::Redirect(CreateURL($proj->id ? 'pm' : 'admin', 'groups', $proj->id));
     }
     // Allow all groups to update permissions except for global Admin
     if (Post::val('group_id') != '1') {
         $cols = array_merge($cols, array('manage_project', 'view_tasks', 'edit_own_comments', 'open_new_tasks', 'modify_own_tasks', 'modify_all_tasks', 'view_comments', 'add_comments', 'edit_comments', 'delete_comments', 'create_attachments', 'delete_attachments', 'show_as_assignees', 'view_history', 'close_own_tasks', 'close_other_tasks', 'edit_assignments', 'assign_to_self', 'assign_others_to_self', 'add_to_assignees', 'view_reports', 'add_votes', 'group_open'));
     }
     $args = array_map('Post_to0', $cols);
     $args[] = Post::val('group_id');
     $args[] = $proj->id;
     $db->Query("UPDATE  {groups}\n                       SET  " . join('=?,', $cols) . "=?\n                     WHERE  group_id = ? AND project_id = ?", $args);
     $_SESSION['SUCCESS'] = L('groupupdated');
     break;
     // ##################
     // updating a list
     // ##################
 // ##################
Esempio n. 23
0
    if (!$slicelist || !count($slicelist)) {
        continue;
    }
    # The form attributes:
    $table = array('#id' => $type, '#title' => $which, '#sortable' => 1, '#headings' => array("idx" => "ID", "hrn" => "HRN", "created" => "Created", "expires" => "Expires"));
    $rows = array();
    foreach ($slicelist as $slice) {
        $slice_idx = $slice->idx();
        $slice_hrn = $slice->hrn();
        $created = $slice->created();
        $expires = $slice->expires();
        $url = CreateURL("showslice", "showtype", $type, "slice_idx", $slice_idx);
        $href = "<a href='{$url}'>{$slice_hrn}</a>";
        $experiment = Experiment::LookupByUUID($slice->uuid());
        if ($experiment) {
            $eid = $experiment->eid();
            $expurl = CreateURL("showexp", $experiment);
            $href = "{$href} (<a href='{$expurl}'>{$eid}</a>)";
        }
        $rows[$slice_idx] = array("idx" => $slice_idx, "hrn" => $href, "created" => $created, "expires" => $expires);
    }
    list($html, $button) = TableRender($table, $rows);
    echo $html;
}
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>

Esempio n. 24
0
if ($retval) {
    CLEARBUSY();
} else {
    STOPBUSY();
}
#
# Fatal Error. Report to the user, even though there is not much he can
# do with the error. Also reports to tbops.
#
if ($retval < 0) {
    SUEXECERROR(SUEXEC_ACTION_CONTINUE);
}
# User error. Tell user and exit.
if ($retval) {
    SUEXECERROR(SUEXEC_ACTION_USERERROR);
    return;
}
if (!isset($referrer)) {
    $referrer = CreateURL("template_show", $template);
}
# Zap back to template page.
PAGEREPLACE($referrer);
#
# In case the above fails.
#
echo "<center><b>Done!</b></center>";
echo "<br><br>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
Esempio n. 25
0
}
if ($show == "vis") {
    $li_current = "li_vis";
    $init_show = Show("vis", 0, 0);
} elseif ($show == "nsfile") {
    $li_current = "li_nsfile";
    $init_show = Show("nsfile", 0, 0);
} elseif ($show == "graph") {
    $li_current = "li_graph";
    $init_show = Show("graph", 0, 0);
}
#
# The center area is a form that can show NS file, Template Graph, or Vis.
#
echo "<script type='text/javascript' src='template_sup.js'></script>\n";
echo "<script type='text/javascript' language='javascript'>\n        var li_current = '{$li_current}';\n        function Show(which) {\n\t    li = getObjbyName(li_current);\n            li.style.backgroundColor = '#DDE';\n            li.style.borderBottom = 'none';\n\n            li_current = 'li_' + which;\n\t    li = getObjbyName(li_current);\n            li.style.backgroundColor = 'white';\n            li.style.borderBottom = '1px solid white';\n\n            x_Show(which, 0, 0, Show_cb);\n            return false;\n        }\n        function Show_cb(html) {\n\t    visarea = getObjbyName('showexp_visarea');\n            if (visarea) {\n                visarea.innerHTML = html;\n            }\n        }\n        function Setup() {\n\t    li = getObjbyName(li_current);\n            li.style.backgroundColor = 'white';\n            li.style.borderBottom = '1px solid white';\n        }\n        function ShowVisInit() {\n            ADD_DHTML(\"myvisdiv\");\n        }\n        function ShowGraphInit() {\n \t    ADD_DHTML(\"mygraphdiv\");\n  \t    SetActiveTemplate(\"mygraphimg\", \"CurrentTemplate\", \n\t\t\t      \"Tarea{$vers}\");\n            tt_Init();\n        }\n        function VisChange(zoom, detail) {\n            x_Show('vis', zoom, detail, Show_cb);\n            return false;\n        }\n        function DeleteTemplate() {\n            confirm_flag = 0;\n            confirm_box  = getObjbyName('confirm_delete');\n\n\t    if (confirm_box) {\n                confirm_flag = ((confirm_box.checked == true) ? 1 : 0);\n            }\n            if (confirm_flag == 0) {\n                return false;\n            }\n\t    window.location.replace('{$this_url}" . "&action=deletetemplate&confirmed=yep');\n            return false;\n        }\n        function GraphChange(action) {\n            recursive_flag = 0;\n\n\t    recursive = getObjbyName('showexp_recursive');\n            if (recursive) {\n                recursive_flag = ((recursive.checked == true) ? 1 : 0);\n            }\n\n            x_GraphChange(action, recursive_flag, Show_cb);\n            return false;\n        }\n        function SaveNS() {\n            window.open('" . CreateURL("spitnsdata", $template) . "',\n                        'Save NS File','width=650,height=400,toolbar=no," . "resizeable=yes,scrollbars=yes,status=yes," . "menubar=yes');\n        }\n\n";
sajax_show_javascript();
echo "</script>\n";
echo "<script type='text/javascript' src='js/wz_dragdrop.js'></script>";
#
# This has to happen for dragdrop to work.
#
$bodyclosestring = "<script type='text/javascript'>SET_DHTML();</script>\n";
#
# This is the topbar
#
echo "<div width=\"100%\" align=center>\n";
echo "<ul id=\"topnavbar\">\n";
echo "<li>\n          <a href=\"#A\" " . "class=topnavbar onfocus=\"this.hideFocus=true;\" " . "id=\"li_vis\" onclick=\"Show('vis');\">" . "Topology</a></li>\n";
echo "<li>\n          <a href=\"#B\" " . "class=topnavbar onfocus=\"this.hideFocus=true;\" " . "id=\"li_nsfile\" onclick=\"Show('nsfile');\">" . "NS File</a></li>\n";
echo "<li>\n          <a href=\"#C\" " . "class=topnavbar onfocus=\"this.hideFocus=true;\" " . "id=\"li_graph\" onclick=\"Show('graph');\">" . "History</a></li>\n";
Esempio n. 26
0
  | Task Dependancy Graph                                  |
  | ~~~~~~~~~~~~~~~~~~~~~                                  |
  \********************************************************/
/**
 * XXX: This stuff looks incredible ugly, rewrite me for 1.0
 */
if (!defined('IN_FS')) {
    die('Do not access this file directly.');
}
if (!($task_details = Flyspray::GetTaskDetails(Req::num('task_id'))) || !$user->can_view_task($task_details)) {
    Flyspray::show_error(9);
}
$id = Req::num('task_id');
$page->assign('task_id', $id);
$prunemode = Req::num('prune', 0);
$selfurl = CreateURL('depends', $id);
$pmodes = array(L('none'), L('pruneclosedlinks'), L('pruneclosedtasks'));
foreach ($pmodes as $mode => $desc) {
    if ($mode == $prunemode) {
        $strlist[] = $desc;
    } else {
        $strlist[] = "<a href='" . htmlspecialchars($selfurl, ENT_QUOTES, 'utf-8') . ($mode != 0 ? "&amp;prune={$mode}" : "") . "'>{$desc}</a>\n";
    }
}
$page->uses('strlist');
$starttime = microtime();
$sql = 'SELECT t1.task_id AS id1, t1.item_summary AS sum1,
             t1.percent_complete AS pct1, t1.is_closed AS clsd1,
             lst1.status_name AS stat1, t1.task_severity AS sev1,
             t1.task_priority AS pri1,
             t1.closure_comment AS com1, u1c.real_name AS clsdby1,
Esempio n. 27
0
     }
     $result = $db->Query('SELECT  * FROM {dependencies}
                            WHERE  depend_id = ?', array(Post::val('depend_id')));
     $dep_info = $db->FetchRow($result);
     $db->Query('DELETE FROM {dependencies} WHERE depend_id = ? AND task_id = ?', array(Post::val('depend_id'), $task['task_id']));
     if ($db->AffectedRows()) {
         $notify->Create(NOTIFY_DEP_REMOVED, $dep_info['task_id'], $dep_info['dep_task_id'], null, NOTIFY_BOTH, $proj->prefs['lang_code']);
         $notify->Create(NOTIFY_REV_DEP_REMOVED, $dep_info['dep_task_id'], $dep_info['task_id'], null, NOTIFY_BOTH, $proj->prefs['lang_code']);
         Flyspray::logEvent($dep_info['task_id'], 24, $dep_info['dep_task_id']);
         Flyspray::logEvent($dep_info['dep_task_id'], 25, $dep_info['task_id']);
         $_SESSION['SUCCESS'] = L('depremovedmsg');
     } else {
         Flyspray::show_error(L('erroronform'));
     }
     //redirect the user back to the right task
     Flyspray::Redirect(CreateURL('details', Post::val('return_task_id')));
     break;
     // ##################
     // user requesting a password change
     // ##################
 // ##################
 // user requesting a password change
 // ##################
 case 'lostpw.sendmagic':
     // Check that the username exists
     $sql = $db->Query('SELECT * FROM {users} WHERE user_name = ?', array(Post::val('user_name')));
     // If the username doesn't exist, throw an error
     if (!$db->CountRows($sql)) {
         Flyspray::show_error(L('usernotexist'));
         break;
     }
Esempio n. 28
0
 /**
  * Generates a message depending on the $type and using $data
  * @param integer $type
  * @param array $data usually contains task_id => $id ... using by-ref to add headers
  * @return array array($subject, $body)
  * @access public
  */
 function generate_message($type, &$data)
 {
     global $db, $fs, $user;
     // Get the string of modification
     $notify_type_msg = array(0 => L('none'), NOTIFY_TASK_OPENED => L('taskopened'), NOTIFY_TASK_CHANGED => L('pm.taskchanged'), NOTIFY_TASK_CLOSED => L('taskclosed'), NOTIFY_TASK_REOPENED => L('pm.taskreopened'), NOTIFY_DEP_ADDED => L('pm.depadded'), NOTIFY_DEP_REMOVED => L('pm.depremoved'), NOTIFY_COMMENT_ADDED => L('commentadded'), NOTIFY_REL_ADDED => L('relatedadded'), NOTIFY_OWNERSHIP => L('ownershiptaken'), NOTIFY_PM_REQUEST => L('pmrequest'), NOTIFY_PM_DENY_REQUEST => L('pmrequestdenied'), NOTIFY_NEW_ASSIGNEE => L('newassignee'), NOTIFY_REV_DEP => L('revdepadded'), NOTIFY_REV_DEP_REMOVED => L('revdepaddedremoved'), NOTIFY_ADDED_ASSIGNEES => L('assigneeadded'));
     // Generate the nofication message
     if (isset($data['project']->prefs['notify_subject']) && !$data['project']->prefs['notify_subject']) {
         $data['project']->prefs['notify_subject'] = '[%p][#%t] %s';
     }
     if (!isset($data['project']->prefs['notify_subject']) || !isset($notify_type_msg[$type])) {
         $subject = L('notifyfromfs');
     } else {
         $replacement = array('%p' => $data['project']->prefs['project_title'], '%s' => $data['task']['item_summary'], '%t' => $data['task_id'], '%a' => $notify_type_msg[$type], '%u' => $user->infos['user_name'], '%n' => $type);
         $subject = strtr($data['project']->prefs['notify_subject'], $replacement);
         $data['headers'] = strtr($data['project']->prefs['mail_headers'], $replacement);
     }
     $subject = strtr($subject, "\n", ' ');
     /* -------------------------------
        | List of notification types: |
        | 1. Task opened              |
        | 2. Task details changed     |
        | 3. Task closed              |
        | 4. Task re-opened           |
        | 5. Dependency added         |
        | 6. Dependency removed       |
        | 7. Comment added            |
        | 9. Related task added       |
        |10. Taken ownership          |
        |11. Confirmation code        |
        |12. PM request               |
        |13. PM denied request        |
        |14. New assignee             |
        |15. Reversed dep             |
        |16. Reversed dep removed     |
        |17. Added to assignees list  |
        |18. Anon-task opened         |
        |19. Password change          |
        |20. New user                 |
        -------------------------------
        */
     $body = L('donotreply') . "\n\n";
     switch ($type) {
         case NOTIFY_TASK_OPENED:
             $body .= L('newtaskopened') . "\n\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
             $body .= L('attachedtoproject') . ' - ' . $data['project']->prefs['project_title'] . "\n";
             $body .= L('summary') . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('assignedto') . ' - ' . implode(', ', $data['task']['assigned_to_name']) . "\n";
             foreach ($data['project']->fields as $field) {
                 $body .= $field->prefs['field_name'] . ' - ' . $field->view($data['task'], array(), PLAINTEXT) . "\n";
             }
             $body .= L('details') . " - \n" . $data['task']['detailed_desc'] . "\n\n";
             if (isset($data['files'])) {
                 $body .= L('fileaddedtoo') . "\n\n";
                 $subject .= ' (' . L('attachmentadded') . ')';
             }
             $body .= L('moreinfo') . "\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n";
             break;
         case NOTIFY_TASK_CHANGED:
             $body .= L('taskchanged') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ': ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
             foreach ($data['changes'] as $change) {
                 if ($change[0] == 'assigned_to_name') {
                     $change[1] = implode(', ', $change[1]);
                     $change[2] = implode(', ', $change[2]);
                 }
                 if ($change[0] == 'detailed_desc') {
                     $body .= $change[3] . ":\n-------\n" . $change[2] . "\n-------\n";
                 } else {
                     $body .= $change[3] . ': ' . ($change[1] ? $change[1] : '[-]') . ' -> ' . ($change[2] ? $change[2] : '[-]') . "\n";
                 }
             }
             $body .= "\n" . L('moreinfo') . "\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n";
             break;
         case NOTIFY_TASK_CLOSED:
             $body .= L('notify.taskclosed') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
             $body .= L('reasonforclosing') . ' ' . $data['task']['resolution_name'] . "\n";
             if (!empty($data['task']['closure_comment'])) {
                 $body .= L('closurecomment') . ' ' . $data['task']['closure_comment'] . "\n\n";
             }
             $body .= L('moreinfo') . "\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n";
             break;
         case NOTIFY_TASK_REOPENED:
             $body .= L('notify.taskreopened') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
             $body .= L('moreinfo') . "\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n";
             break;
         case NOTIFY_DEP_ADDED:
             $depend_task = Flyspray::getTaskDetails($data['dep_task']);
             $body .= L('newdep') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n\n";
             $body .= L('newdepis') . ':' . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $depend_task['prefix_id'] . ' - ' . $depend_task['item_summary'] . "\n";
             $body .= CreateURL(array('details', 'task' . $depend_task['task_id'])) . "\n\n";
             break;
         case NOTIFY_DEP_REMOVED:
             $depend_task = Flyspray::getTaskDetails($data['dep_task']);
             $body .= L('notify.depremoved') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n\n";
             $body .= L('removeddepis') . ':' . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $depend_task['prefix_id'] . ' - ' . $depend_task['item_summary'] . "\n";
             $body .= CreateURL(array('details', 'task' . $depend_task['task_id'])) . "\n\n";
             break;
         case NOTIFY_COMMENT_ADDED:
             // Get the comment information
             $comment = $db->x->getRow('SELECT comment_text FROM {comments} WHERE comment_id = ?', null, $data['cid']);
             $body .= L('notify.commentadded') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
             $body .= "----------\n";
             $body .= $comment['comment_text'] . "\n";
             $body .= "----------\n\n";
             if (isset($data['files'])) {
                 $body .= L('fileaddedtoo') . "\n\n";
                 $subject .= ' (' . L('attachmentadded') . ')';
             }
             $body .= L('moreinfo') . "\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . '#comment' . $data['cid'] . "\n\n";
             break;
         case NOTIFY_REL_ADDED:
             $related_task = Flyspray::getTaskDetails($data['rel_task']);
             $body .= L('notify.relatedadded') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n\n";
             $body .= L('relatedis') . ':' . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $related_task['prefix_id'] . ' - ' . $related_task['item_summary'] . "\n";
             $body .= CreateURL(array('details', 'task' . $related_task['task_id'])) . "\n\n";
             break;
         case NOTIFY_OWNERSHIP:
             $body .= implode(', ', $data['task']['assigned_to_name']) . ' ' . L('takenownership') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n\n";
             $body .= L('moreinfo') . "\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n";
             break;
         case NOTIFY_CONFIRMATION:
             $body .= L('noticefrom') . " {$data['project']->prefs['project_title']}\n\n";
             $body .= L('addressused') . "\n\n";
             $body .= "{$data[0]}index.php?do=register&magic_url={$data[1]}\n\n";
             // In case that spaces in the username have been removed
             $body .= L('username') . ": {$data['2']} \n\n";
             break;
         case NOTIFY_PM_REQUEST:
             $body .= L('requiresaction') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
             $body .= L('moreinfo') . "\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n";
             break;
         case NOTIFY_PM_DENY_REQUEST:
             $body .= L('pmdeny') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
             $body .= L('denialreason') . ':' . "\n";
             $body .= $data['deny_reason'] . "\n\n";
             $body .= L('moreinfo') . "\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n";
             break;
         case NOTIFY_NEW_ASSIGNEE:
             $body .= L('assignedtoyou') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
             $body .= L('moreinfo') . "\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n";
             break;
         case NOTIFY_REV_DEP:
             $depend_task = Flyspray::getTaskDetails($data['dep_task']);
             $body .= L('taskwatching') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n\n";
             $body .= L('isdepfor') . ':' . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $depend_task['prefix_id'] . ' - ' . $depend_task['item_summary'] . "\n";
             $body .= CreateURL(array('details', 'task' . $depend_task['task_id'])) . "\n\n";
             break;
         case NOTIFY_REV_DEP_REMOVED:
             $depend_task = Flyspray::getTaskDetails($data['dep_task']);
             $body .= L('taskwatching') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n\n";
             $body .= L('isnodepfor') . ':' . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $depend_task['prefix_id'] . ' - ' . $depend_task['item_summary'] . "\n";
             $body .= CreateURL(array('details', 'task' . $depend_task['task_id'])) . "\n\n";
             break;
         case NOTIFY_ADDED_ASSIGNEES:
             $body .= L('useraddedtoassignees') . "\n\n";
             $body .= $data['task']['project_prefix'] . '#' . $data['task']['prefix_id'] . ' - ' . $data['task']['item_summary'] . "\n";
             $body .= L('userwho') . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id'])) . "\n\n\n";
             break;
         case NOTIFY_ANON_TASK:
             $body .= L('thankyouforbug') . "\n\n";
             $body .= CreateURL(array('details', 'task' . $data['task_id']), array('task_token' => $data['token'])) . "\n\n";
             break;
         case NOTIFY_PW_CHANGE:
             $body = L('messagefrom') . $data[0] . "\n\n";
             $body .= L('magicurlmessage') . " \n";
             $body .= "{$data[0]}index.php?do=lostpw&magic_url={$data['1']}\n";
             break;
         case NOTIFY_NEW_USER:
             $body = L('messagefrom') . $data[0] . "\n\n";
             $body .= L('newuserregistered') . " \n\n";
             $body .= L('username') . ': ' . $data[1] . "\n";
             $body .= L('realname') . ': ' . $data[2] . "\n";
             if ($data[6]) {
                 $body .= L('password') . ': ' . $data[5] . "\n";
             }
             $body .= L('emailaddress') . ': ' . $data[3] . "\n";
             if ($data[4]) {
                 $body .= L('jabberid') . ':' . $data[4] . "\n\n";
             }
             break;
         case NOTIFY_REMINDER:
         case NOTIFY_DIGEST:
             $body = $data['message'] . "\n\n";
             break;
     }
     $body .= L('disclaimer');
     return array($subject, $body);
 }
Esempio n. 29
0
    $error = "UID: Must supply a new UID";
} elseif (!TBvalid_uid($new_uid)) {
    $error = "UID: " . TBFieldErrorString();
} elseif (User::Lookup($new_uid) || posix_getpwnam($new_uid)) {
    $error = "UID: Already in use. Pick another";
}
if ($error) {
    SPITFORM($target_user, $new_uid, $error);
    return;
}
#
# Standard Testbed Header.
#
PAGEHEADER("Change login UID for user");
# Okay, call out to backend to change.
STARTBUSY("Changing UID");
#
# Run the backend script.
#
SUEXEC($uid, $TBADMINGROUP, "webchangeuid {$target_idx} {$new_uid}", SUEXEC_ACTION_USERERROR);
# Stop the busy indicator and zap to user page.
STOPBUSY();
PAGEREPLACE(CreateURL("showuser", $target_user));
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>


Esempio n. 30
0
 function action_editgroup()
 {
     global $fs, $db, $proj, $user;
     if (!Post::val('group_name')) {
         return array(ERROR_RECOVER, L('groupanddesc'));
     }
     $cols = array('group_name', 'group_desc');
     // Add a user to a group
     $users = Backend::UserIdsFromUserNameList(Post::val('uid'));
     if (count($users)) {
         $users = array_map(array('Flyspray', 'UserNameOrId'), $users);
         Backend::add_user_to_group($users, Post::val('group_id'), $proj->id);
     }
     if (Post::val('delete_group') && Post::val('group_id') != '1') {
         $db->x->execParam('DELETE FROM {groups} WHERE group_id = ?', Post::val('group_id'));
         if (Post::val('move_to')) {
             $db->x->execParam('UPDATE {users_in_groups} SET group_id = ? WHERE group_id = ?', array(Post::val('move_to'), Post::val('group_id')));
         }
         return array(SUBMIT_OK, L('groupupdated'), CreateURL(array($proj->id ? 'pm' : 'admin', 'proj' . $proj->id, 'groups')));
     }
     // Allow all groups to update permissions except for global Admin
     if (Post::val('group_id') != '1') {
         $cols[] = 'group_open';
         $cols = array_merge($fs->perms, $cols);
     }
     $args = array_map('Post_to0', $cols);
     $args[] = Post::val('group_id');
     $args[] = $proj->id;
     $db->x->execParam('UPDATE  {groups}
                    SET  ' . join('=?,', $cols) . '=?
                  WHERE  group_id = ? AND project_id = ?', $args);
     return array(SUBMIT_OK, L('groupupdated'));
 }