Date index for May 2003


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Redefine a function in an built-in module.



Howdy,

I am trying to modify some functions in the project class in the project
module's (class.project.inc) file by extending them with an add-on module I
called projectstatus, though the module appears to load fine, it does not
override the project() or initial_values() functions in the project class. I
would prefer to use an override to replacing the whole module or recoding
the base module because I want to try to avoid problems when upgrading to
newer versions and it seemed more extensible for small changes. With this
method I should only need to modify the exact functions I need in a given
class and I can keep my changes and the existing base code separated. Does
anyone have any suggestions as to what I am doing wrong or a better way to
do this? Just to clarify when I put the modified code from the two function
I want to change into the actual module and test, it does work so I know
that the related status module (statustypes.statustypes) that produces "the
statustypeid" data I added do function correctly.

I first tried "extends project" but that failed with an error "Cannot
inherit undefined class project" so I tried (extends mod_project) instead
and it did not break, though it did not work either. The dbg messages do
state that the module has loaded successfully.

class mod_projectstatus extends mod_project
  {
  function project()
    {
      global $ATK_VARS, $g_sessionManager;

      $this->atkNode("project",NF_EDITAFTERADD);

      $this->add(new atkAttribute("id",AF_AUTOKEY));
      
      $this->add(new
atkAttribute("name",AF_UNIQUE|AF_OBLIGATORY|AF_SEARCHABLE, 50));
      $this->add(new atkAttribute("abbreviation",
AF_SEARCHABLE|AF_HIDE_LIST, 10));

      $this->add(new
atkManyToOneRelation("coordinator","employee.employee",AF_SEARCHABLE|AF_HIDE
_ADD|AF_RELATION_AUTOLINK));
      $this->add(new
atkTextAttribute("description",AF_HIDE_LIST|AF_HIDE_ADD));
      $this->add(new
atkNumberAttribute("fixed_price",AF_HIDE_LIST|AF_HIDE_ADD, 13, 5));      

      // If we are in project administration mode, we show all projects.
Otherwise, we only
      // show active projects.
      if ($ATK_VARS["atknodetype"]=="project.project"&&
in_array($ATK_VARS["atkaction"],array("admin","add","update","edit","search"
, "view")))
      {
        $this->add(new
atkListAttribute("status",array("active","nonactive","archived"),array(),AF_
HIDE_ADD|AF_SEARCHABLE, 15));
      }
      else
      {
        $this->add(new
atkListAttribute("status",array("active","nonactive","archived"),array(),AF_
HIDE, 15));
        $this->addFilter("project.status","active");
      }

      $this->add(new
atkOneToManyRelation("contacts","project.project_personcontact",
"projectid", AF_HIDE_LIST));
      $this->add(new
atkOneToManyRelation("employees","project.project_personemployee",
"projectid", AF_HIDE_LIST), "planning");
      
      $this->add(new atkDateAttribute("startdate","F d Y","d F
Y",0,0,AF_HIDE_ADD), "planning");      
      $this->add(new atkDateAttribute("enddate","F d Y","d F
Y",0,0,AF_HIDE_ADD|AF_HIDE_LIST), "planning");      

      $this->add(new
atkOneToManyRelation("phase","project.phase","projectid",AF_HIDE_LIST|AF_CAS
CADE_DELETE), "planning");

      $this->add(new
dependencyAttribute("dependencies",AF_HIDE_ADD|AF_HIDE_LIST|AF_BLANKLABEL|AF
_HIDE_VIEW), "planning");
      $this->add(new
projecttemplateAttribute("template","project.tpl_project",
AF_HIDE_LIST|AF_HIDE_EDIT|AF_HIDE_SEARCH|AF_HIDE_VIEW));
      
      $this->add(new atkOneToManyRelation("todos", "todo.todo", "projectid",
AF_HIDE_LIST|AF_HIDE_SEARCH), "todos");
 
 // This is the only new line in this function
  $this->add(new atkManyToOneRelation("statustypeid",
"statustypes.statustypes", AF_HIDE_ADD|AF_SEARCHABLE|AF_RELATION_AUTOLINK));
  //
      $timeline = &new dataGraphAttribute("timeline", "timeline",
array("projectid"=>"[id]", "resolution"=>"auto"), "line",
AF_HIDE_ADD|AF_HIDE_LIST|AF_HIDE_EDIT);
      $timeline->addDynamicParam("resolution", array("day", "week", "month",
"auto"));
      $this->add($timeline, "stats");
      $this->add(new dataGraphAttribute("phasetimedistribution",
"phasetime", array("projectid"=>"[id]"), "auto",
AF_HIDE_ADD|AF_HIDE_LIST|AF_HIDE_EDIT), "stats");
      $this->add(new dataGraphAttribute("emptimedistribution", "emptime",
array("projectid"=>"[id]"), "auto", AF_HIDE_ADD|AF_HIDE_LIST|AF_HIDE_EDIT),
"stats");
      $this->add(new dataGraphAttribute("activitytimedistribution",
"activitytime", array("projectid"=>"[id]"), "auto",
AF_HIDE_ADD|AF_HIDE_LIST|AF_HIDE_EDIT), "stats");      

      $this->setTable("project","project");

      $this->setOrder("name");
      $this->setIndex("name");
    
      atkdebug("project::project()");
    }
  
  // This function's array has statustypeid added to it.	
  function initial_values()
    {
		return array(
			"startdate"=>array("year"=>date(Y),
			"month"=>date(m),
			"day"=>date(d)),
			"enddate"=>array("year"=>(date(Y)+1),
			"month"=>date(m),
			"day"=>date(d)),
			"status"=>"active",
			"statustypeid"=>"N",
			
		);
    }
  

Thanks,
Robert

http://www.achievo.org/lists achievo.org - ©1999-2002 ibuildings.nl BV