Main Page | Directories | File List | File Members

cookbook.php File Reference

Go to the source code of this file.

Functions

 cookbook_audience_possiblevalues ()
 cookbook_context_project_possiblevalues ()
 cookbook_context_site_possiblevalues ()
 cookbook_context_project_impossiblevalues ()
 cookbook_context_possiblevalues ()
 cookbook_subcontext_possiblevalues ()
 cookbook_build_form ($which="audience")
 cookbook_describe ($which="audience")
 cookbook_print_form ()
 cookbook_handle_update ($item_id, $group_id)


Function Documentation

cookbook_audience_possiblevalues  ) 
 

This will return an array of possible values, like anonymous, logged-in...

Definition at line 27 of file cookbook.php.

Referenced by cookbook_build_form(), cookbook_handle_update(), and show_item_list_sober().

00027                                             {
00028   return array("anonymous" => _("Anonymous Users"),
00029                "loggedin" => _("Logged-in Users"),
00030                "members" => _("All Project Members"),
00031                "technicians" => _("Project Members who are technicians"),
00032                "managers" => _("Project Members who are managers"));
00033 }

cookbook_build_form which = "audience"  ) 
 

Return a bit of form that should be used inside the item post/edit forms

Definition at line 143 of file cookbook.php.

References $content, $group_id, $item_id, $label, $result, cookbook_audience_possiblevalues(), cookbook_context_possiblevalues(), cookbook_subcontext_possiblevalues(), db_query(), db_result, and sane_post().

Referenced by cookbook_print_form().

00144 {
00145   global $item_id, $group_id, $previous_form_bad_fields;
00146 
00147   $possiblevalues = array();
00148   if ($which == "audience")
00149     {
00150       $possiblevalues = cookbook_audience_possiblevalues();
00151     }
00152   if ($which == "context")
00153     {
00154       $possiblevalues = cookbook_context_possiblevalues();
00155     }
00156   if ($which == "subcontext")
00157     {
00158       $possiblevalues = cookbook_subcontext_possiblevalues();
00159     }
00160 
00161   # If there is an item id available, it means we are editing an item
00162   # and we want to previous results from the database
00163   if ($item_id)
00164     {
00165       $result = db_query("SELECT * FROM cookbook_context2recipe WHERE recipe_id='$item_id' AND group_id='$group_id' LIMIT 1");
00166     }
00167 
00168   unset($content);
00169   while(list($field,$label) = each($possiblevalues))
00170     {
00171       unset($checked);
00172 
00173       # Take into account database content
00174       if ($item_id && db_result($result, 0, $which."_".$field) == 1)
00175         { $checked = ' checked="checked"'; }
00176 
00177       # Ultimately take into account what was posted, in the case the form
00178       # was reprovided to the user because he forgot mandatory fields
00179       if ($previous_form_bad_fields)
00180         {
00181           if (sane_post("recipe_".$which."_".$field) == true)
00182             { $checked = ' checked="checked"'; }
00183           else
00184             { unset($checked); }
00185         }
00186 
00187       if (!defined('PRINTER'))
00188         {
00189           # Normal output
00190           $content .= '<input type="checkbox" name="recipe_'.$which.'_'.$field.'"'.$checked.' />'.$label.'<br />';
00191         }
00192       else
00193         {
00194           # Printer mode output, show only selected entries
00195           if ($checked)
00196             { $content .= $label.'<br />'; }
00197 
00198         }
00199     }
00200 
00201   # remove the extra line break
00202   $content = rtrim($content, '<br />');
00203 
00204   return $content;
00205 }

cookbook_context_possiblevalues  ) 
 

Find out the really possible value in the current context

Definition at line 97 of file cookbook.php.

References $group_id, $sys_group_id, cookbook_context_project_impossiblevalues(), cookbook_context_project_possiblevalues(), cookbook_context_site_possiblevalues(), and group_id.

Referenced by cookbook_build_form(), cookbook_handle_update(), and show_item_list_sober().

00097                                            {
00098   global $group_id, $sys_group_id;
00099 
00100   # All projec-wide possible values, ordered in a clean way
00101   $array_possible = cookbook_context_project_possiblevalues();
00102   
00103   if ($group_id != $sys_group_id)
00104     {
00105       # If we are in a normal group, remove impossible values.
00106       # For instance, remove all unused features
00107       $array_impossible = cookbook_context_project_impossiblevalues();
00108 
00109       while(list($feature,) = each($array_impossible))
00110         {
00111           unset($array_possible[$feature]);
00112         }
00113     }
00114   else
00115     {
00116       # For the site admin group, present all possible values
00117       $array_possible = array_merge(cookbook_context_site_possiblevalues(),
00118                                     $array_possible);
00119     }
00120 
00121 
00122   reset($array_possible);
00123   return $array_possible;
00124 }

