function get_user_links()
 {
     $extra = unserialize(PA::$network_info->extra);
     if (Network::is_mother_network(PA::$network_info->network_id)) {
         $uid = SUPER_USER_ID;
     } else {
         $uid = Network::get_network_owner(PA::$network_info->network_id);
     }
     $condition = array('user_id' => $uid, 'is_active' => 1);
     $limit = 5;
     // 5 lists to be display on home page
     $Links = new NetworkLinks();
     $category_list = $Links->load_category($condition, $limit);
     if (!empty($category_list)) {
         for ($counter = 0; $counter < count($category_list); $counter++) {
             $links_data_array[$counter]['category_id'] = $category_list[$counter]->category_id;
             $links_data_array[$counter]['category_name'] = $category_list[$counter]->category_name;
             $Links->user_id = $uid;
             $condition = array('category_id' => $category_list[$counter]->category_id, 'is_active' => 1);
             $limit = 5;
             // 5 links to be display on home page
             $links_array = $Links->load_link($condition, $limit);
             $links_data_array[$counter]['links'] = $links_array;
         }
         return $links_data_array;
     }
 }
 public static function add_default_links($user_id)
 {
     require_once "api/CNNetworkLinks/CNNetworkLinks.php";
     require_once "api/CNLinks/CNLinks.php";
     $network_links = new NetworkLinks();
     $network_owner_id = PA::$network_info->type == MOTHER_NETWORK_TYPE ? SUPER_USER_ID : Network::get_network_owner(PA::$network_info->network_id);
     $condition = array('user_id' => $network_owner_id, 'is_active' => 1);
     $link_categories = $network_links->load_category($condition);
     // load category as set by network operator
     $Links = new Links();
     $error_array = array();
     //providing default links to the user, as set by network operator
     for ($counter = 0; $counter < count($link_categories); $counter++) {
         $param_array = array('category_name' => $link_categories[$counter]->category_name, 'user_id' => $user_id, 'created' => time(), 'changed' => time(), 'is_active' => ACTIVE);
         $Links->set_params($param_array);
         $category_id = $Links->save_category();
         // save network operator category as user's link category
         $network_lists = new NetworkLinks();
         $network_lists->user_id = $network_info->owner_id;
         $condition = array('category_id' => $link_categories[$counter]->category_id, 'is_active' => ACTIVE);
         $list_array = $network_lists->load_link($condition);
         // load list for network operator's category
         for ($i = 0; $i < count($list_array); $i++) {
             $param_array = array('title' => $list_array[$i]->title, 'url' => $list_array[$i]->url, 'category_id' => $category_id, 'created' => time(), 'changed' => time(), 'is_active' => ACTIVE);
             $Links->set_params($param_array);
             $Links->save_link();
             // save network operator list as user's list
         }
     }
 }