function get_link_categories()
 {
     $Links = new NetworkLinks();
     $condition = array('is_active' => 1);
     $link_categories_array = $Links->load_category($condition);
     return $link_categories_array;
 }
 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;
     }
 }
 function get_link_categories()
 {
     $Links = new NetworkLinks();
     $condition = array('user_id' => $_SESSION['user']['id'], 'is_active' => 1);
     $link_categories_array = $Links->load_category($condition);
     return $link_categories_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
         }
     }
 }
                $link_ids[] = $temp_array[1];
            }
            $Links = new NetworkLinks();
            $param_array = array('user_id' => $_SESSION['user']['id'], 'changed' => time(), 'link_id' => $link_ids);
            $Links->set_params($param_array);
            try {
                $Links->delete_link();
                $set_net = TRUE;
                $error_array[] = "Links deleted successfully";
            } catch (PAException $e) {
                $error_array[] = $e->message;
            }
        } else {
            if (@$_POST['form_action'] == "delete_category" && !empty($_POST['link_categories'])) {
                $param_array = array('user_id' => $_SESSION['user']['id'], 'category_id' => $_POST['category_id'], 'changed' => time());
                $Links = new NetworkLinks();
                $Links->set_params($param_array);
                try {
                    $Links->delete_category();
                    $set_net = TRUE;
                    $error_array[] = "Category deleted successfully";
                } catch (PAException $e) {
                    $error_array[] = $e->message;
                }
            }
        }
    }
}
function setup_module($column, $moduleName, $obj)
{
    global $uid, $configure_permission;
 * http://peopleaggregator.org
 * For questions, help, comments, discussion, etc. please visit 
 * http://wiki.peopleaggregator.org/index.php
 * TODO:      Need to call here link module to generate inner html
 */
$login_required = TRUE;
require_once dirname(__FILE__) . "/includes/page.php";
require_once "api/NetworkLinks/NetworkLinks.php";
if (!empty($_GET['category_id'])) {
    $condition = array('category_id' => $_GET['category_id'], 'is_active' => 1);
    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);
    }
    $params_array = array('user_id' => $uid);
    $Links = new NetworkLinks();
    $Links->set_params($params_array);
    $result_array = $Links->network_owner_link($condition);
    $return_string = "";
    if (count($result_array) > 0) {
        $return_string .= "<table width='100%' cellspacing='0' cellpadding='0'>";
        for ($counter = 0; $counter < count($result_array); $counter++) {
            $return_string .= "\n              <tr>\n                <td width='6%' rowspan='2'>\n                  <input type='checkbox' name='link_id[]' id='link_id_" . $result_array[$counter]->link_id . "' value='link_id:" . $result_array[$counter]->link_id . "' />\n                </td>\n                <td width='94%'>  \n                  <input type='text' size=65 value=\"" . $result_array[$counter]->title . "\"  id='link_id_" . $result_array[$counter]->link_id . "_title' style='border:0px;'/>\n                </td>\n               </tr>\n               <tr>\n                 <td>\n                   <input type='text' size=65 value='" . $result_array[$counter]->url . "' id='link_id_" . $result_array[$counter]->link_id . "_url' style='border:0px;'/>\n                 </td>  \n               </tr><br /> ";
        }
        $return_string .= "</table>";
    } else {
        $return_string = "<center>There are no links under this category</center> ";
    }
    print $return_string;
}