cookbook_context_project_impossiblevalues  ) 
 

Definition at line 63 of file cookbook.php.

References $group_id, $project, cookbook_context_project_possiblevalues(), cookbook_context_site_possiblevalues(), and group_id.

Referenced by cookbook_context_possiblevalues(), and show_item_list_sober().

00063                                                      {
00064   global $group_id;
00065   
00066   # Site values are per definition impossible for a normal project
00067   $array_impossible = cookbook_context_site_possiblevalues();
00068 
00069   # Impossible values are values of unactivated features for the project
00070   $array_possible = cookbook_context_project_possiblevalues();
00071   $project = project_get_object($group_id);
00072   while(list($feature,) = each($array_possible))
00073     {
00074       # Cookbook cannot be deactivated
00075       if ($feature == 'cookbook')
00076         { continue; }
00077 
00078       # Project main pages cannot be deactivated
00079       if ($feature == 'project')
00080         { continue; }
00081 
00082       if (!$project->Uses($feature))
00083         {
00084           $array_impossible[$feature] = 1;
00085         }
00086     }
00087   
00088 
00089   return $array_impossible;
00090 }

cookbook_context_project_possiblevalues  ) 
 

Same for context Guess all the possible values in theory on the site for a project

Definition at line 39 of file cookbook.php.

Referenced by cookbook_context_possiblevalues(), and cookbook_context_project_impossiblevalues().

00039                                                    {
00040   return array("project" => _("Project Main Pages"),
00041                "homepage" => _("Project Homepage"),
00042                "cookbook" => _("Cookbook"),
00043                "download" => _("Download Area"),
00044                "support" => _("Support Tracker"),
00045                "bugs" => _("Bugs Tracker"),
00046                "task" => _("Task Manager"),
00047                "patch" => _("Patch Tracker"),
00048                "news" => _("News Manager"),
00049                "mail" => _("Mailing Lists"),
00050                "cvs" => _("Source Code Manager: CVS Repositories"),
00051                "arch" => _("Source Code Manager: GNU Arch Repositories"),
00052                "svn" => _("Source Code Manager: Subversion Repositories"));
00053 }

cookbook_context_site_possiblevalues  ) 
 

Definition at line 56 of file cookbook.php.

Referenced by cookbook_context_possiblevalues(), and cookbook_context_project_impossiblevalues().

00056                                                 {
00057   return array("my" => _("My (User Personal Area)"),
00058                "stats" => _("Site Statistics"),
00059                "siteadmin" => _("Site Administration"));
00060 }

cookbook_describe which = "audience"  ) 
 

Describe a field type

Definition at line 210 of file cookbook.php.

00211 {
00212   unset($text);
00213   if ($which == "audience")
00214     {
00215       $text = _("Defines which users will actually get such recipe showing up as related recipe while browsing the site. It will not prevent other users to see the recipe in the big list inside the Cookbook.");
00216     }
00217   if ($which == "context")
00218     {
00219       $text = _("Defines on which pages such recipe will show up as related recipe. It will not prevent other users to see the recipe in the big list inside the Cookbook.");
00220     }
00221   if ($which == "subcontext")
00222     {
00223       $text = _("Defines while doing which actions such recipe will show up as related recipe. It will not prevent other users to see the recipe in the big list inside the Cookbook.");
00224     }
00225 
00226   return $text;
00227 }

cookbook_handle_update item_id,
group_id
 

Handle update or create of cookbook specific things in items: the related items links

Definition at line 289 of file cookbook.php.

References $result, $sql, $value, cookbook_audience_possiblevalues(), cookbook_context_possiblevalues(), cookbook_subcontext_possiblevalues(), db_affected_rows(), db_numrows(), db_query(), sane_post(), and trackers_data_add_history().

Referenced by trackers_data_handle_update().

