How to add sec_apps.description value

I know that this works - and saves me from having to manually input application descriptions - but the code has to be put into each application and executes every time the application is used (which I think is unnecessary activity - I only need it once)

sc_exec_sql(“UPDATE sec_apps SET description = '”. $this->Ini->nm_nome_apl ."’ WHERE app_name = ‘". $this->Ini->nm_cod_apl ."’ ");

I’m wondering if there is a way to do this using the sync_apps application so that it is run once when the app is added to sec_apps. The idea is to have something easier for the end user to understand (ie. instead of seeing “app_grid_sec_users / Security Application” the user sees “app_grid_sec_users / List Users” or something like that.

Or is there some other way to achieve what I am trying to do?

I should add …I have also tried using friendly url (and maybe I should revisit that) but in the past I’ve found friendly url to not be so friendly.

Well … alternate solution … not sure yet where I am going to put it or how it’s going to work. Dependent on the structure of app_name (dependent on naming convention). Could get a lot more fancy with this.

My naming convention is:
module_apptype_db_table_action_more

Example:
app_form_sec_users_add (becomes “Manage Users Add”)
app_form_sec_users_edit (becomes “Manage Users Edit”)
app_grid_sec_users (becomes “List Users”)
app_control_sec_users_force_password (becomes “Process Users force password”)

I am also using Friendly URL - but only for those applications displayed outside the menu system (still on the fence about it - although I have found that friendly url is working better in the latest version than it has in the past (thanks guys!) Where I am using a friendly URL (which has no app_type) I’m just using the friendly url as the description too.

//Parse app_name to create the value of sec_apps.description

sc_select(rs, “SELECT app_name FROM sec_apps”);

//Array1 = Applications in sec_apps
$arr_apps_db = array();
while(!$rs->EOF)
{
$arr_apps_db[] = $rs->fields[0];
$rs->MoveNext();
}
$rs->Close();

//print_r($arr_apps_db); //this shows the values in array format

//process that array
foreach($arr_apps_db as $k => $app_name) {
//echo “$app_name <br>” ; // this shows a list of appnames

//array2 - words in app_name
$word_count = str_word_count($app_name); //how many words are in app_name
    //echo str_word_count($app_name); //number - how many words are in the app_name

$word = (str_word_count($app_name, 1)) ; //returns the words in app_name
    //print_r(str_word_count($app_name, 1)); //this shows the appname further into words in an array

//Try to get app_type
if ($word_count &gt;= '2') {
    $app_type =  $word[1] ;

        switch ($app_type) {

            case 'form':          
                 $action = 'Manage' ; 
             break;

            case 'grid':         
                $action = 'List' ; 
            break;

            case 'calendar':                
                $action = 'Schedule' ; 
            break;

            case 'control':            
                $action = 'Process' ; 
            break;

            case 'pdfreport':           
                $action = 'Report' ; 
            break;

            case 'blank':              
                $action = 'Compute' ; 
            break;        

            case 'search':              
                $action = 'Filter' ; 
            break;        

            case 'dashboard':              
                $action = 'Dashboard' ; 
            break;                            

            default:          //others
                $action = $app_type ; 
            break;
    } //end case        

        } else {
        $app_type = '' ; 
        $desc = $word[0] ;
    } //end app_type


//Create Description
switch ($word_count) {
        case '3' :
            $desc = $action . ' ' . $word[2] ;
        break;

        case '4' :
            $desc = $action . ' ' . $word[3] ;
        break;

        case '5' :
            $desc = $action . ' ' . $word[3] . ' ' . $word[4] ;
        break;

        default:          //others
             $desc = $word[0] ; ; 
        break;

        } // end switch of word count

//Update the description field in sec_apps
$sql="UPDATE sec_apps SET description = '$desc' WHERE app_name = '$app_name' " ;
sc_exec_sql($sql) ;

}