00290 {
00291   global $change_exists;
00292 
00293   ## Pass thru all the available/configurable fields
00294   unset($cookbook_upd_list);
00295 
00296   # Find out the targetted audience
00297   $audience_cases = array();
00298   $possiblevalues = cookbook_audience_possiblevalues();
00299   while(list($field,) = each($possiblevalues))
00300     {
00301       $value = 0;
00302       if (sane_post("recipe_audience_".$field))
00303         { $value = 1; }
00304       $cookbook_upd_list .= "audience_$field='$value',";
00305     }
00306 
00307   # Find out the targetted context (feature)
00308   $context_cases = array();
00309   $possiblevalues = cookbook_context_possiblevalues();
00310   while(list($field,) = each($possiblevalues))
00311     {
00312       $value = 0;
00313       if (sane_post("recipe_context_".$field))
00314         { $value = 1; }
00315       $cookbook_upd_list .= "context_$field='$value',";
00316     }
00317 
00318 
00319   # Find out the targetted subcontext (action)
00320   $subcontext_cases = array();
00321   $possiblevalues = cookbook_subcontext_possiblevalues();
00322   while(list($field,) = each($possiblevalues))
00323     {
00324       $value = 0;
00325       if (sane_post("recipe_subcontext_".$field))
00326         { $value = 1; }
00327       $cookbook_upd_list .= "subcontext_$field='$value',";
00328     }
00329 
00330   # Create from scratch a row, to be able to do a simple update afterwards
00331   if (!db_numrows(db_query("SELECT context_id FROM cookbook_context2recipe WHERE recipe_id='$item_id' AND group_id='$group_id' LIMIT 1")))
00332     {
00333       db_query("INSERT INTO cookbook_context2recipe (recipe_id,group_id) VALUES ('$item_id','$group_id')");
00334     }
00335 
00336   # Now do an update
00337   $cookbook_upd_list = rtrim($cookbook_upd_list, ",");
00338   $sql="UPDATE cookbook_context2recipe SET $cookbook_upd_list ".
00339     " WHERE recipe_id='$item_id' AND group_id='$group_id'";
00340   $result=db_affected_rows(db_query($sql));
00341 
00342   # If there was affected rows, it means we did an update
00343   # (ignoring the very unusual case where the SQL would fail)
00344   if ($result)
00345     {
00346       $change_exists = 1;
00347       fb(_("Audience/Feature/Action updated"));
00348       trackers_data_add_history("Audience/Feature/Action",
00349                                 '',
00350                                 '',
00351                                 $item_id);
00352 
00353     }
00354 }

cookbook_print_form  ) 
 

Use cookbook_build_form to return a nice form that can be included in mod and post forms.

Definition at line 233 of file cookbook.php.

References $fields_per_line, $i, $j, cookbook_build_form(), and print.

00234 {
00235   global $j, $fields_per_line, $i, $row_class, $field_class;
00236 
00237   # Field getting one line for itself
00238   #  |            Audience                     |
00239 
00240   # prepare next background color change
00241   $j++;
00242 
00243   print "\n<tr".$row_class.">".
00244     '<td valign="middle" '.$field_class.' width="15%"><span class="preinput"><span class="help" title="'.cookbook_describe("audience").'">'._("Audience:").'</span></span></td>'.
00245     '<td valign="middle" '.$field_class.' colspan="'.(2*$fields_per_line-1).'" width="75%">'.
00246     cookbook_build_form("audience").'</td>'.
00247     "\n</tr>";
00248 
00249   $i = 0;
00250 
00251   # Field getting half of a line for itself
00252   #  | context, kind of pages | context, kind of action
00253   #       (CONTEXT)                   (SUBCONTEXT)
00254 
00255   # Change background color
00256   unset($row_class);
00257   if ($j % 2)
00258     {
00259       $row_class = ' class="'.utils_altrow($j+1).'"';
00260     }
00261 
00262   # prepare next background color change
00263   $j++;
00264 
00265   print ($i % $fields_per_line ? '':"\n<tr".$row_class.">");
00266   print '<td valign="middle"'.$field_class.' width="15%"><span class="preinput"><span class="help" title="'.cookbook_describe("context").'">'._("Feature:").'</span></span></td><td valign="middle"'.$field_class.' width="35%">'.cookbook_build_form("context").'</td>';
00267   $i++;
00268   print ($i % $fields_per_line ? '':"\n</tr>");
00269   print ($i % $fields_per_line ? '':"\n<tr".$row_class.">");
00270   print '<td valign="middle"'.$field_class.' width="15%"><span class="preinput"><span class="help" title="'.cookbook_describe("subcontext").'">'._("Action:").'</span></span></td><td valign="middle"'.$field_class.' width="35%">'.cookbook_build_form("subcontext").'</td>';
00271   $i++;
00272   print ($i % $fields_per_line ? '':"\n</tr>");
00273 
00274   $i = 0;
00275 
00276   # Change background color
00277   unset($row_class);
00278   if ($j % 2)
00279     {
00280       $row_class = ' class="'.utils_altrow($j+1).'"';
00281     }
00282 
00283 }

cookbook_subcontext_possiblevalues  ) 
 

Same for subcontext

Definition at line 129 of file cookbook.php.

Referenced by cookbook_build_form(), and cookbook_handle_update().

00129                                               {
00130   return array("browsing" => _("Browsing"),
00131                "postitem" => _("Posting New Items"),
00132                "edititem" => _("Editing Items, Posting Comments"),
00133                "search" => _("Doing Searches"),
00134                "configure" => _("Configuring Features"));
00135 }


Generated on Sun Feb 26 13:23:04 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4